Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Example Program
NI Supported: Yes
Publish Date: Sep 6, 2006

Hardware-Timed Analog I/O Control Loop

3 ratings | 5.00 out of 5
Print

Downloads

Filename: 3639.zip
Requirements: View

"Analog IO Control Loop (hw timed)" demonstrates a hardware-timed analog I/O control loop. With hardware timing, you can go faster than the rates provided by the LabVIEW timing functions. With hardware timing the scan clock on the board is started and acquires data into the on-board FIFO. Acquired scans are read directly from the FIFO using AI Single Scan. AO Write One Update is called to update analog output channels 0 and 1. Each scan is also plotted on a sweep chart after it is read. This VI uses error chaining and the General Error Handler VI. The chart display is a sweep chart, which is faster than a strip chart, but the chart can be removed for faster performance.

The acquisition is configured with no buffer, and the on-board scan clock is started at the selected scan rate. In the first loop iteration, the newest (most recent) scan is read from the FIFO. In each subsequent loop iteration AI Single Scan is called to read the oldest scan from the FIFO. Then if a scan is missed because the acquisition does not keep up, an error message will be displayed, and the acquisition stopped. AO Write One Update configures the hardware only on the first iteration of the loop since "i" is hooked up to it. This improves the control loop timing.
This example uses the lower level intermediate functions: AI Config, AI Start, AI Single Scan, AI Clear and the intermediate function AO Write One Update.

Before running this VI, set the values of the controls on the front panel. Select Show Help Window from the Help menu to see a description of each control. If the values you select for all the controls are values you will usually use, select Make Current Values Default from the Operate menu and save the VI. Or, you may save individual control's default values by popping up on the control, selecting Data Operations, then selecting Make Current Value Default, and saving the VI.

To modify this VI:
- A dummy processing VI "My Control Calc" is executed for each analog output channel, you should substitute your control VI here.
- To modify/expand error handling: Take advantage of the error cluster. The error cluster chained between VIs is simply a cluster of:
"status", type Boolean: True=error, False=no error (or warning);
"code", type I32: NI-DAQ error or warning code;
"source", type string: name of error source;

In this example, the loop is terminated if any error occurs. The error cluster along with the task ID forces control flow between the subVIs. If you add any processing subVI that might produce its own errors, give it an error cluster input and output and insert it into this chain. The VI "My Data Processing" in the analog input examples demonstrates how to use the error cluster in a subVI.

Requirements


Filename: 3639.zip

Software Requirements


Application Software: LabVIEW Full Development System 5.0.1
Language(s): LabVIEW

Hardware Requirements


Hardware Group: Multifunction DAQ (MIO)
Driver: Traditional NI-DAQ (Legacy)

 
3 ratings | 5.00 out of 5
Print

Reader Comments | Submit a comment »

 

Legal
This example program (this "program") was developed by a National Instruments ("NI") Applications Engineer. Although technical support of this program may be made available by National Instruments, this program may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this program with each new revision of related products and drivers. THIS EXAMPLE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).