Programming instructions

Chapter 6 One-Stop Single-Point Acquisition
©
National Instruments Corporation 6-9 LabVIEW Data Acquisition Basics Manual
acquisition at the
loop rate
(scan rate) parameter. On the first iteration of
the loop, the AI Single Scan VI reads the newest data in the FIFO. Some
data may have been acquired between the execution of the AI Start and the
AI Single Scan VIs. On the first iteration of the loop, the application reads
the latest data acquired between the AI Start and the AI Single Scan VIs.
On every subsequent iteration of the loop, the application reads the oldest
data in the FIFO, which is the next acquired point in the FIFO.
If more than one value was stored in the DAQ device FIFO when you read
it, your application was not able to keep up with the control loop acquisition
and you have not responded with one control loop interval. This eventually
leads to an error condition, which makes the loops complete. After the
application completes analog acquisition and generation, then the AI Clear
VI clears the analog input task.
Figure 6-8 also includes a waveform chart in the control loop. This reduces
your maximum loop rate. You can speed up the maximum rate of the
control loop by removing this graph indicator.
You easily can add other processing to your analog I/O control loop by
putting the analog input, control loop calculations and analog output in
the first frame of a sequence inside the loop, and additional processing in
subsequent frames of the sequence. Keep in mind that this additional
processing must be less than your control loop interval. Otherwise, you will
not be able to keep up with your control loop rate.
Improving Control Loop Performance
There are some performance issues you should take into account if you plan
to have other VIs or loops execute in parallel with your hardware-timed
control loop. When you call the AI Single Scan VI in a hardware-timed
control loop, the VI waits until the next scan is acquired before returning,
which means that the CPU is waiting inside the NI-DAQ driver until the
scan is acquired. Consequently, if you try to run other LabVIEW VIs or
while loops in the same diagram in parallel with your hardware-timed
control loop, they may run more slowly or intermittently. You can reduce
this problem by putting a software delay (with the Wait (ms) VI) at the end
of your loop after you write your analog output values. Your other
LabVIEW VIs and loops can then execute during this time.
Another good technique is to poll for your analog input without waiting
in the driver. You can set the AI Single Scan VI
time limit in sec
to
zero. Then, the VI reads the DAQ Device FIFO and returns immediately,
regardless of whether the next scan was acquired. The AI Single Scan VI
scaled data
output array is empty if the scan was not yet acquired. Poll for