# Is this a reliable circuit to monitor AC mains voltage?

I want to design a simple circuit to monitor AC mains voltage and take simple decisions if the voltage falls below a specific reference voltage.

It's important to mention that accuracy isn't an issue at all.

Circuit description : The input voltage is stepped down to 9 V peak voltage and rectified, the rectifier plus the capacitor is intended to act like a peak detector and the output voltage at C1 would represent the peak input voltage (of course after stepping down).

This voltage is scaled via R1 and R2 then compared to a reference voltage using hysteresis comparator (using LM358 but not found in ltspice).

Is this a valid concept ?

For reference and to protect against future edits, here is your circuit that will be discussed:

The basic idea is OK, but there are some things to consider:

1. Powering the opamp from the same signal you are trying to measure is asking for trouble.

2. I don't like how this circuit looks at peaks instead of more a average. Ideally you probably want RMS, but that's difficult to do. You know the voltage is mostly a sine, so the average tells you what you need to know.

The problem with grabbing peaks is that it's quite susceptible to noise. You're only getting information from the waveform at two points each cycle. This means you have little opportunity to filter out noise.

Worse yet, the susceptibility to noise is non-linear. One positive glitch at a peak will make the measurement read high for quite a while. A single negative glitch at a peak will go largely unnoticed.

Put a resistor before the capacitor so that you get low pass filtered absolute value, not recent max peaks.

3. You may not need a opamp or comparator at all. If the output of OP07 is going into a microcontroller, then you might as well feed the filtered and clipped analog signal to the micro directly instead. The micro can trivially compare the result to some threshold in firmware. Then changing the threshold is a firmware change, not a hardware change.

• I'm sorry but I'm kinda lost at the "clipped" voltage thing, You said that I may not need an op-amp at all if the output of OP07 is going to a microcontroller, how is that? the OP07(in the schematic) is supposed to be the comparator and its output would be my output digital signal. and what do you mean by the clipped voltage in the circuit? (my mind goes to clipping circuit using zener diodes.) I know i have missed something so please hold out my ignorance :D . Commented Jun 30, 2017 at 23:15
• @iMo: I mentioned clipping to protec the rest of the circuit from unusual but large voltage spike. Those sometimes happen on power lines. I was suggesting that if your digital signal would go into a micro, feed the analog signal into a A/D input of the micro, then the rest is firmware. Some micros have comparators built in too. You can arrange to scale the rectified and filtered AC signal so that the threshold is about the midpoint of the micro's power supply, then feed such a midpoint signal into the other comparator input. Commented Jun 30, 2017 at 23:30

EDIT: The question now mentions a transformer, so this answer is somewhat unfitting.

Your circuit hasn't potential separation so it's a safety nightmare. Experienced engineers can build such things safely but there has to be some justifaction to do so, e.g. a self-contained circuit in a extension lead not heaving any connections to outside but 120/230V circuits anyways.

I recommend you to make the 120/230V part as simple as possible, and put the whole other circuit behind an optocouple.

simulate this circuit – Schematic created using CircuitLab

The values 1kΩ, 100nF of the RC pair depend on the CTR of the optocouple you are using. Pick the correct voltage range and power rating. The 1MΩ resistor is there to discharge the capacitor when the device is unplugged, it's uncritical. Pick the correct voltage rating for the rectifier, too (your 1n914 aren't useable for mains voltage.)

Don't even think of leaving the fuse out!

The current through the photodiode (or phototransistor) follows the current through the LED, but safely seperated. As that one depends on the mains voltage, you can measure it that way.

• I'm using a 220 V /9 V transformer for isolation, is that what you mean? Commented Jun 30, 2017 at 20:08
• I don't see that transformer in your circuit. But yes, that would make the thing safe, too. Commented Jun 30, 2017 at 20:10
• Janka, actually the two conducting diodes among the bridge together with forward biased LED clamp voltage at bridge AC connection around a few volts peak. That's diodes VRM called for. Commented Jun 30, 2017 at 20:12
• I've edited the question to mention the transformer clearly. Commented Jun 30, 2017 at 20:13
• @carloc: yes, I thought about that, too, but it's not safe to rely on clamping. (But then, when the LED burns out, we may give up all hope and let the rectifier burn out, too?) Commented Jun 30, 2017 at 20:14