|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
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. |
|
#2
|
||||||
|
||||||
|
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
Here's what we did. http://forums.usfirst.org/showthread.php?t=10544
|
|
#3
|
||||
|
||||
|
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
Take a look at the Joystick Button Latching example we added this year. It will show you how to do it. Once you understand it, you may want to create a simple subVI that can be put in a loop to do the same thing.
|
|
#4
|
||||
|
||||
|
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
Here's a code snippet (picture) that does what you want. You could put this in your loop, or you could make it a subVI. If you make it a subVI to be used in multiple places, be sure to make it a reentrant subVI. That way it will allocate separate memory for each call. To make a subVI reentrant go to File>>VI Properties>>Execution and choose Reentrant execution.
|
|
#5
|
||||
|
||||
|
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
I'm not familiar with that double-lined-arrow icon in Doug's pic ...
I don't have access to Labview at the moment ... what's it called? |
|
#6
|
|||||
|
|||||
|
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
It's an "implies" gate. The output is FALSE only when the first input is TRUE and the second input is FALSE.
|
|
#7
|
||||
|
||||
|
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
[shrugs] It might do the same thing, with the same number of gates, but it's easier for me to read the simple "AND" with the previous inverted value.
Ta-MAY-toe, Ta-MAH-toe ... Thanks again. |
|
#8
|
||||
|
||||
|
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
I like to use the the greater than/less than on booleans for edge detect
|
|
#9
|
|||
|
|||
|
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
Quote:
Theres also a VI in the OpenG toolkit, (can be acquired through the VI Package Manager) which is called "Boolean Trigger" it takes a boolean in, and has a rising edge and falling edge output. I never much liked Feedback nodes... They make it difficult to comprehend whats going on. To me a shift register makes more visual sense, despite being functionally the same. |
|
#10
|
||||
|
||||
|
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
Quote:
But in this simple application I like the less real estate that the feedback node uses Posted is another way to implement a Boolean Edge detect that 1075guy speaks of. Omar |
|
#11
|
||||
|
||||
|
Re: Joystick Button Flip Flop
Just in case someone needs a Flip-Flop latch for a boolean.
|
|
#12
|
|||
|
|||
|
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
On the response to keep the limit switch with the motor going value from going less than zero? How do we do that?
Software kids are stumped! |
|
#13
|
|||||
|
|||||
|
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
Using the "In Range and Coerce" function makes it easy. The attached image shows the True case, where the value is to be limited. The False case simply wires the value straight through without modification.
|
|
#14
|
|||||
|
|||||
|
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
That's beautiful.
|
|
#15
|
|||
|
|||
|
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
Is there anyway to use a limit switch to stop a motor and then be able to restart with Joystick?
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ellipse Finding/Edge Detection Example Code? | brianc217 | NI LabVIEW | 3 | 20-01-2010 08:57 |
| Full solenoid controll off of one joystick button? | m3rc1l3ss | NI LabVIEW | 2 | 11-02-2009 02:06 |
| joystick button | furiousgeorge | Programming | 5 | 07-02-2009 15:57 |
| Ganged Interrupt Edge Detection | cprogrammer | Programming | 8 | 01-02-2008 10:52 |
| More than one joystick from one port | Jmoo | Programming | 3 | 26-06-2003 18:01 |