On Tuesday 26 March 2019 13:38:32 Chris Albertson wrote: > 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? > We have a debounce module you can put in series with the swtches output. very handy where there is a fast base thread, but not so usefull with the much slower servo thread. It function is to block a switch status change until so many of the threads have passed. With a 1 millisecond servo thread, the switch has generally well settled, but in a 30 microsecnd base thread, it might take a noisy switch 3 or more thread cycles to have 3 alike.
> 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. > Chuckle, you need a slower scope. t=rc is generally greater than 10 nanosecs anyway. The t is self-explanatory, the r is the pullup, and the c is a combo of the cable capacitance and its propagation delay at its surge impedance. All of that is generally faster than LCNC anyway so its moot 99% of the time, delayed by one thread cycle the remaining 1% of the time. Might make .0003" diff to the machine at the speeds the machine can move in 1 millisecond. > 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. Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) Genes Web page <http://geneslinuxbox.net:6309/gene> _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users