Go to Post Kudos to you IFI, for your continued support of FIRST and its stated ideals - Racer26 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 13-02-2010, 23:13
daltore's Avatar
daltore daltore is offline
Electronics/programming/design
AKA: Aaron Osmer
FRC #3529 (ausTIN CANs)
Team Role: Mentor
 
Join Date: Dec 2007
Rookie Year: 2007
Location: San Antonio, TX
Posts: 272
daltore has a spectacular aura aboutdaltore has a spectacular aura aboutdaltore has a spectacular aura about
Send a message via AIM to daltore Send a message via MSN to daltore Send a message via Yahoo to daltore
Re: Toggle through button?

Okay, so the setup for LabView will be the same as in Java, you need to variables. In LabView, variables are just read/write calls to indicators and controls. Create two indicators or controls on the front panel (one boolean, one numeric). Then go to the block diagram, right-click, and go to the Structures pallet. There will be a gray box near the bottom that says "LOCAL". Click this and place it on the block diagram. It will have a question mark and a pin on the left. Click the question mark, and it will show a list of indicators and controls that currently exist in that VI. Select your boolean or numeric. To change the variable to read instead of write, right-click on the variable, and select "Change to Read". This will allow you to input and output data from the controls and indicators in your VI more than once.

However, since LabView is by nature a parallel language, we need a way of doing the increment and setting the last seen variable separately. To do this, you can use either a Flat Sequence Structure or a Stacked Sequence Structure (both in the structures pallet). A Flat Sequence structure looks like a film reel, and each frame is executed one after another, from left to right. To add a frame, right click on the right edge of the structure and select "Add Frame After". In the first frame, you need to have an AND operator (boolean pallet), a NOT operator on the lastSeen variable to negate its value (also boolean pallet), a Quotient and Remainder VI (numeric pallet, I think), and a case statement. The Quotient and Remainder VI works just like the "%" modulus symbol in the Java example, you plug in "number + 1" into X and "3" into Y, and the remainder appears on the top right corner (R, for "remainder). Wire that to your "number" variable.

In the next frame, you need to set "lastSeen" (or whatever you called your boolean variable) to the joystick button value.

That should be it, let me know if you want me to explain anything further.
  #2   Spotlight this post!  
Unread 14-02-2010, 00:35
exprg:melonhead's Avatar
exprg:melonhead exprg:melonhead is offline
The Teamless/ Travelling Mentor
AKA: Justin Sticht
FRC #3278 (Qwerty)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2004
Location: Fargo, ND
Posts: 34
exprg:melonhead has a spectacular aura aboutexprg:melonhead has a spectacular aura aboutexprg:melonhead has a spectacular aura about
Re: Toggle through button?

http://frcmastery.com/try-me/state-machines/
this may actually be able to explain it better than any of us can. this is the clean way of doing that
  #3   Spotlight this post!  
Unread 14-02-2010, 00:52
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
Re: Toggle through button?

Quote:
Originally Posted by daltore View Post
In LabView, variables are just read/write calls to indicators and controls...
You could just use a Shift Register or Feedback Node, that seems like the simplest thing to do. Add a feedback node, set the input (bottom terminal) to what you want it to start as, then when you set it set the right terminal and that data will be available to the left terminal when you next run the loop.
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
  #4   Spotlight this post!  
Unread 14-02-2010, 01:10
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,521
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: Toggle through button?

Yep. In labview, a true/false structure that increments or decrements the number, along with an in-range check to keep it within the numbers you want and a feedback node to return the last value. The only hitch is that you will need to code a trigger-style VI that latches until it sees the button released so it won't count up if it loops several times during a single button press.
Closed Thread


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
Labview toggle switch GunfighterJ NI LabVIEW 8 13-02-2011 18:03
can you use a single button as a toggle? woogit General Forum 1 15-02-2008 14:21
toggle switch Windward Programming 31 27-01-2006 22:38
Code: Toggle on Tap Dave Scheck Programming 0 11-02-2005 18:07
Toggle? f22flyboy Programming 5 03-11-2002 08:03


All times are GMT -5. The time now is 02:01.

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