Creating and Using Shared Variables in the LabVIEW PDA Module

Publish Date: Mar 06, 2008 | 1 Ratings | 5.00 out of 5 |  PDF

Overview

This tutorial illustrates how to create and use network-published shared variables in PDA applications you create with the LabVIEW PDA Module. Network-published shared variables allow you to easily and efficiently transfer data between a PDA device and various distributed targets connected together over a network. This tutorial includes a step-by-step guide to creating and configuring shared variables, and provides an example of how to use these variables within a distributed monitoring application.
Although this tutorial uses a Pocket PC 2003 PDA as a target, it also applies to Windows Mobile 5.0 and supported Windows CE targets. You also can use the LabVIEW Touch Panel Module for Touch Panel targets.

Table of Contents

  1. Table of Contents
  2. System Requirements
  3. Creating and Configuring a New PDA Project
  4. Installing Support for Shared Variables on the PDA
  5. Adding Shared Variables to the Project
  6. Using Shared Variables within PDA Applications
  7. Deploying and Running the PDA Application

1. Table of Contents

  • System Requirements
  • Creating and Configuring a New PDA Project
  • Installing Support for Shared Variables on the PDA
  • Adding Shared Variables to the Project
  • Using Shared Variables within PDA Applications
  • Deploying and Running the PDA Application
  • Conclusion

Back to Top

2. System Requirements

The steps outlined in this tutorial assume the following system requirements:

  1. LabVIEW Professional Development System (8.0 or later)
  2. LabVIEW PDA Module (8.0 or later)
  3. Pocket PC 2003, Windows Mobile 5.0, or other supported Windows CE portable device with network connection and ActiveSync capabilities.
  4. Windows 2000/XP development machine connected to an ethernet or wireless network.

See Also:

NI LabVIEW PDA Module for Windows Mobile
NI LabVIEW Touch Panel Module
Product Manuals: Getting Started with the LabVIEW PDA Module for Windows Mobile
Product Manuals: Getting Started with the LabVIEW Touch Panel Module for Windows CE

Back to Top

3. Creating and Configuring a New PDA Project

The Project Explorer window provides the framework for organizing and interacting with various distributed targets from a single location within the LabVIEW programming environment. Shared variables provide an easy method for sharing data between various targets. The first step of this tutorial is to create a new LabVIEW project and add a PDA target to the project.

You can create an empty project or use the PDA Project Wizard to create the project. This tutorial uses an empty project.

Complete the following steps to create a project and add a PDA target to that project.

  1. From the Getting Started window, click Empty Project to open a new project. The project contains the My Computer target, which is the development, or host, PC.
  2. Select File»Save Project in the Project Explorer window and save the new project as PDA Shared Variable.lvproj.
  3. Right-click the project and select New»Targets and Devices from the shortcut menu to open the Add Targets and Devices dialog box.

  4. Select Existing target or device and expand the PDA category to show the available targets. Select PDA»Windows Mobile»Pocket PC 2003 Device to add a Pocket PC target to the project.

The Pocket PC 2003 Device appears as a new target within the project.

Back to Top

4. Installing Support for Shared Variables on the PDA

You must install support for the shared variable engine on the target device before you can access data from network-published shared variables from a PDA target.
Tip: You can install various support files on a PDA target by right-clicking the target in the Project Explorer window and selecting Install from the shortcut menu if you can establish an ActiveSync connection between the host PC and the PDA target.

Complete the following steps to install support for shared variables on a PDA target.

  1. Verify you have an ActiveSync connection between the host PC and the PDA target.
  2. Right-click the Pocket PC 2003 Device target in the Project Explorer window, select Install»Support for Shared Variables.

Back to Top

5. Adding Shared Variables to the Project

You can now add network-published shared variables to the LabVIEW project. The shared variables provide a memory space that can be used to send and receive data between different targets in the project. One target in the project must host the shared variables. All other targets can connect to that host as clients to publish or subscribe to the data stored in the shared variable memory space. Only certain targets, such as Windows PCs, FieldPoint controllers, and CompactRIO controllers are capable of hosting shared variables. PDA targets cannot host shared variables and can only access shared variables as clients. You create and host the shared variables on the host PC. The PDA target serves as a client and subscribes/publishes to the shared variables remotely that are hosted on the host PC.

Complete the following steps to add shared variables to the project:

  1. Right-click My Computer in the Project Explorer window and select New»Variable from the shortcut menu to open the Shared Variable Properties dialog box.

  2. Give the shared variable a logical name by typing Temperature in the Name text box.
  3. Select Double from the Data Type drop-down list.
  4. Select Network Published from the Variable Type drop-down list.

  5. Click the OK button.The shared variables appear in the Project Explorer window under Untitled Library 1. LabVIEW automatically creates this library because all shared variables must reside in a library in a project.
  6. Right-click Untitled Library 1, select Save As from the shortcut menu, and save the library as Weather Data.lvlib.
  7. Create another network-published shared variable and name it Wind Speed.

