LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to eliminate all the zero values in "Write to Spreadsheet"

I am working on a thermocouple measurement VI. The code will read the thermocouple readings in a while loop, and there is a case structure inside the while loop box that has a "build an array" function in it. That will collect the data only if the case structure is true. Then by placing "write to spreadheet" vi outside of the loop, the data collected will be saved to a spreadsheet file.

 

The problem that I'm having is, for every "false" case, it will return zero values and "write to spreadsheet" will also record those values. Clearly I am not interested in the readings when the case structure is false. I'm guessing the problem might come from the fact that I checked "default if unwired" option, but I'm not sure how to fix that. I also tried to put the "write to spreadsheet" vi inside a case structure which is also controlled by the same save button, but that doesn't fix it. 

0 Kudos
Message 1 of 4
(2,724 Views)

Hello Saiful.hk,

 

If you're using 2012 (which it looks like you are), the "easiest" (as in working in three clicks) option is to enable the conditional terminal on your auto-indexing loop tunnel and connect the "save" control to the conditional terminal.  Right-click on your tunnel and select the option there to enable conditional indexing.

 

However, if this application is intended to run for any significant period of time (how long this is is somewhat arbitrary, since you're only sampling on one channel it could be a while before you hit trouble), I would strongly recommend that you take the time to implement a simple state machine that buffers data and saves to file periodically- if left unwatched your auto-indexed while loop tunnel could easily grow indefinitely until your computer (or LabVIEW) runs out of available memory.

 

Regards,

Tom L.
0 Kudos
Message 2 of 4
(2,719 Views)

Another approach which eliminates the growing array and the memory re-allocations is to use Replace Array Subset. First initialize an array outside the loop to a size larger than the maximum size your array will ever reach. Inside the array use Replace Array Subset to put new data into the array by overwriting the initialized data rather than expanding the array. Keep track of how many replacements have been done. After the loop use Array Subset to trim off the part of the initialized array that was never replaced. Save the trimmed array.

 

Note that I disabled the DAQ and file VIs to test the VI. Also note that I arbitrarily chose 1000 rows as the maximum size.

 

Lynn

0 Kudos
Message 3 of 4
(2,708 Views)

I have made some changes in your VI using OpenG functions. Hope it works on your system.


Thanks,

Ninad Regundwar
Junior Engineer | ARAV Technologies | www.aravtech.com
0 Kudos
Message 4 of 4
(2,681 Views)