2
\$\begingroup\$

How do you choose the series resistor value for the LED side of an optocoupler. My application uses this opto to interface a button that is about 25meters(50 meter wire roundtrip) away from the device.

enter image description here

For choosing R44 or the collector pullup was pretty easy since the datasheet has provided a 1k. On the other side however there is no mention of a resistor. I would like for the led to be able to take inputs from at least 3.3 to 12volts.

And having a look at the input characteristics of from the datasheet the maximum forward current is 60 mA(for a typical LED this is very very large). What would be the minimum current of the LED for so that the PIN can still safely register an "ON" state. Would a higher current(lower value resistor) on the led (30-40mA) be safe for repetitive use?

Going further, to skip using a voltage regulator (it will come from mains anyway) is it possible to use the mains voltage 240 VAC instead since the optocoupler is capable of using AC anyway. How would I choose my resistors then ?

\$\endgroup\$
1
  • \$\begingroup\$ Jake, one thing I personally like to do is use a current source/sink and not a resistor. \$\endgroup\$
    – jonk
    Commented Jul 2, 2020 at 20:57

3 Answers 3

5
\$\begingroup\$

If you want to accommodate a wide range of voltages, the easiest thing to do is to increase the resistance at the phototransistor so it will work at lower currents. I would not go over about 15mA, LEDs age and will eventually drop in brightness to the point where the CTR is not high enough to work. Speed suffers approximately proportionally, but that's not so much a concern with a manual pushbutton.

The next simplest thing is to add a constant current circuit to the input. For example:

schematic

simulate this circuit – Schematic created using CircuitLab

By adding a couple pennies worth of parts, the current is typically maintained fairly constant from about 2V to 25V (at room temperature).

enter image description here

In either case you want to have a lot of margin (maybe 2-3:1) to make sure the transistor saturates and to allow for normal aging. The output current is 3.3mA so if your minimum CTR is 100% you might want 10mA nominal at the LED. That would lead to excessive current with 25V in and a simple resistor R = (3.3V-1.2V)/0.01A = 210\$\Omega\$ so at 25V you'd have 108mA (but not for long).

If you allowed only 15mA at 25V in that would require about a 1.5K resistor, so the current at 3.3V would be only 1.4mA so with a CTR of 100% you'd want more like 7K at the output. Maybe 2K and 10K would be acceptable, again assuming a nominal CTR of 100% minimum over the LED current range of 1~10mA.

\$\endgroup\$
13
  • 2
    \$\begingroup\$ Oh, crap. You just did what I was thinking. Okay. Thanks! +1 (for what it's worth.) Can you make the schematic a little smaller, though? Like add tiny 10-point periods to either side of the darned thing? (Also, to the OP, see here for an expanded discussion.) \$\endgroup\$
    – jonk
    Commented Jul 2, 2020 at 20:58
  • 1
    \$\begingroup\$ @jonk Was going to do that anyway. Which was that question you referenced a vibrator on? You might want to watch this video - the relevant section starts at 9:32 but I think the whole thing is fascinating. This guy has a home shop that is incredible, courtesy of having made a fortune in business. \$\endgroup\$ Commented Jul 2, 2020 at 21:04
  • \$\begingroup\$ Thanks for that link!!! I'll watch the entire thing when I get a moment (and then more that he may have added!) The link I added is about placing the 2-BJT current sink/source under some design management. \$\endgroup\$
    – jonk
    Commented Jul 2, 2020 at 21:07
  • 2
    \$\begingroup\$ Not even "almost." I've taken no classes. ;) \$\endgroup\$
    – jonk
    Commented Jul 2, 2020 at 21:34
  • 1
    \$\begingroup\$ I've been listening and I see the moment (about 11 minutes in) where he talks about the mechanical vibrator. As a young kid I'd repair car radios with these. Because (a) this is usually the "point of failure;" and, (b) it was really easy for me to understand the basic idea and know where to find it and replace it; and, (c) I didn't yet have enough knowledge to do other kinds of repairs ;) I've really enjoyed his discussion -- most especially so far what he said right at the beginning about the motive for inventing the phone dialer system. Real life is often better than fiction! Again, thanks! \$\endgroup\$
    – jonk
    Commented Jul 2, 2020 at 22:08
3
\$\begingroup\$

These devices usually spec a current transfer ratio which makes it hard to determine how the LED is actually working (it would be better if they gave a curve for the LED).

With LED's more current can cause lifetime issues, so it's best to stay at the nominal value. In their testing diagrams they used 10mA, I would stick with that. If you were running into issues on the transistor side with it not turning on, then I could see needing to get a better current transfer ratio, but it looks like you can also set R44, so that would be a better way to adjust the transistor current.

So if you use 10mA and a forward current of 1.15V with a 3.3V Vcc then you'd need a V drop on the resistor. V/I = R

so 2.15V/0.01A = 215Ω

For (12V-1.15V)/0.01A= 1085Ω

On the transistor side, it really depends on what the transistor of the opto is connected to. The resistor needs to source more current than the load (whatever pin is connected to). For most microprocessors 20k or 10k is plenty.

enter image description here
Source: https://www.vishay.com/docs/83653/ild620.pdf

As far as connecting the LED directly to mains, it's not safe. At minimum need an isolation transformer. You could use a step down transformer. The problem with connecting the LED side to an AC signal is if you push the button down and turn the LED on, it will cycle at the mains frequency and turn on and off rapidly, if you don't want this to happen the best way would probably be to use an LDO.

\$\endgroup\$
1
\$\begingroup\$

There is no need for an Optocoupler here.

RS232 can go much further than this easily with higher impedance. Just need UTP cable for balance on ingress EMI.

You show common grounds and there is probably supply crosstalk leakage. Just use a low impedance switching circuit to shunt Vbe with ESD protection when the switch closes.

schematic

simulate this circuit – Schematic created using CircuitLab

All R values can be scaled up if 5mW power is a concern.

If there are high current noise impulses on wires nearby, you can add 10nF to 100nF Cap across Vbe. Use UTP wire for CM rejection and STP wire for an aggressive noise environment.

Optoisolator will not block help on the above noises since there is no ground current in the open switch state to have crosstalk. Thus no advantage. But if there was capacitive coupled noise to the cable, the opto would pass that thru as current.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.