Programming instructions

Chapter 7 Buffering Your Way through Waveform Acquisition
LabVIEW Data Acquisition Basics Manual 7-10
©
National Instruments Corporation
Because of the buffer maintenance, you can only use the Intermediate or
Advanced VIs with this type of data acquisition.
While a circular buffer works well in many applications, there are two
possible problems that can occur with this type of acquisition: your VI
could try to retrieve data from the buffer faster than data is placed into it,
or your VI might not retrieve data from the buffer fast enough before
LabVIEW overwrites the data into the buffer. When your VI tries to read
data from the buffer that has not yet been collected, LabVIEW waits for the
data your VI requested to be acquired and then returns the data. If your VI
does not read the data from the circular buffer fast enough, the VI sends
back an error, advising you that the data that you retrieved from the buffer
is overwritten data.
Continuously Acquiring Data from Multiple Channels
You can acquire time-sampled data continuously from one or more
channels with the Intermediate VIs. An example using these VIs is the
Acquire & Process N Scans VI, found in
labview\examples\daq\
anlogin\anlogin.llb
. This example is shown in Figure 7-10. There
are inputs for setting the channels, size of the circular buffer, scan rate, and
the number of samples to retrieve from the circular buffer each time. This
VI defaults to a
input buffer size
of 2,000 samples and 1,000
number of
scans to read at a time
, which means the VI reads in half of the buffer’s
data while the VI fills the second half of the buffer with new data.
Note
The number of scans to read can be any number less than the input buffer size.
If you do not retrieve data from the circular buffer fast enough, your unread
data will be overwritten by newer data. You can resolve this problem in one
of three ways: by adjusting the
input buffer size
,
scan rate
, or the
number
of scans to read at a time
parameters. If your program overwrites data in
the buffer, then data is coming into the buffer faster than your VI can read
all of the previous buffer data, and LabVIEW returns an error code
–10846
overWriteError
. You can increase the size of the buffer so that it takes
longer to fill up, which leaves your VI with more time to read data from it.
If you slow down the
scan rate
, you reduce the speed at which the buffer
fills up, which also leaves more time for your program to retrieve data.
You can also increase the
number of scans to read at a time
, which will
retrieve more data out of the buffer each time and effectively reduce the
number of times to access the buffer before it becomes full. Check the
output
scan backlog
to see how many data values remain in the circular
buffer after the read.