Searching \ for 'how to detect AC power loss' 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=power
Search entire site for: 'how to detect AC power loss'.

Truncated match.
PICList Thread
'how to detect AC power loss'
1998\08\01@013212 by Norayr S. Elmayan

flavicon
One of the main problems we have faced during UPS designs, is the detection
of AC power loss.  Using capacitor filtered stepped down DC signal, will be
far too slow to respond.  We need in the order of 5 to 10 ms, be able to
detect a surge or loss accurately.  Any suggestions on how to achieve with
our mighty PIC, piccers.

Please comment

1998\08\01@015934 by Kevin Fisk

flavicon
face
Just as a real quick thought. Obviously you cannot use zero crossing as no
matter where you are, the time for zeros is beyond what you require. You
tried the Cap/filter/step down to no avail.

OK, my quick though. How about some form of inductive measure of power
loss/surge. Since you mention UPS; I'm assuming the current requirement is
quite large (reasonable speaking), you could close couple an inductor and
use the surge/loss to trigger.

Remember, if I'm way off base - its late Friday and I have had a long week
<G>

Cheers,

K.Fisk ( spam_OUTkfiskTakeThisOuTspamwkpowerlink.com)
<Opinions are my own worthless dribble that might otherwise be put to more
constructive uses o->

{Quote hidden}

1998\08\01@020743 by Mike Ghormley

flavicon
face
Norayr S. Elmayan wrote:

> One of the main problems we have faced during UPS designs, is the detection
> of AC power loss.  Using capacitor filtered stepped down DC signal, will be
> far too slow to respond.  We need in the order of 5 to 10 ms, be able to
> detect a surge or loss accurately.  Any suggestions on how to achieve with
> our mighty PIC, piccers.

Here's an idea that occurs to me off the top of my head:

First synchronize an ADC reading of the mains by finding a positive zero-crossin
g and
then begin to take readings say every 1mS (perhaps using an interrupt routine fr
om a
timer) and compare that value to a 19 byte (for 50Hz, 16 for 60 Hz) lookup table
which
holds the appropriate sine values.  Any reading more than (hmmmm, say) +/- 2 out
side
of the ideal value would trigger a fault.  At the end of the table, instead of a
last
read, go into a fast loop looking for the positive zero-crossing again to re-syn
ch the
reads.  Just before the fast positive-zero-crossing loop you could set TMR0 for
a 2mS
timeout which would trigger the fault routine.  Thus, even if the power fails ju
st
after the last table read, it would be detected in 2mS.  You could even incorpor
ate an
auto-adjust of the lookup table values at power-up.  A PIC with a built-in ADC (
like
the 16C71) would seem a good choice methinks.

Seems to work.  If I am wrong, I'm sure it will be pointed out.  ;^)

Michael

*************************************************************************
When the way of the Tao is forgotten, kindness and ethics must be taught.
Men must learn to pretend to be wise and good.  --  Lao Tzu
*************************************************************************

1998\08\01@115853 by Thomas McGahee

flavicon
face
You could compare the actual monitored AC waveform with a lookup
table. The table itself only has to cover a single 90 degree
quadrant, not the full 360 degrees. The monitored AC could be
derived from a 12 volt transformer, full-wave rectified,
ground referenced, and reduced by a simple voltage divider
to a value that can be handled by the PIC's ADC.

I'll assume a 8 Mhz crystal and 50Hz AC for the following example.
You can adjust for 60 Hz by using a 9.6 Mhz crystal and keeping all
else the same! I will also assume that the PIC is dedicated to
performing just the functions listed below, so that all PIC
resources are assumed available.

At 50Hz the time for a period is 20 ms. We measure by quadrants,
so 20/4 = 5 ms per quadrant. If we sample at 100 us intervals, we
would have time for 200 clock cycles per measurement. We would be taking
50 samples per quadrant, or 200 samples per sine wave cycle. I think
that would be a reasonable sample rate, with a timing window of
.1 ms.

The PIC could drive LEDs to indicate conditions such as 'Too Low',
'Too High' 'OK/out-of-bounds', and "Calibration OK". That would allow for easy
calibration
in the field. No oscilloscope or meters required.

The PIC would start out by waiting for positive zero crossing
x number of times to ensure initial stabilization. Once this
stabilization had occured the program would run through a calibration
routine where it would sample the AC at key points and establish baseline
values for voltage deviation at the key points. Interpolation can be used
to arrive at the approximate deviation values that should be occuring
at points *between* the 'key' points. This method helps us conserve the
amount of RAM that we are using for calibration.

