Go to Post The longer you play robots, the more you realize that it's not about the robots. - dtengineering [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 08-03-2011, 14:57
jrz126 jrz126 is offline
Registered User
no team
Team Role: Mentor
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Erie, PA
Posts: 12
jrz126 is an unknown quantity at this point
How To use Global variables and sequences

Whats the proper way to use global variables? I've used quite a few in my project to pass variables between subvi's. In another thread, (here), Greg said "you will get burned by parallel updates or race conditions."
I made sure I'm only writing the variables in one place. So I think I'm ok with the parallel updates.
I don't think I'd have an issue with a race condition. But if I did, how should it be handled?
Reply With Quote
  #2   Spotlight this post!  
Unread 08-03-2011, 15:46
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
Re: How To use Global variables and sequences

It is all about using the right tool for the right job. Are you sure you want a global? Would a queue, a notifier or a user event work better for your application?

User events notifiers and queues can be passed around to subVIs, which makes code re-use easier later.

A queue allows you to guarantee that you will get all the data across, but is typically one write/one read.

A notifier only pushes data when you are ready to read it - if the listener is busy, it (intenionally) drops the write on the floor.

A user event is one write/multi read, but harder to use.

A global is easy to use, but doesn't have some of the extra features of the other options.



Also, always lump related data together - if you use something as a cluster, make it a cluster. This will ensure that the entire kit'n'kaboodle gets written simultaneously, and will prevent you from reading half new and half old data.
Reply With Quote
  #3   Spotlight this post!  
Unread 08-03-2011, 16:08
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,112
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: How To use Global variables and sequences

Quote:
Originally Posted by EricVanWyk View Post
User events notifiers and queues can be passed around to subVIs, which makes code re-use easier later.
We're using globals to communicate between teleop and periodic tasks, and to hold information to be sent in the dashboard data. I gave some thought to using other features such as queues or events, but I couldn't see a good way to pass the queue or event itself around without using a global variable anyway.
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 09:25.

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