Searching \ for '[PIC]: Reading Mains Voltage From a PIC' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/power.htm?key=voltage
Search entire site for: 'Reading Mains Voltage From a PIC'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Reading Mains Voltage From a PIC'
2001\06\21@081729 by jeethu

flavicon
face
Hi,
I'm into a UPS application which requires a PIC16F877 to monitor the mains
voltage (230 Volts AC here in India). The most obvious answer may be to use
a step down transformer. But How do I read the AC level. PIC ADCs are
supposed to take the DC voltages. And since its AC what if I read the Line
during Zero Crossing ?
Adding a small bridge rectifier out of 4148 diodes may help. but still,
there will be some Alternating component left. Adding a capacitor (1 mfd
tantalum) might increase the voltage a bit. I guess i'll have to Compensate
for this increase in software.

Worst of all problems is that since it's a UPS application, the program flow
will be highly non-linear as TMR0 interrupt will be called very often. And
It'll be very hard to synchronize with the zero crossing of the line
voltage.

Can someone suggest a good solution ?

Thainking You,

Jeethu Rao
http://www.jeethurao.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\06\22@035419 by Vasile Surducan

flavicon
face
The simplest one you've pointed partially, step down transformer,
rectifying bridge, small filtering capacitor ( which will not increase but
keep constant Vmax, or Uvv/2, a resistive divider to obtain effective
value and drop to pic AD ( less than 5V ). No software for calibration...
Vasile

On Thu, 21 Jun 2001, Jeethu Rao wrote:

{Quote hidden}

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\06\22@040315 by Peter L. Peres

picon face
Jeethu, imho look into a National analog databook and build one of the
'perfect rectifier' circuits pictured there. They accept AC (you use a
resistive divider) and output DC which can be fed to the A/D. They are
rather good (i.e. precise) even if using cheap parts.

Peter

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\06\22@072657 by Bob Ammerman

picon face
> The simplest one you've pointed partially, step down transformer,
> rectifying bridge, small filtering capacitor ( which will not increase but
> keep constant Vmax, or Uvv/2, a resistive divider to obtain effective
> value and drop to pic AD ( less than 5V ). No software for calibration...
> Vasile

Just remember, this will read PEAK voltage. To read RMS (assuming a sine
wave!) just divide by a factor of SQRT(2).

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)



> On Thu, 21 Jun 2001, Jeethu Rao wrote:
>
> > Hi,
> > I'm into a UPS application which requires a PIC16F877 to monitor the
mains
> > voltage (230 Volts AC here in India). The most obvious answer may be to
use
> > a step down transformer. But How do I read the AC level. PIC ADCs are
> > supposed to take the DC voltages. And since its AC what if I read the
Line
> > during Zero Crossing ?
> > Adding a small bridge rectifier out of 4148 diodes may help. but still,
> > there will be some Alternating component left. Adding a capacitor (1 mfd
> > tantalum) might increase the voltage a bit. I guess i'll have to
Compensate
> > for this increase in software.
> >
> > Worst of all problems is that since it's a UPS application, the program
flow
> > will be highly non-linear as TMR0 interrupt will be called very often.
And
{Quote hidden}

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\06\22@094407 by Douglas Butler
flavicon
face
If you rectify the 230VAC first you can use a very non-perfect
rectifier.  The errors will be insignificant vs. the 300VDC result.
Then use a resistive divider to reduce the 300V to 5V for the PIC A/D.

The will give you the average voltage level.  If you are looking for
single cycle dropouts you will have to do something faster, probably
synchronized to the power line frequency.

Do you need to isolate the PIC ground from the AC mains?

Sherpa Doug

> {Original Message removed}

2001\06\22@095655 by Olin Lathrop

face picon face
> I'm into a UPS application which requires a PIC16F877 to monitor the mains
> voltage (230 Volts AC here in India). The most obvious answer may be to
use
> a step down transformer. But How do I read the AC level.

You could low pass filter the AC line signal first to make sure it is mostly
a sine wave, then peak detect it with a diode, then low pass filter that and
trade off ripple rejection with response speed.  How fast do you need to
know the AC line voltage changed?  If you don't want the diode drop in there
you can do an absolute value circuit with opamps.  Fortunately you have very
low bandwidth requirements.

You could also read the LPF AC line signal fast enough to "follow" the sine
wave.  At 50Hz you have 20mS per cycle, which is quite a lot.

If you want to throw hardware at it and simplify the software, you could
sample and hold the line voltage at its peak once per cycle.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, spam_OUTolinTakeThisOuTspamembedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\06\22@103347 by Lawrence Lile

flavicon
face
>using rectified AC to measure AC mains voltage

I would only use a rectifierbridge/capacitor as a cheap and dirty
alternative to a *real* analog measuring system.  If you want a cheap and
dirty solution, that's OK nothing wrong with it.  I do it all the time
myself, too.

The signal from a transformer is distorted by the diode drop ( 2 diode drops
in a full wave bridge), only the peak values are filtered by the capacitor,
and the precision of the transformer turns will not be very consistent.  I
would not use such a circuit and expect any precision from it unless I used
a specially made transformer.

If you want something more accurate, I'd suggest an op-amp precision
rectifier.  This could be driven by a simple resistor divider, or a low-cost
low-power transformer if you need mains isolation.  This could produce an
instantaneous value, useful in detecting fault conditions.  Could also
calibrate out transformer variations.

If you want an RMS value, you can obtain it several ways.  There are some
dedicated analog chips for this purpose (Try  http://www.national.com )  or you
could do it in software.  Take a number of readings over the AC cycle, take
the square root of each, average them, and square the result  (root mean
square).

If you want to filter out spikes and noise, you need to average the value
for a long time, several cycles.  Or use a software median filter
http://members.socket.net/~llile/    .

If you are concerned about READING spikes, you might want a sample-and-hold
analog circuit.  This would hold the spike level until you can get around to
measuring it.

At any rate, a general rule could be that processing analog signals directly
from a PIC A/D port is OK, if you want a cheap design.  If you desire any
sort of precision, noise immunity, filtering, etc. you should consider a
dedicated anlog section before the A/D input.

-- Lawrence Lile

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\06\22@114338 by Spehro Pefhany

picon face
At 09:33 AM 6/22/01 -0500, you wrote:

>If you want an RMS value, you can obtain it several ways.  There are some
>dedicated analog chips for this purpose (Try  http://www.national.com )  or you
>could do it in software.  Take a number of readings over the AC cycle, take
>the square root of each, average them, and square the result  (root mean

Just the opposite, actually. You want to integrate the instantaneous power
in an assumed constant resistance load over one cycle, divide it by the
duration of the cycle, then get rid of the assumed load resistance and
take the sqrt to get back to the voltage. (In fact you don't use any
resistance value, it's just a way of thinking of it that gives the
calculations some physical meaning).

There's other ways besides just summing the squares of the measurements
to perform the numerical integration, but I think the simple way will
work ok if the waveform is reasonably symmetrical about the middle of
each half cycle. Otherwise, you'd better go to the trapezoidal rule or
Simpson's rule (see any numerical analysis text or do a web search).

Best regards,

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Spehro Pefhany --"it's the network..."            "The Journey is the reward"
.....speffKILLspamspam@spam@interlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com
Contributions invited->The AVR-gcc FAQ is at: http://www.bluecollarlinux.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\06\23@060916 by jeethu

flavicon
face
Hi,
I like Mr Doug's Idea as its the cheapest and would save quite some space
required by the transformer. I could just rectify the AC Voltage and then
use a
resistive divider to scale the voltage down to say 3 volts. But i'll have to
add a
couple of Mica Capacitors of say 0.47mfd/300 Volts to flatten out the DC.
And after
the Voltage Divider, I might also put up a small LC network based Low Pass
Filter.
And finally, a Kamikaze Zener Diode of say 5.2 Volts to Commit Suicide and
Protect
the PIC if one of the Divider resistors is to fail.

So, the voltage I'll be getting will be the peak voltage. How do I get the
RMS Voltage ?
Any ready made algorithms on PICList would be great.

And finally, anyone's got any comments on this design ?

Jeethu Rao
http://www.jeethurao.com

{Original Message removed}

2001\06\23@101630 by Olin Lathrop

face picon face
> I like Mr Doug's Idea as its the cheapest and would save quite some space
> required by the transformer.

I like it too as long as the PIC does not need to be isolated from the AC
line.

> I could just rectify the AC Voltage and then
> use a
> resistive divider to scale the voltage down to say 3 volts. But i'll have
to
> add a
> couple of Mica Capacitors of say 0.47mfd/300 Volts to flatten out the DC.
> And after
> the Voltage Divider, I might also put up a small LC network based Low Pass
> Filter.

I don't see any need for LC.  RC should be fine unless you're right on the
edge of the tradeoff between ripple rejection and response time.

> And finally, a Kamikaze Zener Diode of say 5.2 Volts to Commit Suicide and
> Protect
> the PIC if one of the Divider resistors is to fail.
>
> So, the voltage I'll be getting will be the peak voltage. How do I get the
> RMS Voltage ?

For a sinusoid, RMS = peak / SQRT(2).  If the waveshape is not known, then
you have to take lots of samples, square them, average them, and take the
square root of the average.  RMS = "root mean square".

Please fix your reply address.  The default reply goes to you instead of the
list.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, olinspamKILLspamembedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\06\25@070125 by Vasile Surducan

flavicon
face
On Sat, 23 Jun 2001, Jeethu Rao wrote:

>
> So, the voltage I'll be getting will be the peak voltage. How do I get the
> RMS Voltage ?
> Any ready made algorithms on PICList would be great.


 Of course you dont need any PIC algorithm to decrease a voltage with
1.41 ( sqrt 2 ) from initial value. You need just a potentiometer or two
resistors. And keep your electronics isolated from the 220...240V mains.
Else you'll can't talk with other devices only through optoisolated
devices: RS232/485 etc.
Vasile






{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu


2001\06\25@120402 by Douglas Butler

flavicon
face
> > And finally, a Kamikaze Zener Diode of say 5.2 Volts to
> Commit Suicide and
> > Protect
> > the PIC if one of the Divider resistors is to fail.

The Microchip app note on connecting a PIC to the power line (AN521)
recommends using two resistors in series so that a simultanious short
failure of both resistors will be extreemly unlikely.

{Quote hidden}

Two stages of RC filtering with 2.2meg resistors and 6800pf caps will
provide a safe resistance and will filter out harmonics leaving nothing
much more than a 50/60Hz sine wave.  Then the RMS = Peak/sqrt(2)
approximation will be pretty good.

Sherpa Doug

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam_OUTspamTakeThisOuTmitvma.mit.edu


2001\06\25@182846 by Lawrence Lile

flavicon
face
> The Microchip app note on connecting a PIC to the power line (AN521)
> recommends using two resistors in series so that a simultanious short
> failure of both resistors will be extreemly unlikely.
>


Also, be sure you use resistors rated at sufficient voltage.  you would
*not* for instance, want to risk 0805 surface mount resistors in this case -
insufficient creepage path!  I think you'll be stuck with good ol' 1/4 watt
thru hole resistors - but I can't find the reference just now.


-- Lawrence Lile

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu


2001\06\26@134911 by D. Schouten

flavicon
face
I use Philips VR25 resistors for this purpose.

Daniel...

----- Original Message -----
From: Lawrence Lile <@spam@llileKILLspamspamTOASTMASTER.COM>
To: <KILLspamPICLISTKILLspamspamMITVMA.MIT.EDU>
Sent: Tuesday, June 26, 2001 00:27
Subject: Re: [PIC]: Reading Mains Voltage From a PIC


> > The Microchip app note on connecting a PIC to the power line
(AN521)
> > recommends using two resistors in series so that a simultanious
short
> > failure of both resistors will be extreemly unlikely.
> >
>
>
> Also, be sure you use resistors rated at sufficient voltage.  you
would
> *not* for instance, want to risk 0805 surface mount resistors in
this case -
> insufficient creepage path!  I think you'll be stuck with good ol'
1/4 watt
{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


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