Shop OBEX P1 Docs P2 Docs Learn Events
Connecting a float switch — Parallax Forums

Connecting a float switch

Greg LaPollaGreg LaPolla Posts: 323
edited 2009-09-07 01:15 in Propeller 1
I am looking to use a float switch like the the one in the attachment.

Would it work if connected as follows:

One wiire to GND, one wire to the prop, 10K pull up to VDD on the wire to the prop.
set prop pin to input and check ina[noparse][[/noparse]PIN] for 0 or 1 to determine if the switch is open or closed?

Also should I use a 1k resister inline to protect the prop pin ?


Thanks


Greg

Comments

  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-09-06 01:13
    I'm no expert but your idea sounds okay to me so long as you are measuring fluid levels that are varying smoothly (and not sloshing around, changing rapidly). And a 1k resistor sounds good, too. You might want to write something in your software to debounce the switch in the event the fluid level hovers around some critical point.

    That's my newbie 2 cents worth. Hope it helps.

    Mark
  • Mike GreenMike Green Posts: 23,101
    edited 2009-09-06 01:15
    1) Yes, your scheme would work for any switch including the float switch ... one wire to ground, the other wire to the Prop pin with a 10K pull up to Vdd.

    2) Yes, a 1K inline resistor would be a good idea.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-09-06 01:31
    Put the series resistor between the prop and the pullup which is connected to the switch. The pullup needs to be at least 1K or less as float switches normally need a little "wetting" current to keep the contacts clean. The series resistor could be a much larger value though as we are dealing with slow inputs so even 100K would not be unreasonable and great protection against any nasties.

    As for debouncing it probably isn't necessary as you are not counting or anything but your program obviously would have to have some sort of hysteresis that prevents the system from chattering (float high, start the pump, float low, no no no .... stop the pump, float high....get the picture).

    *Peter*
  • kwinnkwinn Posts: 8,697
    edited 2009-09-06 18:10
    Peter has a good point regarding chattering of the system. Turning a motor on and off continuously is a good way to burn it out. In most cases this is not a problem since a reed switch actuated by a magnet has some built in hysteresis, but it pays to make sure this is adequate for your application.

    There are also float switches available that have 2 separate reed switches, where one is used to start and the other to stop a system.
  • Greg LaPollaGreg LaPolla Posts: 323
    edited 2009-09-07 01:15
    Thanks for the info. I think I will write the code to check the float switch every 15 seconds. It is a very slow flow from the pump, approx 1 gallon every 10-15 minutes. That should eliminate any chattering, although I highly doubt there would be any.


    Greg
Sign In or Register to comment.