LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to store DAQ data and other related questions.

So I have a DAQ setup measuring a signal with a start and stop. I want to save this data to an Excel sheet and also to make some mathematical operations like area under graph etc. Hence I need to post process this data.

 

Question 1:

What am doing is to send the acquired data to a chart and then I use ' chart history'. But sometimes I had issues as for some reason the chart history became an array of arrays with different time stamps ( not sure how and why this was the case) instead of being just one array with a start time and a stop time. So is there a better way to acquire this signal and then post process it?  

 

Question 2:

What is the difference between: using for purpose above, a local variable for a chart, using chart history, using value property node?

 

Question 3:

This is an unrelated question but in same context: when to use local variable, when to use global variable when to use a FGV

: so far my understanding is to use GV when we intend to use a subvi. Use FGV when there can be a race condition but what about local variables? What are the performance issues, what is the best practice?

 

Thanks for your comments and answers!

0 Kudos
Message 1 of 5
(2,618 Views)

Hi rajiv,

 

Question 1: What am doing is to send the acquired data to a chart and then I use ' chart history'. But sometimes I had issues…

A chart is an indicator aka "data sink". It could be (mis-)used as a data buffer, but I advise against that.

Use your own buffer instead!

 

Question 2: What is the difference between: using for purpose above, a local variable for a chart, using chart history, using value property node?

There is a difference between chart history and local variable/ value proerty: the history keeps thw whole history, the value is only the last sample of the plot(s).

Again I suggest NOT to use the chart as data buffer…

 

Question 3: when to use global variable when to use a FGV

I prefer FGVs over globals because of encapsulation and code reuse…

You might use globals to distribute data, but to avoid race conditions you should use them in a "write once, read multiple" way. But then you could use notifiers, queues or wire channels, too…

 

I want to save this data to an Excel sheet and also to make some mathematical operations like area under graph etc. Hence I need to post process this data.

Use your own buffer: either a queue to a consumer loop doing the postprocessing. Or a buffer kept in a shift register in your main loop - depending on your processing requirements…

Are you saving the data to an Excel file or to a simple CSV file? This will make a difference in processing time!)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(2,609 Views)

Thank you so much for the elaborate response!

 

-> It is a CSV file.

 

I have been using a queue and consumer loops. So you say either a buffer in the consumer loop or one in the producer loop as a shift register.

 

Producer loop:

So do I initialise an array as a shift register then from the output of the  producer loop and insert into array?.. Am not sure how to indicate to it where in the array to insert the new array..  In the case of a buffer in a consumer loop how would that be implemented? What would be the difference/advantages between the 2 approaches?  Also then how do we deal with time stamps etc?

 

Thank you a lot for the response and the help.

 

 

0 Kudos
Message 3 of 5
(2,587 Views)

Hi rajiv,

 

in general a buffer can be implemented with a shift register, holding an array.

It depends on your requirements where you implement that buffer…

 

Am not sure how to indicate to it where in the array to insert the new array.

In a ring buffer you would keep an index to know where to replace an entry in the buffer.

In a "lossy queue"-type buffer you append at the end and cut at the start (or vice versa).

In general you DON'T INSERT into the array.

 

Also then how do we deal with time stamps etc?

I don't know! What are your requirements?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(2,582 Views)

Hello Gerd,

 

So would it be something like this ? It is not quite an array in this case however there is the use of shift registers. I have question marks regarding setting the buffer size, should I initialise an array outside the loop, are there issues with cases where data is missed, (or can it happen that a tiny number of data is inserted in excess to the sample number per loop?), will it be a ring buffer-> if yes, how to make sure that the graph is represented correctly when plotted-> this means the end part does not end up to the front? how to deal with timestamps if we are using a ring buffer-> If there is an example I could find where this was done using an array this would be great. 

 

 

source: https://flylib.com/books/en/3.352.1.146/1/ 

 

Edit1: 

 

I saw this example, on stack overflow, I think I could use something like this: (however the idea of circular buffer in relation to plotting the graph and not having the end part appearing in front is still unclear to me.. I would have probably cleared the buffer after each measurement and not use a circular buffer..) 

 

enter image description here

 

Edit2, missing source: https://stackoverflow.com/questions/34791801/labview-buffer-data-then-save-to-excel-file 

0 Kudos
Message 5 of 5
(2,555 Views)