Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Switch Open/Closed Detetion with a differance

  • 05-05-2010 5:33pm
    #1
    Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭


    Does anyone know a robust, low current (<20uA or so) way of determining if a switch is open or closed, the difficult bit is that the switch/cable/connections may (or may not) be immersed in water.

    I've thought of a few ways to do this, but none of them are particularly neat. The problem is your trickling so little current around the switch.

    I can do it by pulling in a strong pull up resistor, for a few micro-seconds, then polling the input, but i don't want to have to do this. I've also played around with some current sources too, but nothing really robust yet.


Comments

  • Registered Users, Registered Users 2 Posts: 368 ✭✭backboiler


    Does anyone know a robust, low current (<20uA or so) way of determining if a switch is open or closed, the difficult bit is that the switch/cable/connections may (or may not) be immersed in water.

    I've thought of a few ways to do this, but none of them are particularly neat. The problem is your trickling so little current around the switch.

    I can do it by pulling in a strong pull up resistor, for a few micro-seconds, then polling the input, but i don't want to have to do this. I've also played around with some current sources too, but nothing really robust yet.

    A smallish capacitor (10 nF?) between Vcc and the switch, whose other terminal is to GND and watch for pulses at cap -ve terminal. Nearly zero quiescent current and shouldn't be too hard to set the threshold somewhere that will only trigger with sudden metal contact of switch but not on slower water contact. Doesn't help with steady state detection (is switch open or closed at a given point in time) but the pulse edge direction will show whether it's opening or closing.

    Main problem I'd see is that switch contacts will corrode with long-term water contact, reducing effectiveness.


  • Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭DublinDilbert


    backboiler wrote: »
    A smallish capacitor (10 nF?) between Vcc and the switch, whose other terminal is to GND and watch for pulses at cap -ve terminal. Nearly zero quiescent current and shouldn't be too hard to set the threshold somewhere that will only trigger with sudden metal contact of switch but not on slower water contact. Doesn't help with steady state detection (is switch open or closed at a given point in time) but the pulse edge direction will show whether it's opening or closing.

    Main problem I'd see is that switch contacts will corrode with long-term water contact, reducing effectiveness.

    Hi,

    Yep i did think about putting a cap in series with the switch all right. The input to the CPU is a schmitt trigger, so would probably be able to deal with this. I'll have to have a think about how to denounce the switch.

    Another issue might be the length of cable to the switch and its capacitance. We might end up with 2 capacitors in series when the switch contacts are open...


  • Registered Users, Registered Users 2 Posts: 1,134 ✭✭✭FarmerGreen


    Electrical noise could be a problem.
    Just one decent spike straight up the CPU and its a gonner.
    Normally you'd have an opto-isolator between the two.


  • Registered Users, Registered Users 2 Posts: 368 ✭✭backboiler


    With a Schmitt trigger a capacitor and resistor you can make a simple debounce circuit.

    For bonus points, you could craft the two passive components using suitably long wires.
    :p


  • Registered Users, Registered Users 2 Posts: 1,134 ✭✭✭FarmerGreen


    EMC test should be fun.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭DublinDilbert


    Normally you'd have an opto-isolator between the two.
    I've never used an opto for something like this. Normally with simple circuit design and a few components you can easily protect the CPU. Sure even if the opto saw an ESD spike it would be toast.
    EMC test should be fun.
    Exactly!!!

    The existing circuit works quite well (apart from the under water bit!), its a pull up to 5V, with a cap to ground. There's a diode in series with the switch input which only allows it to be pulled low (via the switch contacts).

    I was wondering if there was any clever way of doing it with a current source, but I can't see it.


  • Registered Users, Registered Users 2 Posts: 1,134 ✭✭✭FarmerGreen


    Damned if I know.
    Sheer cold fear concentrates the mind wonderfully.
    I'm sure you'll come up with something.


  • Registered Users, Registered Users 2 Posts: 108 ✭✭gotBass


    Just want to get clarification before I input:
    "the difficult bit is that the switch/cable/connections may (or may not) be immersed in water."

    Is it a straighforward mechanical switch?
    what is the purpose of the switch?
    Question is the switch sealed in an enclosure of some sort?
    Or is everything under water?









    Does anyone know a robust, low current (<20uA or so) way of determining if a switch is open or closed, the difficult bit is that the switch/cable/connections may (or may not) be immersed in water.

    I've thought of a few ways to do this, but none of them are particularly neat. The problem is your trickling so little current around the switch.

    I can do it by pulling in a strong pull up resistor, for a few micro-seconds, then polling the input, but i don't want to have to do this. I've also played around with some current sources too, but nothing really robust yet.


  • Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭DublinDilbert


    gotBass wrote: »
    Just want to get clarification before I input:
    "the difficult bit is that the switch/cable/connections may (or may not) be immersed in water."

    Is it a straighforward mechanical switch?
    what is the purpose of the switch?
    Question is the switch sealed in an enclosure of some sort?
    Or is everything under water?

    Sorry i should of made it clearer. The switch contacts will be sealed, like a reed switch. Just the 2 wires going to it may be in contact with water.


  • Registered Users, Registered Users 2 Posts: 108 ✭✭gotBass


    Sorry i should of made it clearer. The switch contacts will be sealed, like a reed switch. Just the 2 wires going to it may be in contact with water.


    apologies in advance if I go over ground you've already covered re circuit configurations.

    right so here's my first try, I'm assuming first off simplicity first.
    would this circuit suit your needs with the reedswitch in parallel to R2?
    http://www.linear.com/pc/productDetail.jsp?navId=H0,C1,C1154,C1004,C1013,P1593


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 5,401 ✭✭✭DublinDilbert


    gotBass wrote: »
    apologies in advance if I go over ground you've already covered re circuit configurations.

    right so here's my first try, I'm assuming first off simplicity first.
    would this circuit suit your needs with the reedswitch in parallel to R2?
    http://www.linear.com/pc/productDetail.jsp?navId=H0,C1,C1154,C1004,C1013,P1593

    Ummmmm that doesn't look bad. The circuit is currently something similar using the schmitt trigger interrupt input to the PIC. The main issue with it is that the hysteresis limits are fixed inside the PIC. With that IC i could alter the amount of hystersis applied, so it might work.

    I tried using the comparator module in the PIC, which worked fine, the only problem was that it greatly increased the sleep current of the device, from 7uA -> 80uA, just for one comparator. That IC only takes 0.3uA :)


Advertisement