Designing Control Applications with Data Acquisition Hardware and NI-DAQmx

Overview

Data acquisition (DAQ) hardware adds inputs and outputs (I/O) to standard laptop and desktop computers, turning a general-purpose PC into a flexible, high-performance control system. Some DAQ hardware includes an embedded controller, with fully featured operating systems designed for data acquisition. By taking advantage of the fast pace of standard computing technology improvements, you can achieve progressively faster processing, more memory, larger hard drives, and graphics displays for system visualization at increasingly lower costs. If you need to control the temperature of a room, the speed of a motor, or the pressure of hydraulic fluids, you can use data acquisition hardware and the NI-DAQmx API to connect sensors and actuators to your computer and build the exact control system for your application needs.

This white paper compares the NI data acquisition systems that can be used in control applications, and explains key functions and concepts when building a control application with NI-DAQmx. It also introduces some hardware/software combinations that can be used in more advanced control applications, which require faster control loop rates or higher determinism.

Contents

Data Acquisition Hardware to Match Your Application Requirements

With hundreds of hardware options to choose from, you have several factors to consider when selecting the right data acquisition (DAQ) device for a control application. First, you should understand the channel count, data type, filtering and signal conditioning needs for the sensors you would like to use in your data acquisition application. Next, you’ll need to know the performance you need from your DAQ device: the accuracy, resolution, determinism, and latency needed to acquire clear signals at appropriate sample rates. This will inform which DAQ platform you should choose.

Once your I/O is fully understood, you can select the right hardware platform for your application. All the systems below can be programmed using the NI-DAQmx API, to access data and perform control quickly and easily.

PC-Based Measurement and Control Systems

PC-Based Measurement & Control Systems provide electrical and physical measurement capabilities for engineers who need a customizable and accurate, yet cost effective way of conducting benchtop measurements. Use USB or Ethernet to connect NI hardware products to your PC or laptop to create a PC-based measurement or control system. See NI’s low-cost DAQ offerings to learn more about DAQ devices, or explore all USB, Ethernet and PCI Multifunction DAQ Devices.

CompactDAQ Systems

CompactDAQ provides a customizable solution for engineers to perform electrical and physical measurements either at their benchtop or in a distributed architecture. In a CompactDAQ system, a chassis is connected to your PC via USB or Ethernet, then populated with one or more conditioned I/O modules that provide direct sensor connectivity. Ethernet chassis can be synchronized to create a distributed system. Click here to learn more about CompactDAQ, or use our online advisor to configure a CompactDAQ system.

CompactRIO Systems

CompactRIO provides high-performance processing capabilities, sensor-specific conditioned I/O and a closely integrated software toolchain that make it ideal in industrial IoT, monitoring, and control applications. In a CompactRIO system, a controller with a processor and user-programmable FPGA is populated with one or more conditioned I/O modules from NI or third-party vendors. These modules provide direct sensor connectivity and specialty functions. CompactRIO is available in both a rugged industrial form factor and board level design. The CompactRIO 904x introduced support for NI-DAQmx – older CompactRIO models will use LabVIEW Real-Time and/or LabVIEW FPGA to perform control. Click here to learn more about CompactRIO, or use our online advisor to configure a CompactRIO system.

PXI Systems

PXI systems provide high-performance I/O modules that feature specialized synchronization and key software features for test and measurement applications from device validation to manufacturing test. In a PXI system, a chassis provides power, cooling, and a communication bus for the instrumentation or I/O modules that populate it. You can control these modules from either an embedded controller or an external PC, leveraging one or several of NI's specialized engineering software tools to customize your system. Click here to learn more about PXI, or use our online advisor to configure a PXI system.

 Figure 1. NI DAQ Systems, including USB DAQ (center), CompactDAQ (front left), CompactRIO (right), and PXI (back left).

 

Graphical Programming with LabVIEW and NI-DAQmx

NI-DAQmx, the driver software used to communicate with NI DAQ measurement devices, is included with more than 200 National Instruments data acquisition devices. NI-DAQmx has support for multiple programming languages including NI LabVIEW, LabWindows™/CVI, ANSI C/C++, Visual Basic 6.0, and C#/Visual Basic .NET. For control applications, NI-DAQmx has specific deterministic features like hardware-timed single-point function calls and support for LabVIEW Real-Time operating systems.

This white paper will focus on using the NI-DAQmx driver with LabVIEW. LabVIEW graphical programming software offers an easy-to-use application development environment designed specifically for the needs of engineers and scientists. Without any prior programming experience, you can configure your hardware, take sensor measurements, compare the measured value to the desired setpoint, and update output signals. The NI-DAQmx driver provides graphical functions to read and write values and directly interact with hardware I/O. LabVIEW delivers the best integration between software and hardware, reducing the overall programming complexity and saving you development time.

 Figure 2. NI-DAQmx Read and Write functions.

 

The NI-DAQmx application programming interface (API) is completely scalable from simple ON/OFF control to PID and other advanced control algorithms. The following few sections offer examples of the graphical programming required to implement various control systems.

 

LabVIEW and NI-DAQmx: ON/OFF Control