During this auto-calibration phase the program would cause the value
for each 'key' point to be calculated by doing some kind of averaging
on the deviation value. By doing only one 'key' point at a time you
can conserve tha amount of RAM required to perform the averaging
function.

Once the baseline calibration is complete, then the program would start
regular sampling. By keeping track of a few previous ADC readings, the
program can determine whether the present slope is positive or negative.
When it detects a change from negative slope to positive slope, then
it has established positive zero crossing. It then uses the first 'key'
point as a second reference. If it doesn't find this value (within certain
limits)
by the time it actually reaches the first 'key' point, then it declares
a fault condition. Because the possibility for error is greatest when
the waveform is near zero, the use of this first 'key' point is important.
We "hang around" waiting for a possible match for the first key point. We
synchronize on the time *or* on the AC value determined by the 'key' point
RAM. If too much time goes by and we still don't have a match, then we
know something is wrong. If we find the proper value *within* the alloted time
frame, then we synchronize our time base. This is usually done by jamming
a zero value into the TMR0 register.

Once we get past this first re-synchronization point we have an easy time
of it. At 'key' points we use the stored deviation value to determine if we
are high, low, or ok/out-of-bounds. ('calibration ok' is a further refinement.
It is asserted
whenever the match is almost exact.)

Points that are *between* 'key' points use an interpolated value based on the
previous and next 'key' point deviation values.

At *every* point, 'key' or otherwise, the state of deviation is determined
and compared with the RAM deviation value. The present state of affairs is
then reported via the LEDs. If it is determined that a major problem has
occured, a 'ShutDown UPS' command can be issued.

If there is enough 'free' time available, then the program can do a little math
during the 'free' time and compare the last three key points and the values
of deviation that ACTUALLY occured, and possibly tweak the deviation values
stored for the most distant 'key' point. This assumes that you are storing
the actual deviation values and shifting them down a set of three registers,
such as oldkey1 oldkey2 and oldkey3. The idea is to allow the stored deviation
values to be slightly tweaked each run, so that the error tolerated is
constantly
adjusted. There should be limits to the maximum deviation values that the
system will tolerate, of course.

The algorithms used should allow some tolerance for brown-outs and the like.
You might want to specify that an error must be present on at least two
consecutive test points before the ShutDown UPS command is issued.
Thus the worst-case time between a line error occuring and the ShutDown UPS
command being issued would be .3 ms max.

Because the AC has been converted to rectified AC, we only have to look
at two quadrants. The first quadrant is scanned by counting UP, and the
second quadrant is scanned by counting DOWN. How simple.

The PIC can report on various LEVELS of error occuring, so there can
be indications for possible brown-out conditions, single large
errors, and recurrent large errors.

An input port Bit can be read as part of the initialization routine. If a 0
is found, then a special manual calibration mode could be entered where the
LEDs could be used to indicate in binary (or as a bar readout) the present
average deviation for the whole cycle. You would adjust the voltage divider
trim pot to achieve the smallest reading, then release the pushbutton
so that the port Bit now reads 1, and the program would divert back to the
original initialization routine and continue as usual.

In other words, if you held a pushbutton down and turned the unit on it
would go into a special manual calibration mode. Releasing the button would
cause normal operation to begin. You could even check for this button being
down as part of the regular loop, and  initiate a manual calibrate
*any* time the switch was pushed.

Well, I have other things to do here today, so I'll be on my way for now.
Hope this helps.
Fr. Tom McGahee


----------
{Quote hidden}

