User manual

Chapter 4 NI-DAQ Double Buffering
NI-DAQ User Manual for PC Compatibles 4-2 ni.com
In double-buffered input operations, the data buffer is configured as a
circular buffer. For input operations, the DAQ device fills the circular
buffer with data. When the end of the buffer is reached, the device returns
to the beginning of the buffer and fills it with data again. This process
continues indefinitely until it is interrupted by a hardware error or cleared
by a function call.
Double-buffered output operations also use a circular buffer. In this case,
however, the DAQ device retrieves data from the circular buffer for output.
When the end of the buffer is reached, the device begins retrieving data
from the beginning of the buffer again.
Unlike single-buffered operations, double-buffered operations reuse
the same buffer and are therefore able to input or output an infinite number
of data points without requiring an infinite amount of memory. However,
for double buffering to be useful, there must be a means by which to access
the data for updating, storing, and processing. The next two sections
explain how to access the data for double-buffered input and output
operations.
Double-Buffered Input Operations
The data buffer for double-buffered input operations is configured as
a circular buffer. In addition, NI-DAQ logically divides the buffer into two
equal halves (no actual division exists in the buffer). By dividing the buffer
into two halves, NI-DAQ can coordinate user access to the data buffer with
the DAQ device. The coordination scheme is simpleNI-DAQ copies data
from the circular buffer in sequential halves to a transfer buffer you create.
You can process or store the data in the transfer buffer however you choose.