06-16-2015 01:28 PM
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?
06-16-2015 01:32 PM
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.
06-16-2015 01:34 PM
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?
06-16-2015 01:37 PM
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.
06-16-2015 01:39 PM
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.
06-16-2015 01:44 PM
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.
06-16-2015 01:54 PM - edited 06-16-2015 01:56 PM
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.
06-16-2015 01:54 PM
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.
06-16-2015 01:55 PM
I was thinking about that! Can I use property nodes to set default values?
06-16-2015 01:56 PM
Thanks aputman, I'll check it out.