View Single Post
  #3   Spotlight this post!  
Unread 04-02-2011, 23:29
WizenedEE's Avatar
WizenedEE WizenedEE is offline
Registered User
AKA: Adam
FRC #3238 (Cyborg Ferrets)
Team Role: Leadership
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Anacortes, WA
Posts: 395
WizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to all
Re: turning a push button into a switch

I attached the code we made this year. To use it, just put it in a vi, connect up your momentary button and "switched" output, and then make a shift register and wire that up to the top. The shift register is outside the vi so we can use the same vi many times (if it were inside, the shift register would maintain its values from call to call, not just from loop to loop.)

The problem with your program is that if you press the button for more than 10 ms, it will change twice. My program waits until the button then gets unpressed before going back to the "ready to receive button" state.

I have no idea why your code would switch when you're not pressing the button if that's the actual way you coded it.

My vi works fine in teleop; there's a 20ms loop in teleop and your code has a 10ms loop; it's not a big difference. The 20ms actually helps debounce the switch for us.

NOTE: This code is untested in the real world - you might have to do something to debounce switches. I did test it in the vi with the front panel controls though.

EDIT: Added bundle/unbundle to code to have only one shift register.
Attached Files
File Type: vi Latch.vi (8.2 KB, 27 views)

Last edited by WizenedEE : 04-02-2011 at 23:34.
Reply With Quote