How to detect power cutout for PC?

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.

Reply to
emre.sevinc
Loading thread data ...

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.

Reply to
JeffM

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

Reply to
ehsjr

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

Reply to
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

Reply to
Paul

IMO, one of the handshake signal inputs of the Serialport is used for exactly that purpose. A decent OS already has a driver to listen to this signal.

Rene

--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com
& commercial newsgroups - http://www.talkto.net
Reply to
Rene Tschaggelar

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

Reply to
Pooh Bear

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
Reply to
Emre Sevinc

My main OS at home is Debian GNU/Linux and if I can construct such a circuit I think it is not going to be very difficult to write a program that listens to the serial port and issues the shutdown command when it receives some bit from there.

The main challenge for me is to construct such a circuit.

--
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
Reply to
Emre Sevinc

I read in sci.electronics.design that Rene Tschaggelar wrote (in ) about 'How to detect power cutout for PC?', on Sun, 18 Sep 2005:

Would a Protestant do instead of an RC?

--
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
Reply to
John Woodgate

Detection of missing power is not that hard as long as you have some left. From the battery powered, detect whether the secondary of the transformer is delivering power. EG, attach before the rectifyer a diode plus an RC. As long as the RC is having voltage, there is line power.

Rene

Reply to
Rene Tschaggelar

...

Well, do it in software. Get a 6 to 9 volt AC wall wart and hook up the two wires up to the receive data and ground pins on the RS-232 serial port. (Not to a logic level signal).

The line receiver chip in the serial port will convert the AC sine wave to a digital pulse of about 10 milliseconds, (with the 50 Hz power there in Turkiye), which can be interpeted as a single serial character when the port is set up for a 600 bits/second. (Asynchronous serial starts with a start bit, then sends bits LSB to MSB. So it will be 4, 5, or 6 "zero" bits followed by several "one" bits, so the characters will probably be '@', '`', or 'p').

Then you run two very simple daemon processes. One reads the serial port (recommend in raw mode) and reads the current time and writes this to a shared memory (or a file on ram disk) for each (or every n) character(s). The second process reads the shared memory every few seconds and compares it to the current time. If the time in the shared memory isn't getting updated, the power is off.

Mark Zenier snipped-for-privacy@eskimo.com Googleproofaddress(account:mzenier provider:eskimo domain:com)

Reply to
Mark Zenier

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
Reply to
Jamie

Yip. Also, to try to point out that you mean *RC network*, and you haven't said whether it is series or parallel. The OP is, after all, not very well-versed in this electronics stuff.

--
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
Reply to
John Woodgate

Apparently there is something funny about an RC, but I fail to recognize it. roman catholic ?

Rene

Reply to
Rene Tschaggelar

"From the battery powered"... you mean the circuit that is going to be constructed?

Hmm, first I have to learn what a rectifier diode is and what is its specification.

You mean an RC circuit? Just a resistor and capacitor? Or some specific RC circuit? What kinds of resistor(s) and capacitor(s)?

--
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
Reply to
Emre Sevinc

Yes, the original poster is an electronics newbie :) (just ordered The Art of Electronics from Amazon.com, refreshing his introductory level university physics electricity knowledge and trying to learn some PIC programming).

That's why I asked if there is a some ready made circuit schematics with some explanation so I may examine and learn something.

What kind of "RC network" do I need? Components, connections, etc.?

BTW, I'm living in Turkey and AC voltage is 220 V (I guess it is 110 V in some other countries, USA, etc.?).

--
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
Reply to
Emre Sevinc

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/
Reply to
mike

12 volt relay DC relay contacts ------ ----- |->|
Reply to
ehsjr

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
Reply to
John Woodgate

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.