# Does this optocoupler circuit work practically?

I've been trying to make a circuit that:

1. Outputs 12V when the power is off
2. Outputs 0V when the power is on.

Input is 230V 50Hz AC.

I have a question about the voltage across the output capacitor. When the mains is on, it seems the average voltage across the capacitor is 0V. Am I correct or missing anything? I'd highly appreciate your input before going to mess with the high voltages...

simulate this circuit – Schematic created using CircuitLab

• Might not work as you intend (e.g. LED stays on if there is power, else off). If that's directly the mains, you may want to consider the heat, too. Commented Aug 25, 2020 at 19:21
• You've drawn ground symbols on the "live" side and the "safe" (low voltage) side and as all symbols are the same, it means that they're connected. In reality you would not want that, I would remove the ground on the mains side (the left one) and only have ground on the safe part of the circuit. Commented Aug 25, 2020 at 19:24
• 230 V AC across just one resistor is "pushing it" as ordinary 1/4 resistors are rated for about 200 V. It is better to use two 15 k ohm resistors in series. Commented Aug 25, 2020 at 19:26
• @across Suppose that LED can take full 325 V reverse voltage. The power dissipated by the resistor would be ~323^2 / 30k ~3.48 W. You'll need at least some 5 W rated resistor. If you want to prepare for the winter, that's fine. BTW, 1N4148 can only take 75 V (or 200?, can't remembrer). Commented Aug 25, 2020 at 19:27
• There are "smarter" ways to make an LED (inside an optocoupler) light up more efficiently, search this site for "LED mains voltage" and you'll find some examples like the "capacitive dropper circuit". Commented Aug 25, 2020 at 19:29

This is pretty much fair, you just need a high power resistor.

The resistor can be replaced with a capacitor (220n 275VAC) and will not heat up.

• May I know if R1 1k is required? It seems the 220n capacitor reactance limits the current, so... Thank you so much for the beautiful simulations:) Commented Aug 25, 2020 at 20:36
• When first switched on, it is not known in which phase the capacitor is switched on. So the first charging current must be limited. Commented Aug 25, 2020 at 20:45
• Indeed it must be limited, but isn't 1k a bit too small for that? I wouldn't risk exposing the LED to more than 100 mA even momentarily. Commented Aug 26, 2020 at 14:58
• Forward surge current for the LED 1,5A. Commented Aug 26, 2020 at 15:53

Supposing the whole circuit works without smoke, what you have there is an optocoupler which will be turned on/off 50 times per second. This makes the transistor act the same. Which means that the cap will be charged according to the time constant, but discharged by the transistor. So there will be some voltage, but if you use a comparator afterwards, it should work.

However, the resistor will dissipate some 1.75 W (miscalculated in the comments), which means it will need a rating of at least 2 W (3 more likely). It might be best to listen to Bimpelrekkie's suggestion.

Here's a quick simulation in LTspice:

So if you want a relay afterwards, you could use it, since the voltage across the cap, even if not zero, will be, most probably, below the threshold. But be careful, even that little voltage as it is will still be considered a load by its inductance. Only don't connect the relay straight on the optocoupler's transistor, instead of the 10k resistor, because you'll have an LC tank there.

• interesting... so the average voltage on capacitor is not 0V! I'll be connecting the output to a relay. Do I still need a comparator or will I be okay? Commented Aug 25, 2020 at 19:58
• @across I've updated my answer. I still say it's too crude a circuit, but it's your choice. Commented Aug 25, 2020 at 20:07
• As you said, 50 times on/off cycle may cause in long term, some AC Input Optocouplers can help to improve circuit. Commented Aug 25, 2020 at 20:14