Maker Pro
Maker Pro

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.
 
P

petrus bitbyter

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.

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
 
J

JeffM

...a circuit that can detect when electricity goes out...
[and send] a signal to...the operating system.
emre.sevinc @ gmail.com

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.
 
E

ehsjr

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.

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
 
P

Paul

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.

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
 
R

Rene Tschaggelar

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.

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
 
P

Pooh Bear

petrus said:
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

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
 
E

Emre Sevinc

ehsjr said:
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.

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
 
E

Emre Sevinc

Rene Tschaggelar said:
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.

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
 
R

Rene Tschaggelar

Emre said:
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.

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
 
J

John Woodgate

I read in sci.electronics.design that Rene Tschaggelar <[email protected]>
EG, attach before the rectifyer
a diode plus an RC. As long as the RC is having voltage,
there is line power.

Would a Protestant do instead of an RC?
 
R

Rene Tschaggelar

John said:
I read in sci.electronics.design that Rene Tschaggelar <[email protected]>



Would a Protestant do instead of an RC?

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

Rene
 
J

John Woodgate

I read in sci.electronics.design that Rene Tschaggelar <[email protected]>
wrote (in said:
Apparently there is something funny about an RC,
but I fail to recognize it. roman catholic ?
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.
 
M

Mark Zenier

....
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.

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 [email protected]
Googleproofaddress(account:mzenier provider:eskimo domain:com)
 
E

Emre Sevinc

Rene Tschaggelar said:
Detection of missing power is not that hard as
long as you have some left. From the battery powered,

"From the battery powered"... you mean the circuit that
is going to be constructed?
detect whether the secondary of the transformer
is delivering power. EG, attach before the rectifyer

Hmm, first I have to learn what a rectifier diode is and what
is its specification.
a diode plus an RC. As long as the RC is having voltage,
there is line power.

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
 
E

Emre Sevinc

John Woodgate said:
I read in sci.electronics.design that Rene Tschaggelar <[email protected]>

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.

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
 
J

Jamie

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.
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.
 
E

ehsjr

Emre said:
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?
12 volt relay
DC relay contacts
------ ----- |->| <|
| (||) |---| / |---+ | | |
--| (||) | ----- | N/C o o o N/O
--| (||) | | COM
| (||) |-------------+
------
12 volt DC N/C = Normally Closed
regulated COM = Common
wall wart N/O = Normally Open

When mains power is available, the wall wart will produce 12
volts DC. That will energize the relay, and will cause the
common and normally open contacts to come together. That would
complete a circuit connected to those points. It would also
interrupt a circuit connected to the normally closed and
common contacts, because energizing the relay would separate
those contacts.

When mains power is interrupted, the relay will de-energize and the
circuit connected to the common and normally open contacts will
be opened. The normally closed and the common contacts would come
together, which would complete a circuit connected to those contacts.

You would use the common and normally closed contacts to
signal the serial port.

Ed
 
M

mike

ehsjr said:
12 volt relay
DC relay contacts
------ ----- |->| <|
| (||) |---| / |---+ | | |
--| (||) | ----- | N/C o o o N/O
--| (||) | | COM
| (||) |-------------+
------
12 volt DC N/C = Normally Closed
regulated COM = Common
wall wart N/O = Normally Open

When mains power is available, the wall wart will produce 12
volts DC. That will energize the relay, and will cause the
common and normally open contacts to come together. That would
complete a circuit connected to those points. It would also
interrupt a circuit connected to the normally closed and
common contacts, because energizing the relay would separate
those contacts.

When mains power is interrupted, the relay will de-energize and the
circuit connected to the common and normally open contacts will
be opened. The normally closed and the common contacts would come
together, which would complete a circuit connected to those contacts.

You would use the common and normally closed contacts to
signal the serial port.

Ed

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
ht<removethis>tp://www.geocities.com/SiliconValley/Monitor/4710/
 
E

Emre Sevinc

ehsjr said:
12 volt relay
DC relay contacts
------ ----- |->| <|
| (||) |---| / |---+ | | |
--| (||) | ----- | N/C o o o N/O
--| (||) | | COM
| (||) |-------------+
------
12 volt DC N/C = Normally Closed
regulated COM = Common
wall wart N/O = Normally Open

When mains power is available, the wall wart will produce 12
volts DC. That will energize the relay, and will cause the
common and normally open contacts to come together. That would
complete a circuit connected to those points. It would also
interrupt a circuit connected to the normally closed and
common contacts, because energizing the relay would separate
those contacts.

When mains power is interrupted, the relay will de-energize and the
circuit connected to the common and normally open contacts will
be opened. The normally closed and the common contacts would come
together, which would complete a circuit connected to those contacts.

You would use the common and normally closed contacts to
signal the serial port.

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
 
Top