Back to Top

6. Using Shared Variables within PDA Applications

With the network-published shared variables hosted on the development PC in the project, you can use these shared variables to send and receive data between all of the targets in the project. The next step is to create example applications that run on the host PC and the PDA target that publishes and subscribes to these shared variables. The example application that runs on the development PC simulates the acquisition of weather data and publishes that data to the Temperature and Wind Speed shared variables. The example application you create and deploy to the PDA target subscribes to the weather data and presents the results on the PDA user interface. This example shows shared variables in a distributed acquisition and monitoring application.

  1. Right-click My Computer and select New»VI from the shortcut menu. Save this VI as Weather Station.vi. This VI will run on the host PC.

The easiest way to add shared variables to a VI is to drag and drop the shared variables from the Project Explorer window to the block diagram. You can then change whether to read from or write to the shared variable by right-clicking the shared variable and selecting either Change to Read or Change to Write from the shortcut menu.

Complete the following steps to add the shared variables to Weather Station.vi.

  1. With the Project Explorer window and the Weather Station.vi block diagram visible, drag and drop the Temperature and Wind Speed shared variables from the Weather Data library in the Project Explorer window onto the block diagram.
  2. Right-click the shared variables on the block diagram and select Change to Write from the shortcut menu.

For the purposes of this tutorial, this example application publishes simulated weather data to the Temperature and Wind Speed shared variables. Realistically, this simulated data would be replaced by data acquired from a data acquisition device or distributed I/O system. Complete the following steps to create the host application that simulates weather data.

  1. Place two Simulate Signal Express VIs on the block diagram, configure the simulated signals with your choice of settings, and wire the data outputs of the Express VIs to the Temperature and Wind Speed inputs of the shared variables.
  2. Place While Loop around the Simulate Signals Express VIs and shared variables. Place a Wait for Next ms Multiple function within the loop and wire a value of 50 to update the shared variables every 50 ms.
  3. Wire the error clusters and stop button to the While Loop condition terminal, as shown in the following block diagram.

The next step is to create a PDA application that subscribes to the shared variables hosted on the host PC. Complete the following steps to create a PDA VI under the Pocket PC 2003 Device target, and read from the Temperature and Wind Speed shared variables within that VI.

  1. Right-click the Pocket PC 2003 Device target in the Project Explorer window and select New»PDA VI from the shortcut menu. Select an appropriate template for the PDA VI and save this VI as PDA Weather Monitor.vi.
  2. Add the shared variables to the PDA VI by dragging and dropping them from the Weather Data library in the Project Explorer window to the block diagram. Place the shared variables within the existing Case structure and While Loop on the block diagram of the PDA VI.

  3. To display the data read from the Temperature and Wind Speed shared variables, you must place indicators on the front panel window of our PDA VI. Place a Thermometer and Gauge indicator, located on the Controls»Numeric palette on the front panel of the PDA VI.

  4. On the block diagram of the PDA VI, wire the data outputs of the Temperature and Wind Speed shared variables to the Thermometer and Gauge indicators.
  5. Place a While Loop around the shared variables and indicators to update them continuously when you click the Run button.
  6. Place a Wait for Next ms Multiple function within the While Loop. Wire a constant with a value of 50 to the input of the function to control the speed at which the shared variables are read and the indicators updated.

Back to Top

7. Deploying and Running the PDA Application

You are now ready to deploy and run the applications, and share data between the two through network-published shared variables. You must connect the PDA device to the host PC through ActiveSync before you can deploy a PDA application to a PDA target. You can quickly build, deploy, and run the VI by clicking the Run button. LabVIEW prompts you to create a build specification. Refer to the LabVIEW Help, available by selecting Help»Search the LabVIEW Help, for more information about building, deploying, and running PDA applications.

After you deploy the PDA application (Weather Monitor.exe) to the PDA target, you run the Windows VI (Weather Station.vi) on the host PC. When you run the VI on the host PC, you deploy the Weather Data shared variables in the project to the host PC and begin writing simulated data to these variables. You can now run the PDA application on the PDA target and read that simulated data over the network. Note that the PDA device must have an active connection to the Ethernet or wireless network to subscribe to the network-published shared variables hosted on the host PC.

Conclusion

This tutorial shows how to create, configure, and use network-published shared variables to communicate data over a network between a host PC and a PDA target. The Project Explorer window serves as the framework for organizing various targets and configuring how the nodes in a distributed network communicate with each other through shared variables. The example application illustrates how you can use network-published shared variables to develop an application where a PDA device is used to remotely monitor a process running on a host PC. You could expand this example to create an application to monitor processes running on multiple embedded targets using a PDA device. This really shows the power and ease of use network-published shared variables provides for quickly developing applications with distributed intelligence.

Back to Top

Bookmark & Share


Ratings

Rate this document

Answered Your Question?
Yes No

Submit