LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write & Read Config VI's

I have been trying this method and I can get it to work. I know it is hard to explain in a message but I'll do my best. Ok let's say I have 5 numeric controls in the front panel...and they are ratio, voltage, current, amps, and another one....Ok now I have a text file with the values for each of those numeric controls....I need to upload those numeric values into their respective numeric control in the front panel. I have been using the write and read configuration files from labview 8.5...I am not certain how to work with the Key and the Section of the VI....so if anyone has done this and can give a hand...my program is done all I need now is to input those values....THANKS
0 Kudos
Message 1 of 14
(3,666 Views)
It depends how the text file is formatted.
Config files look like the Labview.ini file:

[Section1]
Keyname1=Value1
Keyname2=Value2
...

If your file is formatted differently you might have a look at 'Scan From File' or just 'Read Text File' and the parse it.

0 Kudos
Message 2 of 14
(3,662 Views)
I have two files
One is
Current 2mA
Voltage 10V
.
.
.
.
Ratio 50

But Im the one that writes the file...so you are saying that I should write the file like this
[Section 1]
[Current] = 2
[Voltage] = 10
.
.
.
[Ratio] = 50
0 Kudos
Message 3 of 14
(3,654 Views)
You can write the files in config file style if you want to use the config file VIs. No need to Smiley Wink
But leave away the square brackets for the key names, they are reserved for section names:

[Section 1]
Current = 2E-3
Voltage = 10
.
.
.
Ratio = 50

You can also use the formatting as is and use the scan from file function.
It looks like you want the values SI formatted. That works, but you have to separate the number from the unit (using a space).
Probably you can do something like this:
Current 2m A
Voltage 10 V

and then use the scan from file using "Current %p" or "Voltage %p". This should return the numbers.



0 Kudos
Message 4 of 14
(3,648 Views)
I just did a quick test an I had a hard time getting the scan from file to work correctly. It just wouldn't recognize SI formatted numbers. It works using engineering formatting, but you have to be really exact in both formatting and order. Probably it's easier to use the config file.

0 Kudos
Message 5 of 14
(3,639 Views)
Hey Dan,

Thanks for your help...Im going to attach what I have so far so you can take a look at it...I will be attaching boht the text file and the labview vi. Im trying to read 120 into the numeric control called Sweet Spot and I get a 5 into it because I have that as the default value....is there anything wrong with it??? Do I have to write first before read??? IDK im confused now

0 Kudos
Message 6 of 14
(3,635 Views)
I forgot to attach the files,,,here they are
Download All
0 Kudos
Message 7 of 14
(3,634 Views)
You're on the right track. Just correct the section name, it's 'My Section' in the file and 'Section1' in the VI. Make them the same and you're done 🙂

0 Kudos
Message 8 of 14
(3,623 Views)
If your import.txt is your configuration file. I don't see how you expect to get 120 when the value is 5.0000
0 Kudos
Message 9 of 14
(3,621 Views)
Just a comment... when you just read the file you can set the 'write configuration file' input of 'Close config data' to False.
0 Kudos
Message 10 of 14
(3,616 Views)