Go to Post Viva la geek! - Andy Baker [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-2013, 10:58
Anatole's Avatar
Anatole Anatole is offline
Registered User
FRC #4531 (STEMpunk 4531)
Team Role: Programmer
 
Join Date: Feb 2013
Rookie Year: 2013
Location: RobotLand
Posts: 7
Anatole is an unknown quantity at this point
Question Programmatically Toggling a Boolean Control

Hey,
I have a Boolean control set so that when a joystick button is pressed and released, it switches a case statement.
Since the joystick button is momentary I have it set up so:
True + False = True, then the next True+False sets it back to False. In essence, pressing & releasing the joystick button toggles the case structure.
Now, my question is, I have a sequence inside each case structure. I want to be able to toggle the case structure programmatically when the sequence is finished. (Basically, the program can run back and forth between true and false, but the user can hit the joystick button to manually override the back and forth.)
Any ideas on how I can do this?
Thanks!
Reply With Quote
  #2   Spotlight this post!  
Unread 05-02-2013, 13:48
stingray27's Avatar
stingray27 stingray27 is offline
Registered User
AKA: Michael Ray
FRC #0027 (Team RUSH)
Team Role: Alumni
 
Join Date: Mar 2011
Rookie Year: 2010
Location: Clarkston, MI
Posts: 209
stingray27 is a name known to allstingray27 is a name known to allstingray27 is a name known to allstingray27 is a name known to allstingray27 is a name known to allstingray27 is a name known to all
Re: Programmatically Toggling a Boolean Control

Quote:
Originally Posted by Anatole View Post
Hey,
I have a Boolean control set so that when a joystick button is pressed and released, it switches a case statement.
Since the joystick button is momentary I have it set up so:
True + False = True, then the next True+False sets it back to False. In essence, pressing & releasing the joystick button toggles the case structure.
Now, my question is, I have a sequence inside each case structure. I want to be able to toggle the case structure programmatically when the sequence is finished. (Basically, the program can run back and forth between true and false, but the user can hit the joystick button to manually override the back and forth.)
Any ideas on how I can do this?
Thanks!
We do not like to use sequence structures inside of our code because if a processing error occurs in the sequence it holds up the rest of the code. Therefore, we use a case machine to do all of our sequence processing (via feedback nodes or through globals. Feedback nodes wherever possible though). What happens is if a user control is pressed and the state of the case machine is in the default, or do nothing stage, we then switch the case to the beginning of the sequence's case. Then, once a certain condition is met after continuous iterations of the specific case, we then add 1, or set the state control to the next state that needs to be done. Each stage exists in a specific case. We keep doing this until the operation is complete. Then, set the state to the default state where it does nothing. At that point, the user control can activate the sequence all over again. If the user control is pressed during the operation, it doesn't do anything because it is programmed to only start the sequence if it is residing in the default state.
__________________
Michael Ray
Team RUSH 27

Driving Record: 93-64-0 Best Finish: Finalist (x4 FiM Districts)
Coaching Record: 16-7-0 Best Finish: Winner (Kettering Invitationa)l

Reply With Quote
  #3   Spotlight this post!  
Unread 05-02-2013, 13:58
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,731
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Programmatically Toggling a Boolean Control

Quote:
Originally Posted by Anatole View Post
Basically, the program can run back and forth between true and false, but the user can hit the joystick button to manually override the back and forth.
You'd just need an outer case that checks your button press and if pressed, does what the button wants, if not pressed, continue with what a feedback loop says to do.

If you have a simplified specific example, we can help you refine it.

And like Michael said, a delaying sequence can be done in Teleop as a state machine, or put in Periodic Tasks as a true sequence.

Is this the kind of thing you're hoping to do?
Attached Thumbnails
Click image for larger version

Name:	RepeatUntilResetByButton.png
Views:	443
Size:	20.8 KB
ID:	13812  
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 05-02-2013 at 14:27.
Reply With Quote
  #4   Spotlight this post!  
Unread 05-02-2013, 15:50
Anatole's Avatar
Anatole Anatole is offline
Registered User
FRC #4531 (STEMpunk 4531)
Team Role: Programmer
 
Join Date: Feb 2013
Rookie Year: 2013
Location: RobotLand
Posts: 7
Anatole is an unknown quantity at this point
Re: Programmatically Toggling a Boolean Control

Thanks for the replies!
I've got to the next step.
I have another problem -- now, when I'm running a while loop in one of the case sequences, there's no way I can stop this loop outside of the loop itself. Here's the vi I'm using:
I try to use the cancel boolean, but it doesn't change any values, because the while loop is running.
Attached Files
File Type: vi example.vi (10.8 KB, 39 views)
Reply With Quote
  #5   Spotlight this post!  
Unread 05-02-2013, 16:08
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,731
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Programmatically Toggling a Boolean Control

Can't directly break into a while loop while it's running. New values won't pass through it's borders
It alone decides when it's done.

You could set a Global variable in a parallel task (i.e., not a check that is linked to the loop in any way) that gets read within the loop.
Here's your example using that. (Adding Global Variables )
Attached Thumbnails
Click image for larger version

Name:	GlobalExample.png
Views:	238
Size:	42.8 KB
ID:	13814  
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 05-02-2013 at 16:30.
Reply With Quote
  #6   Spotlight this post!  
Unread 05-02-2013, 18:55
Anatole's Avatar
Anatole Anatole is offline
Registered User
FRC #4531 (STEMpunk 4531)
Team Role: Programmer
 
Join Date: Feb 2013
Rookie Year: 2013
Location: RobotLand
Posts: 7
Anatole is an unknown quantity at this point
Re: Programmatically Toggling a Boolean Control

thanks alot!
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 03:45.

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