Reading output of a float switch with PIC - Page 1
Forum section: electronics / general

author: victorgozman
author_rank: Newbie
timestamp: April 11, 2016, 06:42:03 pm
content: please, I need help on how to read output from a float switch with PIC microcontroller. Image of the float switch is attached below. Thank you

author: rstofer
author_rank: Super Contributor
timestamp: April 12, 2016, 02:48:09 pm
content: I starter to reply to this thread yesterday but I thought I may go way off course.I don't know anything about that switch, is it a mechanical switch, an electronic switch (maybe open collector transistor output), etc. It matters and, lacking a datasheet, I didn't want to get too wrapped up in the problem.If the device is truly a mechanical switch, all you need to do is connect one side of the switch to a pin and the other side to ground. Any internal pull-up on the pin will probably not be sufficient so I would use a 470 ohm resistor between the pin and Vcc. Hopefully, that would cause enough current to flow to prevent erratic operation. But no guarantees! It's voltage that breaks through the oxidation on mechanical contacts. If the operation is erratic, I would use an opto isolator and use 12VDC or 24VDC through the switch and LED.If it is not actually a mechanical switch, there's not much to say without access to a datasheet. Many sensors have some kind of electronics with, usually, an open collector transistor at the output. These devices take Vcc, Gnd and provide that open collector output. OTOH, there are sensors that provide a voltage output derived from Vcc. Not knowing anything about the switch, it's difficult to say much about it.Can you post a link to more information?

author: Seekonk
author_rank: Super Contributor
timestamp: April 12, 2016, 02:58:30 pm
content: Every machanical switch has an upper and lower current rating. The lower current is what is required to break down the oxidation layer. A friend has float switches on his system and he has to replace them every couple years when they stop working. A good size capacitor across the contacts may supply enough cleaning current.

author: rstofer
author_rank: Super Contributor
timestamp: April 12, 2016, 03:55:29 pm
content: Quote from: Seekonk on April 12, 2016, 02:58:30 pmAnd the specifications for the current ratings are unlikely to be available, particularly the lower end. Maybe if you buy some mil-std device but the average float switch at Home Depot isn't going to have much of anything except the maximum.I might even have the float switch activate a relay with low current contacts. This way I could get the voltage through the float switch up to, perhaps, 120VAC. The relay could have very nice low current contacts. Maybe even gold plated, bifurcated, contacts.http://www.omron-ap.com/selection_guide/relay/main.aspCheck out the bifurcated models and their minimum current specs.Connected garden variety high current switches to microcontrollers is seldom satisfactory. It works for awhile but, sooner or later, the contacts oxidize and the switch looks like an open circuit to the micro.

author: dannyf
author_rank: Super Contributor
timestamp: April 12, 2016, 10:37:53 pm
content: Tough to read anything that's floating in the air.

author: ade
author_rank: Unknown
timestamp: April 12, 2016, 11:03:32 pm
content: I believe those tend to have simple mechanical switches:http://vlink-technik.com/handler/download.ashx?url=/UpLoadImage/201310/2013102314151614020.pdfOr Google for JK-M15-2.

author: tautech
author_rank: Super Contributor
timestamp: April 12, 2016, 11:18:47 pm
content: Nice imageade.Confirms my suspicions that they do indeed contain a simple micro switch.So for PIC the OP would be wise to add some de-bouncing circuitry to the PIC input.