This example implements a continuous simultaneous analog input and analog output operation on the 9002/4 CompactRIO controller. Analog input is performed on a NI 9215 module, while analog output is performed on a NI 9263 module.
The analog input data is streamed from the FPGA to the RT controller using a DMA FIFO. The DMA FIFO is configured in the LV project. In the RT host VI, a DMA buffer is configured which receives the data from the DMA FIFO on the FPGA. Blocks of AI data read from the DMA buffer are displayed on a waveform graph.
The analog output data is streamed from RT to the FPGA using the FPGA host interface read/write node (register I/O). A FIFO is configured on the FPGA to buffer the AO data. The AO FIFO has 8192 elements. We will consider this to be a 8000 element buffer. From the RT host VI we write data in blocks to the AO FIFO on the FPGA. At the beginning of the VI we fill the AO FIFO once completely (8000 writes). Once the AO operation is started, the FPGA notifies the RT host whenever half the data in the buffer has been read and sent to the analog output. On this notification the RT host writes another half buffer worth of data to the AO FIFO (4000 writes).
In the RT host VI we simultaneously read data from the DMA buffer and check the AO operation for the next half buffer write operation. Neither of these operation can occupy the RT to FPGA interface for an extended period of time as otherwise the other operation would miss a necessary update. Therefore the timeout on the DMA read function is set to a small value (10 ms).
In this example the analog output waveform is defined in an array constant. This data could be read from a file or be generated using LabVIEW analysis VIs.
This example does not use cRIO calibration which would normally be part of an application. Therefore all data in this example is handled as binary values.
The cRIO-9002 and 9004 controllers do not support DMA data streaming from the RT host VI to the FPGA, which is the reason that the analog output stream is implemented using register I/O and a regular FIFO on the FPGA. The cRIO-9012 and 9014 controllers do support DMA streaming from the RT VI to the FPGA and the AO portion of the example could be changed to use DMA on these controllers.
Note: The ciosimaio85.zip example is updated for LabVIEW 8.5 and corrected some earlier issues in the code mistake.