how to use an optocoupler? - Page 1
Forum section: electronics / projects

author: drakejest
author_rank: Regular Contributor
timestamp: October 05, 2021, 11:44:48 pm
content: Hello i would like to use an optocoupler to isolate between signals, digital isolators are expensive thus im opting to use optocouplers as they are cheap and anyway the signals im dealing with are not that fast anyway.I went ondigikeyand pretty much they all the same exempt for the Current transfer ration min/max , what does that mean?So i would like to use 2 opto couplers actuallythe first one:Is to drive a mosfet from the mCu on the other side. I do not know what values to place on R7 and R8The second one is a sigal line going into the micro controller. The characteristic of the signal is, the line is always pulled up when something happens the line will be pulled low for 1.8 milli seconds and go back to high. there is significant capacitance on the line about 1-2nF( Again not sure about R9 and R10 values)Is my circuits correct? is high CTR good>? or i should pick the lowerst?

author: pqass
author_rank: Super Contributor
timestamp: October 06, 2021, 04:03:13 am
content: Quote from: drakejest on October 05, 2021, 11:44:48 pmhttps://toshiba.semicon-storage.com/us/semiconductor/knowledge/faq/opto/opto-015.htmlFor example, if CTR=50% and you drive the LED with 10mA, the phototransistor side will allow 5mA to pass (CTR＝(Ic/If)×100).I don't think this matters too much to your circuit because your opto's phototransistor is driving a high impedence MOSFET gate.QuoteIn the first circuit,size R7 for the lesser of a current that is below the Ifm (max current) of the opto LED and a current that your uC GPIO pin can provide.But not too low a current in the LED such that the phototransistor won't be able to drive your MOSFET (which is a very low value since your MOSFET won't need very much).I'd start with 10mA for the LED. R7 = (Vcc-Vf)/If = (3.3V - 1.25V)/0.010A = 205R, or 220R (next standard value).Vf for opto LEDs are typcially very low; about 1.25V.You chose 100R, which if you follow the formula above, will be 20mA. Can your uC provide this current? Is it below the Ifm (max current) of the opto LED?I think R8 at 100R is too low as [you would think] it could conduct 50mA if placed across 5V (when the phototransistor conducts). Update: actually, CTR likely won't allow the voltage to approach 5V so may never actually turn on the MOSFET (has to exceed gate threshold voltage). More typical values for pullup/down resistors are 10K.Also, the LED drive arrangement is atypical; defaults to on when the MOSFETs are off and R1 and R2 would conduct 50mA when the two MOSFETs are on. Why don't you re-arrange them so they are connected: Vcc -> resistor -> LED -> MOSFET drain -> MOSFET source -> GND. R3 would still be connected to the Q1 drain.QuoteIn the second circuit,R9 should be higher, say, 4.7K (given 3.3V Vcc). R10, see above on how to choose an acceptable current (lesser than the opto max and source can provide). Capacitance would just make the signal rise slower. May cause problems on the uC side if it isn't a schmitt trigger input.QuoteSee first link above. It may not matter to your circuit. Other criteria may be more important; eg. speed, package size.I've been playing with a MCT6 dual opto and can't really put more than 2KHz square wave (3.3V through a 2K LED resistor) without seeing a noticeably slow rise on the phototransistor side (using a 10K pullup on the collector to 5V). The datasheet says it can do 150KHz but only with 100R pullup to 10V Vcc.This will draw 100mA!Actually, this will be limited by the CTR so your output won't touch ground any more. Using 3.3V squarewave through a 2K resistor to drive the LED, and a 330R pullup on collector to 5V Vcc, the output switches between 3.6V and 5V @ 22KHz before the square wave gets mangled too much. Changing the 2K for a 330R LED resistor now shows a 30KHz rounded square wave on the phototransistor side that switches between 1.7V and 5V. Increasing the LED current from 1mA to 6mA caused output p-p to grow from 1.7V to 3.3V. Tradeoffs will need to be made.