LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to store a dynamic date to a array and file?

Hi there,

I am trying to store a dynamic data to a array, then to a file, I have made a block diagram as attached, but I only can store one data, anyone can tell me the reason?

 

thanks.

 

Mike

Message Edited by 798789 on 04-20-2009 05:12 PM
0 Kudos
Message 1 of 9
(4,150 Views)

Hi Mike,

 

You're simply overwriting your array with each iteration of the loop.  You need to use a shift register to store the previous value of the array between loop iterations.  See attached.  In the first picture, the shift register is initialized with an empty array, which is wired to the "insert into array" function.  The random number is inserted into the array at index 0, and the resulting array is wired to the shift register.  On the next iteration of the loop, the previous value of the array is wired to the "insert into array" function and your new point is inserted into that array at index 0.  And so on.

 

Building an array this way is somewhat inefficient, memory-wise.  If you know in advancehow big your array is going to be (i.e. if you are always collecting a specific number of data points), use the "Initialize array" function instead of an empty array to initialize your shift register (see second picture).  That allows LabVIEW to preallocate the memory instead of allocating new memory every time you add an element to your array.

 

Hope that helps.

d

Download All
0 Kudos
Message 2 of 9
(4,137 Views)

Note:  It is almost always better to use the Build Array function for this kind of operation rather than Insert into Array.

0 Kudos
Message 3 of 9
(4,117 Views)

Well, yes, that's how I'd normally do it if it were I.

 

I'm curious, though...aside from being more intuitive, which it clearly is, is it also more efficient (from a memory/processor standpoint) to use "build array"?

0 Kudos
Message 4 of 9
(4,109 Views)
Thank you guys, so any one can tell me how to put the time stamp with the output data and store the time-stamp vs data to a file?
0 Kudos
Message 5 of 9
(4,069 Views)

Hi 798789,

 

maybe you could be a little bit more specific?

 

Do you want to store exactly one timestamp ( "put the timestamp" ) with all the data? Do you want to store a timestamp for each datapoint? Which format do you want to store to (text/binary)? Any order of the data (rows, columns)?

 

Have you looked through the examples?

Message Edited by GerdW on 04-23-2009 11:08 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 9
(4,055 Views)

We want the timestamp for each data point, thank you guys.

 

Mike

0 Kudos
Message 7 of 9
(4,040 Views)

You are really just repeating the original, somewhat vague question. What is the exact format that you want? For example, absolute time, relative time, text format , binary format, columns separated by tabs, columns separated by commas, etc. etc.

 

For something simple, just use the Get Date/Time String and convert your measurement to a string. Now you have two strings that you can combine in a variety of ways. Look at all the examples of saving to file and try them out.

 

And what's with the different user name?

Message Edited by Dennis Knutson on 04-23-2009 06:54 PM
0 Kudos
Message 8 of 9
(4,034 Views)

is this what you are looking for?

 

 ( note the manner in which the build array is wired, currently it will prepend the new element to the beginning of the array)

 

simply switch the wires on the build array to append new data to the end of the array

Message Edited by James R on 04-23-2009 08:20 PM
- James

Using LV 2012 on Windows 7 64 bit
0 Kudos
Message 9 of 9
(4,022 Views)