LabVIEW Data Acquisition: Capturing the First and Last Data Point

Updated Jul 27, 2022

Reported In


  • LabVIEW

Issue Details

I am collecting a random length of data samples during data acquisition but I only need to capture the first and last data point. How can I do this in the most efficient way possible? 


While capturing data varies depending on what hardware you are using, a similar method can be used to capture the first and last data point.

The example code shown below is simulating acquisition from a communications card acquiring random samples. The card collects samples until the program is stopped and then the code outputs the first and last data points.

The program is made of 2 VIs. The first VI, 'Main VI', and contains the data acquisition card (represented by a random number generator), timing for the acquisition and the current data point. The second VI, 'Capture First Data Point VI', captures the first data point.
[Image 1: Main VI Block Diagram]

[Image 2: Capture First Point VI Block Diagram]

Additional Information

How does the Capture First Point VI work?

The VI used 3 main functions to capture the first data point: Shift Registers, Equals? and Switch. The VI takes input from the Data Acquisition Device, the While Loop Iteration (from the Main VI) and the Previous Shift Register Iteration.
  • Shift registers (boxes with arrows inside on the edge of loops) are similar to static variables in text-based programming languages and are used to pass values from one loop iteration to the next. This VI uses shift registers as a way of capturing the first data point and continually passing it throughout each iteration of the loop. On the first iteration of the loop, the initial value from the shift register is zero.
  • The Equals? function (yellow triangle with equals sign inside it) is taken from the comparisons palette and is used to check what iteration the while loop is currently on. When a while loop runs for the first time, the output from the iteration terminal is zero. The Equals? functions checks to see if the loop is on its first iteration (if the Loop Iteration is zero) and outputs a Boolean true/false value.
  • Finally, the Switch function (yellow triangle with a T, F and ? inside of it) is also taken from the comparisons palette and is used to switch the value of the output between value above threshold and value below threshold based on the value of the control input. In the specific case of this code, the switch function will output either the Shift Register Value or the Data Value based on the true/false value outputted from the Equals? function.