AC Line Safety

In order to make the power measurement unit more compact, I am considering following in the footsteps of the open energy monitor project as well as the low-cost single phase power meter design published over at Atmel. The line voltage is a nominal 120VAC.

Below, you can see the circuit that I am considering for the AC voltage measurement. Both line and neutral have drop-down resistor while the measurements are taken off of the 4.7k resistor (i.e. it's floating - 59VAC above and 59VAC below). The two 1k resistors create a DC voltage divider that the 10uF tantalum cap supports. The 22 Ohm resistor, BAV99, and the 100pF capacitor are protections that Grumpy Mike suggested on his site and I hope I implemented them correctly.

For this design I expect the output signal for the Arduino to fluctuate from about 0-2.5VDC (i.e. 0VDC to AREF). I have successfully used this topology before with a AC-AC transformer. Note: the AREF has it's own 2.5V linear voltage regulator that derives its power from an isolated 5VDC switch-mode power supply (VOF-6 from CUI).

Here now my questions: For one, is it a good idea to have the 220k-4.7k-220k resistor network set up this way? The reason I chose this topology is to guard against the possibility of a line/neutral reversal in the wall socket. Having a drop down resistor on either leg feeding the 4.7k resistor that measurements are made on reduces the maximum current to less than 10mA even under peak line voltage conditions and a short to GND on the Arduino side of things.

Atmel goes a slightly different route in their design. They use a series of drop down resistors and tie the AC neutral and AC ground lines together. Their power supply is a drop-cap design that feeds a linear regulator. I could tie the AC GND and AC Neutral together as well, I simply worried about fireworks if the outlet was miswired. This does not seem to be a concern for a power meter... :smiley: Which design is better?

Also, as designed the 120GND and the board GND are not tied to each other and there doesn't seem to be a need given that a similar design has worked in the past when I used an external AC-AC wall transformer and a external switchmode DC power supply. Is the above sane?

  1. I am not a qualified electrician nor an electrical engineer so I don't know about this. But, if you have to ask these questions on this forum then you don't know enough either.
  2. There is a path from LINE1A through a couple of resistors and a diode to the Arduino AREF. If you actually try this out without qualified advice, you'd better stand well back before you switch it on and be prepared to clean up the mess and order another Arduino.

Pete

I would not recommend this circuit because it connects the arduino directly to the mains, with all the problems that brings.

The 22 Ohm resistor, BAV99, and the 100pF capacitor are protections that Grumpy Mike suggested on his site and I hope I implemented them correctly.

I think you misunderstood what that was protection for, it was for line transients not for continuous operation. In effect you have the mains connected through a 220K resistor and a diode to the Aref input which will blow sky high anything connected to or powering the Aref pin.
You also seem to have made a connection to ground, which should not be used as part of the return circuitry in a mains unit.

The reason I chose this topology is to guard against the possibility of a line/neutral reversal in the wall socket.

Good the live and neutral must be considered interchangeable for safety purposes. However this is a dangerous circuit.

OK, I thought I was missing something. In the past, I used a wall-wart AC-AC transformer for the AC input signal. Here is a analogous circuit with an on-board transformer from Pulse Engineering. The specific model is designed to bring 230VAC down to 6VAC, so in use with the 115VAC input the output should be 3VAC.

Pulse Engineering was nice enough to list the no-load voltage, 4.6VACrms in this usage. Adding 20% of safety factor and multiplying by 1.41, I get a peak voltage of about 7.8V. The voltage divider circuit then reduces that AC voltage signal down to less than 2.5V, centered around 1.25VDC. Does the above seem reasonable?

So I expect the BAV99 to activate only when the voltage shows significant excursions above 140VACrms. That's hopefully rare - but do I have it right? Circuits similar to this one have worked well for me and I was too greedy trying to eliminate the transformer. FWIW, the transformer is allegedly short-circuit proof and the attached circuit only draws about 1mA (vs. the 13mA that the transformer can deliver). Would loading the transformer more help with accuracy? That is, decrease the load resistor from 1k to 200 Ohms, the drop resistor from 2.2k to 470 Ohms and hence increase the circuit draw to about 6mA, for example?

Presumably, since this is a transformer-based design, the polarity is less of an issue? I have the fuse on the presumed line input, 1A, which also protects the switch-mode power supply. I guess I shouldn't worry too much about reversed polarity then?

Speaking of which, some of the CUI power supplies suggest common-mode chokes for better EMI performance but this one specifically does not in its datasheets. Per the manufacturer (I inquired) they are not necessary. But would you add other external components beyond the fuse to limit transients, reduce EMI noise, etc?

Many, many thanks again and I apologize to Mike for misapplying the knowledge he so generously shares.

You still have a problem with this. You are feeding AC into a polierised capacitor and into the Aref. The BAV99 will be active on every negitave cycle. I can't see how the potential dividers work as they are not refracted to ground.

OK, let me go back to past documentation and come back again later when I have more information. It's entirely possible that I got the drawing wrong.

FWIW, I based my implementation on the prior work done by the open energy monitor project. Their description of the AC-voltage detection circuit can be found here. The circuit there seems similar to the one I have posted above (minus the BAV99, 22Ohm Resistor, and the 100pF capacitor), which is what is baffling me. If you have a moment to review the above, I'd be much obliged. And even if you don't, many thanks again for your help, Mike, I really appreciate it.

What is it about your circuit that is similar to the one you linked? Their circuit connects to Arduino's +5V, Gnd and an Analog input (unspecified pin number) whereas you've hooked it to "VOLTS" (whatever that means), Gnd and AREF (which is NOT an analog input pin).

I have the fuse on the presumed line input, 1A, which also protects the switch-mode power supply

What switch-mode power supply?

Pete

Ok I have had look at that link. Basically what it is doing is providing a strong 2.5V bias and then letting the AC pull it slightly one way or the other. It is the resistor values that are vital here and I think you have R3 and R4 way too low and too close to each other. If you look at that circuit in the link Those resistors are ten times each other where you only have them twice each other.

Prudence would say to ground one side of the secondary, apply the voltage dividers for line scaling then capacitively couple the ac to the arduino input biased at 1/2 IOReference. This keeps any winding leakacge that may or may not be present from being applied to the cmos inputs of the arduino.

Constantin:
OK, I thought I was missing something. In the past, I used a wall-wart AC-AC transformer for the AC input signal. Here is a analogous circuit with an on-board transformer from Pulse Engineering. The specific model is designed to bring 230VAC down to 6VAC, so in use with the 115VAC input the output should be 3VAC.
...

I've used a very similar circuit to monitor mains voltage in the past. My Aref voltage was 5v, my equivalent of R13 and R25 were 47K, so the bias was 2.5v. The transformer provided about 9V RMS, R4 was 82K, R3 was 10K and C3 was 1nF. The resistor you have marked as 22 didn't exist. I didn't use extra protection diodes, I relied on the ones already in the Arduino. The purpose of making R13 and R25 higher than you have them was to limit the current flowing into the Arduino protection diodes when a transient passes through the transformer. It's a good idea to ground the core of the transformer if you can get at it, to help prevent transients being capacitively coupled between the transformer primary and secondary.

I think you've miscalculated the voltage: the peak voltage may be 7.8v but the peak to peak voltage is double that. So the input to the Arduino is 5V peak to peak. If you're centering the voltage at 1.25v (which implies that your Aref is fed from 2.5v somehow) then you need the peak to peak input to be below 2.5v.

I think loading the transformer more will make it less rather than more accurate, because it will make it more sensitive to the resistance of the windings and hence to temperature.

I think you misunderstood what that was protection for, it was for line transients not for continuous operation. In effect you have the mains connected through a 220K resistor and a diode to the Aref input which will blow sky high anything connected to or powering the Aref pin.
You also seem to have made a connection to ground, which should not be used as part of the return circuitry in a mains unit.

The reason I chose this topology is to guard against the possibility of a line/neutral reversal in the wall socket.

Good the live and neutral must be considered interchangeable for safety purposes. However this is a dangerous circuit.

Connection to the AC line directly constitutes a HOT chassis. Your computer equipment is not. Under hot chassis conditions grater than 71V ac is present on the hot chassis. Old televisions were HOT chassis, that is why the cords unplugged with the back cabinet. On the service bench we referred to our TV power cords as suicide cords, the sets had to be powered by isolation transformers so you could use your scopes without frying them.

ajofscott:
Prudence would say to ground one side of the secondary, apply the voltage dividers for line scaling then capacitively couple the ac to the arduino input biased at 1/2 IOReference. This keeps any winding leakage that may or may not be present from being applied to the cmos inputs of the arduino.

Hi there and thanks for your thoughtful replies! Based on your feedback and that of Mike's, here is a updated circuit drawing that attempts to meld the two sets of suggestions, i.e. higher resistance values for the signal voltage divider, a de-coupling capacitor in the middle, etc. I think I have it right, but would appreciate further feedback.


The inputs are the same, i.e. nominal 115VACrms input with a nominal 4.6VACrms output. One of the secondary legs has been grounded, the voltage divider circuit across the secondary windings now features higher-resistance resistors as well as a decoupling capacitor. Based on a suggested cutoff frequency of 6 Hz I found elsewhere, I calculated C to be ideally around 0.035uF. Based on the availability of a 0.027uF film cap chip, I selected that value instead. I have omitted the BAV99, the 22 Ohm, and the 100 pF transient protection from the drawing above to keep things simple. The voltage coming into the DC-bias circuit is 2.5VDC as before, which is also the externally-applied AREF voltage (linear regulator).

DC42, you are correct, the AC signal has to vary from a maximum condition of -Vbias/2 to +Vbias/2 for this circuit to function. There is a tradeoff to make between measureable range and voltage protection - how much range to trade for headroom vs. accuracy of measurements at nominal conditions. So the secondary voltage divider resistors are still closer in value than those used by the open energy monitor project (about 5:1 vs. 10:1 ratio, respectively). My reasoning is that I want the Arduino to capture the nominal AC signal as best as it can, there is a allowance for 25% over-voltage, there is the BAV99, the series resistor, the 100pF cap, and then there is whatever is inside the Atmel.

Thanks everyone, I really appreciate all the help. You guys are the best.

The 27nF capacitor is way too small, its impedance at 60Hz is around 100K ohms. If you want to stick with that circuit, I suggest you increase the two 1K resistors to 22K each and increase the capacitor to 100uF (impedance about 60 26 ohms @ 60Hz). Alternatively, I think your previous circuit was OK, because the capacitor from pin 5 of the transformer to ground means that one end of the transformer secondary is virtually grounded anyway.

VRMS=VPEAK0.7071
XC= 1/(2
PIFC)
XL= 2PIF*L
Z=SQR((XC-XL)2+R2))

