LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How should I store constants for use between labview sessions?

I'm using a calibration VI to compute a line of best fit for my sensor, and I'd like to store the coefficients of the line for use in a VI that will be running on a future date. Is this best done using a text file, or can I store the coefficients inside the VI somehow? What's the best practice for this sort of thing?

0 Kudos
Message 1 of 26
(3,470 Views)

If your coefficients are subject to change and you want your system to be calibrated once in a while, it's better to keep them in a config file.

 

If there is no reason for those coefficients to ever change, then it's better to keep them harcoded in constants in your VI.

0 Kudos
Message 2 of 26
(3,466 Views)

They change. Can the config file be part of some kind of "header" inside the VI, so it keeps things nice, clean, and portable? Or will it have to be a .cfg, .txt, or .ini somewhere in the application directory?

0 Kudos
Message 3 of 26
(3,458 Views)

I store my calibration constants in a text file by using the Write to / Read from Spreadsheet File.  If you open the file and look at it, it has no meaning because its just a bunch of numbers. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 26
(3,447 Views)

I'm not too worried about people seeing the configuration constants, I just want this code to be robust, and deployable in many places other than my computer. If storing them as a spreadsheet file is the best way to do it, I'll definitely do that.

0 Kudos
Message 5 of 26
(3,440 Views)

This format works for me because my constants are stored in an array during execution so I just have to read the file and i'm done.  I have seen a toolkit somewhere (don't remember the name at the moment) but it reads all controls on a front panel and writes the values to an ini file.  And it also works in reverse to read the file and write the values back into the proper controls.  I'll see if i can find it again.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 6 of 26
(3,431 Views)

If you are using the development system there is a way to cheat your way out of the trouble of writing to config files.  You can use the Edit > Make Current Values Default command to store the current values and Edit > Reinitialize Values to Default to restore them.  It's a good way to try out various sets of test parameters one by one but lacks the ability to store multiple configurations like you could with config files.

 

EDIT:  Don't forget to save your VI after you make current values default if you want the stored values to persist until the next time you open the VI.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 7 of 26
(3,415 Views)

I found it.  If you have VIPM installed, there is a package called MGI Application Control.  In it, there is a Save and Restore Front Panel Data VI.  I haven't used them so i can't vouch for their effectiveness but it is another option for you to consider. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 8 of 26
(3,409 Views)

I was thinking about that! Can I use property nodes to set default values?

0 Kudos
Message 9 of 26
(3,407 Views)

Thanks aputman, I'll check it out.

0 Kudos
Message 10 of 26
(3,405 Views)