View Single Post
  #1   Spotlight this post!  
Unread 22-12-2013, 21:26
garyk garyk is offline
Programming Mentor: 668, 972, 2643
FRC #0668 (Apes of Wrath)
Team Role: Mentor
 
Join Date: Dec 2006
Rookie Year: 2005
Location: Santa Clara (Silicon Valley) Calif.
Posts: 93
garyk is a jewel in the roughgaryk is a jewel in the roughgaryk is a jewel in the roughgaryk is a jewel in the rough
Re: C++ Toggle Button

Quote:
Originally Posted by thelegend View Post
I am trying to make a toggle for switching between Arcade Drive and Tank drive. I wrote and tested this code but the only result I get is a switch between Tank to Arcade, not the other way back. I have such a complicated system because I believe that if I simply set a variable to be True or False, it won't compensate for if the driver holds on to the button. That's why I have a clause in there that checks if the button has been released.

If you find any issues, please reply!

<< code deleted >>
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.
__________________

Silicon Valley Regional 2005, 2006 972
Silicon Valley Regional 2007 668 Xerox Creativity Award
Championship Event 2007 668
Portland Regional 2008 668
Silicon Valley Regional 2008 668, 972
Beta Test Team 2008 668 (with 100 & 254)
Silicon Valley Regional 2009 668 Regional Chairman's Award; 2643
Sacramento Regional 2009 668 Winning Alliance (thanks, 1717 & 2473!), 2010 Winning Alliance 3256
CalGames 2006, 2007, 2008, 2009, 2010, 2011 Field Tech
NorCal FTC Regional 2008, 2009 Inspector
Championship Event 2009
San Diego, Silicon Valley Regionals; Champ. Event 2010 668, 2643, 3256
Silicon Valley, Madera Regional 2012 2643
WRRF Programming Instructor 2006-2016
Regional Woodie Flowers Award 2014 2643 Utah Regional

Reply With Quote