A feedback control system can be as simple as taking a measurement, comparing the measured value with the desired value, and then turning an actuator on or off to get closer to the desired value. This typically involves driving a relay or switch that controls the power flowing to an actuator. Everyday air conditioning systems, for example, work in this manner. A temperature reading device (usually your thermostat) monitors the current temperature and engages a relay or switch if the temperature exceeds the desired value. The relay turns the air conditioning unit on until the temperature returns to a comfortable level.

Figure 3 shows an example of a LabVIEW block diagram for creating a basic on/off control system. The DAQmx Read.vi function takes a temperature reading, and the temperature value is compared to the Setpoint value using the Greater? function. If the temperature is greater than the Setpoint value, a TRUE value is sent to the digital output channel controlling the relay with the DAQmx Write.vi function.

 Figure 3. Example block diagram of an ON/OFF control system.

 

Many buildings have both an air conditioner and a heater to help regulate the temperature of a room. While cooling and heating are typically done independently, you can use a PC-based data acquisition system to operate both simultaneously.

Figure 4 shows an example of a LabVIEW block diagram for controlling both cooling and heating. In this block diagram, the measured temperature value is compared to two different setpoints, each connected to either the air conditioner or the heater.

 Figure 4. Example block diagram of an ON/OFF control system with two outputs.

 

With additional logic, you can customize the control system even further and add features such as setpoint scheduling, temperature averaging, and dead band configuration. You can also add data-logging and report generation capabilities to the same PC-based control system.

 

LabVIEW and NI-DAQmx: PID Control

Simple on/off control may not provide enough granularity to accurately control a particular system with the required speed and precision. Proportional integral derivative (PID) control is the most common control algorithm used in industry. The popularity of PID controllers can be attributed to their robust performance in a wide range of operating conditions as well as their simple, straightforward manner of operation. LabVIEW features a PID Control Toolkit that you can use to install prebuilt graphical functions to easily implement a PID control system. The basic PID.vi function is shown in Figure 5.

 Figure 5. Graphical PID function from the LabVIEW PID Toolkit.

 

As the name suggests, the PID algorithm consists of three basic coefficients, proportional, integral, and derivative, which you can adjust to get optimal response. The basic idea behind a PID controller is to read a sensor and compute the desired actuator output by calculating proportional, integral, and derivative responses. The controller takes the sum of these three components to compute the output. Figure 6 shows an example block diagram with a PID control loop using one analog input channel and one analog output channel.

 Figure 6. Analog I/O control application with the PID function circled in red.

 

LabVIEW and NI-DAQmx: Advanced Control with the LabVIEW Control Design and Simulation Module

Beyond PID control, there are several advanced control systems based on the state-space model of a plant and several custom control parameters based on the desired system response. Designing such a control system requires knowledge and experience in control systems theory. You can use the LabVIEW Control Design and Simulation Module, which is included with LabVIEW Professional, for applications that require this level of sophistication. This software can help you test and iterate on a newly designed control algorithm, which can save you considerable time and resources when trying to prototype and validate an advanced control system.


 Figure 7. The LabVIEW Control Design and Simulation Module offers a graphical programming environment and advanced API with real hardware I/O for designing a controller.

 

Increased Determinism and Faster Control Loops with LabVIEW Real-Time and LabVIEW FPGA

NI-DAQmx is a powerful API for data acquisition and control applications, but some applications call for more determinism, lower latency, and faster control loops than DAQmx can provide. A real-time operating system (RTOS) provides the maximum level of software determinism and reliability for control systems by dedicating all resources to a deployed application. CompactRIO and PXI controllers can make use of this real-time OS for advanced determinism with the LabVIEW Real-Time Module, an add-on for LabVIEW. When installed, this software compiles LabVIEW graphical code and optimizes it for the selected real-time target. Using the LabVIEW Real-Time Module, you can develop and deploy applications to all NI real-time hardware targets including standard desktop PCs and PXI systems. With the NI-DAQmx driver software, you can easily migrate PCI, PCI Express, and PXI platform devices from LabVIEW for Windows to LabVIEW Real-Time on CompactRIO or PXI and retain the same function calls and hardware configuration.

For applications that require even higher-performance control loops with hardware-timed speed and reliability, consider using the LabVIEW FPGA Module with CompactRIO or multifunction reconfigurable devices. FPGAs are reconfigurable silicon chips that you can program with the same LabVIEW graphical development environment. CompactRIO and reconfigurable devices feature user-defined onboard processing as well as completely flexible I/O timing and triggering. You can configure device functionality by creating LabVIEW block diagrams with the LabVIEW FPGA Module. Your block diagram executes in hardware, giving you direct, immediate control of all I/O signals without needing to communicate with a processor. With CompactRIO and reconfigurable devices, you can create multiple PID control loops that execute at speeds up to the MHz range.

 Figure 8. RIO's heterogeneous architecture combines the determinism of a real-time OS with the advanced control and processing of an FPGA.

 

The combination of LabVIEW Real-Time and LabVIEW FPGA offers unsurpassed advantages in any high performance embedded control application. For more information on FPGA-based data acquisition devices, learn more about CompactRIO and R Series Multifunction RIO.

Take the Next Step

The trademark LabWindows is used under a license from Microsoft Corporation. Windows is a registered trademark of Microsoft Corporation in the United States and other countries.