Shop OBEX P1 Docs P2 Docs Learn Events
Driving an optocoupler from 5V — Parallax Forums

Driving an optocoupler from 5V

Alex.StanfieldAlex.Stanfield Posts: 198
edited 2011-10-31 20:18 in Propeller 1
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

Comments

  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2011-10-25 10:22
    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
  • LeonLeon Posts: 7,620
    edited 2011-10-25 10:23
    Why can't you just drive it at 3.3V from an output?
  • Alex.StanfieldAlex.Stanfield Posts: 198
    edited 2011-10-25 10:31
    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
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2011-10-25 10:58
    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.
  • RaymanRayman Posts: 14,864
    edited 2011-10-25 11:15
    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...
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2011-10-25 11:19
    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.
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2011-10-25 11:31
    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)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-25 11:57
    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
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2011-10-25 12:15
    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)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-25 12:23
    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.StanfieldAlex.Stanfield Posts: 198
    edited 2011-10-25 13:59
    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.StanfieldAlex.Stanfield Posts: 198
    edited 2011-10-25 14:02
    Which low cost FET would you recommend for this?

    Thanks
    Alex
  • CircuitsoftCircuitsoft Posts: 1,166
    edited 2011-10-25 14:13
    ZVNL110A is a cheap TO-92 mosfet that will work just fine driven from the prop.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2011-10-25 17:14
    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 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?
  • jmgjmg Posts: 15,185
    edited 2011-10-25 17:46
    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.StanfieldAlex.Stanfield Posts: 198
    edited 2011-10-26 16:40
    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 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...
    San Isidro-20111025-00048.jpg


    The H-bridge is discrete with 4 transistors between the pcb and the heat-sink
    Below, what I believe are the optocouplers
    Vicente López-20111025-00022.jpg


    enjoy.
    Alex
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-10-26 16:51
    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 JakackiPeter Jakacki Posts: 10,193
    edited 2011-10-26 16:54
    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!!
  • RaymanRayman Posts: 14,864
    edited 2011-10-26 17:02
    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.StanfieldAlex.Stanfield Posts: 198
    edited 2011-10-26 18:42
    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 JakackiPeter Jakacki Posts: 10,193
    edited 2011-10-26 19:06
    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

    The link was pasted in my first post under "stepper driver"
  • Alex.StanfieldAlex.Stanfield Posts: 198
    edited 2011-10-27 07:47
    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

    The link was pasted in my first post under "stepper driver"

    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 JakackiPeter Jakacki Posts: 10,193
    edited 2011-10-27 08:59
    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.StanfieldAlex.Stanfield Posts: 198
    edited 2011-10-27 13:20
    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.StanfieldAlex.Stanfield Posts: 198
    edited 2011-10-31 07:27
    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 JakackiPeter Jakacki Posts: 10,193
    edited 2011-10-31 19:49
    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.StanfieldAlex.Stanfield Posts: 198
    edited 2011-10-31 20:18
    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
Sign In or Register to comment.