![]() |
Re: Toggle switches to Analog board?
Switch bounce would affect switches connected to a digital input at least as much as it would analog inputs. Most of the time, the programming is going to be such that it simply doesn't care whether the switch gets detected several times in quick succession.
For reading a switch on an analog input, the WPILib "analog trigger" function is what you want. That rejects glitch-type noise as part of its implementation. |
Re: Toggle switches to Analog board?
Edit: Looks like I need to type faster if I am going to post in the same threads as Al and Alan. But what I posted may still be usefull so I will leave it up.
Quote:
Psuedo Code Create Counter- Initialize to Zero Assuming Switch sampling occusr every ~1ms If (Software_representation of switch = not-pressed) If switch is not pressed Reset Counter Set Software representation of switch to not-pressed else (switch is pressed) increment counter end if if counter > 10 Set software representation of swtch to pressed end if Then you can reverse the switched/not-switched cases for then the butto is pressed if you need to detect the release as well. |
Re: Toggle switches to Analog board?
Cool discussion, I am happy I can use my SPST switches. I already had a bunch purchased and laying around. I also appreciate the pseudocode. Thanks again.
|
Re: Toggle switches to Analog board?
Darren,
Sorry I led you down the rosy path earlier. |
| All times are GMT -5. The time now is 07:07. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi