LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PicoLog example VI not saving data properly

Solved!
Go to solution

Hey, I am playing around with the PT104 example VI provided by picolog. I am trying to save some temperature data with timestamps. See the attached VI. For some reason, the saved CSV file that this code produces only consists of two lines, the first
"Time, Temperature" and the second "0, 17". How can I append datapoints to the file?
I want my CSV file to look like this:

Time                        Temperature
0                              23.647

0.1                           23.456

0.2                           24.186

...                             ...
Cheers in advance.

0 Kudos
Message 1 of 3
(2,829 Views)
Solution
Accepted by topic author bockdoug

The problem is your Write to Spreadsheet File is outside the loop, and you are only writing your last value that comes out of your while loop.

 

You should open the file and write the header before your while loop.  Write each line of data inside the while loop.  Close the file after your while loop ends.

 

Other tips:

Insert into Array is not the best function to use there.  Use Build Array whenever you are just adding data to the beginning or end.  In this case, because you used Insert into Array with a zero index, you were probably getting your data line BEFORE your header line.

 

Get rid of the stacked sequence and replace with a flat sequence.  Once you do that, you will probably find your code is already in sequence because of dataflow and can get rid of any kind of sequence structure.

 

Your while loop inside of another while loop probably gives you execution problems due to race conditions on the Stop local variable.  Make is a single while loop.  The code to "update settings" should be in a case structure tied to that control rather than in an outer While loop.

 

Use your debugging tools such as probes and highlight execution.  Then you'll see why your code isn't doing what you want it to.

Message 2 of 3
(2,808 Views)

Thanks for those hints. I left the structures unchanged as this was the example VI provided by Picolog and the data write/save stuff was all I added. I trusted them blindly...

0 Kudos
Message 3 of 3
(2,792 Views)