Efficient switch polling

Status
Not open for further replies.

qtommer

Member
I am polling 3 TACT switches in a continuous loop using a MCU. Should a switch be asserted, the worst case delay that the switch has to wait for the program to poll it again is 14us. Is there any sort of RC arrangement I can apply to the switch to hold the value (once asserted) for at least 14us so that the MCU can receive it without any possibility of 'missing' the switch input.

I know 14us is very short, but I want the reading of the switches to be as smooth and efficient as possible.

Thanks
 
To avoid noise and switch bounce, 14 µs is too short.

I would count at least 100 times that, and probably 1000 times, so 14 ms or more, before I registered the switch as being pressed. I would also apply the same on release.

It will still seem instant to the user.
 
There was flickering of the output (on an LED) when it was too short. The contact of the button when pressed was way longer than the program execution. I added a delay in between and everything's sweet now. Thanks!
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…