November 24, 2024, 02:48:16 PM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Optical Emitter/Sensor for Prop-1 input?

Started by Regor, January 18, 2013, 08:21:03 PM

Previous topic - Next topic

Regor

Hello all.  I'm working on a project that requires detecting a ping pong ball as it passes through a 2.5" diameter  tube and activating an input.  The project is basically a lottery ball type machine that consists of a cabinet and blower that holds 300 ping pong balls.  I have built the mechanism that captures and releases balls one at a time and now I need to automate it.  When a ball passes a certain point it will trigger an input that will activate an output that will close a set of gates.  I will get into more detail in a later post as I will undoubtedly need a little help with the program once I get the hardware lined out.

I can use a lever type snap switch but would rather use something less 'clunky'.  I found an optical emitter and sensor pair that I think may work but am unsure of the proper connection to the prop-1.  Here is a link to the datasheet http://www.optekinc.com/datasheets/opb100.pdf.  Do you think this would be a good choice to use as a beam break type sensor across a short distance of 2.5 inches?  Or does anyone have a better suggestion perhaps?

Thanks in advance
Roger

JonnyMac

January 19, 2013, 10:13:16 AM #1 Last Edit: January 19, 2013, 10:15:29 AM by JonnyMac
You could use that sensor pair and connect it to the Prop-1 by one of our heavy duty extension cables (cut one of the connectors off to hook into your circuit). Here are the connections:

WHITE
-- connect this to the white wire on the sensor

RED
-- connect to 150 ohm resistor, feed the other side or resistor to red wire of the emitter

BLACK
-- connect to the green wire on the sensor
-- connect to the black wire on the emitter


You will plug the connector side of the wire into P7 -- after making an adjustment to the baord which allows for an active-low input.

1) Move the P7 SETUP jumper to the UP position
2) Replace the ULN2803 with a ULN2003, or remove pin 1 from the ULN2803.
    -- more info: http://www.efx-tek.com/php/smf/index.php?topic=130.0

Finally, you need to adapt the code to look for a short, low-going pulse. Here's an update to our standard template that should do it for you. Note that I've cut the debounce time down to ~5ms to detect the dropping ball. This is a starting point. I would suggest making this as large as possible without missing a ball (you'll need experiment with this -- unless you can put an o'scope on the pin and measure the duration of the pulse caused by the ball dropping through).

Have fun!

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  Trigger         = PIN7                  ' SETUP = UP, no ULN


' -----[ Constants ]-------------------------------------------------------

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  TrOn            = 0                     ' active-low trigger
SYMBOL  TrOff           = 1

SYMBOL  IsOn            = 1                     ' active-high I/O
SYMBOL  IsOff           = 0

SYMBOL  Baud            = OT2400


' -----[ Variables ]-------------------------------------------------------

SYMBOL  timer           = B2                    ' for debounce loop


' -----[ Initialization ]--------------------------------------------------

Power_Up:
  ' put code here that only happens at power-up/hard reset

Reset:
  PINS = %00000000                              ' all off
  DIRS = %00111111                              ' P5..P0 are outputs


' -----[ Program Code ]----------------------------------------------------

Main:
  timer = 0                                     ' reset debounce timer

Check_Trigger:
  PAUSE 1                                       ' scan delay
  IF Trigger = TrOff THEN Main                  ' check trigger input
    timer = timer + 1                           ' update timer
  IF timer < 5 THEN Check_Trigger               ' check timer

  ' program code here

  GOTO Reset


' -----[ Subroutines ]-----------------------------------------------------


' -------------------------------------------------------------------------


' -------------------------------------------------------------------------


' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

Regor

Got it.  I'll order parts tonight and will hopefully give it a go by the end of next week.  Thanks very much Jon.

Roger

Regor

I finally got all of the parts in and the sensors and program works brilliantly.  I changed TrOn to 1 and TrOff to 0 as I needed to go high when the beam is broken.  Now I want to use two sets of the sensors along with a N/O push button to start the whole thing off.

We are using this machine for a fundraiser that is based on a reverse lottery.  300 tickets (balls) are sold and the last ball out is the grand prize winner - $10,000.  A number of balls pay out as well, for example, the 25th ball, the 50th, the 100th, etc. in order to keep everyone engaged through the entire event.  So all 300 balls need to be managed one at a time as they are trying to shoot out of the tube like a machine gun. 

The catch and release chamber is controlled by a series of gates that are operated with two 12 vdc linear actuators.  I am using two 12 vdc bosch type automotive relays per actuator in order to reverse polarity. 

