Searching \ for 'Measuring AC volts' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page:
Search entire site for: 'Measuring AC volts'.

Truncated match.
PICList Thread
'Measuring AC volts'
1999\02\08@101303 by Andres Tarzia

I am interested in making an AC volt meter for monitoring the 115V power
But I don't know how to use the A/D converter, which only accepts DC.

Can someone suggest a technique to do just that?

Thank you.

Andres Tarzia
Technology Consultant, SMART S.A.

1999\02\08@115115 by andre

Andres Tarzia wrote:

> I am interested in making an AC volt meter for monitoring the 115V power
> line.
> But I don't know how to use the A/D converter, which only accepts DC.


all you need is DC input.  make AC to DC and lower the voltage .
maximum AC voltage should be your maximum DC 5v or your
reference voltage.


150 v  -    5v    0xFF
75 v    -   2.5 v   0x7D
0 v    -    0.0  v    0x00

you can use pic16c711 or 71 with  4 segment LED display it will take 12
you have one input available. Keep in your mind that if you need
push buttons to add in this project you can add 12 buttons without
changing the chip.

Andre Abelian

{Quote hidden}

1999\02\08@124457 by Andres Tarzia

{Quote hidden}


I know that I have to get DC from AC.

But I don't know whether to build a half-cycle rectifier, a full-cycle
rectifier or not to rectify the AC altogether. Besides that, I am not sure
about adding a capacitor to "smooth" the rectified AC or to repeatedly
measure the rectified sine wave to get the "peak" (maximum) and then work on

                  R1       |
      115V AC           R2 /          To PIC

If R2/(R1+R2) = 1/25, then I can get the mains voltage within the 0-5V
range. Using the PIC built-in input protection, I can forget reverse-voltage
protection diodes, and so on (see AN521, available at

But the problem is that I still have AC.
          o-----/\/\/\/\---+-------|~          |
                  R1       |       |          +|------+---------o
                           \       |   Full    |      |
      115V AC           R2 /       |   Wave    |     --- C1    To PIC
                           \       | Rectifier |     ---
                           /       |           |      |
                           |       |          -|------+---------o
          o----------------+-------|~          |
Using the above circuit, with the same R1 and R2 as before I now have DC,
but some issues remain.
1) I have to take into account the 0.7V drop from the rectifier.
2) What am I measuring? I mean 115V/25 = 4.6V, then 3.9V will be feed to the
PIC. If the converter shows 3.9V, should I display 115V? I always confuse
"peak" voltage and "mean" voltage and I always forget to which one "115V"
3) Should I include C1 in the circuit above? Which capacitor is best suited
to the task? A large electrolytic cap? Or a small one?

Again, thank you for your help

Andres Tarzia
Technology Consultant, SMART S.A.

1999\02\08@161248 by Harold Hallikainen

picon face
       A few comments...

       1.  Watch out for line voltage isolation.  Try not to electrocute
       2.  If you decide to rectify the AC, do it prior to a voltage
divider so the diode knee voltage is a small portion of the AC,
minimizing nonlinearity due to the knee.
       3.  You can rectify and drive a low pass filter (RC network) to
get the average voltage, then correct to RMS assuming the voltage is a
sine wave.
       4.  You can put an RMS to DC converter in front of the PIC.
       5.  You can have the PIC calculate the RMS.  Of course, the PIC
A/D only accepts 0..5 volts, so we're tempted to rectify the incoming AC
prior to driving the PIC.  However, we then have possible nonlinearity
problems (which, as above, can be minimized by rectifying prior to
voltage division).  However, as someone cleverly pointed out on this
thread, we could just apply the AC (voltage divided and current limited)
to the PIC pin.  The protection diode would remove the negative half
cycle.  We would then be able to A/D the positive half cycle.  The RMS
can be calculated for the positive half cycles, then doubled, assuming
the AC is symmetrical.  To calculate RMS, take a sample, square it, add
to an accumulator.  After some number of samples (like maybe 256), divide
by the number of samples (256 is nice, since you can just throw out the
low half of a 16 bit value), then take the square root.  RMS is the
square root of the mean (average) of the squares.


Harold Hallikainen
Hallikainen & Friends, Inc.
See the FCC Rules at and comments filed
in LPFM proceeding at

You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at
or call Juno at (800) 654-JUNO [654-5866]

1999\02\08@181158 by Scott Dattalo

On Mon, 8 Feb 1999, Andres Tarzia wrote:

{Quote hidden}

Since no one has suggested, I'll | in...

If you add a "pull-up" resistor between the pic I/O pin and say +5V, then
you can add a DC offset and keep the signal from swinging below 0V. This
will allow you to sample the complete waveform to obtain a more accurate
RMS calculation.

However, if your voltage signal is fairly clean and you feel comfortable
capturing the peak and approximating the RMS voltage, then I'd suggest
building a circuit that would capture peaks in the range between low and
high line (typically + and - 15% of 115Vrms) and scale that to a 0 to 5V
range for the A/D converter. Might as well use the A/D resolution only
where it's needed.

1999\02\09@084922 by Andres Tarzia


Following your suggestions, what about the following circuit:

         Diode       R1        |          |          |
                               |          |          |
                               \          |          |
                               /          | +        |
    115V AC                 R2 \     C1 =====   C2 =====     To PIC
                               /          |          |
                               \          |          |
                               |          |          |
         Fuse        R3        |          |          |
      o----~------/\/\/\/\-----*----------*----------*-------o GND

Where the resistors are in the order (not EXACTLY equal to) of: R1=R3=5M and
R2=400K. So we will get a voltage drop of aprox 4.5V on R2 with an input
voltage of 115V (full 5V with 130V input).

That way the circuit common ground will not be tied to the power line, but
isolated by a 5M resistor. That will take care of the isolation. Shifting
the diode in front of the voltage divider will cause the 0.7V drop to be
subtracted from 115V instead of 5V, so impacting the measurements much less.
Using a large electrolytic cap for C1 will get rectified DC. Adding a low
value ceramic cap (C2) will filter any high freq noise that can be present
on the power line.

Any further suggestions?

Andres Tarzia
Technology Consultant, SMART S.A.

{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...