Go to Post I was proud that there was no whining, no finger pointing and no complaining. - Vikesrock [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 22-02-2009, 17:57
smackee618 smackee618 is offline
Registered User
FRC #1327
 
Join Date: Jan 2009
Location: St. Louis, MO
Posts: 7
smackee618 is an unknown quantity at this point
Create single file for empirical values in labview

Hi,

My labview code has a good deal of constants which will probably change multiple times once more testing is done, and these constants are located all over the place in the advanced framework. I was wondering whether there was a way to make a single file which stores all of these constants and puts them in the right places when the program is compiled.

I know that I could create a single VI with lots of controls, create global variables which link these controls to the appropriate places, and simply set the default values to be the ones I want to use, but I would rather not do that since global variables use for this purpose would cause unnecessary inefficiency (from what I understand).

Any help would be greatly appreciated.
  #2   Spotlight this post!  
Unread 22-02-2009, 18:01
EricH's Avatar
EricH EricH is online now
New year, new team
FRC #1197 (Torbots)
Team Role: Engineer
 
Join Date: Jan 2005
Rookie Year: 2003
Location: SoCal
Posts: 19,789
EricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond repute
Re: Create single file for empirical values in labview

If you're looking for constant values, is there a way to create global constants in Labview?
__________________
Past teams:
2003-2007: FRC0330 BeachBots
2008: FRC1135 Shmoebotics
2012: FRC4046 Schroedinger's Dragons

"Rockets are tricky..."--Elon Musk

  #3   Spotlight this post!  
Unread 22-02-2009, 18:19
Tanner's Avatar
Tanner Tanner is offline
Registered User
FRC #1261 (Roblions)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Suwanee, GA
Posts: 311
Tanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to beholdTanner is a splendid one to behold
Re: Create single file for empirical values in labview

I don't see how a global variable/constant would be the inefficient.

Once you create a global variable, you shouldn't have to create a VI just to set everything, last time I checked you could manipulate a global variable from it's little VI. Then you could just have the VIs where you need to use a variable from it read the stuff from the global variable.

-Tanner
  #4   Spotlight this post!  
Unread 22-02-2009, 20:24
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,751
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Create single file for empirical values in labview

Global variables are quite efficient. Write a test to see how long it takes to read a million of something. On the mac laptop I'm using, an empty for loop took 2ms for 1 million iterations. Adding a double precision constant makes it 5. Changing that to a control terminal is also 5. Using a control local makes it 75, and using a global upped it to 77.

All of this was with debugging turned off for the VI. So you have a few nanosecs for this in most cases and when using something that could change at any time and doesn't have optimizations will use more like 70 nanosecs. You can afford that if you do any calculations at all.

By the way, when doing tests like this, avoid using constants for things like loop iterations. If it can, LV will optimize your entire loop to run at compile time to give you unbelievable numbers.

Greg McKaskle
  #5   Spotlight this post!  
Unread 22-02-2009, 23:57
smackee618 smackee618 is offline
Registered User
FRC #1327
 
Join Date: Jan 2009
Location: St. Louis, MO
Posts: 7
smackee618 is an unknown quantity at this point
Re: Create single file for empirical values in labview

Quote:
Originally Posted by Greg McKaskle View Post
Global variables are quite efficient. Write a test to see how long it takes to read a million of something. On the mac laptop I'm using, an empty for loop took 2ms for 1 million iterations. Adding a double precision constant makes it 5. Changing that to a control terminal is also 5. Using a control local makes it 75, and using a global upped it to 77.

All of this was with debugging turned off for the VI. So you have a few nanosecs for this in most cases and when using something that could change at any time and doesn't have optimizations will use more like 70 nanosecs. You can afford that if you do any calculations at all.

By the way, when doing tests like this, avoid using constants for things like loop iterations. If it can, LV will optimize your entire loop to run at compile time to give you unbelievable numbers.

Greg McKaskle
Tell me if I am wrong, but I think that you are telling me that, since I will probably have other calculations running at the same time as I read from these globals, the slight speed decreases will not matter because other, much more processor-intensive tasks will overshadow them.

By the way, could you give me an example of "using constants for loop iterations" and the better alternative? Sorry about my slowness; sleep is a scarcity these days.

One more thing: somewhere along the line there, milliseconds turned into nanoseconds, and I was wondering whether that was intentional.

One more thing (yes I am starting to sound like Uncle from Jackie Chan Adventures): Tanner, thank you for keeping me from doing something extraordinarily stupidly inefficient. I didn't even think about simply using the global data VI.

One more thing: I don't know why, but for some reason I was predisposed toward thinking that global variables were really slow. I think I read about it somewhere. Does anybody know why I thought this?
  #6   Spotlight this post!  
Unread 23-02-2009, 08:28
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,751
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Create single file for empirical values in labview

Milliseconds divided by one million gives nanoseconds. And yes, I was simply showing a common and accurate way of profiling stuff, though I didn't really show it.

The first picture shows a way to time this, and the second shows a way to get zero when doing something a million times.

Variables aren't efficient, but inefficient has different meanings depending on what you are doing. Since this will allow you to change code and retune on the fly without even recompiling, I think it is a good tradeoff. If it seems like it is getting too expensive, you pull the global outside of a fast loop and read it once and put it into a shift register.

Greg McKaskle
Attached Thumbnails
Click image for larger version

Name:	Picture 9.png
Views:	53
Size:	15.6 KB
ID:	7549  Click image for larger version

Name:	Picture 10.png
Views:	47
Size:	16.5 KB
ID:	7550  
  #7   Spotlight this post!  
Unread 23-02-2009, 09:18
Uberbots's Avatar
Uberbots Uberbots is offline
Mad Programmer
AKA: Billy Sisson
FRC #1124 (ÜberBots)
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Avon
Posts: 739
Uberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond reputeUberbots has a reputation beyond repute
Re: Create single file for empirical values in labview

Quote:
Originally Posted by smackee618 View Post
One more thing: I don't know why, but for some reason I was predisposed toward thinking that global variables were really slow. I think I read about it somewhere. Does anybody know why I thought this?
Global variables are horrendously slow if you use arrays. Labview will attempt to copy the entire contents of the global array before using it, which as you know can be quite inefficient, especially when you only need a specific element.

here: http://zone.ni.com/reference/en-XX/h...al_and_global/
__________________
A few of my favorite numbers:
175 176 177 195 230 558 716 1024 1071 1592 1784 1816
RPI 2012
BREAKAWAY
  #8   Spotlight this post!  
Unread 23-02-2009, 19:24
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,751
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Create single file for empirical values in labview

Yep, arrays may be it. But just to be clear, LV doesn't attempt to copy the array, it does copy the array, ditto for all data types that aren't references, they are by value. So a small array will be similar to a scalar, a small cluster, ditto. Large arrays or clusters will degrade linearly.

The reason for the copy is to support parallel program execution safely.

To get around this you make a functional wrapper that returns only the elements you want or makes the modifications you want, and this wrapper will automatically be a critical section.

Greg McKaskle
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
How to do file i/o in labview rsisk NI LabVIEW 4 08-02-2009 14:26
Combining many SLDDRW files into a single file Madison SolidWorks 1 09-01-2008 20:23
File Open Problems in LabVIEW pyroslev LabView and Data Acquisition 3 20-01-2007 15:52
Labview Demo File for 2006 Camera? JABianchi General Forum 2 15-09-2006 18:23


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

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