How do you detect a main ac power loss as quickly as possible ? - Page 1
Forum section: electronics / projects

author: chipeater
author_rank: Contributor
timestamp: November 09, 2023, 04:20:40 pm
content: Hello,I'd like to try to disconnect loads from the AC main power as quickly as possible using a microcontroller.I thought of using a zero crossing detector principle but I will only be able to disconnect the charge after 20ms in the worst case (50Hz).Do you have any ideas on how to detect a main AC power loss more quickly ( 1-2ms max ) ?Thank you very much

author: 2N3055
author_rank: Super Contributor
timestamp: November 09, 2023, 04:29:29 pm
content: Quote from: chipeater on November 09, 2023, 04:20:40 pmSeriously??Sit down and think about it..What would be the reason for this in a first place?That source of electricity goes off 100 times per second..There is also thing that wall outlet electricity has many partial brownout events during day. Any power supply survives them easily..

author: RAPo
author_rank: Super Contributor
timestamp: November 09, 2023, 04:39:29 pm
content: If you want schematics, "look for ups online double conversion". Why 2ms switch over time?

author: PCB.Wiz
author_rank: Super Contributor
timestamp: November 09, 2023, 06:38:43 pm
content: Quote from: chipeater on November 09, 2023, 04:20:40 pmYou just capture the ac sine using the MCU's ADC, at some sub-ms rate, and compare to an ideal average sine.Of course, you will quickly find that 1-2 ms disturbances are quite common on mains, and do not mean ‘power loss’

author: Conrad Hoffman
author_rank: Super Contributor
timestamp: November 09, 2023, 06:49:45 pm
content: Conceptually, it seems like you could have a line frequency oscillator, synced to the line, but with a very long time constant and light coupling, such that if the line dropped out, the oscillator would take a long time to be affected. Now just compare line to oscillator and, in theory, you could detect when the line wasn't at the instantaneous voltage it's supposed to be. IMO, the pitfalls are many, including brownouts and changing loads changing the amplitude. Since you can't predict what the line does short term, it's probably not possible to reliably detect a power failure at the ms level. (last post says about the same thing, but I type slower!)

author: shakalnokturn
author_rank: Super Contributor
timestamp: November 11, 2023, 12:06:58 am
content: Quote from: 2N3055 on November 09, 2023, 04:29:29 pmIt is a bit of an unusual question. Still if it's being asked there may be an actual need.One possible case that comes to mind is grid-tie inverter shutdown when grid is lost, I have no idea on regulatory shutdown time requirements, nor motivation to search them right now.

author: 2N3055
author_rank: Super Contributor
timestamp: November 11, 2023, 01:32:52 am
content: Quote from: shakalnokturn on November 11, 2023, 12:06:58 amOr it is asked before homework is done. I don't know. That is why I asked for use case explanation.But let's think about it. It is a sinewave (distorted one).It has 50 positive and 50 negative half periods and 100 zero crossings a second.100 times a second it will be 0 by definition.In that context, what does it means to detect power loss in 1ms?1ms after zero crossing, 50 HZ 240V mains will reach cca 100V.If you make a comparator that will detect 100V threshold, you will still get 100 2ms pulses each second detecting "dropout".Make threshold 10V. Still 100 pulses just shorter..That is why power detector circuits usually simply count zero crossings and have some threshold of missed pulses.Or you have voltage too low detectors that also do some averaging.You can also use window comparators (in analog or sampled digital domain) that will detect voltage raising above some voltage but not other detecting brownouts..In practical terms power grid is source of energy. We take quantas of energy (because AC) and feed them to our devices.Any device must survive 50ms blackout like nothing happened. 2.5 full periods. Power grid is very imperfect. Single period dropouts are not rare..And that is why I asked for use case. Detecting 1 ms dropout on DC makes perfect sense.On 50 Hz power grid not so much. So it must be something very specific or misguided.

author: David Hess
author_rank: Super Contributor
timestamp: November 11, 2023, 03:10:43 am
content: Quote from: Conrad Hoffman on November 09, 2023, 06:49:45 pmThere is probably a smarter way, but that is how I would do it; phase lock an oscillator to the line frequency and then compare the two to detect a line dropout. This will work to detect failure within a fraction of half of a line cycle.Phasing locking an oscillator is also a good way to detect zero crossings with little noise.

author: bdunham7
author_rank: Super Contributor
timestamp: November 11, 2023, 06:22:01 am
content: Quote from: 2N3055 on November 11, 2023, 01:32:52 amBack when I was doing a bit of bitcoin mining, I learned that many computer PSUs had a 'holdup time' of 10ms or less when fully loaded. My APC UPS units, IIRC, had a response time of about 10ms (pretty fast--1 half cycle plus 2ms), so it was hit or miss as to whether they'd drop out during power glitches. Running them at 50% or less of rated power fixed that.

author: jonpaul
author_rank: Super Contributor
timestamp: November 11, 2023, 12:21:19 pm
content: The simpleset solution:use a 120V or 240V AC relay.The DPDT NC contacts open on power loss and we transfer the load from utility to backup solar/gas genWith a UPS on the load side never miss a beat.Jon

author: DavidAlfa
author_rank: Super Contributor
timestamp: November 11, 2023, 12:54:06 pm
content: Use the zero cross signal, if at any given moment it goes off for more than 500us you know something is wrong.

author: NiHaoMike
author_rank: Super Contributor
timestamp: November 11, 2023, 01:05:31 pm
content: This is how the Prusa MK3 does it:https://github.com/prusa3d/MK3_Power_Panic/blob/master/rev.04/power-panic.pdfTakes a little more than half a cycle to detect, which is about as quick as can be done without getting a lot of false triggers.

author: Terry Bites
author_rank: Super Contributor
timestamp: November 14, 2023, 02:25:19 pm
content: Add a lagging phase shift to delay the power waveform. Use the unshifted waveform to control the lagged?