# Measuring mains - shifting ground from mains to bridge

The circuit below is a simplified and partial front end schematic of a solution that measures main voltages and takes action if over voltage, under voltage or "wrong voltage" (e.g. user plugged into 220 Vac and appliance is not automatic). Main measurement should be within 1% error.

EDIT: fixing U4 connection. EDIT2: updating figure

(Still need a DC shift before R4 reaches secondary ground. Or dual supply to the op amps.)

From the rectifier bridge, a LM317 supplies power to all the ICs (not shown). Under_voltage, Over_voltage and Wrong_voltage are triggers, coming from comparators and going into latches and logic (also not shown)). A NO relay at the end of the circuit must be activated to allow appliance to be main powered (just guess, not shown lol).

There is a difference between the secondary and the bridge references, indicated on the schematic by the common ground and chassis ground (should be earth gnd, but no such symbol in LTSpice :) ). The difference is, of course, a 0.7 V diode drop, and I should account for it in measurement.

One way to go is just use an instrumentation amp, and that ground shift is solved. But that looks like an overkill, since I don't need all the CMRR, either extra high input impedance an instrumentation amp has to offer. Also, it is somewhat expensive (although I've just found a $0.54/1k unit in amp: http://www.ti.com/product/ina332). A differential amp would be not ideal, since I can't cheaply match input resistances (at least not precisely), and I have surprisingly found that the cheapest diff. amps is more expansive than the INA332 in amp mentioned above: http://www.ti.com/product/ina154. I am not sure if other manufacturers follow this price tag as well. I was considering maybe using a charge pump for powering the ICs, then there is no 0.7 V drop. In the charge pump case, its power capability should be well calculated - just closing a miniature 10A relay might need about 30mA, indefinitely. What do you think, can you suggest me a strategy? Keep the bridge and deal with the ground shift, going with the charge pump, or something else? • Why not just measure the DC voltage across C1? As it stands, your circuit is trying to measure AC voltage which is harder to do than DC as it keeps changing. Mar 27 '17 at 8:52 • And, by the way, your inputs to U4 are the wrong way round. Mar 27 '17 at 10:12 • @Finbarr This solution is meant to protect other equipment from "wrong" voltages and last at least 10 years. Since I need an electrolyctic cap on C1, degradation will probably be an issue for measurement. OTOH, degradation may not pose a problem to the LM317, since it can handle some ripple. After many years and possible severe degradation, in case there is no proper rectified supply for the LM317, all the circuits above go down. In this case, that is not a safety issue, because there is a NO relay at the end. – tfm Mar 27 '17 at 16:14 • @Finbarr Furthermore, I can't say the temperature my circuit will be exposed to, and that may add to C1 degradation, and finally leakage current may be a problem to measurement. So I'd rather measure the secondary and compare the peak with a reference. Any trigger will be latched, so I don't think it will be any harder. – tfm Mar 27 '17 at 16:15 • @Finbarr U4 input fixed. Thank you, that is a "late night" effect... – tfm Mar 27 '17 at 16:15 ## 2 Answers The Vsec voltage is an AC voltage ( in addition of being offset to GND ) so you will get square waves off the comparators. A small-signal diode connected to positive terminal of C1 plus a non-electrolytic cap will give you a GND referenced DC voltage that can be checked for under/over/other voltage conditions. • That is still referenced to the bridge rectifier ground, and not to secondary. There is no need to rectify it to DC. But OTOH, your idea gets me rid of the problem that I either need a positive DC shift before the voltage divider reaches the secondary ground, or a dual supply for the op amps. Also, the slight voltage variation on the diodes are well within the 1% error budget. – tfm Mar 28 '17 at 6:32 • But thinking again, the C1 cap would prevent any event coming from main at one cycle time scale. C1 would smooth too much! – tfm Mar 28 '17 at 6:37 • If you need fast response from the over/under voltage circuit connect a diode from + output of the bridge to the C1 cap and connect the resistor divider directly across bridge output. Mar 28 '17 at 7:50 • Yes, user117884. I believe that is the cheapest solution. I'll try it and see how it fits with everything else. Thank you – tfm Mar 29 '17 at 17:01 Unless you just want a trigger on an overvoltage spike (a bit hard to open a relay in time to do anything about that though) you will need to rectify the voltage you are going to be measuring anyway to make it DC, so you might as well measure across the capacitor, this will also help it to not be triggered by transients that will be soaked up in a basic filter and do not pose a risk. Is the device to be powered drawing from the rectified output? If not then you need a resistor to discharge the capacitor or it will not detect undervoltages. Optically isolated amplifiers are an alternative for crossing awkward ground level differences and would allow you to safely measure voltages on the primary side, here's a common one that doesn't even need a power supply for the input side: http://www.farnell.com/datasheets/2212115.pdf They cost about$1 though.

Edit: Ah good I see. If you want a very tight limit on line voltage you will want to measure it directly rather than from the secondary of the transformer. Put a bridge rectifier across the line and measure voltages from that. The upper limit is easy and can be implemented how you did in the question, the low voltage limit will need an averaging circuit though.

(voltage regulators and comparator references and some other stuff omitted but you get the idea)

simulate this circuit – Schematic created using CircuitLab

The overvoltage comparator will be triggered if the peak exceeds the reference by enough and for enough cycles. The undervoltage comparator will be triggered every cycle if the voltage is high enough before being passed through an integrator and comparator, if the input does not spend enough time above the minimum voltage each cycle the undervoltage signal will be triggered. The decay of the integrators can be adjusted with the pots to control the sensitivity, the dividers should have a much higher resistance than the pots if you use them.

I would highly recommend not sensing through a transformer unless you do not need much accuracy, or if you do then use one that is a fair bit larger than required to power the circuit, rectifiers are a lot cheaper than larger transformers though and you do not need the isolation. I would definitely not use the capacitor for the power supply as an integrator though, it will have much too long a response time for one that is big enough to remove ripple for the op-amp supply and you will use a lot of power for the size of decay resistor you would need for the size of capacitor.

• Thank you for your reply. I have updated the circuit. It is still simplified, but more complete than before. This circuit is intended to deal with sags and swells that last over a cycle. Release time of a relay is ~ 5 msec, so total response time will be within a cycle (50 or 60Hz). It is also intended to protect against wrong voltages (eg, user plugged into 220V, and the appliance is designed for 110/127V). This circuit is not concerned with fast spikes. Yes, optical isolated amps and instumentation amps are the usual choices for dealing with incompatible ground levels.
– tfm
Mar 28 '17 at 6:06
• But there is no need to rectify the AC for measurement. AC can be compared against a DC reference, provided that all that matters is the peak value.
– tfm
Mar 28 '17 at 6:11
• The device to be powered is not powered by the rectified output. It is powered by a main line. The first (maybe only) purpose of the bridge rectifier is to provide a DC value for powering the ICs. So C1 should indeed keep voltage from bridge smooth enough for the LM317 to operate properly.
– tfm
Mar 28 '17 at 6:40
• Ah good, opamps are usually quite resistant to supply noise anyway. I've added things to my answer that I hope are what you are looking for.
– TWiz
Mar 29 '17 at 6:49
• Thank you TWiz. We can avoid using 2 bridges using what @user117884 suggested: just a diode between the bridge and C1. Also, I believe that the error contribution form the xfrm and the Vdrop variations will be quite below the 1% error budget for measurement. You are right about the integrator, otherwise fast spikes may trigger the latch. So it is probably a good idea to have an low sensitivity integrator before over and under voltages comparators. I'll test it on the bench and let you know.
– tfm
Mar 29 '17 at 16:54