View Single Post
  #17   Spotlight this post!  
Unread 23-12-2013, 04:02
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: C++ Toggle Button

Quote:
Originally Posted by garyk View Post
Note to future EEs - and not pertaining to our FRC/FTC control systems - mechanical switches "bounce" when they close, there are multiple on/off events before the switch consistently stays closed. This may not matter if you're just turning something on, but it will confuse any "toggle" algorithms, registering multiple toggles. Mechanical switches have to be "debounced", which can be done with an r-s latch in hardware, or by designing in an time interval after the first make, in which other transitions are ignored. Our joystick buttons are debounced in this manner because they provide a clean off => on transition. I haven't tried it, but I think if one designed a toggle algorithm for, say, a microswitch (like we use for limit switches) connected to a digital input of the Digital Sidecar, one would see multiple toggles for one switch "make."

Apologies, I don't remember if there are contact bounces when a mechanical switch disconnects. When I can get to our control system I'll test this out and post an update.

Remember, again, we don't need to worry about this for our joystick buttons, they've been debounced for us.
Yes, debounce could be an issue if you are using a tight loop monitoring the switches. But I assume a reasonable robot loop will have a delay in it, typically between 20-100 msec. That is the time interval where you ignore all the bounces of the switches. Our team uses our own "Multi-tasking Robot" class instead of the SimpleRobot or the IterativeRobot templates that provides a very constant timed loop. This takes care of all the debounce issue automatically.
__________________
Reply With Quote