Odd opto switch behaviour
big_mark
Posts: 49
Hi
I am building a dmx-controlled moving mirror like one of these : www.rosco.com/us/lightingequipment/icue.asp
I have got the stepper motors spinning but I'm getting an odd problem with the opto-switches, which I'm using for limit switches. I'm using Optek OPB830L's connected to the 3.3volt supply on my dev. board, with a suitable 40ohm resistor in series with the IR emitter to limit the current. The photo-transistor is also connected to the 3.3volt supply and pin 0.
When I tested the switch with my multimeter it worked correctly giving 3.29volts from the phototransistor when the beam was not obstructed, and 0.01volts when it was. I then connected it to my dev. board to test the software. It read the pin as always being high, even when the beam was obstructed (with a 1mm sheet of Aluminium, so it wasn't like the beam was leaking through it or anything...). The odd thing was when I put my volt meter between the big VDD pin on the dev. board and the transistor output everything started working as it should, with the pin going low and high at the right times. Is this normal? And what can I do to correct it? (And no, I'm not making my multimeter an integral part of my circuit )
I am building a dmx-controlled moving mirror like one of these : www.rosco.com/us/lightingequipment/icue.asp
I have got the stepper motors spinning but I'm getting an odd problem with the opto-switches, which I'm using for limit switches. I'm using Optek OPB830L's connected to the 3.3volt supply on my dev. board, with a suitable 40ohm resistor in series with the IR emitter to limit the current. The photo-transistor is also connected to the 3.3volt supply and pin 0.
When I tested the switch with my multimeter it worked correctly giving 3.29volts from the phototransistor when the beam was not obstructed, and 0.01volts when it was. I then connected it to my dev. board to test the software. It read the pin as always being high, even when the beam was obstructed (with a 1mm sheet of Aluminium, so it wasn't like the beam was leaking through it or anything...). The odd thing was when I put my volt meter between the big VDD pin on the dev. board and the transistor output everything started working as it should, with the pin going low and high at the right times. Is this normal? And what can I do to correct it? (And no, I'm not making my multimeter an integral part of my circuit )
Comments
I think, you are taking out from the opto-phototransistor from the emiter, but you are getting a "high" incorrect read because .......Have you an R for the emiter to ground ????
Your tester is introducing a R when you test it !!!
Coud be more simple and safety, using your phototransistor emiter to ground, and a R between collector and +Vcc. take the propeller input form collector and ready (don't forget to invert the INA read, for that input).
Regards.
Alberto.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.owlnet.rice.edu/~elec201/Book/images/img156.gif
you may want more resistance than 40ohms, remember it forms a sort of potential divider.
Graham
I'm not getting an incorrect reading from the emitter of the phototransistor. It goes low and high when it should. Its just that the Prop chip doesn't 'see' it correctly unless my multimeter is between the emitter and ground. This seems quite strange to me as I thought that since I'm getting 0 volts and 3.3 volts (logic 0 and 1) in the right places then it ought to work. If I connect a mechanical switch in place of the transistor, then it all works as it should so I don't see why using a transistor should be any different.
Thanks you both for explaining how it should be done, but how is this method 'safer' (to quote BTX). Would I not be better off just connecting a resistor between the transistor emitter and ground, leaving the rest of my circuit as-is, since that is what is happening anyway when I use my meter? Its seems odd to me to connect a transistor straight to ground and take the switch signal from the transistors input, but then I am much more of a programmer than a hardware guy...
Thanks
Mark.
The propeller is drawing current, that is why the voltage changes, the meter adds more resistance => less current.
The DC model of a transistor is a junction where the current comming out of the emmiter equals the base current plus the collector current. The collector current is the base current multiplied by the beta and you must have a voltage of about 0.6v between base and emmitter to get it conducting.
A very common way to use a tranistor is to tie the emmitter to ground, that way you can assume the base is at 0.6v when the transistor is turned on. If the emmiter is connected to a load then the voltage required will vary depending on the voltage across the load (which depends on the current and R). Adding the resistor from the collector to supply is a way of converting current to voltage, if no current flows then the voltage must be that of the supply (both ends of resistor at equal potential) if the transistor is on then the voltage is pulled down to ground. In your case of course the base current is supplied by light but its the same thing overall.
One final note is that although your meter may have read 0v, it would do that if you stuck it in your ears, however your ears are not attached to ground of your circuit (I assume).
Graham
Let me explain how I tested the opto switch. I connected the LED to the props 3.3 volt supply, using a 40 ohm series resistor. I connected the photo-transistors collector to the 3.3volt supply. I connected my multimeter between the transistors emitter and ground. When the beam is blocked the meter shows 0.01volts, and when it is not blocked I get 3.29 volts. Thats what I meant when I said that I'm getting logic 0s and 1s in the right places. I know I'd get 0 volts if I stuck my meter in my ears...
Anyway, I'll use the circuit you have provided. One thing though: since my supply to the transistor is 3.3volts and not 5volts as per your diagram I take it I'll need a different resistor? How do I calculate the right value?
Thanks
mark
I mentioned it because I once spent ages debugging a circuit, I checked the 0v connection to a chip ten times. It was 0v everytime, then I check continuity, doh!!! I hope you didn't think I was being rude, just trying to make the point.
The resistor is chosen such that when the transistor is on it limits the current through the device, and when it is off it will limit the current into the rest of the circuit (which in some case matters). The usual some number of kohms should work fine but the datasheet may provide a proper value for current.
Graham
Look at this code.
Regards.
Alberto.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
From the spec sheet :
Collector-Emitter breakdown voltage : 30V
Emitter-Collector breakdown voltage : 5V
Collector DC current : 30mA
On-state collector current : 500uA
Collector-Emitter dark current : 100nA
I take it that the one we are interested in is the Collector DC current? From here, how do I work out the right value for the resistor?
Thanks
Mark
Edit : Thats right BTX, I do have it connected like the first example. I'll use your second example. Thanks
Post Edited (big_mark) : 1/8/2007 1:22:36 AM GMT
See my post inmediatly before.
Alberto.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The key specs there are the dark current and the on state current. You need to pick a resistor that gives less than the low threshold voltage of the propeller when the opto is blocked, and above the threshold of a high when the opto is illuminated. The 500uA illuminated vs 100nA dark is 5000 to one ratio, so not too hard to do.
I'm assuming The prop thresholds are around 1/4 vcc or less for a low input, and 3/4 vcc or higher for a high input.
So 3.3/4 is .825V or less for low, 3.3*3/4 is 2.475V or more for a high.
The maximum resistor to guarantee a low with 100nA leakage would be R=V/I or .825/.0000001 = 8.25 Mohm. Anything less than that should guarantee less than .825 V when your opto is blocked.
For a minimum high, I would assume half the specified on state current in order to allow for aging of the opto LED.
So we want a voltage drop on the resistor of 2.475V at 250uA which is 2.475/.00025 = 9.9Kohm. Anything more than that will guarantee more than 2.475V when the opto is not blocked.
So the range of values that should work is between 9.9Kohm and 8.25 Mohm
A 10Kohm resistor should work nicely, 20K would give a little more margin on the high voltage. I would use any common value I had handy up to 100Kohm. 47K, 22K or whatever in that range should work.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
MRC