Here is what I am trying to do,
  When a N/O push button Trigger (PIN 5?)  is pressed,
  GateInOpen (OUT 0) goes high for 500 ms,
  When ball passes through beam of Sensor1 (PIN 7?),
  GateInClose (OUT 1) goes high for 500 ms,
  PAUSE 2000 ms,
  GateOutOpen (OUT 2) goes high for 500 ms,
  When ball passes through beam of Sensor2 (PIN 6?),
  GateOutClose (OUT 3) goes high for 500 ms,
  Sequence over until Trigger is pressed for the next ball

So I have three inputs - Trigger, Sensor1, and Sensor2.  And four outputs - GateInOpen, GateInClose, GateOutOpen, and GateOutClose.

I am unsure of:
1.  the best way to debounce all of these inputs,
2.  the SETUP (Up on pins 6 and 7?),
3.  do pins 1 and 2 need to be clipped on the ULN?

Thanks in advance
Roger













JonnyMac

February 01, 2013, 09:59:37 AM #4 Last Edit: February 01, 2013, 10:02:29 AM by JonnyMac
QuoteI finally got all of the parts in and the sensors and program works brilliantly.

JonnyMac rules!  ;D


QuoteI changed TrOn to 1 and TrOff to 0 as I needed to go high when the beam is broken.

Okay; when the beam is visible the output transistor conducts, pulling the line low -- makes sense. When the beam breaks the SETUP pull-up takes the line high.

Yes, you can use P5 as an active-high input (ULN acts as pull-down for it); connect a N.O. button between P5.W and P5.R.


Here's an update of the program, written as you describe (I believe). Give it a test. As I don't know your hardware for the gates, I'm wondering if we need to wait for the ball to enter the optical device and then exit before closing the gate. Perhaps the device moves slowly and that is not a requirement -- if it becomes necessary, it's easy to add.

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL  GateOut         = PIN7                  ' SETUP = UP, no ULN
SYMBOL  GateIn          = PIN6                  ' SETUP = UP, no ULN

SYMBOL  Trigger         = PIN5                  ' P5.W/P5.R (ULN is pull-down)

SYMBOL  GateOutClose    = PIN3                  ' V+/OUT3
SYMBOL  GateOutOpen     = PIN2                  ' V+/OUT2

SYMBOL  GateInClose     = PIN1                  ' V+/OUT1
SYMBOL  GateInOpen      = PIN0                  ' V+/OUT0


' -----[ Constants ]-------------------------------------------------------

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  TrOn            = 1                     ' active-high trigger
SYMBOL  TrOff           = 0

SYMBOL  IsOn            = 1                     ' active-high I/O
SYMBOL  IsOff           = 0


' -----[ Variables ]-------------------------------------------------------

SYMBOL  timer           = B2                    ' for debounce loop


' -----[ Initialization ]--------------------------------------------------

Power_Up:
  ' put code here that only happens at power-up/hard reset

Reset:
  PINS = %00000000                              ' all clear
  DIRS = %00011111                              ' P7-P5 ins, P4-P0 outs


' -----[ Program Code ]----------------------------------------------------

Main:
  timer = 0                                     ' reset debounce timer

Check_Trigger:                                  ' wait for trigger button
  PAUSE 5                                       ' scan delay
  IF Trigger = TrOff THEN Main                  ' check trigger input
    timer = timer + 5                           ' update timer
  IF timer < 100 THEN Check_Trigger             ' check timer

Ball_Enter:
  GateInOpen = IsOn                             ' open input gate
  PAUSE 500
  GateInOpen = Isoff

Wait_4_Entry:
  PAUSE 10
  IF GateIn = IsOff THEN Wait_4_Entry

  GateInClose = IsOn                            ' close input gate
  PAUSE 500
  GateInClose = Isoff

  PAUSE 2000                                    ' read ball #?

Ball_Exit:
  GateOutOpen = IsOn                            ' open input gate
  PAUSE 500
  GateOutOpen = Isoff

Wait_4_Exit:
  PAUSE 10
  IF GateOut = IsOff THEN Wait_4_Exit

  GateOutClose = IsOn                           ' close output gate
  PAUSE 500
  GateOutClose = Isoff

  PAUSE 2000                                    ' clean exit before trigger

  GOTO Main                                     ' back to top


' -----[ Subroutines ]-----------------------------------------------------


' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------


Jon McPhalen
EFX-TEK Hollywood Office

Regor

JonnyMac rules indeed!   ;)

The program works flawlessly.  I'm having to tweak some timings as I run balls thru it, and did have to insert a slight delay as you suggested to keep from guillotining some balls, but it's just what I was needing.

Thanks again Jon.

Roger

JonnyMac

Excellent. Perhaps you can post a video on YouTube and then share a link -- I'm sure many of us would love to see it in action.
Jon McPhalen
EFX-TEK Hollywood Office