Calculating resistor for optocoupler - Page 1
Forum section: electronics / beginners

author: joeyjoejoe
author_rank: Frequent Contributor
timestamp: April 07, 2020, 10:19:41 pm
content: I'd like to use a TLP290-4 in my design.https://media.digikey.com/pdf/Data%20Sheets/Toshiba%20PDFs/Half-Pitch%204-Ch%20Trans%20Photocouplers%20Ref.pdfIt is an opto-coupler that works with both AC and DC. The primary use will be 24VAC signals, but it would be great to have it work down to 5VDC. (Something like thishttps://www.robotshop.com/ca/en/elexol-8-channel-opto-i-o-board-3-24v-dc-ac.html,which has a schematic)The output side of the opto is going in to a micro controller, so the current needs are next to nothing.How can I determine the proper sized resistor to put on the input side of the opto?Maximum current for the LED is 50mA - aim for 45mA at the high end.24VAC = 34V RMSR= V / I = 34 / 45 = 755 ohmsAt this resistance, a 5VDC input would have around 4mA. I don't know where in the datasheet to know if this will be enough current to trigger the opto.

author: Vovk_Z
author_rank: Super Contributor
timestamp: April 07, 2020, 10:25:15 pm
content: You have to work with CTR - current transfer ratio (minimal value, 50% here).You have to know load current (output current). Divide it to CTR and the result is your needed input current.For example, if output curŕent is 1 mA, CTR is 50% (0.5), then input current is 1 mA / 0.5 = 2 mA.

author: Smokey
author_rank: Super Contributor
timestamp: April 07, 2020, 10:27:52 pm
content: As was said, make sure you always have enough current to meet the minimum given the CTR at all operating voltages. Pick a resistance value based on that.Then size the resistor package(s) such that it can dissipate the worst case power at that resistance value.

author: joeyjoejoe
author_rank: Frequent Contributor
timestamp: April 07, 2020, 10:28:34 pm
content: With a micro-controller, with such a high input impedance, wouldn't the current needs be minuscule?

author: Vovk_Z
author_rank: Super Contributor
timestamp: April 07, 2020, 10:36:08 pm
content: If microcontroller input impedance is very high (so current is in order of microamps-nanoamps) it is better to increase that current to the value which is at least an order larger then optocoupler dark current.I mean just add some resistor in parallel to microcomtroller input.For example, that TLP290 collector dark current is 0.1 uA max, then load current have to be at least 10 x 0.1 = 1 uA.

author: joeyjoejoe
author_rank: Frequent Contributor
timestamp: April 07, 2020, 10:59:34 pm
content: So I guess something like this wouldn't work?(ESP32 will be set to input pulldown, no need for external pulldown resistors)MCU is an ESP32 - I can't seem to find input impedance anywhere (datasheets or brief googling)

author: iMo
author_rank: Super Contributor
timestamp: April 07, 2020, 11:12:15 pm
content: Quote from: joeyjoejoe on April 07, 2020, 10:28:34 pmIt depends on the speed of your signals. With lower currents the parasitic capacities need more time to be charged/discharged (thus the edges will be slow).With slowish signals you may use, say 50k pullup at the mcu input (opto-collector wired to the mcu_input, emitter to GND), with 3.3V mcu_Vcc the Ic=67uA.With CTR=50% min the led diode resistor's value Rf should be lower thanIf = 67uA / 0.5 = 134uARf = (Vinp_min - Vf) / If = (5V - 1.5V) / 134uA = 25k (to be on the safe side I would go with 4k7)Check:5V input .... If = (5 - 1.5) / 4k7 = 0.75mA34Vpeak ... If = (34 - 1.5) / 4k7 = 7mAPS: also mind the diode's reverse voltage max is 5V, thus you need an anti-parallel diode at the input.

author: Zero999
author_rank: Super Contributor
timestamp: April 08, 2020, 11:30:42 am
content: Quote from: joeyjoejoe on April 07, 2020, 10:59:34 pmJust use an external pull-down resistor, that way you can be certain of the impedance.Quote from: imo on April 07, 2020, 11:12:15 pmThat's reasonable, yes it's better to have slightly more, than too little current.QuoteNot necessary, because the opto-coupler used by the OP is bidirectional.https://www.mouser.com/datasheet/2/408/TLP290-4-1209274.pdf

author: joeyjoejoe
author_rank: Frequent Contributor
timestamp: April 08, 2020, 12:39:02 pm
content: Awesome, thanks Zero!I added the capacitor in hopes of eliminating noise. I wonder if I should increase R? to also raise the threshold for noise as well?What's good is if the overall schematic is good, I can order the boards and then play with the resistance value after the fact.

author: Zero999
author_rank: Super Contributor
timestamp: April 08, 2020, 01:13:54 pm
content: Quote from: joeyjoejoe on April 08, 2020, 12:39:02 pmYou probably want to increase R? just to decrease the power dissipation a bit. P = V²/R = 24²/750 = 576/750 = 0.77W. Of course this doesn't take into account the small amount of power lost in the opto-coupler, but it's still a fairly chunky resistor and what if the voltage is higher than 24VAC? I think the 4k7 calculated by imo is a more sensible value.

author: joeyjoejoe
author_rank: Frequent Contributor
timestamp: April 08, 2020, 01:23:39 pm
content: Okay thanks.The signal speed is slow - it is HVAC signalling, so... a few seconds

author: wraper
author_rank: Unknown
timestamp: April 08, 2020, 01:24:09 pm
content: Quote from: Smokey on April 07, 2020, 10:27:52 pmMeet and exceed by 50% at least. Optocoupler CTR tend to degrade over time.

author: Smokey
author_rank: Super Contributor
timestamp: April 08, 2020, 08:10:25 pm
content: Quote from: wraper on April 08, 2020, 01:24:09 pm+

author: Ian.M
author_rank: Super Contributor
timestamp: April 08, 2020, 08:47:30 pm
content: Yep. A prudent engineer never drives an Optocoupler too close to its max If, and always derates the CTR by at least a factor of two to avoid problems as the LED output drops with age. 10000 hours rated life is under 14 months if its on 24/7! You also need to figure out how much more margin you need if the tolerances of the resistor, LED Vf, driver ON state voltage drop, and supply voltage all stack up in the unfavourable direction.

author: Zero999
author_rank: Super Contributor
timestamp: April 09, 2020, 09:16:42 am
content: With such a wide input voltage range of 5V to 24VAC, it might even be worth using a constant current source, although it is extra complexity which you might want to avoid.

author: max_torque
author_rank: Super Contributor
timestamp: April 09, 2020, 09:53:06 am
content: Quote from: Zero999 on April 09, 2020, 09:16:42 amconstant current diodes are reasonably affordable these days? One component so not difficult to put into the circuit!

author: Zero999
author_rank: Super Contributor
timestamp: April 09, 2020, 02:00:27 pm
content: Quote from: max_torque on April 09, 2020, 09:53:06 amJust looking at Mouser, they're not cheap and it's AC, so a bridge rectifier would also be required.https://www.mouser.co.uk/Semiconductors/Discrete-Semiconductors/Diodes-Rectifiers/Current-Regulator-Diodes/_/N-ax1ml?Ns=Pricing|0

author: joeyjoejoe
author_rank: Frequent Contributor
timestamp: April 09, 2020, 02:22:42 pm
content: Yeah not cheap. I think with what is proposed here and a bit of testing I should hopefully be OK with an opto. Even with a 4k7 resistor, that should be plenty of current to trigger a MCU input?