PDA

View Full Version : Driving an optocoupler from 5V



Alex.Stanfield
10-25-2011, 05:18 PM
Hi there, what's your best bet to drive an optocoupler tied to the 5V rail and making sure you don't have any current when off?

The optocoupler is made of a 270ohm resistor in series with the internal LED.
When active I need to drive between 7mA and 16mA

If I drive it directly from the propeller's pin I'm guessing that: Even when setting the pin as an input, current will flow through the clamping diodes, right? (~5ma which is too near the threshold)

Thanks
Alex

RobotWorkshop
10-25-2011, 05:22 PM
If you are driving it from the Propeller Pin why aren't you using the 3.3V supply? Depending upon the OPTO you are using you can probably use a larger value fro the resistor as well. It shouldn't take that much current to drive the optocoupler.

Robert

Leon
10-25-2011, 05:23 PM
Why can't you just drive it at 3.3V from an output?

Alex.Stanfield
10-25-2011, 05:31 PM
I'm assuming a 1.6v drop across the LED in the optocoupler so that would give only about 6mA (the 270ohm and the optocoupler are inside the device I'm driving)
That would leave me out of specifications

Alex

RobotWorkshop
10-25-2011, 05:58 PM
What is the part # for the optocoupler you are using? Do you have the datasheet for it? There are definitely ones specifically made for 3.3v operation but I have used the 4n26 with the Propeller at 3.3v ok.

Rayman
10-25-2011, 06:15 PM
With the Prop pin set as input, the voltage would have to be more than 3.3V to draw current. Your LED in the optocoupler probably has a >2V threshold. So, I think you'll be safe with a 5V voltage...

Loopy Byteloose
10-25-2011, 06:19 PM
Frankly, optcouplers are not really necessary and may be rather fiddly to get right. A Schmitt trigger or a hex buffer can be placed in line as a protective device and will sacrifice itself. These offer faster and cleaner response.

RobotWorkshop
10-25-2011, 06:31 PM
Frankly, optcouplers are not really necessary and may be rather fiddly to get right. A Schmitt trigger or a hex buffer can be placed in line as a protective device and will sacrifice itself. These offer faster and cleaner response.

It all depends upon what Alex is trying to control. What the optocoupler is driving was never discussed.

For some projects I have used a 74HC14 with a pair of the inverters back to back that buffer the signal. The 74HC14 runs at 5V and has resistors between the inputs of that and the propeller pin. For inductive loads or high voltage signals that may be on the other side of the opto then I still feel the optocoupler is definitely worth considering.

Phil Pilgrim (PhiPi)
10-25-2011, 06:57 PM
He might be trying to drive an Opto22-type coupler, which has the resistor built-in. They really do need a 5V input to function reliably.

Alex, try using a 74HCT buffer between the output of your Propeller and the coupler. Power the buffer from +5V, and you'll be good to go. The other option would be a common-emitter NPN driver, with the collector connected to the opto's cathode, and its anode connected to +5V.

One thing to consider: if the opto's overall voltage drop at 500uA is more than 1.1V, you could get by with driving it directly from the Prop's output pin. You'll get some conduction through the protection diodes, but probably not enough to turn it on. The other option would be to add a series diode to add another 0.6V to the opto's voltage drop, thus providing additional protection and still giving you 10mA of drive current.

-Phil

RobotWorkshop
10-25-2011, 07:15 PM
He might be trying to drive an Opto22-type coupler, which has the resistor built-in. They really do need a 5V input to function reliably.

Could be but since the actual part # of the Optocoupler was never mentioned we don't know for sure.

Phil Pilgrim (PhiPi)
10-25-2011, 07:23 PM
Yes, but we do know that it has a built-in resistor, and he's stated its current requirements and voltage drop. That's enough info to go on.

-Phil

Alex.Stanfield
10-25-2011, 08:59 PM
First I'd like to thank everyone for the replies, really helpful.

I don't have the part # for the optocoupler since it' embedded in a stepper driver (2M542 from goodluckbuy.com)
The spec sheet says to drive it between 7 and 16mA. States it has a 270ohm resistor and suggests driving it from 5V directly or adding another resistor when driving from higher voltages.

I'll try to get some measures of the current it draws using the 5v and 3.3v supplies of a protoboard. Maybe adding some diodes to get less voltage across the drivers input, good idea.

Alex

Alex.Stanfield
10-25-2011, 09:02 PM
Which low cost FET would you recommend for this?

Thanks
Alex

Circuitsoft
10-25-2011, 09:13 PM
ZVNL110A is a cheap TO-92 mosfet that will work just fine driven from the prop.

Peter Jakacki
10-26-2011, 12:14 AM
I don't know where all these high voltage drops of 2V or so are coming from. All diodes exhibit a forward voltage drop and this varies depending upon the type of diode. In this case the diode is an infrared LED which exhibits around 1.2V drop at 10ma. This means the internal 270R resistor will result in a forward current of 7.7ma when driven directly from the Prop's 3.3V. Nice and simple, just drive it.