dc42:
The 27nF capacitor is way too small, its impedance at 60Hz is around 100K ohms. If you want to stick with that circuit, I suggest you increase the two 1K resistors to 22K each and increase the capacitor to 100uF (impedance about 60 ohms @ 60Hz). Alternatively, I think your previous circuit was OK, because the capacitor from pin 5 of the transformer to ground means that one end of the transformer secondary is virtually grounded anyway.

Both of you, thanks for the suggestions and formulas. The previously posted circuit topology has worked for me in the past - I just got my resistor value ratios wrong in my haste to post here.

What is interesting in the light of Grumpy_Mikes earlier comments is that the previous voltage divider on the secondary side was fed by a nominal 6VACrms wall wart, whose unloaded output was closer to 7.2VACrms. The resistors I used on the secondaries were 100 Ohm (whose output fed into the Arduino) and 2.2k for most of the voltage drop. Even though the combined resistance of the two resistors on the secondary of the transformer were very close to the total resistance of the bias circuit, the circuit works... Curious.

I thought I'd explore the capacitive-coupled circuit topology because it's allegedly better at protecting the Atmel. That I got my Xc reactance wrong is just typical of me, it's been a while since I took my last EE course. Thing is, when I plug in the above formulas, I get a reactance of 26 not 60 Ohms as expected with a 100uF cap @ 60Hz. I must be missing something because the ESR of the types of caps I usually consider only add another Ohm or two per their spec sheet...

