Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Joystick Button One-Shot (a.k.a. Rising Edge) Detection (http://www.chiefdelphi.com/forums/showthread.php?t=81938)

Ziaholic 05-02-2010 09:26

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.

Joe Ross 05-02-2010 09:35

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
Here's what we did. http://forums.usfirst.org/showthread.php?t=10544

Doug Norman 05-02-2010 09:39

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.

Alan Anderson 05-02-2010 10:05

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
1 Attachment(s)
I use a feedback node and a tiny bit of logic to get a single "true" pulse output when the input changes from false to true. It's so simple that I don't feel a need to encapsulate it as a vi.

Ziaholic 05-02-2010 10:07

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
All very good advice. Thanks.

The Labview example is good ... but it's a latching toggle ... and I'm in the market for a one-shot. I could use that structure to create a one-shot, but I'd prefer a more elegant solution.

I've never used one before, but wouldn't a simple feedback node be able to help me. That is, I'd only enter into the new state case if the button is TRUE now, and was FALSE the last time thru.

I'll play with it at this afternoon's session and report back later.

Thanks again.


[edit] ... Nice one Alan! That's exactly what I was picturing in my head.

Doug Norman 05-02-2010 10:37

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
1 Attachment(s)
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.

Ziaholic 05-02-2010 11:09

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?

Alan Anderson 05-02-2010 11:16

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
Quote:

Originally Posted by Ziaholic (Post 913912)
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?

It's an "implies" gate. The output is FALSE only when the first input is TRUE and the second input is FALSE.

Ziaholic 05-02-2010 11:33

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.

Omar 10-02-2010 11:33

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
1 Attachment(s)
I like to use the the greater than/less than on booleans for edge detect

Racer26 10-02-2010 11:41

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
Quote:

Originally Posted by Omar (Post 917107)
I like to use the the greater than/less than on booleans for edge detect

That certainly is elegant.

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.

Alan Anderson 10-02-2010 13:49

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
Quote:

Originally Posted by Omar (Post 917107)
I like to use the the greater than/less than on booleans for edge detect

That's beautiful.

D Peterschick 10-02-2010 13:55

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?

Alan Anderson 10-02-2010 14:13

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
Quote:

Originally Posted by D Peterschick (Post 917189)
Is there anyway to use a limit switch to stop a motor and then be able to restart with Joystick?

Do you mean to use the joystick to move the motor in the opposite direction, away from the limit? That's easy. Just have the limit switch keep the motor control value from going less* than zero.

Or do you mean to use the joystick to cause the motor to ignore the limit and go past it? You can do it, but it goes against the usual purpose of a limit switch, and I'd have to know more about the system before giving any advice.

(* or greater, depending on wiring)

Omar 10-02-2010 15:25

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
1 Attachment(s)
Quote:

Originally Posted by 1075guy (Post 917113)
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.

I agree, I use Shift Registers far more often than I use Feedback nodes because I too find the feedback node harder to comprehend.

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

Omar 10-02-2010 15:41

Re: Joystick Button Flip Flop
 
1 Attachment(s)
Just in case someone needs a Flip-Flop latch for a boolean.

D Peterschick 10-02-2010 17:01

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!

Alan Anderson 10-02-2010 20:19

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
1 Attachment(s)
Quote:

Originally Posted by D Peterschick (Post 917323)
On the response to keep the limit switch with the motor going value from going less than zero? How do we do that?

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.

grosh 13-02-2010 15:02

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
Really frustrated!!! We are close to throwing in the towel. Alan you keep saying this is easy, but we have spent countless hours over the past two years trying to get a switch to stop a motor without any success...it may be easy for all of you in this forum but I guarantee that we are not the only ones having this issue. We have been relying on the graciousness of Chief Delphi and LVMastery to get our robot programmed.

Can anyone write and attach a sample program with ALL of the elements included.

Here is what we need:
If button 1 is pressed a motor will spin until the limit switch is closed... AND it will not keep spinning even if the button 1 is pressed...AND it will spin in the opposite direction when button 2 is pressed even if the limit switch is closed.

We're not trying to cop-out we just need to see and example to understand the thinking behind what we are trying to do.

Mark McLeod 13-02-2010 15:12

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
Using a speed controller or a Spike?
Is the motor driven full speed in forward and reverse, e.g., on a Spike?

Does button 2 interrupt what button 1 started, or is the button 1 action stopped solely by the limit switch?

How do you want to stop after button 2 is pressed? Is there a limit switch at the other end too?

grosh 13-02-2010 20:08

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
Quote:

Originally Posted by Mark McLeod (Post 919391)
Using a speed controller or a Spike?
Is the motor driven full speed in forward and reverse, e.g., on a Spike?

Does button 2 interrupt what button 1 started, or is the button 1 action stopped solely by the limit switch?

How do you want to stop after button 2 is pressed? Is there a limit switch at the other end too?

We are using a speed controller to power a Denso window motor BUT we could use a Spike if it would be easier.

Just to clarify-
We want a ramp to move UP when button 1 is pressed AND only when button 1is pressed. We want the ramp to go DOWN when button 2 is pressed AND only when button two is pressed.

Our issue is we need the ramp to stop when the ramp is all the way down, hence the need for a switch. We don't want to rely on the driver seeing that the ramp is down and letting go of the button in time. The plastic hex output shaft on the Denso window motor is awfully susceptible to shear.

Thanks for the help.

Alan Anderson 14-02-2010 12:00

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
Quote:

Originally Posted by grosh (Post 919578)
We want a ramp to move UP when button 1 is pressed AND only when button 1is pressed. We want the ramp to go DOWN when button 2 is pressed AND only when button two is pressed.

Our issue is we need the ramp to stop when the ramp is all the way down, hence the need for a switch.

Controlling a motor with a pair of buttons is not difficult. Use the state of the first button to select between the True and False of a case block, wiring a constant zero out of the False case and wiring the desired "UP" motor speed out of the True case. Run that output through another case block controlled by the second button, wiring the value straight through without modification in the False case and wiring the desired "DOWN" motor speed out of the True case. Run that output through the In Range and Coerce select block controlled by the limit switch; I showed an example of that a few posts ago.

grosh 14-02-2010 16:55

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
1 Attachment(s)
Quote:

Originally Posted by Alan Anderson (Post 919881)
Run that output through another case block controlled by the second button, wiring the value straight through without modification in the False case and wiring the desired "DOWN" motor speed out of the True case. Run that output through the In Range and Coerce select block controlled by the limit switch; I showed an example of that a few posts ago.

Alan- Is this what you are describing?

Alan Anderson 14-02-2010 18:28

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
1 Attachment(s)
Quote:

Originally Posted by grosh (Post 919977)
Alan- Is this what you are describing?

Not quite. I suggest that the motor should be set only once at the end of the process, with just the numeric values that will be set going through the case blocks.

It looks like your ramp runs upward with -1 and downward with +1, so the "down" limit should prevent the value from going positive. Using -1 and 0 as the range limits will let it run upward but not downward when the limit input is active.

(The three "False" cases at the top are just there to show what's going on in the bottom case blocks.)

grosh 14-02-2010 20:50

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
Thanks for the life-ring. I think I understand how this works now.

Can I ask one more question? Can you explain the logic of the In Range and Coerce for this instance. I have read the context help but don't understand how it works in this instance.

Thanks again!

Alan Anderson 14-02-2010 22:26

Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection
 
Quote:

Originally Posted by grosh (Post 920149)
Can I ask one more question? Can you explain the logic of the In Range and Coerce for this instance. I have read the context help but don't understand how it works in this instance.

In Range and Coerce takes a lower limit, an upper limit, and an input value. It then does two things.

1: It provides an "In Range" boolean output that is True when the value is between the limits, and False when the value is outside the limits. This feature is not used in the code I showed.

2: It provides a "Coerce"d output value that matches the input value when it is inside the limits, but does not exceed the limits in either direction when the input is outside the range. This is how the motor is kept from driving in a particular direction, by making sure the value never goes above 0.


All times are GMT -5. The time now is 22:35.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi