LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Two "While Loop" array questions

Solved!
Go to solution

Hi,

 

I've got two questions about building arrays within while loops. I'm using LabView 8.5.1.

 

In its simplest form, my current while loop (time delay set at 0.2s) has 3 variables which are changed by moving a slider. These are each sent to a line within a "Build Array" block (data type is DBL 1D) - this array is then written to a spreadsheet file, such that the three values are written to a new row each time (one value per column) the while loop runs.

 

Question 1

How can I add a "Time" column into this spreadsheet? In other words, get the current time that the loop has been running for, starting at 0 seconds into the spreadsheet, via the Build Array block.

 

I can think how to do this with a For loop, but given that the While loop is running through an unknown number of iterations, I can't figure out how to get the counter to work.

 

Question 2

How can I have text column headings in the spreadsheet?

 

 

Thanks for the help, and if you require anything clarifying, please let me know 🙂 

0 Kudos
Message 1 of 4
(3,123 Views)
Solution
Accepted by topic author thomas_p

To answer question 1:

 

There is an 'Elapsed Time' function that you can put as the first colum of data.

This will then format your spreadsheet as
Time Data1 Data2 Data3

Time Data1 Data2 Data3

Time Data1 Data2 Data3

etc.... 

 

 

 

To answer question 2:

Build an array of the headings, then write that array to the file once, outside of the loop.

Your array with the time and data will write inside the loop.

 

 


Message Edited by Cory K on 12-29-2008 10:50 AM
Cory K
Download All
0 Kudos
Message 2 of 4
(3,103 Views)

This will work. Although it is easiest, its not the most efficient method.

 

 

 

The Write To Spreadsheet vi opens and closes the file every time. For better performance, open the file manually at the start, write your data as it goes, and then close the file at the end of the program.

 

😎

Message Edited by LabViewGuruWannabe on 12-29-2008 10:52 AM
Message 3 of 4
(3,098 Views)
Thanks to both for the help - seems to work now 🙂
0 Kudos
Message 4 of 4
(3,081 Views)