LabVIEW Real-Time Control (NI-DAQmx)

The LabVIEW Real-Time Control (NI-DAQmx) sample project uses NI-DAQmx code to implement deterministic, software-based control of a plant. The control algorithm runs on a real-time controller that reads data from DAQ input channels and writes data to DAQ output channels. You send commands and setpoint changes to the control algorithm from the user interface that runs on a desktop computer. The real-time controller also monitors the status of the application, such as CPU load and memory usage.

Features

System Requirements

Development System

Real-Time Target, such as an NI PXI Chassis with a Real-Time Controller

Overview

This sample project consists of eight parallel loops on two execution targets. The following loops run in parallel on the desktop computer:

The following loops run in parallel on the real-time controller:

Running This Sample Project

  1. Ensure all devices are configured and connected to the same network as the development computer.
  2. In the Project Explorer window, add or discover your RT target to the to the top-level project item.
  3. Drag the following project items from the default RT target to the one you added in step 2:
  4. Delete the default RT target project item that no longer has any VIs associated with it.
  5. Customize the code in the following places to communicate with your DAQ device:
  6. In the Project Explorer window, run RT PXI Target»RT Main.vi. This VI deploys the program to the DAQ device. RT Main.vi now runs on the target device.
  7. Open and run My Computer»UI Main.vi.
  8. Enter the IP address of the RT controller in the Controller Address text box and click Connect.
  9. After you are connected, click either Run Control (on the Control Settings page) or Run Manual (on the Manual Settings page).
  10. Adjust the channel values as necessary and view the outputs on the Data Monitoring page. Until you define a control algorithm, all Control Output Values will read 0.

Modifying This Sample Project

Defining a Control Algorithm

Locate the Control (PID) subdiagram of the Case structure in RT Loop - DAQ Control.vi and modify this subdiagram to apply a control algorithm. For example, you can use the PID VI that is included with the NI LabVIEW PID & Fuzzy Logic Toolkit. By default, this algorithm returns a constant value of 0 on all output channels. You can perform a different algorithm on each individual channel.

Although this sample project is designed to implement a PID algorithm, you can modify the sample project to use any algorithm.

Defining Safe Values for Hardware Connected to the DAQ Device

The Safe Output Value in Global - Configuration Options.vi defines the value that is considered safe for the hardware connected to the output channels of the DAQ device. The Safe State, Default subdiagram of the Case structure in RT Loop - DAQ Control.vi writes this value to all DAQ output channels. By default, this safe state is a value of 0.

Configuring the Application

In the Project Explorer window, open My Computer»Globals»Global - Configuration Options.vi and configure the sample project settings.

Additional Resources

Refer to the LabVIEW Help, available by selecting Help»LabVIEW Help for information about LabVIEW concepts or objects used in this sample project. You can also use the Context Help window to learn basic information about LabVIEW objects as you move the cursor over each object. To display the Context Help window in LabVIEW, select Help»Show Context Help

Refer to ni.com for a developer walkthrough of the LabVIEW Real-Time sample projects.

This sample project is based on the Simple State Machine and Queued Message Handler templates. Refer to the Simple State Machine and Queued Message Handler templates and their documentation, available from the Create Project dialog box, for information about how these templates work.


Important Information

Copyright

© 2013 National Instruments. All rights reserved.

Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying, recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent of National Instruments Corporation.

National Instruments respects the intellectual property of others, and we ask our users to do the same. NI software is protected by copyright and other intellectual property laws. Where NI software may be used to reproduce software or other materials belonging to others, you may use NI software only to reproduce materials that you may reproduce in accordance with the terms of any applicable license or other legal restriction.

End-User License Agreements and Third-Party Legal Notices

You can find end-user license agreements (EULAs) and third-party legal notices in the following locations:

Trademarks

LabVIEW, National Instruments, NI, ni.com, the National Instruments corporate logo, and the Eagle logo are trademarks of National Instruments Corporation. Refer to the Trademark Information at ni.com/trademarks for other National Instruments trademarks.

Other product and company names mentioned herein are trademarks or trade names of their respective companies.

Patents

For patents covering the National Instruments products/technology, refer to the appropriate location: Help»Patents in your software, the patents.txt file on your media, or the National Instruments Patent Notice at ni.com/patents.