From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

1D arrays saving to .lvm to create 2D array on file

Solved!
Go to solution

Hi all,

 

I know this is probably trivial and shouldn't take too long to sort out. For some reason I can't work it out. 

 

I have a producer loop that creates a 1D array every second and sends it to a consumer which then needs to save that line into an LVM file. I can do what I want by creating the 2D array before saving and then overwriting it each time, however I want this to scale to testing that will have millions of data points so I would prefer not to have the 2D array being added to.

 

How do I get it so the LVM saves 1 line, then effectively presses enter and saves the next line etc etc. I've used exactly the same format on the express VI as I have seen work on other projects however it doesn't seem to work here.

 

I have attached the code, it saves the data vertically currently but I would like it to be horizontal per iteration.

Using LV2013 to do this.

 

Many thanks.
Pete

Pete
Systems engineer (CLAD LV2013)
0 Kudos
Message 1 of 5
(2,660 Views)
Solution
Accepted by WoodySLB

Just format the data yourself and save it to the file.  Open/Create the file before your consumer loop, write inside, and close after the loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 5
(2,648 Views)

In addition to Tim's solution, you really should famliarize yourself with proper dataflow and programming techniques.

 

  • You upper inner while loop should be a FOR loop. 80% less code and same functionality.
  • If you close the queue after the lower loop instead, you would not need to add a misguided wait loop that hammers the CPU like crazy doing basically nothing useful.
  • Even with the express VI, you can configure it to append the new data. It is all in the configuration.
0 Kudos
Message 3 of 5
(2,642 Views)

Thank you both for the quick reply.

I will implement the suggested, and the fix does work. 

Just for curiousity's sake when I append the data on the LVM with write to measurement file it automatically goes to 

0 0
1 2
2 4
3 6
4 8
5 10
0 0
1 2
2 4
3 6
4 8
5 10
0 0
1 2
2 4
3 6
4 8
5 10

 

Where as I want it to go to
0 0 2 4 6 8 10

1 0 2 4 6 8 10

2 0 2 4 6 8 10

 

etc

 

How do I tell the array that it needs to be a 1x6 instead of a 6x1?

 

Thanks again for the solution!

 

Edit:
With regards to the closing of the queue, I had forgotten to put a timing in there to stop it ramping the CPU usage, but I do think it needs to be in its current position to prevent any loss of data within the queue. If I were to put the stop in the bottom loop and the close queue after it then there could still be data in the queue when it is closed? If the stop button stays at the top then the error will never occur in the bottom loop to stop it. Obviously the data loss problem won't affect this program too much but it could affect a larger program?

Please do correct me. Many thanks

Pete
Systems engineer (CLAD LV2013)
0 Kudos
Message 4 of 5
(2,632 Views)

WoodySLB wrote:

How do I tell the array that it needs to be a 1x6 instead of a 6x1?


You can't.  A 1D array just has 1 dimention.

 

 


@WoodySLB wrote:

With regards to the closing of the queue, I had forgotten to put a timing in there to stop it ramping the CPU usage, but I do think it needs to be in its current position to prevent any loss of data within the queue. If I were to put the stop in the bottom loop and the close queue after it then there could still be data in the queue when it is closed? If the stop button stays at the top then the error will never occur in the bottom loop to stop it. Obviously the data loss problem won't affect this program too much but it could affect a larger program?


What I typically do is send some kind of message through the queue to tell the consumer to stop.  In this case, I would send an empty array as the stop command.  You can then destroy the queue once the consumer loop is complete.  That way you don't have to poll to see if the queue is empty.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 5
(2,621 Views)