How to detect power cutout for PC?

Sep 17, 2005 57 Replies

I need a circuit that can detect when electricity goes out and sends a signal to the serial port of my PC, so that a program that continously listens to the serial port can understand the situation and send a poweoff command to the operating system. I already have a simple UPS but I need such an extra circuit because UPS doesn't last for long.



I have two purposes:


1- Learn how to build such a circuit.


2- Save my PC from unhealthy shutdowns.



I have only beginner's knowledge of electronics so any resource, URL, etc. that provides clear instructions will be very useful.



It sounds like you bought your UPS at Fry's. Any good UPS comes with all of this

--unless someone removed it from the box and returned the unit.

The simplest safe circuit is a relay powered from a regulated wall wart. The output from the wall wart energizes the relay coil. When power drops, the relay de-energizes. The normally closed contacts on the relay can be used to switch whatever you want.

Ed

schreef in bericht news: snipped-for-privacy@o13g2000cwo.googlegroups.com...

You perfectly described the standard use for a UPS. Most of them have a serial port (or USB these days) to communicate with the PCs they are protecting. What UPS do you have? I can hardly imagine it has no way to signal to the outside world that it has taken over. The minimum is a single signal that changes from high to low (or the other way around) when the mains are gone. You may need to adapt for the correct level but such a signal is all you need to to trigger an interrupt of a serial or parallel port. All of the rest is software.

petrus bitbyter

It will not help you with 1- but a lot of UPS's you can buy these days have the option (cable-software) to shut down you PC just before the battery runs out. One advantage of this is that if you have a short power faillure your PC will keep running. Look for instance at APC.

Paul

Maybe he bought a UPS ( e.g. second hand off ebay ) that came without the software and serial cable it ought to have had ?

Graham

Thank you very much for the answer. My main aim is to learn how to design such a circuit and you have provided a few tips. Do you know any example, or circuit schematics that describes such a device?

PS: For the curious, I have an old and very cheap UPS (not from any retailer or eBay you mentioned, I live in Istanbul, Turkey) that doesn't have such a circuit to interface with my PC and I want to meet the challenge of designing one ;-)

Emre Sevinc eMBA Software Developer Actively engaged in: http:www.bilgi.edu.tr http://ileriseviye.org http://www.bilgi.edu.tr http://fazlamesai.net Cognitive Science Student http://cazci.com http://www.cogsci.boun.edu.tr

simply use a 120 volt AC relay control inputs of the serial port. when the AC is gone, the relay goes into the off pos and thus you can use the NC contact etc.. writing the software is another story how ever. you need to open the Serial port via CreateFile or What ever language you are using to perform a Read on the input. the file name is like "COM1:" for example. Use the WaitCommEvent on a specific event you are interested in. this would be the which ever input lines you decide to use or! you can use the GetCommModemStatus which does not wait but simply returns the current state of all the input lines.

Real Programmers Do things like this. http://webpages.charter.net/jamie_5

YOu might want to consider a delay either in hardware or software.

Turkey may be different, but here in the good ole us of a, there are two kinds of power outages, very brief and very long. The distribution has a big hole in the middle. You'd likely want to skip the shutdown on the short ones. mike

Wanted, Serial cable for Dell Axim X5 PDA. FS 512MB 45X SD Flash memory. Return address is VALID but some sites block emails with links. Delete this sig when replying. FS 500MHz Tek DSOscilloscope TDS540 Make Offer Bunch of stuff For Sale and Wanted at the link below. MAKE THE OBVIOUS CHANGES TO THE LINK http://www.geocities.com/SiliconValley/Monitor/4710/

12 volt relay DC relay contacts ------ ----- |->|

I read in sci.electronics.design that Emre Sevinc wrote (in ) about 'How to detect power cutout for PC?', on Mon, 19 Sep 2005:

You can do a 1 to 3 minute delay quite easily with a CMOS 555 timer (7555 or TLC555, which Google will find for you), and that is a very good (and very popular) newbie project.

