Network Communication Methods in LabVIEW
March 14, 2013 Leave a comment
Applications normally involve a variety of systems, such as data acquisition system, controllers and hosts, that must exchange information, often over Ethernet. While one may be reading data from peripheral instruments, such as sensors – camera for instance, others may be processing data and giving results or transferring to a central data system. There are several methods available to accomplish these tasks. In this post, I would like to give some fundamentals about common communication models as well as networking protocols commonly used. As a result, designers can choose an appropriate way for their application.
I – Models of communication
There are several models used for communication that can configure in different ways, for example, (1:1) one host and one target, (N:1) or (1:N). However, in most applications, there are three models commonly used, which are:
– Command or message-based communication
– Process Data Communication
– Streaming/Buffered Communication
In host computer, there are the following parts:
- Command/Parameter Sender loop
- Data Receiver loop
In general, the command/parameter sender loop actions can be driven by any source, for instance, User Interface -UI. On the other hand, The Data Receiver loop is responsible for receiving and processing each incoming message from the target. For example, the Data Receiver simply displays the data, do post-processing, or performing some analysis, etc.
In the target, some parts may be included:
- Command Parser
- Medium Priority Task(s)
- High Priority Task
The Command Parser waits for commands from the host, interprets them and routes the incoming command parameters to the appropriate loop. However, Medium Priority tasks might be signal processing, sending data to the host via TCP/IP or logging data to disk. Since Medium Priority tasks and the Command Parser are not deterministic, we can use various methods of data sharing between them, such as Queues, Local Variables, Functional Globals, etc. Most importantly, it is the High Priority Task loop, which represents the deterministic part of the application. Typical deterministic tasks include data acquisition, closed-loop control or simulation model execution.
Process Data Communication
- Network Streams
- Network-published shared variables
- Time-triggered shared variables
- VI Server
- Web services
- Numeric scalars
- 1D arrays of numeric scalars
- 1D arrays of Booleans
– Network-published shared variables: Network-published shared variables are an easy-to-use LabVIEW tool for sharing data. They are straightforward to implement and support most LabVIEW data types and custom type definitions. it is most suitable for process data communication when the latest value of a process variable is important. Moreover, it is important to know that Shared Variables cannot guarantee high throughput or low latency.
– UDP: UDP differs from TCP in that it will publish data to a specified port but does not require a connection with a client before sending the data. If there is no connection to receive the data at its destination, the data is simply discarded; there is no check for successful delivery. Therefore, UDP is used in applications in which reliability is not critical. For example, an application might transmit informative data to a destination frequently enough that a few lost segments of data are not problematic.
– VI Server: This protocol is used to monitor and control VIs on an RT target. Using VI Server, a LabVIEW VI can invoke RT target VIs remotely. The LabVIEW VI can pass parameter values to and from the RT target VIs, creating a distributed application.
Using the VI Server is that the VI Server allows us to access the functionality of TCP while working within the framework of LabVIEW. However, the VI Server is non-deterministic and using VI Server communication can affect the determinism of the VI.
– Web Services: Web services allow us to create Web applications that communicate over the network with any HTTP-capable Web client, which includes standard web browsers. Many users can monitor one or many application from many different platforms and locations. Data is exchanged with the Web method VI using a URL and standard HTTP methods.
There are several models as well as networking protocols that we can use to perform communication tasks. Each model or protocol has different advantages and disadvantages, using which one are strongly depend on the requirements of the application, which should be analyzed carefully as a first stage of design an application. For example, in my project, determinism and loss-less are very important. In addition, images, which are large amount of data, are transferred between PC and RT Controllers. So, I chose Process Data communication model – Bi-Directional Communication Architecture and relied on TCP/IP and Network-published shared variables protocols.
 LabVIEW Real-Time Application Development Course Manual, National Instruments, 2008
 http://www.ni.com/white-paper/12079/en – Using the right networking protocols
 http://www.ni.com/white-paper/3098/en – Command-based communication using simple TCP/IP messaging
 CompactRIO Developers Guide, National Instruments, 2008
 http://www.ni.com/white-paper/12267/en – Loss-less Communication with Network Streams
 http://www.ni.com/white-paper/4679/en – Using the LabVIEW Shared Variable