Using the LabVIEW Real-Time Communication Wizard
Overview
This paper examines the LabVIEW Real-Time Communication Wizard and the different networking protocols available. Engineers can use the concepts presented in this paper to determine which protocol best fits their application needs. In additon, LabVIEW 8.0 introduce the LabVIEW Real-Time Project Wizard which can be found on the Getting Started page of LabVIEW. The Project Wizard is designed to help you get started with the LabVIEW project as well as provide you with a starting template so that you being to write you code with the proper architecture. Although the Real-Time Communication Wizard is still available, starting from the approriate architecture is recommend.
Table of Contents
Introduction
When programming an application with the LabVIEW Real-Time Module, certain factors must be considered in order to achieve the desired deterministic behavior. The general program architecture for a deployed application is shown below in Figure 1. The code running on the Real-Time (RT) Target (a VI or an executable) is divided into two loops: the control loop and the communication loop. These loops run in separate threads at different priorities. The Time-Critical Loop contains the deterministic, control code and is set to the highest execution priority. The Normal Priority Communication Loop contains the network communication code that communicates between the RT Engine and an application running on a host machine. The Normal Priority Communication Loop is set to normal priority so that it does not interfere with the execution of the code that is desired to be deterministic. These two loops running on the RT Engine pass data back and forth through some means of inter-thread communication such as RT FIFOs. The target and the host can communicate through a variety of different networking protocols.In order to easily and quickly develop an application with this architecture, the RT Communication Wizard was introduced in the LabVIEW 7 Real-Time Module. You simply create a VI containing the code for the Time-Critical loop on the RT Engine and the wizard will generate a fully functional suite of VIs, including the VIs for the normal priority communication loop and the host computer.
Using the RT Communication Wizard
There are three steps to using the RT Communication Wizard. The first step is to select a VI and the communication method as shown in Figure 2. A VI may be selected by typing in the file path or by clicking the browse button with the folder icon. Next, the communication method must be selected. The details about available communication methods will be discussed later in this document. Depending on the method selected, different configuration parameters will be available.
The second step is to select which controls and indicators should be replaced with inter-thread communication [Figure 2.] The RT Communication Wizard uses RT FIFOs for inter-thread communication. You can select or deselect controls or indicators using the check boxes. Also, you can set the name and size of the FIFOs that the VI will create.
The third step is to specify the directories and names of the VIs that the wizard will create [Figure 4.] The wizard will create VIs for the Normal Priority Loop, the Time Critical Loop, and the Host Loop. The Normal Priority Loop VI contains the Time Critical Loop VI as a subVI so that when the Normal Priority Loop VI is downloaded and run, the Time Critical Loop VI is also downloaded and run. Since the Time Critical Loop VI is set to a higher priority, it will run in a different thread at high priority.
The RT Communication Wizard will create a basic set of VIs with the appropriate architecture and communication functions. The VIs that it creates will execute without any further modification. Users may also modify the code that was generated as needed.
Note: In LabVIEW 8.0 and later we introduced the RT project wizard. This is a great utility to use if you are beginning to program with LabVIEW Real-Time. The wizard allows you to choose from different communication architectures, add Real-Time targets, and other application files. Based on the selection you make, the wizard develops template VI's that you can add code to. Refer to the help in the following links for more information on the Real-Time project wizard.
You could use network process shared variables with LabVIEW 8.0 and later. Shared variable can share data between VI's across the network. It uses the NI-PSP protocol that is built over UDP. You can enable RT-FIFO's in the shared variables and perform deterministic transfer between the targets and back to the host. Refer to the link below for information on using shared variables.
See Also:
Real-Time Project Wizard
Shared Variables
Using the LabVIEW Shared Variable
Creating a Shared Variable with Real-Time FIFO
Selecting Between Ethernet Communication Methods
TCP/IP
All LabVIEW Real-Time target platforms are capable of TCP/IP communication. TCP is an industry-standard network communication protocol which is connection based. TCP is a good protocol to use when transferring large amounts of data between systems because it is fast and lossless. Since TCP is a connection-based protocol, a separate connection must be programmatically opened for each system to which communication is desired, making it more complicated to open connections to multiple host applications at once. The RT Communication Wizard generates VIs for communication to a single host machine at a time. Other communication protocols provide a simpler solution for communication with multiple systems simultaneously.
The RT Communication Wizard makes TCP much easier to use by providing subVIs which handle the packaging, transmission, reception, and unpacking of data. The programming of TCP communication in LabVIEW Real-Time utilizes the same VI’s and techniques used for programming TCP on LabVIEW for the PC.
TCP Properties
· Fast, lossless data transfer
· Third-party host applications supported
· Multiple connections must be programmed
· LabVIEW Real-Time Targets: PXI, Compact FieldPoint, FieldPoint, and PCI-7041/6030E
UDP
Similar to TCP, UDP is an industry-standard network communication protocol which is available on all of the LabVIEW Real-Time target platforms. With UDP, data is either read from a specified port or data is written from a specified port to a port at a specific IP address. It can be used to send information to a port at a single IP address or to broadcast information to a range of IP addresses on the subnet at once. For bi-directional data transfers, both computers specify a read and write port and transmit data back and forth using the specified ports. The RT Communication generates VIs for bi-directional communication between the VI running on the Real-Time Engine and the VI running on a single host machine at a time.
UDP is a faster communication protocol than TCP, but it is not connection based and data can be lost since there is no handshaking employed. It is best suited for fast transmission of redundant data since there is no handshaking built into the protocol to ensure that the information is received.
UPD Properties
· Very fast data transfers that can be lossy
· Third-party host applications supported
· Multiple connections require programming, although easier than TCP
· LabVIEW Real-Time Targets: PXI, Compact FieldPoint, FieldPoint, and PCI-7041/6030E
DataSocket
DataSocket is a high-level programming technology based on industry-standard TCP/IP. It was developed by National Instruments in order to simplify network communication. A DataSocket Server running on a Windows PC acts as a data repository. Data placed on the DataSocket Server becomes available for clients to access through DataSocket read and write VIs. Because DataSocket uses a server which can accept multiple connections, multiple systems can access the same data simultaneously, as opposed to TCP where you have to open a connection to each system. All LabVIEW Real-Time target platforms are capable of reading and writing data on a DataSocket Server; however, the server itself is only available on the Windows OS and thus a server machine is necessary for them to communicate to each other.
A new feature of DataSocket with LabVIEW 7.0 is the ability to buffer data on the DataSocket server. This provides the ability to write to an item multiple times without overwriting a previous value giving you lossless communication. The RT Communication Wizard uses buffered DataSocket in the VIs that it generates.
The speed of DataSocket communication is comparable to TCP and it is much easier to program. Because the data is going through DataSocket Server, which can handle multiple connections, it is very easy to have multiple host machines communicating simultaneously. However, it does require a Windows OS machine running DataSocket server in order to have communication.
DataSocket Properties
· Fast, lossless data transfer
· Host application requires DataSocket Server running on a Windows machine
· Multiple connections without additional programming
· LabVIEW Real-Time Targets: PXI, Compact FieldPoint, FieldPoint, and PCI-7041/6030E
Logos
Logos is a network communication protocol developed by National Instruments based on industry-standard UDP. It is used with traditional FieldPoint and Compact FieldPoint Ethernet modules. (From here on, both traditional FieldPoint and Compact FieldPoint are encompassed by the name FieldPoint.) Ethernet FieldPoint modules have an embedded Logos Server which enables reads and writes to the physical I/O modules on the FieldPoint bank from a remote system. On LabVIEW Real-Time enabled FieldPoint network modules, an embedded VI can also use the “Publish Data” VI to create data items on the Logos server. This enables a means to perform analysis and publish the results to the Logos Server for other systems to read. It is also possible to have other systems, such as a Windows OS desktop machine, write data to the item on the Logos Server for the embedded LabVIEW Real-Time program to read. This provides a bi-directional means of communication to Ethernet FieldPoint modules.
You can take advantage of logos in your LabVIEW host application with the LabVIEW Datalogging and Supervisory Control Module. With this module you can easily trend and log data, monitor alarms and events, and add security to your programs. Interactive wizards automatically build program networking for Logos and OPC devices.
Logos communication is an easy protocol to implement. It is also possible to have multiple modules and machines reading and writing to data on the Logos Server without any additional programming. Unlike DataSocket, there is no need for a Windows OS machine to run the server because the Logos Server is on the FieldPoint module. It also is capable of reducing the amount of data transferred over the network by implementing user configurable deadbands.
Logos Properties
· Very fast data transfers that can be lossy
· Host application requires DataSocket Server running on a Windows machine
· Multiple connections without additional programming
· LabVIEW Real-Time Targets: Compact FieldPoint and FieldPoint
Summary
This paper examines the LabVIEW Real-Time Communication Wizard and the different networking protocols available. The protocol that you choose depends on your application needs and your LabVIEW Real-Time targets.
References
See Also:
Organizing Inter-Thread Communication in LabVIEW Real-Time
LabVIEW Real-Time Architecture and Good Programming Practices
Real-Time FIFO for Deterministic Data Transfer Between VIs.
Introduction to Using DataSocket Commands to Communicate with FieldPoint Ethernet Network Modules
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/).




