Shop OBEX P1 Docs P2 Docs Learn Events
AC Power Detection — Parallax Forums

AC Power Detection

edgellmhedgellmh Posts: 85
edited 2008-05-16 20:58 in General Discussion
I want to determine whether house power is on at a remote location. The microcontroller whose job it is to do this will be powered by a UPS. Presumably I need some kind of relay but it is unclear to me what kind of relay and how to sample the ac power. If I use a power cube to put a low voltage onto a relay then what I am detecting is whether or not the power cube is working. Is there a way a more direct way to sample the AC power?

Comments

  • BeanBean Posts: 8,129
    edited 2008-05-15 11:10
    The easiest way would be to use a REGULATED 5 volt adapter and connect it to a pin with a resistor (10K).
    If the pin is high, power is on.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Did you know that 111,111,111 multiplied by 111,111,111 equals 12345678987654321 ?

    www.iElectronicDesigns.com

    ·
  • edgellmhedgellmh Posts: 85
    edited 2008-05-15 12:11
    Thanks. So simple! I'll give it a try.
    marshall
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2008-05-15 18:40
    Here is another solution that might work - I did not test this circuit but I saw it working in some other application. Here the 4N33 protocoupler takes care of the necessary isolation between the mains circuit and the SX. The 220nF capacitor acts as a capacitive resistance (about 12 kOhm @ 60 Hz), limiting the current through the 4N33 LED to about 10 mA. As the 4N33 is activated on positive half-waves only, its output would toggle at 60 Hz. The elcap between the photo transistor's base and Vss should keep the output steady. The MAINS_ON signal can be directly fed into an SX input pin. When Mains is there, MAINS_ON is pulled low, when it is off, MAINS_ON is pulled high by the 10 k resistor.

    Have fun!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
    1242 x 507 - 58K
  • edgellmhedgellmh Posts: 85
    edited 2008-05-15 21:33
    Gunther

    What does LIFE stand for in the diagram?
    I assume we are talking about a three wire mains cable and using one leg of the three wires as LIFE and the ground wire as neutral?
    marshall
  • FireHopperFireHopper Posts: 180
    edited 2008-05-15 21:43
    I guess life = live or hot wire.
  • T'SaavikT'Saavik Posts: 60
    edited 2008-05-15 22:21
    edgellmh said...
    I assume we are talking about a three wire mains cable and using one leg of the three wires as LIFE and the ground wire as neutral?

    Yipes no! Danger Danger!! jumpin.gif

    A 3-wire AC line is
    Live
    Neutral
    Ground.

    For reference a 2-wire ac line (say, a lamp cord) is:
    Live
    Neutral

    Gunther's circuit is using live and Neutral. Neutral is NOT ground!

    Post Edited (T'Saavik) : 5/15/2008 10:26:15 PM GMT
  • FireHopperFireHopper Posts: 180
    edited 2008-05-15 22:51
    most of the AC wiring I've seen Inside some breaker boxes, they connect neutral and ground together.
    at least the ones that the electrician installed a few weeks ago were that way.
  • edgellmhedgellmh Posts: 85
    edited 2008-05-16 00:19
    Thanks guys. Particularly the danger thing.
    marshall
  • Basic JimBasic Jim Posts: 106
    edited 2008-05-16 01:28
    How about this,

    You connect a photo resistor to one of the SX pins and you aim it to a·night light or a neon light that is common on a lot of·surge protectors. If you loose power the night light goes out triggering the resistor. That would give you 100% isolation for your circuit.

    Jim W.
  • FireHopperFireHopper Posts: 180
    edited 2008-05-16 01:32
    nice idea [noparse]:)[/noparse] the neon lights seem to die though..
  • Basic JimBasic Jim Posts: 106
    edited 2008-05-16 01:36
    Good point! Probably best to find a surge protector that uses and LED to show power.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-05-16 04:39
    Firehopper said...
    most of the AC wiring I've seen Inside some breaker boxes, they connect neutral and ground together.

    Yes, BUT, ground is not neutral, even though they're connected together at the breaker box. In normal use, the ground wire should never carry any current; that's what the neutral wire is for. The ground wire is only there in a protective capacity. Since the ground wire doesn't carry any current, there's no voltage drop, and any metal housings connected to it are truly at ground potential. The same cannot be said for the neutral wire, especailly at the end of a lengthy wiring run or long extension cord.

    -Phil
  • edgellmhedgellmh Posts: 85
    edited 2008-05-16 12:33
    How does one recognize the neutral wire in an extension cord?

    marshall
  • Sens-a-DatSens-a-Dat Posts: 44
    edited 2008-05-16 12:40
    In the USA for 120VAC circuits, the terms are LINE and NEUTRAL and GROUND. Depending on how the electrician wired your main electrical panel, it is possible that NEUTRAL and GROUND are connected together there. For safety reasons, there is a reason why they are separate electrical conductors in the wiring.

    For 240VAC, you will have two LINEs, one NEUTRAL, and possibly a GROUND. Each LINE has a voltage of 120VAC, and each are out of phase with the other as their voltage oscillates. As one LINE approaches +120V, the other approaches -120V. These two different LINEs will usually be noted as L1 and L2 on schematics. You arrive at 240VAC but connecting between L1 and L2.

    I cannot speak for Gunther as to whether it was a typo for LIFE, or whether that is the correct term for the hot side of the electrical circuit for the homes.
  • FireHopperFireHopper Posts: 180
    edited 2008-05-16 13:09
    usually.. line or hot is Black, neutral is white, and ground is green..



    on a 2 conductor wire.. one usually has ribs on the wire.. I usually verify thoug.. on·a polarized plug, the wider one is neutral, the smaller one is hot.. some plugs are NOT polarized though. so be carefull.
  • edgellmhedgellmh Posts: 85
    edited 2008-05-16 13:13
    thanks.

    marshall
  • Basic JimBasic Jim Posts: 106
    edited 2008-05-16 13:41
    Just wondering, if your running off a UPS and the power goes out the UPS will know it and will either beep and/or light and LED. Couldn't you just tap off the LED/speaker inside the ups? another option would be, most UPS have a serial port to let the computer know their status and shut the system down when the batery gets low. Couldn't you use a pin off the SX to both get the UPS is on signal and control the ups as well?
  • edgellmhedgellmh Posts: 85
    edited 2008-05-16 14:48
    Jim
    I am using the microcontroller to detect fault conditions in an astronomical observatory that is remote to me. I need to effect dome closure when various parts of the total system fail or the weather gets bad. I wanted an independent assessment of the ac power to start dome closure before the UPS system runs out of power. I am not knowledgeable enough to know whether I should totally trust the UPS to close the dome on its own detection of power loss. However, the uPS can be programmed to execute a dome closure program when it begins its shutdown operations which in principle makes ac power detection moot. Since I need the microcontroller for other chores I thought adding this task would increase reliability. The suggestion of using a regulated 5V power supply directed to an SX input pin through a resister seems a very straight forward way to detect ac power and is logically equivalent to the ups related detectors you suggest.

    marshall
  • Basic JimBasic Jim Posts: 106
    edited 2008-05-16 17:20
    I see, I think you will want to add some kind of a load to the 5V supply. If you just have a 10k ohm going to an input and you loose power the voltage may stay high for a long time without a load to drain it.
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2008-05-16 17:48
    Hi all,

    sorry for causing all that confusion about LIFE and LINE. In many European areas, regular power supply lines come with three wires, (L) - Line or Life, (N) Neutral, and (PE) Protective Earth. As the single-phase supply used in a household is usually derived from a three phase transformer with three secondary coils in a star circuit, you may think of Neutral being connected to the center tap of the star, where all three coils are wired dogether, and with Line conected to one of the star's outer taps. When the three-phase system has a balanced load, the star point has a potential of Zero, therefore, it is called Neutral, and usually connected to earth potential, like a metal water pipe, or a special earth bar under the house's foundation. In earlier years, Neutral was often bridged to the PE contact in a wall outlet. Today, this is no longer allowed, and a separate PE lead is required which is connected to earth potential at a central point. Important to know is that PE wires are always marked green/yellow (green in the US). This separate PE wire also allows the use of what is called Ground Fault Circuit Interruptor (GFCI) in the US, or FI (Failure Current) here.

    Now back to my circuit...

    Well, I assumed that everyone was aware of the fact that the left and the right sides of the photo coupler must be isolated from each other very well, and opto isolators like the 4N33 are specially designed for such tasks. They come with UL approval, and can isolate a couple of 1000 Volts.

    Jim W's idea using a night light together with a photo resisistor is pretty much the same setup, you will find inside an photo coupler, usually consisting of an LED, and a photo transistor.


    Marshall:

    the problem you have regarding dome closure on power failure is that you can't predict when power will fail. IOW, the UPS (or actually, the battery inside) must be sized large enough to supply enough power for a dome closure under worst-case conditions before it runs out of power, and it must begin this operation as soon as a power failure has been detected - right?

    Some UPSes, mostly designed for powering computer systems keep the computer system up and running from battery power for a certain period of time, hoping that regular power will return in time again. When they detect that batteries are going low, they indicate a battery low status to the computer system early enough to powering-down the system from the remaining battery capacity. Actually, this is not what you need. You should check if the UPS has a failure output, like a relay contact that closes as soon as the UPS switches to backup power (most UPSes do have such a signal). If not, you may use a circuit similar to the ones suggested in this thread as an alternative. You may use the output signal to trigger the system that takes care of the dome-closure, whatever it is designed like - maybe with a microcontroller.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • Basic JimBasic Jim Posts: 106
    edited 2008-05-16 20:34
    Hello G
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2008-05-16 20:58
    Hello Jim,

    >>> My only reason for suggesting the photo resistor/diode method was simplicity and would not involve bringing AC voltage to a board. <<<

    I absolutely agree - staying away from mains voltage as far as possible is always a good idea. For professional designs, I prefer using external power supplys with the necessary UL, or European ratings. This protects me against any liability cases. Nevertheless, for private use, there may be some exceptions to that rule as long as you know what you are doing.

    Any method tapping an indicator in the UPS would be fine provided that it comes up as early as possible after a power failure.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
Sign In or Register to comment.