LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing data to spreadsheet in FOR loop without shift register

My program has a case window within a For loop.  The loop iteration index is wired to the case, so there’s a case for each iteration of the loop (about 30 cases).  In each case, data points are gathered, formatted to a spreadsheet and written to a file, along with some occasional header strings to describe the data.  This works fine, as I can simply write the data to file as soon as I get it. 

 

At some point in the loop, I’m gathering from two sources (rpm data for two fans) over several iterations that is to be written to two separate but similar formatted tables in the same output file.  Since I’m writing two tables to one file simultaneously, I can no longer write on-the-fly in a linear fashion; I’d need to store all the information until I complete the iterations, then format the header & raw data to spreadsheet and write to file in two chunks – at least, this is what I believe is the way to go, but I’m all ears if there’s another way.

 

In order to buffer the data, I could use a shift register, but this requires me to wire an array across my loop for all loops, whether I’ll be using it or not.  I’ve also considered initializing an array at the case I’ll need to start buffering, then writing to a local variable of that array, but in fiddling with this approach, I don’t see how to specify what index to which I’m storing the data point.

 

So I’m looking for advice on whether (1) there’s another way to accomplish my goal and/or (2) how to execute the initialize array and local variable approach. 

 

Below is a picture of what I want this portion of the spreadsheet to look like.  Also included is a much abbreviated mock-up of my program for a case where I’m writing on the fly for a single table or column of information and a case where I’m setting up the write to local variable approach.  



Message Edited by TESTIE on 04-03-2008 12:48 PM
Download All
0 Kudos
Message 1 of 5
(3,014 Views)
Hi Testie,

my advice: use the shift register approach! It's by far the most LabView-like kind of programming.

Using locals will result in making copies all the time - slow and memory-consuming...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(2,988 Views)
I agree with Gerd.  Shift registers will be your best bet, even if you have to wire them up all over the place, but if you're dead set on using locals, you would have to read an array local, insert by index, then write to an array local.  So you're using three copies of this array simply to write data to it, which is not only inefficient, but also poor practice.
0 Kudos
Message 3 of 5
(2,969 Views)
Thanks for the input.  I'm actually going to go with the local variable approach.  My reasoning is mostly from a cosmetic standpoint, but I don't think I'm going to take much of a hit on processing.  The local 1d array I'm creating is only 55 indexes deep and it's usage/existence will be limited to a section of the program.  If it turns out to be a problem, I can do the shift register thing if I really have to.   
0 Kudos
Message 4 of 5
(2,936 Views)
An Action Engine can thought of as an encapsulated shift register.
 
AE's out-perform locals while alos elliminating possible race conditions. You may want to review the Nugget I wrote on Action Engines.
 
Just trying to help,
 
Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 5
(2,922 Views)