View Single Post
  #1   Spotlight this post!  
Unread 05-02-2010, 09:26
Ziaholic's Avatar
Ziaholic Ziaholic is offline
Elec/SW Mentor
AKA: Marc
FRC #1164 (Project NEO)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2002
Location: Las Cruces, NM
Posts: 194
Ziaholic is a jewel in the roughZiaholic is a jewel in the roughZiaholic is a jewel in the roughZiaholic is a jewel in the rough
Joystick Button One-Shot (a.k.a. Rising Edge) Detection

I've used this picture a couple times in recent days ... used to help provide advice on joystick buttons and throttle.

Now the shoe is on the other foot and I'd like to ask for some advice.

I wasn't the SW mentor last year, but I seem to remember a VI/block that let you detect the rising edge of a joystick button. I can't seem to find it in this year's LabView installation.

In the linked picture, buttons 3,4, & 5 are used to determine the next state of the Drive state-machine. The image shows some code from the Normal Drive state. When 3 or 4 or 5 is pressed, I set some variables and the next time through the loop, the state will change to the next state. After the maneuver is complete, the state goes back to Normal.

Problem is, if the driver leaves their finger on the button, then it will only stay in the normal state for one cycle, then immediately transition into the maneuver again, over and over and over. I'd rather require the operator to press the button again.

My current band-aid solution is to use a timer (not shown) where I grab the current time when the button is pressed, add a one-second offset, and store it in the Drive shift register. While the current time is less than the offset time, I disable the buttons by AND-ing them with a FALSE. When the current time is greater than the offset time, I re-enable the buttons by AND-ing them with a TRUE.

It'd be a lot cleaner if I could simply drop a box in there that would detect the rising edge.

Any tips/tricks/advice would be greatly appreciated.

Thanks.
__________________
----
There are 10 types of people. Those who understand binary, and those that do not.
Team #1164 - Project NEO Robotics
Reply With Quote