# AC Switching Relay isolation with Optocoupler

I am trying to do a schematic to switch a relay using my MCU. MCU GPIO works at 3.3V. I have come across the following schematic, but unable to calculate proper CTR and thus the value of Base Resistance of Q2.

The Forward Current Vs. CTR graph shows a CTR of 1 at 10mA (Vce 5V)

But I don't see the actually percentage of CTR in the Characeteristic table. The table has listed all the CTR at Vce 10V.

• Possible duplicate of How to convert a digital signal from 5V to 24V? Apr 13 '18 at 11:23
• The opto-coupler is pointless here since it not isolating anything. Apr 13 '18 at 11:24
• Hi @OlinLathrop, no it's not duplicate, the referred question and answers there are completely different. Please do have a look before you mark it duplicate. I did not ask a broad question like that (Operate 24V from 5V). My question is more specific. Apr 13 '18 at 11:27
• Look at the solution posted in the answer to the question this is a duplicate of. The same solution applies here. Since part of the answer is to remove the opto, details about how to choose the right opto are, of course, pointless. Apr 13 '18 at 11:31
• Aside from the value provided by the opto, your driver is not a great design. The current the opto gets varies with the indicator LED voltage. I suggest moving the transistor to the low side and giving each LED its own resistor. Apr 13 '18 at 12:33

The drive circuit as shown, if 'logic' might be TTL at 3.5V, is inadequate. The LED in the opto takes circa 1.2V, the visible light LED takes maybe 1.6, maybe 3 (depends on color), and the base-emitter drop takes 0.7V; that doesn't add up and give you a margin of operation. Try using the high gain of the transistor to drive parallel loads instead of stacking everything in series, like:

simulate this circuit – Schematic created using CircuitLab

As to the 'R3' value, with the mininum CTR of 4N35, 40%, and feeding circa 10 mA to the optoisolator, you get minimum of 4 mA base current. The 5V, 70ohm relay will take 71 mA, so a switch transistor with beta>100 and 200 mA capability (2N3904 or lots of others) will work fine. Figure on wasting one or two volts, with R3 * 4 mA = 1.5V and you get R3 = 360 ohms. At 5V that (if CTR is very high) limits the isolator transistor to 12mA, which won't hurt it or the base of Q2.

4N35 collector current maximum is 50mA continuous, 100mA peak.

In answer to your specific question, you can probably assume the CTR stays within about 80% of the value at Vce=10V down to Vce=1V, so if you design based on that you should be safe.

But when I say "design for that", don't forget to allow for tolerances, worst-case CTR, temperature effects and aging of the IR LED in the photocoupler. Anecdotally, some brands are much worse than others for aging, and higher currents/temperatures are worse, so buying a more expensive opto than a 4N35 with good CTR (so the LED runs at lower current) from a top-tier supplier can be a good move.

Circuit looks simple it can be solved by few minor changes.

1) R1 need to be properly calculated based of forward current of opto led. Consider 10mA for this and vcc is already mentioned as 5V. Use ohms law to calculate R1 value 2) Connect second pin of opto to ground. 3) If you want visual indication on state of opto, remove D2 form opto second pin and connect it to emitter of Q1 with current limiting resistor 4) Configuration you shown above is having 2 led in series which would require higher vcc since voltage drop across opto led and D1 + voltage drop across pn junction on Q1. Which can be easily avoided as i mentioned above.

Secondary side

1) Connect 4th pin of opto to ground via 1k resitor 2) Connect R3 to emitter via 120ohm resisitor which will serve as current limit for base of transistor.

Keep rest of the circuit unchanged.