Reference Design Content

cancel
Showing results for 
Search instead for 
Did you mean: 

Waveform Circular Buffer Library

 

Introduction

 

Continuous data acquisition uses buffering to return segments of a continuous signal. Analysis of multiple segments, or capturing events that cross segment boundaries, requires processing of more than one segment at a time. Here, we share a VI that implements a circular buffer for a waveform datatype, used to combine waveform segments into a single waveform.

 

Requirements

 

  • LabVIEW 2010

 

Implementation

 

Input waveforms are appended to the end of the output waveform, and elements older than the buffer duration are discarded.

 

context.jpg

 

All input waveforms must have matching dt values. To eliminate drift in sample times, only the most recent trigger timestamp is considered; the trigger timestamp of the output waveform is computed from the most recently input trigger timestamp, the duration of the buffer, and dt. This may introduce jitter in sample times if the difference between the final timestamp of the previous input and the trigger timestamp of the next input are not exactly equal to dt. In this case, the timestamps of the most recent portion of the buffer will be correct, but earlier timestamps will be scaled. In buffered continuous acquisition, if no jitter is present in the acquisition, then all waveforms are consecutive and no jitter is introduced by this method.

 

The duration of the buffer may be larger than the requested duration if the duration is not an integer multiple of dt.

 

On first call, the input waveform fills end of the buffer; earlier values are set to zero, and the trigger timestamp is backdated. For performance reasons, buffer duration (s) is read only on first call.

 

Sample Code

 

The following VI continuously simulates a signal. Each iteration of the loop generates 50 samples, which are displayed on a waveform graph, and passed into the circular buffer VI. The output of the circular buffer is shown in an additional waveform graph.

 

example.jpg

 

See Also

 

This VI is similar to the Collector Express VI. Key differences are that the Collector Express VI uses dynamic data type instead of waveforms, it can handle multiple channels simultaneously, and it delays output until its buffer is full. The Collector Express VI does not align timestamps.

 

The Waveform Append VI allows for two waveforms to be appended, but it will discard timestamps from one of the waveforms, and does not implement a circular buffer.

 

There is also a circular buffer implementation for several datatypes in NI DevZone: http://zone.ni.com/devzone/cda/tut/p/id/7188

 

Versions

 

2010-10-06: 1.0 - Initial release

Contributors