A very basic question, unlike the hards ones being discussed here but,
important I think.

How are people handling switch debouncing on home and limit switches?

Always in the past, I have treated the microswitch is a SPST device that is
either open or closed.
The common terminal is pulled up to Vcc voltage and when the switch closes
it connects to ground.

But all my switches have three terminals.  I did some experiments using my
digital oscilloscope.   The normal
method causes a long series of "bounces" that continue for some number of
milliseconds the new method
makes a near-perfect single pulse square wave.  I see oscillation for only
about 10 nanoseconds when the switch
closes and no bounce at all when it opens.

Common terminal goes to the computer and uses a 10K pull-up.   NC terminal
goes to Vcc and NO to ground.  I place a 0.1 uF cap from common to ground.
   I notice the cap can "ring" and go below ground.   So I place a small
diode from common to the ground to protect the uP from negative volts.
  All the passive components are soldered directly to the switch terminals.

Yes, I know a switch can be de-bounced in software but this introduces
latency as the software has to keep checking the state of the switch.
 Reduced latency very much increases the accuracy of the microswitch.

If you have a digital scope you can try rig up some experiments.   Again
the only "trick" is to use all three terminals on the switch.

Yes, I foresaw all kinds of problems but as it turns out in practice I get
nanosecond level latencies.

Perhaps everyone already is doing this and I was the last to think of it.
The switch still actually bounce but in this case, bouncing does not cause
a change of state.
-- 

Chris Albertson
Redondo Beach, California

_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to