1. Table of Contents
- System Requirements
- Creating and Configuring a New Touch Panel Target
- Installing Support for Shared Variables
- Adding Shared Variables to a Project
- Using Shared Variables in Touch Panel Applications
- Deploying and Running Touch Panel Applications
2. System Requirements
This tutorial assumes the following system requirements:
- LabVIEW 8.20 Professional Development System
- LabVIEW 8.20 Touch Panel Module
- NI TPC-2006 Touch Panel Computer
- Windows 2000/XP development machine connected to an ethernet or wireless network
3. Creating and Configuring a New Touch Panel Target
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 communicating and sharing data between various targets. The first part of this tutorial is to create a new LabVIEW project and add a Touch Panel target to the project.
Complete the following steps to create a project and add a Touch Panel target to that project.
- 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.
- Select File»Save Project in the Project Explorer window and save the new project as TP Shared Variable.lvproj.
- Right-click the project and select New»Targets and Devices from the shortcut menu to open the Add Targets and Devices dialog box.
- Select Existing target or device and expand the Touch Panel folder to show the available targets. Select Windows CE»Touch Panel Windows CE 4.2 Device and click OK to add a Windows CE 4.2 target to the project.
The Windows CE Touch Panel device appears as a new target in the project.
4. Installing Support for Shared Variables
You must install support for the shared variable engine on the NI TPC-2006 Touch Panel target before you can access data from network-published shared variables from the Touch Panel target. To install this support, you can connect the Touch Panel target to your development PC through ActiveSync and deploy the support files automatically through the Project Explorer window. You also can install this support manually by transferring the shared variable support files to the Touch Panel target in a .cab file.
Tip: You can install various support files on a Touch Panel target by right-clicking the target in the Project Explorer window and selecting Install from the shortcut menu. You must establish an ActiveSync connection between the host PC and the Touch Panel target.
Complete one of the following methods to install support for shared variables on the Touch Panel target.
Method 1: Install Shared Variable Support through ActiveSync
- Verify you have an ActiveSync connection between the host PC and the TPC-2006.
- Right-click Touch Panel Windows CE 4.2 Device in the Project Explorer window and select Install»Support for Shared Variables(ARM) from the shortcut menu.
Method 2: Install Shared Variable by Manually Deploying Support Files
You also can manually transfer the shared variable support files to the TPC-2006. The support files are in the National Instruments LabVIEW 8.2 Shared Variable Support.CAB file, located in the labview\PDA\Utilities\Variables directory. You can manually transfer the CAB file from the development PC to the TPC-2006 through FTP or by copying it to a CompactFlash card and manually transferring it to the TPC-2006. The following steps use FTP to transfer the support files to the TPC-2006. Refer to the KnowledgeBase 3T9C8LX1 (linked below) for information about configuring the TPC-2006 to accept file transfers through FTP.
- With the TPC-2006 connected to a network, open an FTP session to the device from the development machine by typing ftp://xxx.xxx.xxx.xxx in the address field of an Internet Explorer browser, where xxx.xxx.xxx.xxx is the IP address of the TPC-2006. This allows you to browse the file structure and transfer files to the TPC-2006.
- Copy National Instruments LabVIEW 8.2 Shared Variable Support.CAB, located in the labview\PDA\Utilities\Variables directory, to the HardDisk\wince\config directory. Create the HardDisk\wince\config directory if it does not exist.
- Reboot the TPC-2006 to start the installation process.
- Verify the shared variable support is installed by checking the list of programs in Add/Remove Programs.
5. Adding Shared Variables to a Project
You can now add network-published shared variables to a LabVIEW project. The shared variables provide a memory space that you can use 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. Touch Panel targets cannot host shared variables and only can access shared variables as clients. You create and host the shared variables on the host PC. The Touch Panel 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.
- 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.
- Give the shared variable a logical name by typing Temperature in the Name text box.
- Select Double from the Data Type drop-down list.
- Select Network Published from the Variable Type drop-down list.
- 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.
- Right-click Untitled Library 1, select Save As from the shortcut menu, and save the library as Weather Data.lvlib.
- Create another network-published shared variable and name it Wind Speed.
6. Using Shared Variables in Touch Panel 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 TPC-2006 that publish and subscribe to these shared variables. The example host application simulates the acquisition of weather data and publishes that data to the Temperature and Wind Speed shared variables. The example Touch Panel application subscribes to the weather data and presents the results on the Touch Panel user interface. This tutorial shows shared variables in a distributed acquisition and monitoring application.
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.\
You can add shared variables to a VI by dragging and dropping 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.
- 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.
- Right-click the shared variables on the block diagram and select Change to Write from the shortcut menu.
For the purposes of this tutorial, the 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.
- 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.
- 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.
- 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 Touch Panel application that subscribes to the shared variables hosted on the host PC. Complete the following steps to create a Touch Panel VI under the Touch Panel Windows CE 4.2 target that reads from the Temperature and Wind Speed shared variables within that VI.
- Right-click Touch Panel Windows CE 4.2 Device in the Project Explorer window and select New Touch Panel VI from the shortcut menu. Select an appropriate template for the Touch Panel VI and save this VI as TP Weather Monitor.vi.
- Add the shared variables to the Touch Panel 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 Touch Panel VI.
- To display the data read from the Temperature and Wind Speed shared variables, you must place indicators on the front panel window of your Touch Panel VI. Place a Thermometer and Gauge indicator, located on the Controls»Numeric palette, on the front panel of the Touch Panel VI.
- On the block diagram of the Touch Panel VI, wire the data outputs of the Temperature and Wind Speed shared variables to the Thermometer and Gauge indicators.
- Place a While Loop around the shared variables and indicators to update them continuously when you click the Run button.
- 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.
7. Deploying and Running Touch Panel Applications
You are now ready to deploy and run the applications so you can share data between the host PC and TPC-2006 through network-published shared variables. You can deploy the Touch Panel application to the TPC-2006 through ActiveSync or by manually transferring the executable to the TPC-2006 through FTP. For both methods, you must create a build specification for the Touch Panel VI.
- Right-click Build Specifications under the Touch Panel Windows CE 4.2 Target and select New»Application(EXE) from the shortcut menu.
- Enter TP Weather Monitor in the Build specification name text box.
- Select the Source Files category and add TP Weather Monitor.vi as the top-level VI.
- Select the Machine Aliases category and place a checkmark in the Deploy Aliases File checkbox.
- Click OK.
After you create a build specification, you can click the Run button to build TP Weather Monitor.vi into a Touch Panel application, deploy the application on the Touch Panel target, and run the application on the Touch Panel target. You must connect the Touch Panel target to the host PC through ActiveSync. You also can build the Touch Panel VI into a Touch Panel application by right-clicking the build specification in the Project Explorer window and selecting Build from the shortcut menu. You can then manually download the application by copying TP Weather Monitor.exe and TP Weather Monitor.aliases to the TPC-2006 through FTP. Refer to the LabVIEW Help, available by selecting Help»Search the LabVIEW Help, for more information about building, deploying, and running Touch Panel applications.
After you deploy the Touch Panel application (TP Weather Monitor.exe) to the Touch Panel target, 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 now can run the Touch Panel application on the TPC-2006 and read the simulated data over the network. Note that the TPC-2006 and the host PC must have active connections to the Ethernet or a wireless network to subscribe to the network-published shared variables hosted on the host PC.
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 TPC-2006 Touch Panel 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 TPC-2006 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 Touch Panel device. You can use network-published shared variables to quickly develop applications with distributed intelligence.