LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a Variable

my program has a taring function which tares a scale to 0.  The taring function runs on a feedback node.  The taring option works fine.  My problem is when i exit the program and enter in again the tare dissappears.
 
Example:
 
say i have a reading of 19.9 grams on my scale, and i tare it to 0 grams, scale works fine
 
i exit and log back in, i end up with a reading of  19.9 grams again, not 0 grams
 
Is there a way to save the value in the feedback loop when i log out?  In other words, Is it possible to write a number to a constant or a variable within the feeback loop?
0 Kudos
Message 1 of 8
(3,577 Views)
Have you tried creating a local variable, or using a shift register?  Creating, then updating a local variable might solve your problem.
0 Kudos
Message 2 of 8
(3,569 Views)
I have tried a shift register, doesn't work.  I am new to labview and i am very unsure how to create a local variable.  Is there a reference or explanation how i can do this?  I am still confused on how to make one even from looking at context help
0 Kudos
Message 3 of 8
(3,568 Views)
Variables will not retain values when you exit the program. Look at the configuration file VIs. At the end of your run, save the tare value to a file. When the program starts, one of the first things it does is to read the file and initialize the shift register/feedback node (they are almost the same thing). If the file dose not exist, then the initializtion would use zero or other predefined value.

Read the help files for more information on these VIs.

Lynn
Message 4 of 8
(3,561 Views)

I think your problem is more fundamental than just trying to find a quick bandaid solution.

  1. Why are you constantly exiting and restarting the program? Wouldn't it make more sense to keep it running? You could e.g. filter the "windows close" event and minimize the VI instead.
  2. If you open the program a week from now, I somehow doubt that the current tare value has any meaning left. It would seem foolish to blindly re-use a stale tare value.
  3. You probably should ensure that the system is tared at each new start of the program.
  4. You could insist that people start the program with the scale empty. Simply automatically tare the code with the current reading when the iteration count is zero, i.e. in the first iteration of the loop or as soon as the reading is stable for the first time.
Message 5 of 8
(3,553 Views)
I am weighing an application of a period of 60 to 90 days,  The load cells used to weigh these are sealed off in a chamber, once i tare the load cells they have to stay tared, if i were to shut off my computer within that 60 to 90 day period i would end up with inaccurate results.  i could just scale the system to 0 but i figured a tare command would be nice.
0 Kudos
Message 6 of 8
(3,547 Views)
For a period that long I would definitely recommend writing the data to a file. I would also write measurement data to the file periodically as well, so that a power failure or some software malfucntion in the OS or your program does not cause you to lose all data.

Be aware that the tick count functions will overflow after about 49 days. If you are using any fucntions that use the tick count, like Wait (ms), check to be sure they will work properly during the overflow.

Also any loops that use the iteration counter need to be checked for overflow as well.

Lynn
0 Kudos
Message 7 of 8
(3,536 Views)
I'm not sure what measurement system you're using for your load cells, but if you're for instance using an NI DAQ card that runs the DAQmx driver, then you can actually accomplish these minor calibrations on the hardware level itself. You can do this by using a calibration wizard from MAX that allows you to input channel values and what the result should be. These calibration constants are then stored in the EEPROM (onboard memory) of your device itself, eliminating the need for this. I'm sure there are also API functions to automatically perform these simple calibrations from LabVIEW as well. Just a thought....
Jarrod S.
National Instruments
0 Kudos
Message 8 of 8
(3,527 Views)