Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Sep 3, 2008


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links - Products and Services

Simplifying Communication on Mobile Devices with the LabVIEW Shared Variable

3 ratings | 4.33 out of 5
Print

Overview

Scientists and Engineers are more and more using a distributed infrastructure to monitor their measurement and control applications. This requires an Engineer to be present at a central monitoring station or a dedicated, stationary human-machine interface (HMI). With the growth of wireless communication, however, it is now possible to stay connected to an application without being tied to a fixed workstation.

Benefits of Wireless Technology

Of the many benefits wireless technology brings to measurement and control applications, the most important are portability and cost savings:

Portability
Wireless communication allows for an operator to remain connected to a central application from any location without the need for any wired infrastructure. This connectivity greatly reduces the frequency of required visits by the operator to the remote machine site for data collection.

Cost reduction
Depending on the nature of an application, physical wiring can be expensive and time consuming. Wireless technology helps minimize, or even avoid the use of wires and cables entirely. In a more dynamic environment, such as a manufacturing floor, where stations must be reconfigured for different tests, the absence of wires can dramatically reduce down-time and setup costs.

Most handheld devices, such as PDAs and mobile phones, have built-in wireless capabilities. The proliferation of such mobile technology in recent years has also made these devices cost-effective. Thus, the integration of a wireless handheld device into an existing setup may be accomplished with commercially available technology. National Instruments has created the LabVIEW PDA module to further ease this process of incorporating wireless and handheld devices into a measurement or control application.

Overview of LabVIEW


LabVIEW is an industry-leading software tool for designing test, measurement, and control systems. For years LabVIEW graphical development has revolutionized the way thousands of engineers and scientists work, providing improved product quality, shorter time to market, and greater engineering and manufacturing efficiency. For more information on LabVIEW, refer to the links below:


The LabVIEW PDA module extends the LabVIEW graphical development environment to handheld devices like Windows Mobile for Pocket PC, and select Windows CE OS devices. You can develop applications in LabVIEW and download them to small, portable PDA targets.


Figure 1. Programming with the LabVIEW PDA Module


The LabVIEW PDA module includes all the graphical programming, debugging, and development features that make LabVIEW such a powerful and easy to use platform. It abstracts the complexities of programming a mobile device from the user, leaving you to focus on the application and not the program itself. In addition, the LabVIEW PDA module offers several options for wireless programming, intended to facilitate the addition of a wireless handheld to your applications.

Wireless Programming in LabVIEW


Different handhelds have different options for wireless connectivity, such as Infrared, Bluetooth, and wireless Ethernet (WiFi). Since most PDAs come with built-in WiFi capabilities and existing Ethernet infrastructure is widely available, wireless communication using TCP is the most commonly employed option. For more information about using Infrared and Bluetooth, refer to the links below.

See Also:
Developing Wireless PDA Applications in LabVIEW
LabVIEW Help: Using LabVIEW with Wireless Devices

TCP/IP


TCP ensures reliable transmission across networks while delivering data in sequence without errors, loss, or duplication. The TCP connection automatically retransmits a datagram (data and header information) until the TCP connection receives acknowledgment of the transmission. It uses the client/server model of communication, in which a computer user (the client) requests a service (such as sending a webpage) from another computer (the server). The server listens for a request from the client, and provides the requested information in response. Thus, TCP communication is primarily point-to-point, meaning each communication is from one point (or host computer) in the network to another point or host computer.

The LabVIEW TCP/IP API (application programming interface) greatly simplifies network programming over a text-based approach. You can use the LabVIEW TCP VIs and functions to interface with any Ethernet device on a network. Basic communication using TCP typically involves the following steps:

  1. Opening the connection.
  2. Reading and writing the data.
  3. Closing the connection.

You can use a PDA device as a client or a server, though a client configuration is more common. Figure 2 below shows an example of a typical TCP client application.


Figure 2. Basic TCP/IP Programming in LabVIEW


This example is very basic, however, and not practical for a real-world application. More sophisticated messaging algorithms are necessary to provide for an efficient application architecture. These typically involve formatting command data into a native TCP string data type and parsing response data into something useful. Figure 3 below demonstrates a more practical example of TCP communication:



[+] Enlarge Image

Figure 3. TCP/IP Messaging Protocol Example


Though LabVIEW greatly simplifies TCP programming compared to text-based implementations, the growing complexity of distributed applications necessitates a better solution. The introduction of shared variables in LabVIEW PDA 8.20 makes wireless communication even easier. Shared variables are configuration based, can represent any data type, and eliminate the need for parsing. Thus shared variables are now the recommended method for wireless communication.

See Also:
Simple TCP/IP Messaging Protocol
Basic TCP/IP Communication in LabVIEW

Shared Variables


Network-Published Shared variables are configured software items that can send data among VIs, or between locations in an application block diagram that cannot be connected with wires. Shared variables are easy to create and configure, requiring little to no block diagram programming. In contrast to many existing data sharing methods in LabVIEW, such as TCP, you configure the shared variable using property dialogs, eliminating the need to include configuration code in your application and making the network virtually transparent. To use shared variables, simply drag and drop them between VIs, or from a project to a VI. Also, since the shared variable allows you to specify a wide range of data types, you no longer need to format the data as was necessary with the TCP VIs.

How do Shared Variables Work?


The network-published shared variables use the NI Publish-Subscribe Protocol (NI-PSP) to send and receive data across a network. The NI-PSP protocol is built on top of the UDP protocol and therefore takes advantage of its stateless and connection-less aspects. Unlike the UDP protocol, however, the NI-PSP protocol guarantees delivery by implementing an additional layer of functionality on top of the raw UDP.

In order to use network-published shared variables, a Shared Variable Engine (SVE) must be running on at least one of the nodes in the distributed system. The SVE is a software framework that enables a networked-published shared variable to send values throughout the network. On Windows, LabVIEW configures the SVE as a service and launches the SVE at system startup.

Creating and Using a Shared Variable


The following steps briefly describe the procedure for adding a shared variable to your application. To begin, you must have a LabVIEW project to create a shared variable. (See the links below for more details on shared variables and information on LabVIEW projects). In the example below, we create and configure a shared variable on a host computer (typically a desktop machine). We then publish data to the variable from the host computer, and read the published data from the PDA.

  • In your LabVIEW Project Explorer Window, right-click on "My Computer" and select “New » variable” to create a new shared variable on the host computer.
  • In the configuration window that comes up, select double for data type, and network-published for variable type, and click OK.

[+] Enlarge Image
  • Open the host VI from My Computer, and drag and drop the shared variable you just created to the block diagram.
  • Open the PDA VI from the PDA target and drag the same shared variable to the block diagram. Example block diagrams for the host computer and handheld device are shown below:

Host VI Block Diagram_______________PDA VI Block Diagram
  • Run the LabVIEW VI to publish the data, and PDA VI to deploy the application to handheld device and receive the published data.


See Also:
Using LabVIEW Projects
Managing Large Applications with the LabVIEW Project
Using the LabVIEW Shared Variable

Conclusion


Wireless communication enables you to monitor an application from a portable handheld device without being tied to a specific location. You can readily connect to your application from virtually anywhere at anytime. Using the shared variable and LabVIEW PDA, you can reduce development time and easily extend your application to a wireless handheld device.

3 ratings | 4.33 out of 5
Print

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/).