Measure 120VAC into A/D converter

This is the place for any magazine-related discussions that don't fit in any of the column discussion boards below.
Post Reply
ljbeng
Posts: 99
Joined: Mon Jan 13, 2003 1:01 am
Location: South Central NE
Contact:

Measure 120VAC into A/D converter

Post by ljbeng »

I am thinking of a .08VA transformer, half wave rectified and a 5vdc Zener and filter cap. As the AC side varies, I want to get a 0-5 vdc voltage level. I want to know voltage for a PIC processor A/D input. Has anyone done this before just to measure AC main line voltage?

<small>[ January 25, 2006, 09:57 AM: Message edited by: ljbeng ]</small>
User avatar
haklesup
Posts: 3136
Joined: Thu Aug 01, 2002 1:01 am
Location: San Jose CA
Contact:

Re: Measure 120VAC into A/D converter

Post by haklesup »

We use a 1:1 winding on the transformer for isolation then a full wave bridge rectifier with filter caps and voltage divider. You can use a 12V transformer just as well, just scale the input acordingly by choosing appropriate voltage divider resistance.

Obvioiusly if a resistor shorts, the A/D goes poof (actually an analog Mux in our case). If your pic is expensive, consider a buffer between it and the HV like a cheap opamp. The opamp can also be used to further scale the input (with gain less than one)and filter noise (integrator)
User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Measure 120VAC into A/D converter

Post by philba »

Yes, I'm playing with this stuff now. A lot depends on what you are trying to do.

You might want to use an optoisolater with 2 leds (like the H11AAx series). cheaper and smaller than a transformer. Take a look at this fairchild ap note for a good discussion of monitoring AC: http://www.fairchildsemi.com/an/AN/AN-3007.pdf

while the device, MID400, is designed for monitoring the existance of AC voltage, there are lots of good ideas in the note that will help you.

If you are trying to measure the peak amplitude of the AC wave form, you could generate a zero crossing interrupt and then read the ADC 1/4 period after that (kick off a timer that triggers an interrupt that reads the ADC value). Then you can avoid filtering out the 50/60 hz.

Another ap note that I found somewhat useful is this one: http://www.fairchildsemi.com/an/AN/AN-3001.pdf

Let me know what you come up with. I'm interesting in this area.

Phil
rshayes
Posts: 1286
Joined: Tue Mar 04, 2003 1:01 am
Contact:

Re: Measure 120VAC into A/D converter

Post by rshayes »

Are you trying to detect that AC line voltage is present or to measure the value of the AC line voltage.

The optical isolators are good for detection, but in general, their characteristics are not stable enough for measurement. There are ways around this, but they require special parts that may not be easy to get.

There is nothing wrong with using a transformer for voltage measurement. The power companies have done this for years. However, I would measure the average value rather than the peak value. Most AC power is not a pure sine wave, and the peak measurement only senses a small portion of the cycle. I would feed the secondary of the transformer into a bridge rectifier rather than a half-wave rectifier. This will reduce the effect of assymmetrical waveforms. The output of the rectifier would feed a resistor voltage divider which would scale the voltage down to where the average voltage matches your 0 to 5 volt range. A capacitor on the output of the voltage divider can be used to filter out the AC ripple, giving DC for the A/D input.

The biggest error will probably be due to the voltage drop across the rectifier diodes. This can be reduced by using shottky diodes, but there will still be some error (probably a few percent). The error will be less if the transformer secondary voltage is higher, but this may not be something that you can control. Adding a fixed voltage to the measured voltage will give you a first order correction. The temperature coefficient of the diodes will give a change in voltage of about 4 millivolts per degree centigrade. Unless you need a wide temperature range, this can probably be ignored, since it will only cause an error of a few percent or less (again depending on the transformer voltage).
User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Measure 120VAC into A/D converter

Post by philba »

actually, I think peak is going to be sufficient but if accuracy is wanted, then he should do root mean squared calcs.

diode drop can be pretty easily factored in, you just need to know what it is and add it back in software. You can even sample the temp and correct for that.

By the way, I don't disagree that a transformer is an ok way to do it but I much prefer an optoisolator for its compactness.
Robert Reed
Posts: 2277
Joined: Wed Nov 24, 2004 1:01 am
Location: ASHTABULA,OHIO
Contact:

Re: Measure 120VAC into A/D converter

Post by Robert Reed »

Ljbeng
Any transformer will work for your setup,but a 1:1 ratio would almost negate any diode drop error.Filter this voltage to read peak value.Your decision here is filter performance versus response time. From there just use resistor scaling to suit your needs. The peak to RMS value should be quite accurate as the power company delivers a pretty good sine wave to your outlet. I have never done a harmonic distortion test at home because just by oscilloscope presentation its looks very good. However I have done distortion analysis for the local power plant at their generating plant and saw less than 1% distortion here. Since I assume you are concerned about minor abnormal fluctuations which will not involve extreme accurracy, keep it simple. This isnt exactly rocket science you know.
User avatar
MrAl
Posts: 3862
Joined: Fri Jan 11, 2002 1:01 am
Location: NewJersey
Contact:

Re: Measure 120VAC into A/D converter

Post by MrAl »

Hello there,


I'd like to add a few notes to the other good replies here...


