View Single Post
  #3   Spotlight this post!  
Unread 23-01-2015, 17:00
GuyM142's Avatar
GuyM142 GuyM142 is offline
Registered User
AKA: Guy
FRC #3339 (BumbleBee)
Team Role: Mentor
 
Join Date: Jul 2013
Rookie Year: 2012
Location: Israel
Posts: 157
GuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really nice
Re: Using shared variables instead of global variables

Quote:
Originally Posted by wt200999 View Post
The Shared Variable is meant for sharing data over a network while hiding the network implementation. I can't speak much to the performance, but I can recommend other ways to help.

Ideally you should try to reduce the number of global variables that you use in the first place. If you are getting lost in the number of global variables that you are using, you are probably using too many. There are a number of ways to reduce the number of globals.

The easiest way would be to send a cluster using the global, instead of using single data types and multiple globals.

If you want to get into the more advanced LabVIEW topics, you can change your architecture to use other message passing schemes (Notifiers, Queues etc). Depending on your implementation, you could possibly get away with not using any global variables at all.
We are working with state machines so that we have a state machine for every sub-system on the robot. for example: Tote grabbing arms
For each state machine we have commands/actions like open or close.

Then, in the Teleop.vi we send different commands to the state machines which run in parallel, based on driver's input.

*We have an enum typeDef for each state machine and for each set of actions.

for example:
the grabber state machine is in close state,
pressing button 1 sends "open" to the grabber state machine,
the grabber state machines then moves to "moving to open" state,
and when it detects it reached the target it moves to "open".

Which architecture do you recommend using?
Reply With Quote