NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » reed switch/interrupts
August 06, 2010 by esoderberg |
I'm trying to use a reed switch and some mags to give a tach/speed reading.
Looping in Main:
|
---|---|
August 07, 2010 by Rick_S |
You may be seeing an effect called switch bounce. What happens is in the fraction of a second before the switch changes state from fully open to fully closed then back to open again, there is a 'gray' are where it briefly bounces between open & closed. This gives a device, like a microcontroller that senses a switch quickly, multiple triggers where you would expect one. Adding debounce to your program could help. A better alternative would be to change the input device from a switch to a hall effect sensor or other non-mechacnial device. I don't know what RPM the Wheel you are speaking of is expected to spin at but a switch will limit your ability as the mechanical action will eat up a bit of the time and if the magnetic field passes your reed too quickly it may not actuate at all. The solid state devices whether magnetic or light based have less issues like that. Hope I gave you some food for thought, Rick |
August 07, 2010 by esoderberg |
Rick, I think your supposition was correct. I put a filter on the counter to discount below a certain threshold and I now see the counter climb by ones for each mag pass. However, I'm going to also take your suggestion to use a hall switch because I don't think the reed switch will support a high enough frequency. Thanks for the feedback. Eric |
August 07, 2010 by mongo |
Something that you might want to keep in mind... Most Hall Effect sensors only sense one pole of a magnet so make sure you have the right end facing it as it passes. |
Please log in to post a reply.
Did you know that a thermometer can be made "faster" by using a bit of math? Learn more...
|