LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Recording continuous data to excel

Trying to record N amount of data points to excel. I am getting data to export but it is the same data point copied N times. How can I get it to take the current data point, rather than the first over and over again?

0 Kudos
Message 1 of 7
(1,053 Views)

Hi parker,

 


@parker300 wrote:

I am getting data to export but it is the same data point copied N times.


But that is what you have programmed: to write the very same data 100 times into your file!

(THINK DATAFLOW: you create a string, then you write that string into a file inside a loop set to iterate 100 times!)

 


@parker300 wrote:

How can I get it to take the current data point, rather than the first over and over again?


Get rid of that FOR loop in your image to write the latest string into your file!

 

Btw: Using a format string of "%s" to format a DBL value seems wrong to me…

(There are other things that also seem wrong for me, but that is the first most.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(1,047 Views)

Hi GerdW, 

 

Thanks for the help, and pointing out that %s seems wrong, which I agree and will fix. 

 

I took out the for loop, and now have just the singular data point. I want all data points from the start to the stop of the test, which is why I tried the loop in the first place. How can I make this happen?

 

Thanks again!

0 Kudos
Message 3 of 7
(1,037 Views)

Hi Parker300

 

You need to use function called Write Delimited Spreadsheet.vi

 

this way you wire your 1 d array, with the following setup

format - %.3f (considering 3 digits of precision)

Append to file - TRUE

Transpose - FALSE (default)

delimiter - \t

 

This way you keep this function every time you read the data it will save the 2 sets of data (one line at a time)

By the end of the loop where you read the data, all points will be stored in your file. 

 

I made a simple example where there is a loop  running 100 times, saving 100 points so you understand how it will look like.

I also added the file where the data will be stored. 

 

 

 

Download All
0 Kudos
Message 4 of 7
(997 Views)

LVNinja,

 

Thanks, this makes sense. One issue is that my version of LabVIEW (2014) doesn't have this VI, and I am unable to open your code to grab it from there because it is a different version. Where can I download this VI?

 

Thanks!

0 Kudos
Message 5 of 7
(988 Views)

What NI's "Write Delimited Spreadsheet" did was make it possible to take a 1D or 2D array of numeric data, with columns separated by <tab> or comma (,), and rows corresponding to the "row (first) index" of the Array.  What made it interesting is that you only gave it the File Name you wanted -- it did its own File Opening and File Closing.  [What it really did was open the file, (optionally) go to the end of the file, write the data, and then close the file.  When/if you called it again with more data, it stuck it on the end, where it belonged.]

 

If you've had experience with any other Programming Language and File I/O, you know the basic steps that LabVIEW also gives you (even going back to LabVIEW-at-the-turn-of-the-Century).  There is a function to Open a file (you need to designate it for writing -- read the LabVIEW Help) which you do first.  You then take the "File Reference Wire" into the Loop where you accumulate stuff you want to write, then present it to the File Write VI to write it out.  When you are all done, and exit the loop, then you use Close the file (using the same File Reference Wire that you bring out of the loop).

 

If you look at the Help of the File I/O routines, you can scroll to the bottom where there will be Examples you can select to see example code with explanations.

 

Bob Schor

0 Kudos
Message 6 of 7
(872 Views)

Hi parker,

 


@parker300 wrote:

One issue is that my version of LabVIEW (2014) doesn't have this VI, and I am unable to open your code to grab it from there because it is a different version.


Another issue is that you forgot to attach your VI: we cannot edit/debug/run images showing just (parts of) LabVIEW code…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 7
(850 Views)