LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Combining a circular buffer with dynamic data

Solved!
Go to solution

Hi,

 

I am trying to record data in a test surrounding an impact event to determine the duration of time that the acceleration passes a certain threshold. I want to record one second of data before and after the event occurs, which I have set to be the crossing of the threshold. The duration will be around 10-15 ms, so two seconds of data at 10 kHz will be plenty of data. I have my VI written so far to export the buffer data to an excel file, but is there any way that I could record an additional second of data and concatenate it into what I already have? I usually use the data collection express VI for dynamic data collection and the excel specific report generation VIs for static data, but how would I combine both?

 

Any sort of conceptual brainstorming would be much appreciated. 

Thank you!

0 Kudos
Message 1 of 5
(3,870 Views)
Solution
Accepted by topic author try_guy90

What I have done in the past is use a fixed sized queue with the Lossy Enqueue to store the data (acts as a circular buffer).  Then, when the threshold is detected, record an additional 1 second.  Your queue should now have 2 seconds of data stored that you can then just write to your file (use Queue Status to get the data without emptying the queue).


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
(3,866 Views)

I completely agree with Crossrulz (and have used the Lossy Queue technique myself to do just this).

 

Do a Web search for "Learn 10 Functions in NI-DAQmx", read the excellent NI White Paper it references, then resolve to Never Again Use the DAQ Assistant, and Never Again Use Dynamic Wires.  Set your DAQ up for Continuous Sampling and choose an appropriate number of points to sample.  If you are sampling at 10KHz and sample 1000 points at a time, you'll get 10 samples a second, so after your trigger, if you sample 10 more times before stopping and saving the Queue contents, you'll have 2 seconds of data "surrounding" your trigger point.

 

Bob Schor

Message 3 of 5
(3,852 Views)

Thank you both for your informative answers.

 

Bob_Schor, Could you clarify what you meant by the sampling settings? I don't understand how one can get 10 samples per second if the sampling rate is 10kHz. What did you mean by sampling 1000 points at a time? Wouldn't it make more sense to just sample 10k points twice? 

 

Thanks for the further explanation, and your suggestion to Never Again use DAQ Assistant and Dynamic wires Smiley Very Happy I will avoid it at all costs!

 

Edit: I think I understand, is each element of the queue a 1000 sample waveform array? Thanks!

0 Kudos
Message 4 of 5
(3,849 Views)

Yes, you got it.  There's a tradeoff in how big the buffer is -- if it is 1000 points, then if you acquire data at 10KHz, you will get ten "chunks" of data ("sample" is, indeed, a misleading term) per second.

 

If you save the data as Waveforms in the Queue, you may want to concatenate the various Waveforms in the Lossy Queue into a single Waveform for saving.  Think about how you want to write the 20,000 samples -- as multiple Waveforms, a single Waveform, or what.

 

Bob Schor

Message 5 of 5
(3,830 Views)