# Society of Robots - Robot Forum

## Electronics => Electronics => Topic started by: DTM22 on November 12, 2011, 02:05:18 PM

Title: Questions about Optical Switch
Post by: DTM22 on November 12, 2011, 02:05:18 PM
Hi, Im relatively new to circuit building and I decided to take on the task of building my own chronograph to measure projectile velocity.  Im using an Arduino Duemilanova microcontroller for my programming.  My sensors however are giving me some trouble.  I was told to use slotted optical switches(LED/Phototransistor).  The sensors I ordered were these:
http://www.optekinc.com/datasheets/OPB819.PDF (http://www.optekinc.com/datasheets/OPB819.PDF)
The problem I'm having is I simply have no idea how to wire these up. I'm hoping to drive the sensor using 5V if possible. I don't yet understand the whole concept behind calculating the base resistance needed etc.  If anyone could help me out, it would be very much appreciated.
Title: Re: Questions about Optical Switch
Post by: waltr on November 12, 2011, 03:28:24 PM
The transistor senor's 'base' is a photo-junction and does not require a resistor as a non-photo transistor does.
Look on the left of the first diagram in the data sheet. That shows an LED and a photo-transistor. Wires these as any LED, series resistor to set the LED current) and an NPN transistor but ignore the base biasing.
Title: Re: Questions about Optical Switch
Post by: Soeren on November 12, 2011, 03:35:02 PM
Hi,

Start reading this (http://www.societyofrobots.com/schematics_infraredemitdet.shtml) page.
Title: Re: Questions about Optical Switch
Post by: DTM22 on November 12, 2011, 04:10:59 PM
Thanks.....So reffering to the Infrared/Emitter Detector Basic Circuit I saw on the other page
(http://www.societyofrobots.com/images/schematics_infraredemitdetbas.jpg)
Vcc=5V
R1 would be roughly 120ohms
R2=unecessary if I understood correctly??
Title: Re: Questions about Optical Switch
Post by: Soeren on November 13, 2011, 07:18:31 AM
Hi,

Vcc=5V
R1 would be roughly 120ohms
R2=unecessary if I understood correctly??

You need to look at the numbers in datasheet.
Going for I_LED=40mA with a forward drop of 1.8V and a collector current of around 6mA with a saturation voltage of 0.4V.

R1 should be (5-1.8 )/0.04 = 80 Ohm and nearest standard value is 82 Ohm
R2 should be (5-0.4)/0.006 = 767 Ohm, nearest standard value is 820 Ohm

And no, R2 is certainly not unnecessary (or it wouldn't be there. The photo transistor can only pull toward ground, so, to get the output signal to ever get above ground, you need the pull up resistor.
You may have been thrown off by waltr mentioning the "no base bias" (which really have nothing to do with this opto coupler).
Title: Re: Questions about Optical Switch
Post by: DTM22 on November 13, 2011, 01:09:00 PM
Thanks for clearing that up for me!
Title: Re: Questions about Optical Switch
Post by: DTM22 on November 14, 2011, 03:35:57 PM
So Ive connected up the circuit as shown in the diagram using the Resistance Values given to me by Soeren.  And when I connect my multimeter to Vout, I measure a constant 5V and see no change when I place an object between the slot.  Anyone have any ideas what I might be doing wrong??
Title: Re: Questions about Optical Switch
Post by: waltr on November 14, 2011, 08:24:28 PM
Measure the voltage across R1 (using diagram in DTM22's post). Then use Ohm's law to calculate the current through R1 and the LED.
Is the current close to 40mA?
If not then check the the LED's wiring is not reversed.
If so then the LED probably is working.
Now double check the photo-transistor's wiring.
Title: Re: Questions about Optical Switch
Post by: DTM22 on November 15, 2011, 08:40:05 AM
The LED and PhotoTransistor are pre wired(See the link for the datasheet above).  There are only 4 wires on the sensor, Anode, Cathode, Collector and Emiiter.  All I did was add in the appropriate resistors and connect the circuit to Vcc(5V) and Ground.  I have used a IR LED Detection Circuit in the past and I never had any problems with it, I really don't see what Im doing wrong.
Title: Re: Questions about Optical Switch
Post by: Soeren on November 15, 2011, 09:15:43 AM
Hi,

The LED and PhotoTransistor are pre wired(See the link for the datasheet above).  There are only 4 wires on the sensor, Anode, Cathode, Collector and Emiiter.  All I did was add in the appropriate resistors and connect the circuit to Vcc(5V) and Ground.  I have used a IR LED Detection Circuit in the past and I never had any problems with it, I really don't see what Im doing wrong.
Anyway, there's probably no light in the LED (a camera will tell you in a second) if that's the case, swap the anode and cathode connections.
If you see light in the LED (with a cam), you may have crossed the other two wires.
If all the wires are correct, and both the LED and the photo transistor works, the output should be low until you block the light.
Title: Re: Questions about Optical Switch
Post by: mbmosher on June 05, 2017, 06:54:59 PM
Hey DTM22 & Soeren,

I know this was a while ago, but wondering if you were ever able to get the OPB819 optical switch to work?  I'm having the exact same problem with the OPB819Z, always reads 5V out.  Checked the sensor against my kinect to see if the IR LED is on, and it does not look like it.  Tried swapping anode and cathode, still nothing.  Not sure what's up with this.  Using 82ohm on the anode and 820ohm on the collector.  Thanks for the help.