Regards, John Woodgate, OOO - Own Opinions Only. If everything has been designed, a god designed evolution by natural selection. http://www.jmwa.demon.co.uk Also see http://www.isce.org.uk

Thank you very much, now I'm getting a clearer picture and going to start to build and test the circuit.

Once I have it working correctly on the hardware level, it is going to be a "simple matter of programming" for my Debian GNU/Linux running PC.

Emre Sevinc eMBA Software Developer Actively engaged in: http:www.bilgi.edu.tr http://ileriseviye.org http://www.bilgi.edu.tr http://fazlamesai.net Cognitive Science Student http://cazci.com http://www.cogsci.boun.edu.tr

Yes, I thought about that too, similar situation here in Turkey, some outages are just a few or 10-20 seconds that my UPS can handle. So, modifying the circuit in order not to send a signal as soon as it detects outage but maybe cound 2-3 minutes and then send the signal would be much better. But I think this complicates the matter just a little bit. So, if I can manage to build the circuit described in previous messages and write a program to do what I want, then I can try to introduce some kind of useful delay as you described, but first things first, I'm just an electronics newbie trying to find my way :)

Emre Sevinc eMBA Software Developer Actively engaged in: http:www.bilgi.edu.tr http://ileriseviye.org http://www.bilgi.edu.tr http://fazlamesai.net Cognitive Science Student http://cazci.com http://www.cogsci.boun.edu.tr

Do the delay in software. When the relay drops out, instead of immmediately shutting down, go into a time delay loop (in the background, of course) for whatever delay time you want. At the end of that delay time, check your "power is out" signal, and if it has disappeard (i.e., the power's come back on), then do nothing and exit. (or, go back to whatever it was you were doing before).

Good Luck! Rich

Here's a circuit that adds delay. You add

1 part - C1 a large electrolytic capacitor. 12 volt DC relay ------ ----- | (||) |---+---| / |---+

--| (||) | |+ ----- |

--| (||) | [C1] | | (||) | | | | (||) |---+-------------+ ------

If you use a relay with a high coil resistance, such as Radio Shack #275-248 and a 4,700 uF 16 volt (or higher) capacitor, you will get a few seconds delay. The higher the coil resistance and/or the higher the capacitance, the longer the delay. For example, and Omron G5V-1-2-DC12 relay has more than twice the coil resistance as the Radio Shack relay. If you used that relay, you would get a delay approaching 10 seconds.

Ed

Actually, I had the impression that his question was about acquiring the "power is good" signal in the first place, and that he already knows how to handle it when it gets into the port, ergo he wouldn't _have_ to put together a hardware timer. Like, is the goal "a ups alarm" or is the goal "learn how to build a timer circuit"?

But, yes, if you want to start learning electronics in general, then a 555 is probably a pretty good place to start. :-)

Cheers! Rich

The original answer with a wall-wart called out 12VDC:

--------------------- : 12 volt relay : DC relay contacts : ------ ----- |->|

That John might have missed the post where they specified "DC". If you hadn't seen that, then it _does_ look exactly like a plain transformer, which _will_ blow up a capacitor! :-)

Thanks, Rich

I read in sci.electronics.design that ehsjr wrote (in ) about 'How to detect power cutout for PC?', on Mon, 19 Sep 2005:

This is DANGEROUS RUBBISH. YOU HAVE AN ELECTROLYTIC CAPACITOR CONNECTED TO A LOW-IMPEDANCE AC SUPPLY. IT WILL EXPLODE, LATER IF NOT SOONER.

Regards, John Woodgate, OOO - Own Opinions Only. If everything has been designed, a god designed evolution by natural selection. http://www.jmwa.demon.co.uk Also see http://www.isce.org.uk

I read in sci.electronics.design that Rich Grise wrote (in ) about 'How to detect power cutout for PC?', on Mon, 19 Sep 2005:

But he knows software already. he wants to get into hardware, and a 555 timer project is the ideal introduction.

Regards, John Woodgate, OOO - Own Opinions Only. If everything has been designed, a god designed evolution by natural selection. http://www.jmwa.demon.co.uk Also see http://www.isce.org.uk

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required