Shop OBEX P1 Docs P2 Docs Learn Events
Detecting AC mains voltage with capacitively coupled wires — Parallax Forums

Detecting AC mains voltage with capacitively coupled wires

Mag748Mag748 Posts: 266
edited 2014-05-27 19:42 in General Discussion
Hello,

After watching this video:

http://youtu.be/VFX47ZGOn_o?t=1h8m57s

I want to recreate the "line frequence detector" in order to detect if and when the mains voltage powering my circuit is shut off. This will then give me enough time (~20mS) to write configuration data to the EEPROM before the Propeller losses power. I've looked over a lot of the internet to find a way to do this, but most solutions involve an optocoupler and current limiting resistors, but the method shown in this video seems much more elegant. There is no HV mains coming to the PCB that I would have to worry about.

Now, I believe this works simply by measuring the AC voltage through the wires as if it is a capacitor, and using an Op Amp to amplify that voltage to a usable level to then compare to a reference and have the uC react accordinly. But before I go and throw something together, I wanted to ask around to see if anyone has experience with this type of circuit or has any resources they could recommend to me.

Thanks,
Marcus

Comments

  • jmgjmg Posts: 15,173
    edited 2014-05-23 16:39
    Mag748 wrote: »
    . But before I go and throw something together, I wanted to ask around to see if anyone has experience with this type of circuit or has any resources they could recommend to me.

    Spice is an ideal Vehicle for this (eg LTSpice).
    Choose some coupling value ( eg 3pF) and drive into a couple of clamp diodes.
    Check the current available, and that tells you the PCB leakage and bias resistors needed (if you want to use some, so no-mains, stays no-mains up to some useful voltage)
    My Spice says 200nA is the peak from a 173v pk, 60Hz thru 3pF
    So it seems 10-20M is the ballpark for CMOS threshold pin detect, of Sufficient Mains present.

    Spice also says a few pF into the base of a Transistor (either correctly, or reverse wired for lower Beta) also works quite well. A series R (10k) with the low pF sense helps lower spike energies.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2014-05-23 16:59
    With Spice, just be aware that ideal models are used, and when designing you must take that into consideration.
  • Bill HenningBill Henning Posts: 6,445
    edited 2014-05-23 17:51
    I'd use an opto isolator.

    http://www.digikey.ca/product-detail/en/MID400/MID400-ND/31605
    Mag748 wrote: »
    Hello,

    After watching this video:

    http://youtu.be/VFX47ZGOn_o?t=1h8m57s

    I want to recreate the "line frequence detector" in order to detect if and when the mains voltage powering my circuit is shut off. This will then give me enough time (~20mS) to write configuration data to the EEPROM before the Propeller losses power. I've looked over a lot of the internet to find a way to do this, but most solutions involve an optocoupler and current limiting resistors, but the method shown in this video seems much more elegant. There is no HV mains coming to the PCB that I would have to worry about.

    Now, I believe this works simply by measuring the AC voltage through the wires as if it is a capacitor, and using an Op Amp to amplify that voltage to a usable level to then compare to a reference and have the uC react accordinly. But before I go and throw something together, I wanted to ask around to see if anyone has experience with this type of circuit or has any resources they could recommend to me.

    Thanks,
    Marcus
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2014-05-23 18:56
    Bill,

    The Opto-Isolator won't work with the suggested "capacitor" method described in this post.
  • jmgjmg Posts: 15,173
    edited 2014-05-23 19:55
    The Opto-Isolator won't work with the suggested "capacitor" method described in this post.

    I see it specs 2pF isolation C, so one could use it as the worlds most expensive 2pF capacitor !! ;)

    The MID400 linked, seems to be quite a costly opto, but it does include a monostable action for ease of use points.
    Claims a 1ms detect time.

    Would anyone use that in volume designs tho? - when an AC ip opto like LTV354 is 13c ?
  • kwinnkwinn Posts: 8,697
    edited 2014-05-23 20:26
    A couple of inches of wire next to the AC line with one end floating and the other going to a cmos schmidt gate should give you a nice square wave output. Simpler to use a small 1KV capacitor though.
  • Bill HenningBill Henning Posts: 6,445
    edited 2014-05-23 21:13
    Page six of the data sheet shows just a 22k resistor, I don't think it needs a capacitor - I was suggesting it as an alternate to the capacitor method.

    While the opto is considerably more expensive, it is isolated from the mains.
    Bill,

    The Opto-Isolator won't work with the suggested "capacitor" method described in this post.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2014-05-23 23:52
    While the capacitor method peaked my interest, I decide to try a few things with just a few discrete components.

    First (Fig1) I tried to get tricky, thinking I needed a HUGE amount of amplification, by using a circuit similar to a Re-Gen on the front of a radio. That proved to be interesting sensing the 60Hz plus a whole lot of other stuff. Basically a broadband RF amplifier coupled to a 5 foot Lamp cord. Interestingly enough it didn't matter if the Lamp cord was plugged in or not or even whether the Lamp was on or off. With the lamp cord unplugged, there seemed to be some slight phase shifting when I touched the AC prongs, but nothing at this point other than an observation.

    Second (Fig2) I just threw together a general transistor amplifier. Not even a good design really. Still I was observing similar results to the circuit as in Fig1.


    How Fig1 works:
    The transistor is biased ON with V+ finding it's way to the transistor Base through the 470k and 100k resistors. The Emitter is tied to GND through a 100k resistor. The transistor turns ON allowing the Ground to make it's way to the Collector through the lower 100k and Emitter. This action quenches the positive supply that was turning the Transistor ON through the Base. An equilibrium is met by keeping the Base voltage at just the point of transistor turn on. ( The most sensitive region of the transistor ) . The 0.1 uF capacitor acts to crowbar this voltage as a virtual supply therefore resisting any attempts to change. This allows any small fluctuations at the Emitter to be seen at the Collector in the same phase. This is important, because typically this happens at the Base of the transistor causing the relation at the Collector to be 180 Deg out of Phase. This arrangement however allows a small portion of the Amplified signal to act in a positive re-enforcing (Same Phase) way to the small signal fluctuations at the Emitter. This is the Re-Gen effect where the signal is amplified many many times over the normal capabilities of just a single transistor.

    How Fig2 works:
    This circuit is much simpler and works as just a 'dumb' amplifier... the 0.1uF capacitor in this case is used as a low pass filter. There isn't even a bias on the transistor. There is enough environmental noise that the transistor is ON in the linear region with a capacitive coupling to a 5 foot lamp cord acting as an antenna.


    My conclusion is that a standard Op-Amp or discrete components can't be used here. There is probably some PLL filtering tricks that are done within that IC shown in the video at the top of this thread. A little bit of reverse thinking ... The IC might even send a signal of some kind, and if there isn't an AC load the signal can be read easily, otherwise it is washed out when the AC is plugged in or turned ON.

    AC Detect.jpg
    791 x 813 - 176K
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-05-24 00:12
    Why not a hall effect sensor on the AC power cord?

    I suspect that measuring capacitances may be subject to influence from eternal objects, like a thermin is affected by hands waving near by. When you start using op amps to generate gains of 100X or 1000X, the information that you are presented with may have an added burden of noise.

    In other words, either opto-isolators or hall-effect sensors can offer excellent isolation without having to fool around with amplifying what you are looking for.
  • Heater.Heater. Posts: 21,230
    edited 2014-05-24 00:45
    The circuit Dave Jones mentions in that video is, I believe, a mains locked trigger generator for the oscilloscope.

    As such I'm guessing it is actually a free running oscillator at 50 or 60Hz which is then locked to the actual mains frequency via that capacitively coupled piece of wire close to the mains input cable.

    There is such a circuit in Figs 11 and 13 of the "Circuit Techniques for Clock Sources" Application Note from Linear Technology. http://www.ok1cjb.cz/downloads/an12-85.pdf

    As Beau points out such a capacitive coupling will be full of noise, the oscillator trigger circuits filter all that out.

    This kind of circuit is not going to help with detecting mains drop out.

    Presumably with there is enough capacitance in your Propeller projects power supply that you have a lot longer than 20ms to write data out before total power collapse.
    Why not just trigger a power down sequence by detecting the voltage going low in front of the regulator driving the Propeller circuitry?
  • lanternfishlanternfish Posts: 366
    edited 2014-05-26 21:54
    I have had a look at the video and this is what I can see:

    each leg of the wire(s) from the ac lead are coupled via a resistor (R414, R415) to each of the inputs of one op-amp of a LMC6035.
    each input LMC6035 input is biased (above gnd?) with a diode (CR402, CR403).
    the output is from the second op-amp of the LMC6035 coupled to wherever via another resistor (R413).

    I am guessing the first op-amp is a current amplifier connected to the second op-amp which is a voltage follower?
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2014-05-27 03:27
    This will then give me enough time (~20mS) to write configuration data to the EEPROM before the Propeller losses power.

    If this is what you want to do then...

    How about doing it with low voltage DC which is easier to work with?

    eg Wall wart => 9VDC => sample point => resistor to ground => diode eg 4001 => big capacitor eg 4700uF => propeller board.

    Measure the volts at the sample point. If the power goes off, the voltage will fall at this point, but the big capacitor will keep powering the circuit long enough to write the config data.

    The 'big capacitor' needs to be larger than the wall wart cap (which sometimes are 470uF but can be 4700uF). The resistor to ground bleeds off power from the wall wart capacitor. Value such that it discharges faster than the propeller board is using power, so maybe some experimentation there. Might be 500R to 10K.
  • tonyp12tonyp12 Posts: 1,951
    edited 2014-05-27 09:12
    >This will then give me enough time (~20mS) to write configuration data to the EEPROM before the Propeller losses power.

    I see no need to read the AC main for this, though it could give a mS head start on detecting power outage.

    A LDO with PowerGood pin and the Prop gets it's power from here too but the Prop have a diode and supercap to give it time to do its thing.
    Don't power anything else but the Prop and eeprom past the diode unless the cap is large enough to be called a battery.
  • jmgjmg Posts: 15,173
    edited 2014-05-27 19:42
    How Fig2 works:
    This circuit is much simpler and works as just a 'dumb' amplifier... the 0.1uF capacitor in this case is used as a low pass filter. There isn't even a bias on the transistor. There is enough environmental noise that the transistor is ON in the linear region with a capacitive coupling to a 5 foot lamp cord acting as an antenna.

    My conclusion is that a standard Op-Amp or discrete components can't be used here.

    With care, they can be made to work, with some caveats on what they are measuring.
    The sense the swing between two nominally separate circuits. If both are floating, then it will be hard to decide if the stray AC sensed, is due to swing onthe sensor side, or on the sensed cable due to connected mains (as opposed to pickup mains)

    3 Pin mains designs are likely to be more reliably sensewd than 2 pin ones.

    Fig 2 works because the Vbe junction zeners, and so provides clamping for negative swings.
    - so that will have ~ 6v swing on the base pin.
    A series R and Cap B-E will help remove stray RF, but the sense mode is still relative -AC

    An AC opto coupler, needs a min of 100uA~1mA of active current, which is above stray pickup levels.
Sign In or Register to comment.