As far as capacitor types go, are there preferences one should follow? I was thinking of going with a 100uF 10V ceramic cap as there are no issues with reverse bias then and the cost is only a dollar more vs. some of the polarized capacitor choices. People apparently use Aluminum electrolytic capacitors in this type of circuit, what I wonder is what the reverse bias would do to it over time. I wager you'd have to be more knowledgable about the topic than I presently am...

Anyhow, which circuit to go with is a good question at the end of the day is a good question. With the right voltage divider on the secondary and so on, the first circuit is appealing because of its proven performance in past board iterations. The capacitive-coupled circuit certainly also has appeal thanks to the grounded output and costs only marginally more to implement. Thanks again for the insights...

Constantin:
Thing is, when I plug in the above formulas, I get a impedance of 26 not 60 Ohms as expected with a 100uF cap. I must be missing something.

No, it was I who made the mistake, 26 ohms it is.

Constantin:
As far as capacitor types go, are there preferences one should follow? I was thinking of going with a tantalum cap since reverse bias does not appear to be a problem (i.e. point the positive end to the bias circuit, right?). But ceramic caps are also available in this size class and they cost only marginally more.

I very much doubt that you will find a 100uF ceramic cap! Use aluminium or tantalum electrolytic.

Ah, but for just $1.65, a 100uF, 10V ceramic capacitor can be yours in single quantities. Tantalum caps in this range seem less expensive, ditto for Aluminum Electrolytic but how to verify that the cap can handle the reverse bias? That is, how to orient the thing and to determine that the thing is going to be safe and not explode the way tantalum and aluminum electrolytic capacitors are wont to?

