[ Prev ] [ Index ] [ Next ]

Logging data to disk using queue in LabVIEW

Created Monday 13 February 2017

./data_log.vi

Functional Description

This VI file shows you how to log data at high sampling rate.

Introduction

In real application, high sampling rate is often necessary. The problem comes when we want to log the data to disk. Writing data to disk is an expensive process. Data logging will deteorate our main process if we put data logging in our main loop.
The solution we can use in this problem is by separating our main process with data logging process. So, we will have two loops. Our main process loop will write the data to the queue (enqueue), while data logging loop will fetch the data from the queue (dequeue) and write it to disk. When we click stop button, we can see that the whole process will not stop directly unless all the data in queue have all been written to disk. Using this method we can maintain the sampling rate for our main process.
The negative effect we might encounter is: if we run our process for certain long time, we may have memory full problem, since writing data to memory is faster then fetching the data.
In the follwong picture, we can see two loops. One loop is running at 1KHz (loop for main process) while another loop is running at 0.5KHz (loop for data logging). In loop for data logging, we must make sure that our queue is empty before stopping the whole program.