Button Debouncing Help/Clarification on Analog switch
ShawnKimble
Posts: 4
I have a retro analog switch that I'm using as a button. I'm currently getting what appears to be a lot of noise, resulting in false positives, but I'm not really experianced enough to confirm that it's the problem.
I have two questions:
Can someone more clearly explain the Delay/Rate variables of the Button function? As I understand it Delay/rate gives you three options:
While breadboarding I was able to get the circuit to work perfectly, but due to poor documentation and moving to circuiting, something has changed and I'm having trouble debugging what is going on.
Thanks!
I have two questions:
Can someone more clearly explain the Delay/Rate variables of the Button function? As I understand it Delay/rate gives you three options:
- 0 = no delay, rate variable ignored
- 1 to 254 * rate = ms delay
- 255 = 255 ms with no rate multiplyer
While breadboarding I was able to get the circuit to work perfectly, but due to poor documentation and moving to circuiting, something has changed and I'm having trouble debugging what is going on.
Thanks!
Comments
I have a tutorial on the inner workings of the button command here: http://www.emesystems.com/BS2fsm.htm#BUTTON
The command has both "downstate" and "targetstate" binary parameters, and those interact. That makes it hard to answer your question, "where/why you would use logic state 1 vs logic state 0 wiring configuration on a button?". You have to ask which is the pin state, 0 or 1 that corresponds to the pin being held down, and then you have to ask whether you want the target action to occur when you first press the button or when you release it.
There are other possibly better ways to debounce a button, or two or more buttons.
Debouncing a simple on/off switch is easier, you can add a small cap or modify your software to check its state multiple times.