Shop OBEX P1 Docs P2 Docs Learn Events
SIMPLE and fast way to sense 120VAC with a BS2... Safely — Parallax Forums

SIMPLE and fast way to sense 120VAC with a BS2... Safely

xanatosxanatos Posts: 1,120
edited 2011-11-15 19:23 in General Discussion
I've just been handed an additional task of sensing the state of a switch on an external piece of equipment, and the only way to do so is to sense whether there is 120 VAC present or not. I have tried passing the voltage through a 0.1uF cap and then rectifying that with a bridge rectifier, then passing the output of that through a voltage divider and filter cap... but I feel that it is exposing my circuitry to possible spikes, etc. THERE HAS TO BE A BETTER WAY!

Optoisolators are not an option at the moment... this has to be done with what I have right now. Is there a better, safer, faster way to sense 120VAC than the convoluted method I have described above? I just need to get a few miliamps at 4.5 to 5.0vdc to my BS2. I could use a relay, but jeez.... that's like using a bulldozer to push a marble...

Ideas?

Thanks

Dave

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-11-14 18:43
    Run a neon lamp (incl dropping resistor), very low current they, on the 120vac and "optically" couple that to a phototransistor, isolated, on/off.
  • bomberbomber Posts: 297
    edited 2011-11-14 18:44
    There is the Digital I/O board kit. I am not shure it will work for your device, though.
  • xanatosxanatos Posts: 1,120
    edited 2011-11-14 18:58
    Neon lamp/PhotoQ is a remote possibility depending on availability of parts TOMORROW, Digital IO board is not even a remote possibility. Thanks for the ideas so far, still open to possibilities involving minimal components and zero order/shipping/wait time.

    Dave
  • kwinnkwinn Posts: 8,697
    edited 2011-11-14 18:59
    No need to rectify the AC. Clamping diodes to 5V and ground are all that is needed.
  • xanatosxanatos Posts: 1,120
    edited 2011-11-14 19:11
    kwinn wrote: »
    No need to rectify the AC. Clamping diodes to 5V and ground are all that is needed.

    Can you elaborate a bit more? I've got a single hot side 120 VAC lead coming back at me from the switch. I'm guessing I'd need a current limiting resistor befoe the clamping diode... I'm also assuming that the clamping diode is a special diode type, not just an arrangement of diode... which means might work great for NEXT time, but no time to order for this project. But I am interested in just what the clamping diode can do for me... Thanks! ... Also - how would this protect against voltage spikes to my BS2 input pin?

    Dave
  • pedwardpedward Posts: 1,642
    edited 2011-11-14 19:29
    Wrap a few turns of wire around one leg of the AC (the hot leg) and connect it via a small signal diode to an input on the uC, you may need to add a bypass cap to stabilize the voltage. You should get a DC signal out of this inductive clamp. For bonus points you could try wrapping some wire and connecting it to the input of a 4N35 optoisolator and use the open collector to drive the BS2, giving you even more isolation.

    The inductive clamp will sense current flow in the wire, generating a voltage across the loop when the unit is drawing current from the 120vac.
  • ercoerco Posts: 20,261
    edited 2011-11-14 19:44
    A short circuit and a smoke detector, if one-time sensing is OK.

    No good?
  • xanatosxanatos Posts: 1,120
    edited 2011-11-14 19:48
    :-) I'm having a short circuit myself right about now! You can't imagine how many simple options I can't use due to physical and environmental constraints... It's in a volatile (flammable fumes) environment, so simple microswitches and any exposed wires are out... complete PITA!

    Dave
  • pedwardpedward Posts: 1,642
    edited 2011-11-14 19:55
    My suggestion doesn't have anything to do with bare wires and microswitches, so you should be set. EMF doesn't have problems with plastic or rubber! :)
  • ercoerco Posts: 20,261
    edited 2011-11-14 20:06
    PJ had a nice post a while back about driving an LED off 120V through capacitive reactance, where he showed how to calculate the cap value. You could use that LED driver to switch a phototransistor, as he suggested using a neon bulb in post #2. A DIY optoisolator.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-11-14 20:16
    Here's a simple circuit for detecting an AC line voltage:

    -Phil
  • User NameUser Name Posts: 1,451
    edited 2011-11-14 20:41
    FWIW, if you did have a R/S nearby, the bundled infrared emitter and detector pair that they sell can be used as an opto-coupler. Just tape them together facing each other.

    In fact. an LED can function as a photodetector, but for maximum sensitivity you might have to mix and match colors. So if you simply had two LEDs and a couple resistors you could probably make an optocoupler adequate for your uses.
  • frank freedmanfrank freedman Posts: 1,983
    edited 2011-11-14 21:07
    pedward wrote: »
    My suggestion doesn't have anything to do with bare wires and microswitches, so you should be set. EMF doesn't have problems with plastic or rubber! :)

    Second pewards idea. Inductive probably safest. May think about comparator/op amp though depending on how many turns you use or if you use a current transformer designed for current measurement. You can check the GE AMX4 prints kvp/mA schematics (should be downloadable from their documentation site) for an example of this use.

    Frank
  • Beau SchwabeBeau Schwabe Posts: 6,569
    edited 2011-11-14 22:00
    About 13 years ago I designed an automatic turn On/Off for an industrial vacuum system that had at least 10 different stations connected to the vacuum. Last I checked, this unit was still in operation, now 13 years later and it's been running 24/7.

    Reference #6 on this thread:
    http://forums.parallax.com/showthread.php?87014-stamp-life-expectancy

    The detection circuit monitored power to each station via a twisted pair wire going back to the control unit... some of the ceiling runs were 30 feet. The Attached circuit in combination with a Basic Stamp II at the control board was essentially all there was to it... everything else was software which in turn drove a 40 Amp 120VAC relay to control the Vacuum Motor.
    1024 x 674 - 75K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-11-14 22:47
    Two issues with pedward's idea:

    1. You won't get any inductive coupling by wrapping one wire around another. Any alternating curren in the AC wire will produce an alternating magnetic flux circling the wire. The sense wire has to be a right angles to the magnetic flux to couple to it inductively, not parallel, as it would be if wrapped around the AC line. The correct way to do this is to wrap the sense wire around a magnetic core or toroid, around which, or through which, the AC line also runs.

    2. Even if you get an inductive coupling, it will be sensitive to the current in the AC line, not to the voltage present. IOW, if the switch is on, but there's no load, you won't get a reading.

    -Phil
  • jdoleckijdolecki Posts: 726
    edited 2011-11-15 02:06
    :-) I'm having a short circuit myself right about now! You can't imagine how many simple options I can't use due to physical and environmental constraints... It's in a volatile (flammable fumes) environment, so simple microswitches and any exposed wires are out... complete PITA!


    And you want to put a homemade detector in a explosive enviroment!

    Spend the money and get a engineered device designed for that it will not be worth it if and accident happens.
  • LeonLeon Posts: 7,620
    edited 2011-11-15 05:04
    When I needed to do something similar I used a bridge rectifier, a resistor, and an opto-coupler.
  • Beau SchwabeBeau Schwabe Posts: 6,569
    edited 2011-11-15 06:21
    jdolecki,

    "Spend the money and get a engineered device..." - I agree with you 100%, but an interesting dichotomy.... If an engineer designs a device that is a valid solution to a problem, at what point does it become engineered? time? credentials? both? ... I'm just curious
  • jdoleckijdolecki Posts: 726
    edited 2011-11-15 10:35
    Beau

    Valid Point.

    Is Xanatos a Engineer? Or should I say a Professional Engineer?

    Is this thing for his home or were he works?

    Has it been tested, documented and retested? Does it have a UL certification, EU certification or certification for installation in explosive enviroments?

    Im sure theare a million ways to solve this problem. But what are the risk. a few dollars to throw something together or a couple hundres to purchase something already designed for what he want to do.

    What are the results of failure in this "Explovise Gas enverioment" He blows up his homemade widget or a factory with people inside.

    Are Parallex products rated for explosive enviroments, because someone Is going to ask that I bet?

    Today Lawyers can twist and turn anything into somebody else fault.
  • LeonLeon Posts: 7,620
    edited 2011-11-15 10:53
    "Intrinsically safe" is the term for equipment designed for use in explosive atmospheres. It's a very specialised area.
  • mindrobotsmindrobots Posts: 6,506
    edited 2011-11-15 10:54
    Savings from a "prototype device" - hundreds of $$'s
    Savings from a non-certified engineering design - thousands of $$
    Cost of an explosion - Priceless
  • frank freedmanfrank freedman Posts: 1,983
    edited 2011-11-15 16:54
    Two issues with pedward's idea:

    1. You won't get any inductive coupling by wrapping one wire around another. Any alternating curren in the AC wire will produce an alternating magnetic flux circling the wire. The sense wire has to be a right angles to the magnetic flux to couple to it inductively, not parallel, as it would be if wrapped around the AC line. The correct way to do this is to wrap the sense wire around a magnetic core or toroid, around which, or through which, the AC line also runs.

    2. Even if you get an inductive coupling, it will be sensitive to the current in the AC line, not to the voltage present. IOW, if the switch is on, but there's no load, you won't get a reading.

    -Phil

    My oops on 1, perhaps false assumption of complete ckt to cause detectable current flow in the second. Get out the cat o' nine tails, left hand rule or 2x lashes if I guessed the wrong hand here!

    Frank
  • xanatosxanatos Posts: 1,120
    edited 2011-11-15 19:23
    Thanks for all the ideas, advice and speculation on my wisdom or lack thereof... Trust me that I know what I'm doing. Pay no attention to the large mushroom cloud rising over New England. :-)

    The issue, just to clarify, isn't that I will be putting a sensor of my own or anyone else's design in the explosive environment, hence my need to sense the switch via the voltage coming off of it when it is closed... In a different environment at a distance. That environment is where my control box is, and it is a nice, normal atmosphere.

    For the immediate function I am simply using the wire coming from the switch to drive a relay, which switches an input on my stamp between 5v and ground. Something analogous to pushing a marble with a bulldozer, but it got the project out the door 100% and on time.

    Since it's a prototype/live version, the next dozen or so will not be using a relay, but a nice optoisolator as I would have used here, if I had had them in the evening before the delivery date when the client asked for the change.

    I also like the 2N3904 sensor circuit... That's the kind of quick & dirty little thing I would have gone with (capacitively coupled) had I had it at noon yesterday! I'm adding it to my "stuff to try" book.

    So thanks again everybody,

    Dave
Sign In or Register to comment.