Go to Post Smaller FRC bots...... This is what the Mayans were referring to.... My world is ending.... - CrazyHorse [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #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
  #2   Spotlight this post!  
Unread 05-02-2010, 09:35
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,579
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection

Here's what we did. http://forums.usfirst.org/showthread.php?t=10544
Reply With Quote
  #3   Spotlight this post!  
Unread 05-02-2010, 09:39
Doug Norman's Avatar
Doug Norman Doug Norman is offline
Registered User
no team (National Instruments)
Team Role: Engineer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Austin, TX
Posts: 137
Doug Norman will become famous soon enoughDoug Norman will become famous soon enough
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.
Reply With Quote
  #4   Spotlight this post!  
Unread 05-02-2010, 10:05
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection

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.
Attached Thumbnails
Click image for larger version

Name:	one-shot.jpg
Views:	221
Size:	2.6 KB
ID:	8523  
Reply With Quote
  #5   Spotlight this post!  
Unread 05-02-2010, 10:07
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
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.
__________________
----
There are 10 types of people. Those who understand binary, and those that do not.
Team #1164 - Project NEO Robotics

Last edited by Ziaholic : 05-02-2010 at 10:08. Reason: ... great minds think alike!
Reply With Quote
  #6   Spotlight this post!  
Unread 05-02-2010, 10:37
Doug Norman's Avatar
Doug Norman Doug Norman is offline
Registered User
no team (National Instruments)
Team Role: Engineer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Austin, TX
Posts: 137
Doug Norman will become famous soon enoughDoug Norman will become famous soon enough
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.
Attached Thumbnails
Click image for larger version

Name:	joystick once true.jpg
Views:	273
Size:	19.7 KB
ID:	8524  
Reply With Quote
  #7   Spotlight this post!  
Unread 05-02-2010, 11:09
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
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?
__________________
----
There are 10 types of people. Those who understand binary, and those that do not.
Team #1164 - Project NEO Robotics
Reply With Quote
  #8   Spotlight this post!  
Unread 05-02-2010, 11:16
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection

Quote:
Originally Posted by Ziaholic View Post
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.
Reply With Quote
  #9   Spotlight this post!  
Unread 05-02-2010, 11:33
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
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.
__________________
----
There are 10 types of people. Those who understand binary, and those that do not.
Team #1164 - Project NEO Robotics
Reply With Quote
  #10   Spotlight this post!  
Unread 10-02-2010, 11:33
Omar's Avatar
Omar Omar is offline
Registered User
no team
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Huntsville, AL
Posts: 122
Omar is a glorious beacon of lightOmar is a glorious beacon of lightOmar is a glorious beacon of lightOmar is a glorious beacon of lightOmar is a glorious beacon of light
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
Attached Thumbnails
Click image for larger version

Name:	Edge Detect.png
Views:	244
Size:	4.5 KB
ID:	8604  
__________________
Omar
Reply With Quote
  #11   Spotlight this post!  
Unread 10-02-2010, 11:41
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection

Quote:
Originally Posted by Omar View Post
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.
Reply With Quote
  #12   Spotlight this post!  
Unread 10-02-2010, 13:49
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection

Quote:
Originally Posted by Omar View Post
I like to use the the greater than/less than on booleans for edge detect
That's beautiful.
Reply With Quote
  #13   Spotlight this post!  
Unread 10-02-2010, 13:55
D Peterschick D Peterschick is offline
Aggies Robot Team Coach
FRC #2923 (Aggies)
Team Role: Teacher
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Rosalia, Washington
Posts: 2
D Peterschick is an unknown quantity at this point
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?
Reply With Quote
  #14   Spotlight this post!  
Unread 10-02-2010, 14:13
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection

Quote:
Originally Posted by D Peterschick View Post
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)
Reply With Quote
  #15   Spotlight this post!  
Unread 10-02-2010, 15:25
Omar's Avatar
Omar Omar is offline
Registered User
no team
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Huntsville, AL
Posts: 122
Omar is a glorious beacon of lightOmar is a glorious beacon of lightOmar is a glorious beacon of lightOmar is a glorious beacon of lightOmar is a glorious beacon of light
Re: Joystick Button One-Shot (a.k.a. Rising Edge) Detection

Quote:
Originally Posted by 1075guy View Post
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
Attached Thumbnails
Click image for larger version

Name:	ShiftReg Edge detect.png
Views:	181
Size:	9.0 KB
ID:	8607  
__________________
Omar
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


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

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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