Go to Post If the GDC made a game that consisted of driving in a straight line, it would probably be the hardest game in FRC history. - themccannman [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 15-02-2013, 14:32
ctccromer's Avatar
ctccromer ctccromer is offline
Animus
AKA: Tucker Campbell
FRC #3753 (Bulah Bots)
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Baton Rouge, Louisiana
Posts: 190
ctccromer is a name known to allctccromer is a name known to allctccromer is a name known to allctccromer is a name known to allctccromer is a name known to allctccromer is a name known to all
How to program a button this way?

Rather than program "do [this] when the button is pressed down, do [that] when it's not pressed down", I want to program "do [this] when it's pressed, then do [that] when the same button's pressed again" and alternate between them. It would be really easy in a text based language but I'm a LabVIEW noob and don't know how to do it :/

I'm working with pneumatics. Basically I just need to give one Vi a value of 0 and another Vi a value of 1 when a button is pressed, and leave it that way even when I let go of the button. Then, next time I press the button, switch the two values. Then next time, switch them back, etc.

Pneumatics start retracted. Push button x to push the pneumatic arms out. Push button x again to pull the pneumatic arms back in
__________________
Team 3753 BulahBots
Reply With Quote
  #2   Spotlight this post!  
Unread 15-02-2013, 14:44
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: How to program a button this way?

Do a search for "toggle" and you will find about a dozen ways to toggle between two states.

http://www.chiefdelphi.com/forums/sh...ghlight=toggle
__________________
Omar
Reply With Quote
  #3   Spotlight this post!  
Unread 15-02-2013, 15:10
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,100
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: How to program a button this way?

Quote:
Originally Posted by ctccromer View Post
...
When you encounter a problem like this in LabVIEW, and it seems like "Hmm. I can't be the first person to want to do this. I'm sure somebody has already figured this out"... then go to:

http://team358.org/files/programming...2009-/LabVIEW/

... and scroll down to "Common Robot Operations"


Reply With Quote
  #4   Spotlight this post!  
Unread 15-02-2013, 20:56
bvisness's Avatar
bvisness bvisness is offline
Programming Mentor, Former Driver
FRC #2175 (The Fighting Calculators)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Woodbury, MN
Posts: 181
bvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of light
Re: How to program a button this way?

Quote:
Originally Posted by Ether View Post
When you encounter a problem like this in LabVIEW, and it seems like "Hmm. I can't be the first person to want to do this. I'm sure somebody has already figured this out"... then go to:

http://team358.org/files/programming...2009-/LabVIEW/

... and scroll down to "Common Robot Operations"


358's solution works, but our team's method is a bit simpler.

EDIT: It's remarkably similar to the solution in the thread Omar posted above. Take your pick!

Last edited by bvisness : 15-02-2013 at 21:00.
Reply With Quote
  #5   Spotlight this post!  
Unread 16-02-2013, 00:47
josneville's Avatar
josneville josneville is offline
The Chosen One
FRC #0540 (Talon 540)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: GHS Talon 540 Team
Posts: 15
josneville is on a distinguished road
Talking Re: How to program a button this way?

Its called a feedback loop. It looks like this:
Attached Thumbnails
Click image for larger version

Name:	Feedback Loop.PNG
Views:	47
Size:	13.4 KB
ID:	14030  
__________________
-Success is the Key to Life. I have no life. Hmmm......
Reply With Quote
  #6   Spotlight this post!  
Unread 16-02-2013, 07:56
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: How to program a button this way?

Focussing on the original problem, I'm curious what solution you would have done in a text language? I ask this because this sort of thing comes up often as folks are just learning to program or are learning a new language, and I'm wanting to make sure that I understand the things that kept you from finding the solution.

Greg McKaskle
Reply With Quote
  #7   Spotlight this post!  
Unread 16-02-2013, 19:05
ctccromer's Avatar
ctccromer ctccromer is offline
Animus
AKA: Tucker Campbell
FRC #3753 (Bulah Bots)
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Baton Rouge, Louisiana
Posts: 190
ctccromer is a name known to allctccromer is a name known to allctccromer is a name known to allctccromer is a name known to allctccromer is a name known to allctccromer is a name known to all
Re: How to program a button this way?

Quote:
Originally Posted by Greg McKaskle View Post
Focussing on the original problem, I'm curious what solution you would have done in a text language? I ask this because this sort of thing comes up often as folks are just learning to program or are learning a new language, and I'm wanting to make sure that I understand the things that kept you from finding the solution.

Greg McKaskle
In a text language, I'd just make a boolean PneumaticsRetracted or something like that. Then when I press the right button, if the bool is true, do one thing, if it's false, do the other. And in both, change the bool's value to the opposite of course
__________________
Team 3753 BulahBots
Reply With Quote
  #8   Spotlight this post!  
Unread 17-02-2013, 07:50
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: How to program a button this way?

In the text language, the Boolean variable would need to be static or global in order to keep its value from call to call. That serves the same purpose as the feedback node. It remembers state data in a scope that is longer lived than the function call.

In a text language, the local variables, and in LV, the wires, have a short-lived scope that is cleared each time the function is called. They are temporaries.

FYI, you can actually make global variables in LV too, so if you don't get the hang of the feedback node, try with globals. But the feedback node or shift registers are a somewhat safer and more controlled language feature, like static local variables are in C, etc. So it is good to learn how to use them.

Greg McKaskle

Last edited by Greg McKaskle : 17-02-2013 at 07:51. Reason: commas
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


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

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