Getting Started with Deterministic Distributed I/O Systems
Overview
This tutorial provides step-by-step instructions to help you set up your deterministic distributed I/O system using the NI 9144 eight-slot expansion chassis for NI C Series modules. Follow these guidelines to go from unpacking your hardware to accessing I/O in NI LabVIEW software.
For more details on how to get up and running with the NI 9144, see the official NI 9144 Getting Started Guide.
Table of Contents
Requirements
Hardware
• LabVIEW Real-Time controller with two Ethernet ports, such as CompactRIO, PXI, and NI industrial controller
• NI 9144 expansion chassis
• C Series I/O modules
• Ethernet cable
Software
| Software | Version for Programming in LabVIEW Real-Time Only | Version for Programming in LabVIEW Real-Time and LabVIEW FPGA |
| LabVIEW | 8.6 or later | 2009 or later |
| LabVIEW Real-Time Module | 8.6 or later | 2009 or later |
| LabVIEW FPGA Module | – | 2009 or later |
| NI-RIO driver software | 3.0.1 or later | 3.2 or later |
| NI-Industrial Communications for EtherCAT driver software | 1.0 or later | 1.1 or later |
Setting Up the Hardware
This tutorial uses an NI cRIO-9074 as the LabVIEW Real-Time controller. To set up this hardware system, follow these steps:
- Insert the C Series I/O modules in the appropriate chassis (the CompactRIO local chassis and/or the NI 9144 chassis).
- Connect a standard Category 5 or better Ethernet cable from cRIO-9074 Ethernet Port 2 to NI 9144 Ethernet Port 1. You may daisy chain multiple NI 9144 chassis from the controller in this manner.
Note: Port 1 on the cRIO-9074 is on the bottom. Port 1 on the NI 9144 is on the top.
Figure 1. Connecting the Ethernet Ports on the Master Controller and NI 9144
- Wire an external power supply to each chassis, which then powers on the hardware.
Related Links
Getting Started with CompactRIO and LabVIEW
Configuring the Master Controller
- Once you have connected the hardware, install the required software on the host computer.
- Use an Ethernet cable to connect cRIO-9074 Ethernet Port 1 to the same network as your host PC.
- Launch the NI Measurement & Automation Explorer (MAX) configuration utility from Start»Programs»National Instruments»Measurement & Automation. Double-click on Remote Systems in the Configuration panel tree on the left to autodiscover the cRIO-9074 on the network, and click on the CompactRIO controller.
- Change the name of the controller and select Obtain IP address from DHCP server under IP Settings. Click Reboot when you are done. (To use a static IP address, see the related links below.)
Figure 2. Setting the IP Address for the Real-Time Controller
- To install the software on the real-time controller, expand the cRIO-9074 under Remote Systems. Right-click Software and select Add/Remove Software.
Figure 3. Installing Software on the Real-Time Controller
- Install the recommended software set – NI-RIO driver software with the NI Scan Engine as well as NI-Industrial Communications for EtherCAT driver software – onto the CompactRIO controller.
- Once the controller has rebooted, find the CompactRIO controller under Remote Systems again. Click on Advanced Ethernet Settings in the lower right-hand corner.
- Select cRIO-9074 Ethernet Port 2 (the MAC address that is not primary). Then select EtherCAT in the drop-down box under Mode and click OK.
Figure 4. Selecting EtherCAT Mode for the Ethernet Port of the Real-Time Controller
Note: When the controller’s Ethernet Port 2 is in EtherCAT mode, you cannot use that port in an Ethernet network.
Related Links
Troubleshooting CompactRIO Controllers in Measurement & Automation Explorer
Configuring the Network in LabVIEW
- Launch LabVIEW from Start»Programs»National Instruments»LabVIEW X.X»LabVIEW. Click on Empty Project.
- Right-click on Project and select New»Targets and Devices.
- In the Add Targets and Devices dialog window, select Existing target or device and expand the category Real-Time CompactRIO to autodiscover the controller on the host PC’s subnet. Select the cRIO-9074 and click OK.
- In the LabVIEW Project window, right-click on the cRIO-9074 and select New»Targets and Devices.
Figure 5. Using LabVIEW to Discover Controllers Connected to the Network
- In the Add Targets and Devices dialog window, select Existing target or device and expand the category EtherCAT Master Device to autodiscover the EtherCAT port on the controller.
Figure 6. Selecting the EtherCAT Master Port on the Real-Time Controller
- Select the available EtherCAT master port and click OK. The Scan Slaves dialog window appears. The first option Scan Interface autodiscovers any slaves connected to the controller. Click OK. The LabVIEW Project now lists each slave device, its I/O modules, and the physical I/O on each module (called I/O variables).
- Once all the slaves have been autodiscovered, you may create a VI on the CompactRIO controller. To program the NI 9144 in LabVIEW Real-Time, click and drag the I/O variables from the LabVIEW Project to the block diagram. With these I/O variables, you can read and write from physical channels in the NI 9144 chassis.
Figure 7. Dragging I/O Variables from the LabVIEW Project to the Block Diagram
If you use the I/O variables in a timed loop, you can synchronize the loop timing source to the NI Scan Engine. When you run the VI, the program automatically deploys onto the CompactRIO target. For more information about the LabVIEW I/O variable and CompactRIO Scan Mode, see the related links below.
Related Links
Introduction to CompactRIO Scan Mode
Adding Third-Party EtherCAT Slaves in LabVIEW
Programming the NI 9144 FPGA in LabVIEW FPGA
The program written in LabVIEW Real-Time is deployed to the master controller, which is responsible for collecting, processing, and controlling the I/O in the EtherCAT network. Additionally, each NI 9144 chassis contains an embedded field-programmable gate array (FPGA) that can execute custom timing and signal processing to help you create intelligent distributed devices that are synchronized within 100 ns of each other. To take advantage of the programmable FPGA capabilities, you must use LabVIEW, LabVIEW Real-Time, and LabVIEW FPGA 2009 or later.
- When you add the EtherCAT Master Device to the LabVIEW Project (see step 5 in the previous section), you can either set up the NI 9144 to program in the NI Scan Interface or LabVIEW FPGA Interface. If you select the former, you can still program in LabVIEW FPGA by right-clicking on Device (Address 0, NI 9144) in the LabVIEW Project window and selecting New»FPGA Target.
[+] Enlarge Image
Figure 8. Discovering the FPGA Target on the NI 9144
- In the LabVIEW Project, the NI 9144 chassis features several FPGA signals. For example, Input Virtual Point and Output Virtual Point are digital timing signals used to synchronize FPGA code between different NI 9144 chassis. To program a module in LabVIEW FPGA Mode, drag and drop the module from Device (Address 0, NI 9144) onto the FPGA Target (NI 9144). In the Project Explorer window, you can drag and drop modules between Device and the FPGA Target to switch between Scan Mode and FPGA Mode.
Figure 9. Chassis I/O and Module I/O Listed under the FPGA Target
- In the LabVIEW Project Explorer window, right-click on FPGA Target (NI 9144) in the LabVIEW Project and select New»VI to create a new FPGA VI on the NI 9144. The FPGA I/O channels from modules listed under FPGA Target (NI 9144) can be dragged and dropped into the block diagram of this new FPGA VI.
Differences in the LabVIEW FPGA Programming API
If you are familiar with programming in LabVIEW FPGA for CompactRIO and other NI RIO platforms, there are some differences between programming the local FPGA and the FPGA for expansion I/O. Since LabVIEW 2009, user-defined I/O variables are used to synchronize FPGA data with the Scan Engine. These user-defined I/O variables are also the only means for transferring data between the controller’s real-time VI and the 9144 expansion chassis’ FPGA VI.
| FPGA Transfer Methods | Local Chassis | Expansion Chassis |
| User-defined I/O variables | √ | √ |
| FPGA Host Interface | √ | x |
| DMA transfer functions | √ | x |
| FPGA front panel debugging | √ | x |
- Program the FPGA VI by selecting the FPGA I/O nodes from the LabVIEW Project and dragging them onto the FPGA block diagram. In this example, a PID function was used to control analog I/O in the NI 9144.
Figure 10. Example FPGA code on the NI 9144
- Note the Reset FPGA PID Boolean variable. This is a user-defined I/O variable that allows the real-time VI on the master controller to communicate with the FPGA VI on the NI 9144. To create such a variable, right-click on Device (Address 0, NI 9144) in the LabVIEW Project and select New»User-Defined Variable. The variable name, data type, and data direction (from Host to FPGA or vice versa) may be set from the Properties window. In this case, the controller is sending information to the NI 9144, so the direction is Host to FPGA.
[+] Enlarge ImageFigure 11. Dialogue Window for Creating a User-Defined I/O Variable
You can now program the user-defined I/O variable in the real-time VI, used in this example to reset the PID function running in the FPGA VI.
- To run the FPGA VI, right-click on the cRIO-9074 in the LabVIEW Project and select Deploy All to deploy the NI 9144 chassis. Put the scan engine into Configuration Mode by right clicking the CompactRIO controller and selecting Utilities»Scan Engine Mode»Switch to Configuration and click the Run button on the FPGA VI. This will start the compile process and will download the FPGA bit file to the NI 9144 chassis. Once you have successfully downloaded the bit file to the NI 9144, the FPGA VI begins executing immediately.
Note: You may need to update the firmware on your chassis to run custom FPGA code. If you get an error message stating that your firmware needs to be updated follow the instructions in the NI-9144 User Guide under the Updating Your Firmware section. The user guide can be found by searching on ni.com or you can follow this link.
- When the compile and download process completes you need to set your scan engine back into active mode before the FPGA VI will begin executing. To do so right click your CompactRIO controller and select Utilities»Scan Engine Mode»Switch to Active.
An important note is that there is a limit to the number of user-defined I/O variables that can be created in FPGA Mode. The NI 9144 can hold a total of 512 bytes of input data and 512 bytes of output data for both I/O variables in Scan Mode and user-defined I/O variables in FPGA Mode. For example, if you are using four 32-channel modules in Scan Mode and each channel takes up 32 bits of data, then 256 bytes of input data are being used by Scan Mode I/O variables. With the remaining 256 bytes of input data, you can create 64 input user-defined I/O variables (also of 32-bit length) in FPGA Mode.
For a detailed manual of how to set up and program the NI 9144, see the NI 9144 Getting Started Guide.
Related Links:
CompactRIO Advisor
NI 9144 Getting Started Guide
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial 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 content with each new revision of related products and drivers. THIS TUTORIAL 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/).
