LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving variables in a text file

Highlighted

Hi there,

 

I am using a VI which receives some variables and I'd like to save them all in a text file.

 

I would like to have a row to be added for each iteration of my while loop so that I would get, say:

first line: 2500.000000, 2502.000000, 0.000000, 2529.000000, 2488.270176, 2551.494700, 4704, 423564, 57.303482, 2016-11-10 15-38-42

second line: 2500.000000, 2502.000000, 0.000000, 2529.000000, 2488.270176, 2551.494700, 4704, 423564, 57.303482, 2016-11-10 15-38-42

 

etc

So far I've managed to save my variables in that text file, but the format of saving is not really ideal (not displayed in line, and each iteration saves the new values + everything that has been saved during the previous iterations...)

 

I've attached an example of output as well as my current VI

 

Thank you,

Flo

Download All
0 Kudos
Message 1 of 6
(1,467 Views)
Highlighted

Hi Flo,

 

but the format of saving is not really ideal (not displayed in line

Because you have it programmed this way: each ArrayToSpreadsheetString will add a CR/LF…

 

and each iteration saves the new values + everything that has been saved during the previous iterations...)

Because you have it programmed this way: you collect your data in arrays and each time you save the content of those arrays into your file…

 

Simple solution:

Collect only the values of the next line in an array and use ArrayToSpreadsheetString only once per line of text…

 

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 2 of 6
(1,455 Views)
Highlighted

The problems are in your shift registers.  You are building the individual values into multiple arrays, then combining them all together.

 

You shouldn't need any shift regsiters.  Just combine the various data coming into a single string.  Write that string to the file.

 

You didn't attach your VI, just a picture of your block diagram.  Otherwise it would be easy to fix.

0 Kudos
Message 3 of 6
(1,455 Views)
Highlighted

The picture is actually a snippet.

 

I'll try your solution.

 

 

thank you

0 Kudos
Message 4 of 6
(1,450 Views)
Highlighted

@Flo-w wrote:

The picture is actually a snippet.

 

I'll try your solution.

 

 

thank you


I'm sorry, you are right.  It is.  I didn't notice the header information at the top of the image.

 

EDIT:

Attached is a modified VI.  I cleaned up a lot and used Format Into String to simplify the combination of the data points.

Note, you will need to debug it.  I know a couple things broke such as where data was accumulated.  So you may need to add a shift register or two back in and fix where the data is coming from.  (I just added the constant of 0 to them.)

0 Kudos
Message 5 of 6
(1,431 Views)
Highlighted

Thank you ! I'll try that right now !

 

Flo

0 Kudos
Message 6 of 6
(1,335 Views)