Go to Post We're 30 pounds over LOL. I probably shouldn't be lol'ing, but it is 11:52PM, I just got home from a 15 hour build session, and I find the word 'potato' funny. - ZakuAce [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 20-01-2015, 09:14
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: 156
GuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really niceGuyM142 is just really nice
Using Global Variables Instead of Get Refnum

Is it possible to use a global variable to store the registry refnum for the motors/sensors etc. instead of the refnum get vi?
It can make things a bit easier and prevent stupid name typo mistakes.
Reply With Quote
  #2   Spotlight this post!  
Unread 20-01-2015, 09:46
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: Using Global Variables Instead of Get Refnum

It's certainly possible to use global variables to store RefNum values. The first year of the NI control system, it was normal to do it that way.

Two years ago we discovered a big drawback to not using the RefNum Registry, though. That's the mechanism that lets Test mode work to give you manual access to all the robot inputs and outputs that you use. So we use sort of a hybrid scheme, where we do a RefNum Set in Begin.vi, and also keep the RefNum in another place for easier and less typo-prone access.
Reply With Quote
  #3   Spotlight this post!  
Unread 21-01-2015, 08:55
Doug Norman's Avatar
Doug Norman Doug Norman is offline
Registered User
no team (National Instruments)
Team Role: Engineer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Austin, TX
Posts: 134
Doug Norman will become famous soon enoughDoug Norman will become famous soon enough
Re: Using Global Variables Instead of Get Refnum

Quote:
Originally Posted by Alan Anderson View Post
keep the RefNum in another place for easier and less typo-prone access.
One way some teams do this is by creating a typedef enum updated with a list of all their RefNum names. Then they simply drop that enum followed by the Format Into String function any place they need a RefNum name. It's a bit of extra code, but makes it so they don't have to remember the names or correct spellings - they simply pick it from the enum list.
__________________
Doug Norman
National Instruments
Reply With Quote
  #4   Spotlight this post!  
Unread 21-01-2015, 10:46
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: Using Global Variables Instead of Get Refnum

Quote:
Originally Posted by Doug Norman View Post
One way some teams do this is by creating a typedef enum updated with a list of all their RefNum names. Then they simply drop that enum followed by the Format Into String function any place they need a RefNum name. It's a bit of extra code, but makes it so they don't have to remember the names or correct spellings - they simply pick it from the enum list.
We've done that, and actually took the concept a bit farther a couple of years ago. Along with the typedefs (.ctl files in LabVIEW), we had a Global Variable vi full of cluster constant arrays that defined everything that goes into the Open functions. In Begin, we looped through those arrays for Drive, Digital Input, Motor, Encoder, etc. to open everything. In Finish, we did the same thing to close everything. We made copies of each Refnum Get vi and modified them to take the enum directly. The rest of the robot code looked almost the same as the "normal" way of doing things, except that the enums are blue where strings are pink.
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 08:03.

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