DC biasing an AC signal for input to ADC and zero cross detector
MJHanagan
Posts: 189
Hi everyone - I want to measure a nominal 120 VAC 60 Hz line voltage with a MCP32xx ADC. I would like be accurate to at least ±1 VAC and also produce a digital zero crossing signal. After looking at a few posts in this forum it seems as though I should be able to use a simple voltage divider to reduce the line voltage to a 2 VAC (peak) then superimpose this voltage onto a +2.5 DCV (from a +5VDC supply). I would then feed this voltage to the input of the ADC (the input voltage would thus range from +0.5 to 4.5V) and use the +5V as the Vref on the MCP32xx. I could use this same +0.5 to +4.5V signal as the input on a comparator and use the +2.5VDC signal as the reference voltage. When the AC signal passes through 2.5V the output of the comparator would change thus producing a nice accurate zero cross signal (and not violate and Vin levels on the comparator).
Ultimately I will want to replace the +5VDC signal with a 4.096VDC reference voltage (via something like an LT6654) so the ADC math can be all integer. Down the road I plan on measuring the AC signal off a shunt resistor in the same way. This would then enable me to easily calculate instantaneous power consumption on a point-to-point basis (i.e. TRMS power).
I did a quick LTspice model of a circuit I think should work and while I am getting a nominal DC biased AC signal it is not what I expected. Specifically, I am not getting the desired +2.5V DC bias level. In the case of the attached circuit I get a nominal DC offset of only about +1.65 VDC. I must be missing something fundamental in the values of R2, R6, R5 and R9. Or there is something off in the circuit logic itself?
Any help would be appreciated.
Circuit:
SPICE output:
ACV to ADC V1 Results.wmf
Ultimately I will want to replace the +5VDC signal with a 4.096VDC reference voltage (via something like an LT6654) so the ADC math can be all integer. Down the road I plan on measuring the AC signal off a shunt resistor in the same way. This would then enable me to easily calculate instantaneous power consumption on a point-to-point basis (i.e. TRMS power).
I did a quick LTspice model of a circuit I think should work and while I am getting a nominal DC biased AC signal it is not what I expected. Specifically, I am not getting the desired +2.5V DC bias level. In the case of the attached circuit I get a nominal DC offset of only about +1.65 VDC. I must be missing something fundamental in the values of R2, R6, R5 and R9. Or there is something off in the circuit logic itself?
Any help would be appreciated.
Circuit:
SPICE output:
ACV to ADC V1 Results.wmf
Comments
Spice is invariably right, so adjust your values to suit. Try removing R2.
You might also want to ensure R8 is high voltage rated, and increase the value - 4M7 is ok, and the VR37 family of resistors work well here.
-Phil
Can you explaing why connecting the mains neutral to the DC ground makes things difficult? I see many circuits where the mains neutral is common with the logic circuit ground plane. Even the true "ground" of the mains and neutral are separated only by a nominal copper wire back at the main elecrtical panel, correct?
I doubt that. Mains ground, maybe. Mains neutral is not the same as mains ground, notwithstanding being connected together at the breaker box. Many PCs and measuring instruments have their own signal and logic grounds connected to mains ground. By connecting one of these devices to your circuit, you will force your mains ground to share the the current load with that of the entire breaker circuit (a ground fault), which is not a good thing. Moreover, if your mains neutral connection gets broken for some reason, the entire circuit will be floating at the "hot" level, which is dangerous.
Use an isolation transformer. Just do it.
-Phil
Try this Difference Amp, DiffAmp:
The input is referenced to neutral,
The output is referenced to 2.5V.
And its safe if you use resisters rated for 200V or higher.
Duane J
Nominally correct, but a broken wire changes all that, as does any incorrectly wired cable.
Some countries have non-polarised connectors, so the idea of 'neutral' is not a real one.
This is really not a good idea. In the middle of a factory I have often seen 2 to 6 v between ground(earth) and neutral.
With one particularly troublesome site a few months ago we called in an EMC specialist who diagnosed 200 volt peak, high frequency spikes between neutral and ground.
On top of that if anything bridges your circuit to chassis ground, you're creating an earth loop, and large currents can flow.
If this is one-off, I'd use a transformer, if it is for volume production, a difference amp is a nice way to ensure either can be Phase, and to remove local GND differences.
I'd use the proper resistors, either VR37 or VR68. I've seen designs use 2 x 2 VR37 if you want extra PCB creepage gains, and no single point of failures.
The calibration factor is derived by measuring the AC line voltage with a calibrated 4.5 digit multimeter and using the reading from the ADC. The accuracy is approximately 0.5% over 98 140VAC.
In addition to being much safer and avoiding ground loop problems it simplifies the circuit by allowing one side of the transformer secondary to be connected to the 2.5V offset voltage and the other side to the op amp.
PS - If the secondary voltage of the transformer is less than 5V P-P at the maximum AC voltage expected you may not even need an op amp. Simply connect one side to the offset voltage and the other side to the ADC.
I am curious about the differential op-amp circuit because it seems as though the neutral is indeed connected to the COM of the +5V circuitry (albeit through some 500+kohm worth of resistors). Does this constitute isolation? Could the mains also be isolated using a capacitor? And does that offer and additional isolation protection?
I'm a material engineer not and EE so stuff beyond V=IR is foreign to me!
The RMS current flow would be about 240uA in a 120VAC circuit. This is low enough to
pass most commercial safety standards, (Not medical equipment though).
Also, these 5 resisters must withstand at least a HiPot test at 1500V or so.
Higher valued resistors can be used but generally with less accuracy due
to phase shifting caused by small parasitic capacitance effects.
Full galvanic isolation is easiest done with isolation transformers. These can
be quite small but generally fairly expensive and much larger than DiffAmps.
Do you need full galvanic isolation?
Optocoupled isolation often works depending on what you need.
If analog voltage reading are required this can be expensive.
If simple zero crossing is needed this is probably the lowest cost solution.
Capacitors coupling alone is usually not considered to be isolation
especially if or when the capacitor shorts.
What exactly are you intending on doing?
Duane J
The Dual-resistor string allows you to not care which one is Phase, and in some countries, you have no idea.
Isolation at these levels is usually measured in currents, so a capacitor can be worse than a resistor, as it allows high frequency edges through.
Best to use the highest values you can tolerate, and buy the high voltage spec'd ones.
Your scope probe uses 10-Meg Ohms.
In general I agree with what you are saying but to measure the AC line you do not need to connect the neutral to the circuit ground. The neutral and line can each go through several resistors to the + and - of the op amp. An isolated power supply for the board and an opto isolator (or similar) to communicate the measurements to the outside world should be adequate as long as this circuit is not intended to be in contact with people.
The spark spectrometers I service produce up to 700V and 250A peak currents to analyze metal samples and CSA approves them even though one end of that power supply is connected to the instrument/cabinet ground.
Best to put 3 or more series resistors as Duane showed between the AC line and the op amp as well as the neutral and op amp for protection. Having multiple resistors keeps a single resistor failure from causing a serious problem. Having them on the neutral as well is protection from reversed AC leads. I still recommend an isolated power supply dedicated to this circuit and opto isolators for the output data.
The main purpose of the circuit is to provide "proof of concept" of the features of the circuit board. I need to know what the incoming mains voltage is in order to determine the phase angle of the output triac to control the power delivered to a connected device (we make the connected widget). Adding the current measurement and measuring the actual V and I would allow for a more accurate measurement of the power delivered to the device thus imporoving the performance. These demo boards, of which there may be only 4-6 ever built, would end up in the customer's hands (engineers) along with all the necessary caveots. These circuits are not intended to be used for any purpose other then to demonstrate how the powered device could be utilized for a specific application. In the end the custome will be responsible for designing and building their own control boards - we just want to make the widget connected to it. That being said we would like these demo board to be as similar to what the final board. This would enable the customer can get a more realistic idea of what the final board might cost.
I like using the Propeller as the microcontroller for these demos because it is easy to program. The GG USB Platform boards match up with PCBExpress boards so it makes for a very fast and convienent prototyping system. Again, I'm not an EE so I try to keep things as simple as possible and learn as I go.
I'm working on a project at the moment where different parts of the circuit are connected to different parts of the mains. The 0v rail of the 5v PSU floats 5v below mains Live; the 12v rail floats 12v above mains neutral. This is what is stopping me killing myself...
It's an isolation transformer.
The HCPL-3700 voltage/current threshold detection optocoupler
http://www.mouser.com/ProductDetail/Fairchild-Semiconductor/HCPL3700/?qs=nW0pe8qlIZhV91NUczmkyyLLjrCHp8mlyssDGZDAszc%3d
Not necessarily!
This looks like a good device to test for some minimum voltage/current, but not for trying to measure the actual voltage value.
Yes indeed, but my widget needs the power from the mains - just like my toaster (and there is no isolation transformer in there!). If I swap the L and N wires on my wall outlet the toaster still works the same. The only concern would be if they used a SPST switch instead of a DPST switch (that would result in the L voltage being present on the heating coils so touching them would wake you up post haste).
Again, these demo boards are destine for experienced engineers - not consumers. I assume the appliance engineer on the receiving end knows the implicatons of wiring things up backwards, sticking metal objects onto the components of a circuit board or touching exposed connectors where the widget goes.
If I could find a small inexpensive transformer I would use it, but at the moment I can't seem to find one that fits either criteria. Using a set of 100k resistors as "isolation" per Duane seems to address the cost issue and assuming these are 1/8 W the space needs are probably OK.
-Phil
Wouldn't a hall-effect sensor/s placed perpendicular to a AC line provide a safe way to measure the voltage.
I don't have time but I bet I could whip out a schematic that would cost a few dollars, be small in size and be very precise.