EDIT: Looking at the original post seemed to indicate that it had to be tied to +5V but looking at the stepper driver (http://mycncworld.com/goods-78-2M542+Peak+42A+CNC+NEMA+Stepper+Motor+Driver.html) I see the LEDs are uncommitted in that you can tie them to +5V or +3.3V or even source them directly from the I/O through to ground. I prefer the source approach when the sourcing current doesn't impact on the Prop's regulator as that means that nothing can happen to the supply if it isn't running off-board to an external device. So tie the I/O straight to the LED+ and tie LED- to ground is what I would recommend. BTW, I can't believe the price, is that real?

jmg
10-26-2011, 12:46 AM
First I'd like to thank everyone for the replies, really helpful.

I don't have the part # for the optocoupler since it' embedded in a stepper driver (2M542 from goodluckbuy.com)
The spec sheet says to drive it between 7 and 16mA. States it has a 270ohm resistor and suggests driving it from 5V directly or adding another resistor when driving from higher voltages.

I'll try to get some measures of the current it draws using the 5v and 3.3v supplies of a protoboard. Maybe adding some diodes to get less voltage across the drivers input, good idea.

Alex

A simple LED in series should be inside spec, or 2 series diodes.
I get
1.2+7m*270 = 3.09V to 1.2+16m*270 = 5.52V
and a 1.6V red led, will give ~3.4V, so is above your 7mA level.

Alex.Stanfield
10-26-2011, 11:40 PM
I don't know where all these high voltage drops of 2V or so are coming from. All diodes exhibit a forward voltage drop and this varies depending upon the type of diode. In this case the diode is an infrared LED which exhibits around 1.2V drop at 10ma. This means the internal 270R resistor will result in a forward current of 7.7ma when driven directly from the Prop's 3.3V. Nice and simple, just drive it.


EDIT: Looking at the original post seemed to indicate that it had to be tied to +5V but looking at the stepper driver (http://mycncworld.com/goods-78-2M542+Peak+42A+CNC+NEMA+Stepper+Motor+Driver.html) I see the LEDs are uncommitted in that you can tie them to +5V or +3.3V or even source them directly from the I/O through to ground. I prefer the source approach when the sourcing current doesn't impact on the Prop's regulator as that means that nothing can happen to the supply if it isn't running off-board to an external device. So tie the I/O straight to the LED+ and tie LED- to ground is what I would recommend. BTW, I can't believe the price, is that real?

I ran some manual tests last night and found the following:

Hooked to 5V and grounded it drew between 10-13mA depending on which input I tested. That's exactly what I wanted.
Hooked between the 5V and 3.3V rails (simulating the anode to 5v and a high level on the prop pin) it drew only 1mA, so I believe it should work fine.
Adding a diode in series effectively dropped the high state current to almost 0 but lowered the low state (active) current to 9mA
Probably the best option will be to go with a low cost mosfet.

As for the price, yes it's very real... $40... delivered from hong-kong to your front door. Being such a good price I expected a low tech device with some logic to do the microstepping, however I found some interesting stuff inside. See the picture...
86364

The H-bridge is discrete with 4 transistors between the pcb and the heat-sink
Below, what I believe are the optocouplers
86363

enjoy.
Alex

Phil Pilgrim (PhiPi)
10-26-2011, 11:51 PM
Hooked between the 5V and 3.3V rails (simulating the anode to 5v and a high level on the prop pin) it drew only 1mA, so I believe it should work fine.
500uA is the limit for the Prop's protection diodes. It's actually your test with the additional diode that provides the current going through the protection diode to 3.3V within the Prop.

-Phil

Peter Jakacki
10-26-2011, 11:54 PM
Alex, I think you missed the point. You can drive the anode of the optos directly from the Prop and ground the cathode. +5V is not required and doesn't even come into it. You are really making it way more complicated than it should be.

I've worked with a lot of optos including the 2531 and don't think that just because it says a "minimum" of 7ma that 7.7ma is close the bone, not at all.

BTW, the price of the stepper from my link at mycncworld was quoted as $5.98!!

Rayman
10-27-2011, 12:02 AM
An optocoupler's forward voltage is much lower that I was thinking... If it's closer to 1 volt than 2 volts, then everybody is right and you should try driving it straight from a Prop pin.

If that doesn't work for some reason, you could put in a series diode between the prop pin and the opto to bring the effective forward drop back up to ~2 volts and then it should work...

Alex.Stanfield
10-27-2011, 01:42 AM
Alex, I think you missed the point. You can drive the anode of the optos directly from the Prop and ground the cathode. +5V is not required and doesn't even come into it. You are really making it way more complicated than it should be.

I've worked with a lot of optos including the 2531 and don't think that just because it says a "minimum" of 7ma that 7.7ma is close the bone, not at all.

Peter, maybe it works directly from the propeller pin now, however I need it to keep working after several years when the opto coupler gets "worn" and diminishes it's sensibilty (I've seen this before). It also needs to keep working reliably under extreme weather conditions (between 0 - 40ĄC) so I'd rather spend a little more time and money now instead of reworking the driving line later specially when I can't easily replace the opto-coupler.l


BTW, the price of the stepper from my link at mycncworld was quoted as $5.98!!
can you paste the link?
thks

Alex

Peter Jakacki
10-27-2011, 02:06 AM
The minimums take into account any such aging whereas the minimum CTR is 19% which works out that even with a pullup on the transistor side of the opto of 3.3K @5V the output will still pulldown to 0.4V. The best and easiest way of testing the limits is simply to insert extra resistance in the line and see at what point it stops working.

If however you are going to use a transistor to drive the line then use an NPN rather than a MOSFET as a BJT will turn on fully and faster. I use digital transistors such as the DDTD142JC (http://search.digikey.com/us/en/products/DDTD142JC-7-F/DDTD142JC-FDICT-ND/815643)

The link was pasted in my first post under "stepper driver (http://mycncworld.com/goods-78-2M542+Peak+42A+CNC+NEMA+Stepper+Motor+Driver.html)"

Alex.Stanfield
10-27-2011, 02:47 PM
The minimums take into account any such aging whereas the minimum CTR is 19% which works out that even with a pullup on the transistor side of the opto of 3.3K @5V the output will still pulldown to 0.4V. The best and easiest way of testing the limits is simply to insert extra resistance in the line and see at what point it stops working.

If however you are going to use a transistor to drive the line then use an NPN rather than a MOSFET as a BJT will turn on fully and faster. I use digital transistors such as the DDTD142JC (http://search.digikey.com/us/en/products/DDTD142JC-7-F/DDTD142JC-FDICT-ND/815643)

The link was pasted in my first post under "stepper driver (http://mycncworld.com/goods-78-2M542+Peak+42A+CNC+NEMA+Stepper+Motor+Driver.html)"

Ok, I'll give it a try maybe over the weekend and see what current I get or where it stops working. Thanks for the insight.

I didn't quite trust mycncworld's site since it has strange prices (like this 12Nm stepper for $5.98 http://mycncworld.com/goods-75-12nm+1716oz-in+CNC+NEMA23+Stepper+Motor.html and on the same site a 6.7Nm stepper for $166 http://mycncworld.com/goods-90-67nm+958oz-in+CNC+NEMA23+Stepper+Motor.html. Also none of the pictures belong to these motors) Has anyone used this site?

Thanks to everyone for the tips.

Alex

Peter Jakacki
10-27-2011, 03:59 PM
Yeah, that cncworld had too many weird prices and a lot of them no matter what they were happened to be the same price of $5.98. But they do seem to have a lot of product though.

I understand all too well the need you have to build in that insurance into your product but at the same time if it is totally redundant then it may just become a source of a problem. These problems increase with the number of components and connections so it's a balance between simplicity and "insurance".

Alex.Stanfield
10-27-2011, 08:20 PM
Yeah, that cncworld had too many weird prices and a lot of them no matter what they were happened to be the same price of $5.98. But they do seem to have a lot of product though.

I understand all too well the need you have to build in that insurance into your product but at the same time if it is totally redundant then it may just become a source of a problem. These problems increase with the number of components and connections so it's a balance between simplicity and "insurance".

Couldn't agree more...Thanks.

Alex

Alex.Stanfield
10-31-2011, 02:27 PM
I did some tests over the weekend and these are the findings:

- Driven directly from the prop's pin to ground worked perfectly well !
- Straight 3.3V rail and ground gave a current of about 6.3mA (below specification but close)
- Placing some resistors in series (clk line) I found that It still worked all the way down to aprox 2.75mA, below that it ceased to move

So, maybe it's safe to drive it directly from the prop's pin after all. What do you think? I'm still wodering how it will behave under temperature stress and with aging...

Alex

Peter Jakacki
11-01-2011, 02:49 AM
The fact that it is running at a low emitter current already reduces the aging effect greatly. I crunched some figures and along with the information you supplied I estimate that the CTR will drop by 50% after 6 years of continual 100% operation after which it is still operating. Of course the emitters are not constantly active and you will know yourself what the duty cycle is. So have your software ensure that it only activates the opto for as long as it needs to and that the step direction and signals are deactivated when not required will ensure a long and happy opto life.

Alex.Stanfield
11-01-2011, 03:18 AM
The fact that it is running at a low emitter current already reduces the aging effect greatly. I crunched some figures and along with the information you supplied I estimate that the CTR will drop by 50% after 6 years of continual 100% operation after which it is still operating. Of course the emitters are not constantly active and you will know yourself what the duty cycle is. So have your software ensure that it only activates the opto for as long as it needs to and that the step direction and signals are deactivated when not required will ensure a long and happy opto life.

Great! 6 years should be long enough. Even if I have to replace the opto or rework the driving lines it's fair enough.

Thanks a lot Peter.

Alex