I can order a bi-polar Aluminum electrolytic capacitor from Digikey for less than a dollar but they're only offered as through-hole components. On the Tantalum and Niobium side of things I found the following statement from AVX in this document:

In the reverse mode, tantalum and niobium oxide dielectrics are modeled by a diode DR and resistor RD integrated in the
equivalent circuit diagram. The diode DR has a bend at approximately 10% of the capacitor’s rated voltage to describe the real change of capacitor’s VA curve

There is a chart there also showing the reverse current as a function of voltage for an unspecified chip. I wonder whether one should select the capacitor voltage rating on the basis of the above to survive the reverse bias, i.e. a 25V-rated chip or whether one should select a rated voltage that allows the same amount of reverse flow as it did forwards. For example, using a 10V-rated chip for the 1.25VAC signal that I'm trying to pass here...

Anyhow, an updated diagram is below, the parameters haven't changed, but the values of the capacitors and resistors have based on prior feedback. Additionally, I threw in a MOV to help with permanent excursions above 120VAC. AREF = 2.5VDC, supplied by a linear regulator. The secondary winding voltage is 4.6VACrms. Volts = Analog input pin on Arduino dedicated to Voltage measurements.

Thanks for the help and I appreciate any additional observations, pointers, etc. Cheers!

Ok, so I decided to have some fun with some circuit analysis programs. I modeled the old circuit with it's 6VACrms power supply and the 1.25VDC bias circuit. As born out in real life, the circuit works.


As pointed out by ajofscott, a strong dc bias on the AC side leads to a offset that could lead to a negative input into the ADC as you can see below.

I played around with the capacitive coupling circuit and worked the resistors until I got a good signal on the output. Note the much low resistor values. However, the analysis appears to suggest that they work... Even with a large DC offset, only the AC signal is transferred. Seems like this one might be a winner.

Looks good.
What is the simulator? It looks like a Mac.

What I think your first simulation shows is that at start up while the 10uF capacitor is still charging, the input does go negative. This situation will only last for a short while. Even in the second circuit, the input is likely to go negative for a short while; because when you turn the system on, the AC input will come up immediately but the power to the Arduino and ARef will take a little while as the capacitors in the power supply and between +5v and ground on the Arduino charge up.

Either circuit will result in a negative peak voltage reaching the Arduino input, if the AC input is high enough (e.g. during a transient). Whichever circuit you use, you need to :

  1. Choose the attenuation such that with the AC input within its normal expected range, the signal level at the Arduino input that is high enough to measure accurately but not so high as to cause the input to go negative or above +2.5v even at the maximum "normal" AC input.

  2. Make the total resistance between the AC source and the Arduino input high enough so if a transient occurs and the Arduino input pin is driven negative, the current will be limited to a safe value; but keep the resistance low enough so that the overall accuracy of the measurement is not compromised. If you are using no additional protection diodes then 1mA is a safe value for the peak negative input current. If you use Shottky protection diodes from the input pin to +5v and ground, you can tolerate more current. I'm not sure that a BAV99 offers any significant protection because it will conduct at about the same voltage as the Arduino internal protection diodes do.