zero-crossing and
> then begin to take readings say every 1mS (perhaps using an interrupt routine
from a
> timer) and compare that value to a 19 byte (for 50Hz, 16 for 60 Hz) lookup
table which
> holds the appropriate sine values.  Any reading more than (hmmmm, say) +/- 2
outside
> of the ideal value would trigger a fault.  At the end of the table, instead
of a last
> read, go into a fast loop looking for the positive zero-crossing again to
re-synch the
> reads.  Just before the fast positive-zero-crossing loop you could set TMR0
for a 2mS
> timeout which would trigger the fault routine.  Thus, even if the power fails
just
> after the last table read, it would be detected in 2mS.  You could even
incorporate an
> auto-adjust of the lookup table values at power-up.  A PIC with a built-in
ADC (like
{Quote hidden}

1998\08\01@160932 by PIC development

flavicon
picon face
It seems to me that all you need to do is to detect when the supply
is above a small threshold voltage. On a 50Hz supply, a half cycle
(you will full-wave rectify the supply before detection) will be
10mSec.
Say you transformer the supply down to 10v peak-to-peak, then if
you detect thresholds above 1v (sin (x)) this will give you a trigger
at the +1mSec (rising) and +19mSec (falling) points. Leaving a 2 mSec
dead-zone around the zero-crossing point, then the detector will trigger
When you get this trigger you wait for 3mSec. If the level is still
below threshold trigger your UPS. This gives your 5mSec latency.

Please sent my royalties to the email address below ......

Pete

..............................................................................
. Never trust a man who, when left alone in ....... Pete Lynch               .
. a room with a tea cosy, doesn't try it on ....... Marlow, England          .
..........Billy Connolly. ......................... .....picKILLspamspam.....beowulf.demon.co.uk ..

1998\08\02@201036 by Martin McCormick

flavicon
face
       For what it is worth, you could put an extra diode between the
output of your power supply rectifier and the filter capacitor.  This
gives you an un-filtered DC output at the junction between the
rectifier and the extra series diode.  the frequency will be either
mains frequency for a half-wave rectifier or twice mains frequency if
the rectifier is a full-wave kind.  The peak voltage will be what ever
the rectifier's output voltage is so you will need to clamp it, but it
will be referenced to the same ground as the rest of the PIC circuit.
One can either use this pulsating signal as a voltage reference to get
an idea as to whether the line voltage is correct or take a simpler
approach and use the low portion of the signal as a trigger to an
interrupt which can be timed from one cycle or half-cycle to the next.
If a couple of periods go by without a transition, it may be time to
start the UPS.

       Don't forget that this extra diode will lower the voltage on
the high side of the regulator by about .7 volts so there should be a
good enough margin so as not to keep the regulator from working
correctly.

Martin McCormick WB5AGZ  Stillwater, OK
OSU Center for Computing and Information Services Data Communications Group

1998\08\03@094848 by Roger Morella

flavicon
face
Run the AC (through a proper current limiting resistor) into 2 of the interrupt
inputs on the PIC (many of their chips have interrupts on the B port) .  Set
one of the interrupts to trigger on the rising edge, and the other to trigger
on the falling edge  (or you could set a trigger to interrupt on any change of
the port ).   Set another interrupt to trigger on an internal timer for
something greater than 8.33 mS.  Reset the timer interupt counter every time
you get an interrupt from the AC line (every 8.3mS)  if the timer interrupt
occurs, you have lost your AC. This allows you a response time that is less
than the 10 mS you specified.

We have used this method very successfully in one of our applications.

Good Luck

Roger

Norayr S. Elmayan wrote:

> One of the main problems we have faced during UPS designs, is the detection
> of AC power loss.  Using capacitor filtered stepped down DC signal, will be
> far too slow to respond.  We need in the order of 5 to 10 ms, be able to
> detect a surge or loss accurately.  Any suggestions on how to achieve with
> our mighty PIC, piccers.
>
> Please comment

1998\08\03@122227 by Mike Keitz

picon face
On Sun, 2 Aug 1998 19:09:13 -0500 Martin McCormick
<EraseMEmartinspam_OUTspamTakeThisOuTDC.CIS.OKSTATE.EDU> writes:
>        For what it is worth, you could put an extra diode between the
>output of your power supply rectifier and the filter capacitor.  This
>gives you an un-filtered DC output at the junction between the
>rectifier and the extra series diode.

Rather than that, use two small diodes from the ends of the transformer
to develop another rectified but unfiltered voltage for the sensing
circuit.  This works with either a full-wave bridge or full-wave center
tapped transformer arrangements.  Then there is no loss from having
another diode in series.

For processing, you probably want to compare the full-wave rectified
voltage to a threshold approximately 75% of normal.  This will detect
complete loss of power as well as "brownout" situations.  Most computer
devices here simply rectify the AC line into relatively large capacitors,
so they are sensitive to peak voltage.  The output of the threshold
compare goes to a retriggerable timer set slightly longer than a
half-cycle.  Faster response to complete loss of power could be had by
using another comparator set close to zero.  This comparator output will
be on most of the time except for a brief interval near the
zero-crossing, so a shorter timer could be used.

The two comparators and two timers could be built readily with a quad
comparator such as an LM339.  If there is a processor in the circuit,
software timing could be used.  A PIC with ADC or analog comparators
could do everything internally.


_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

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