1. I have to agree that a 1:1 transformer will eliminate the
error induced by the use of rectifier diodes. To get the
voltage to a lower value to be read by the uCPU you can always
use a voltage divider from the DC output of the rectifers.
You then scale your measurements by whatever the voltage
divider ratio is.
2. I also agree with stephen in that opto-isolators are not that
good for use in analog measurement applications. A transformer
will provide years of decent service without changing gain,
whereas the opto's are prone to all kinds of variations over
time and temperature.
3. There will always be some error due to the effect of ripple
unless you use a filter (cap + resistor) of very long time
constant. This will keep the dc voltage as smooth as possible
as long as you dont need sub cycle response. Im assuming
if your measurements are say 1 second apart that's ok and you
DO NOT need something like 1 ms apart measurements. You need the
resistor in parallel with the cap to make sure that when the
line voltage drops the cap has something to discharge into
so that your instrumentation can detect decreases in voltage
in a reasonable amount of time.


Take care,
Al
LEDs vs Bulbs, LEDs are winning.
bodgy
Posts: 1044
Joined: Tue Dec 04, 2001 1:01 am
Location: Australia
Contact:

Re: Measure 120VAC into A/D converter

Post by bodgy »

After the transformer, why not use a low loss full wave rectifier?

There are two ways to do this -

1. Use two MOSFETS (this technique is often used at mains potential).

2. Easier - use two op-amps fed from a single side supply. If selected properly ones can be found that swing either rail to rail or about 0.1 -2v above/below the rail.

The fact that the op-amp can only swing to the rail due to the single siode power supply, makes an instant active rectifier. Any losses can be made up by adjusting the gain of the op-amp.

Another way of detecting this is to use specialist magnetic field sensing IC's - something I'm sort of playing with at the moment.

If you are measuring the voltage their is a speciualist IC from Anolog Devices which measures true RMS.

Colin
On a clear disk you can seek forever.
ljbeng
Posts: 99
Joined: Mon Jan 13, 2003 1:01 am
Location: South Central NE
Contact:

Re: Measure 120VAC into A/D converter

Post by ljbeng »

Great answers! I am still absorbing it all.

Philba, I am currently using an H11AA1 on this project to give me a relative voltage level as you described. That works fine and I allow some user settings to tweek it. I was looking at getting a way to display the actual voltage level. I will look more at the MID400 as a possible replacement for the H11AA1 ac inputs.

I will probably make the A/D pins available to a connector and have the this AC monitor as an add-on option. In the past we have smoked transformers and associated components, especially when the dummy running the generator on the system lets the voltage ramp up over 150VAC..... It happens. System powered from power grid are less problematic. Thanks again.
rshayes
Posts: 1286
Joined: Tue Mar 04, 2003 1:01 am
Contact:

Re: Measure 120VAC into A/D converter

Post by rshayes »

An alternate way of using a transformer would be to scale the AC signal on the primary side before passing it through the transformer. This will allow a smaller transformer and give it more protection.

Use a large resistor to convert the line voltage to a convenient current, such as 1 milliamp. Pass this current through a 1:1 current transformer. This in turn feeds a bridge rectifier. The rectifier feeds a load resistor, which sets the full scale voltage. The voltage across the transformer windings would be the output voltage (5 volts) plus the rectifier drop (about .6 volts if shottky rectifiers are used).

For example, a 4.99K load resistor would have 5 volts across it at 1 milliamp. Adding the rectifier drop, the transformer would see about 5.6 volts across the secondary, and would reflect this to the primary. A resistor of 145K in series with the primary across the line would give a full scale range of 150 volts. The rectifite drop would cause less than 1 percent error.

If the input voltage is doubled, the current rises to 2 milliamps, which can be easily handled by the transformer. Protection for the integrated circuit can be gained by using a clamping diode to the supply rail.

Since the currents are in the milliamp range, signal diodes, such as the 1N5711, should be adequate.
cdenk
Posts: 74
Joined: Thu Aug 15, 2002 1:01 am
Location: Lagrange, Oh.
Contact:

Re: Measure 120VAC into A/D converter

Post by cdenk »

My application is monitoring utility and generator voltage for a standby generator, so response time and super accuracy aren't issues. I use a 9VAC wall wart transformer, through a rectifier bridge, 10 ufd capacitor on DC side, 39K ohm to the "-", 16K ohm to"+", and a 2K ohm pot between to allow for tolerances of resistors, etc. The output goes to a Tri-PLC 100MD with 0 - 5 VDC input to the ADC.
L. Daniel Rosa
Posts: 400
Joined: Tue Dec 25, 2001 1:01 am
Location: Bellingham, WA
Contact:

Re: Measure 120VAC into A/D converter

Post by L. Daniel Rosa »

I'm thinking about something similar. What I"m considering is using a 99:1 voltage divider (similar to what hacklesup suggests) in the megaohm range with an opamp buffer and offset to the middle of the ADC input range.

In software the input value would be folded, squared, and added to a running average accumulator. Periodically the square root would be extracted.
User avatar
MrAl
Posts: 3862
Joined: Fri Jan 11, 2002 1:01 am
Location: NewJersey
Contact:

Re: Measure 120VAC into A/D converter

Post by MrAl »

Hi again,


Can he take that many readings though in order
to get a true RMS calculation?


Take care,
Al
LEDs vs Bulbs, LEDs are winning.
Post Reply

Who is online

Users browsing this forum: No registered users and 46 guests