Archived: The LabVIEW Wireless Sensor Network Module - Under the Hood

NI does not actively maintain this document.

This content provides support for older products and technology, so you may notice outdated links or obsolete information about operating systems or other relevant products.

Overview

Note: NI WSN products are not supported beyond LabVIEW 2015. If you have questions on migrating products, contact technical support at ni.com/support.



With the NI LabVIEW Wireless Sensor Network (WSN) Module you can use LabVIEW graphical programming to embed applications on NI WSN measurement nodes to perform custom analysis, embed decision making, and extend battery life. This document explains the execution model of an NI WSN measurement node as well as how to communicate with and debug a LabVIEW WSN application.

Contents

Edit 7/15

Supported LabVIEW Feature Set

The NI LabVIEW Wireless Sensor Network (WSN) Module includes basic LabVIEW programming structures such as while loops, for loops, and case structures. It also features support for floating-point math and analysis, which eliminates the need for in-depth knowledge of integer and fixed-point data types. Along with hyperbolic, exponential, and trigonometric math functions, the LabVIEW WSN offers functions for string manipulation, so you can customize user messages that can be transmitted back to the host computer. In addition, this LabVIEW WSN provides the flexibility to incorporate ANSI C code directly in line with the graphical code that runs on the node. 

NI WSN measurement nodes are designed with a low power microcontroller that is optimized for low-power and long-term deployment instead of processor speed. Due to this focus on long-term deployment over computing power, NI WSN nodes have limited performance compared to other embedded LabVIEW targets. For example, LabVIEW WSN does not include LabVIEW style debugging, such as highlight execution and stepping through the code at run time. However, you can send and receive string-based user messages to and from the node to debug your deployed application. Also, LabVIEW WSN is limited to serial execution, so parallel LabVIEW structures do not execute concurrently. Because the node has limited resources, many of the LabVIEW analysis functions – those contained in lvanalysis.dll – are not available for programming the node; however, you can replicate several of these functions using the provided floating-point math functions.

 

NI WSN Execution Model

NI WSN measurement nodes use an event-based execution framework that you can extend with LabVIEW WSN to customize a node's behavior. The framework is designed to optimize battery life by putting the node to sleep until events need to be handled (nodes configured as routers do not sleep). The diagram in Figure 1 shows the relationship between execution states and the events that trigger their execution. Events that occur during the execution of another state are handled immediately following the completion of the current state.

 

Figure 1. This diagram represents the LabVIEW WSN execution model, including execution states and transition logic.

 

Each state in Figure 1, that is programmable with LabVIEW, is represented in a case structure in the LabVIEW WSN template VI. To customize the behavior of any NI WSN node, simply add LabVIEW or C code to the appropriate case, like shown in Figure 2.

Figure 2. Customize the behavior of any NI WSN node by adding LabVIEW or C code to the appropriate case.

 

Start

Start is called once when the node powers up before the node establishes a connection with the gateway and joins the network. In the Start case, the sending of data, debug, or user messages will fail, because the node is not yet connected to the network. 

In the Start case, common operations include the following:

    • Setting the sample interval
    • Configuring I/O (thermocouple types, voltage ranges, and so on)
    • Initializing programming structures

Example 1. Configure the sample interval for 2 S/s and analog input 0 for a voltage range of -10 to +10 V. 

Figure 3. Configuring the Sample Interval with the Config Node in a WSN VI

 

Sample

Sample, generally the primary execution state, is called when the Sample Interval timer expires. Configure the Sample Interval with the Config Node in a WSN VI, as shown in the Start example in Figure 3, or from the node's property page in the LabVIEW Project. 

In the Sample case, common operations include:

    • Reading and writing I/O
    • Sending data using radio channels and network shared variables
    • Performing threshold, deadband, or averaging logic to conserve power by transmitting less often
    • Changing the node's sample rate if battery voltage reaches critical levels
    • Interfacing with sensor by converting raw data into engineering units

Example 2. Acquire the voltage on channel 0 and transmit the data only if it exceeds 5.5 V. Otherwise, conserve power by not transmitting. In this example we are utilizing the I/O Variables available to the user. 

Figure 4. Acquiring the Voltage on Channel 0 and Transmitting the Data If It Exceeds 5.5 V

DIO Notification

DIO Notification is called when a value change event occurs on a digital line that is configured with the Generate Notifications property. You can generate events on rising or falling edges. When a digital value change event occurs, the DIO Notification case is queued to run. Subsequent value change events that occur before the case begins to run are ignored.

In the DIO Notification case, common operations include the following:

    • Event counting
    • Waking up to handle and respond to an event

Example 3. Use the Generate Notifications property to configure DIO channel 0 to generate events on rising edges. In most cases, this code is placed in the Start case.

Figure 5. Using the Generate Notifications Property to Configure DIO Channel 0 to Generate Events on Rising Edges

Network Status Change

Network Status Change is called when the node establishes or loses connection with the gateway. 

In the Network Status Change case, common operations include the following:

    • Notifying the host that a connection is established (upon connection)
    • Changing the behavior of a node until a connection is re-established

Example 4. Notify the host that a connection to the network has been established.

Figure 6. Notifying the Host that a Connection to the Network Has Been Established

 

Receive

Receive is called when a user message is received. User messages are sent from the host and stored on the gateway. The gateway delivers a message to the node during the next radio activity that occurs with the node. This includes data transmission, or the heartbeat, which is described below. Sending user messages to a node is not guaranteed to be lossless (refer to the Communication and Debugging Methods section for more details).

In the Receive case, common operations include the following:

    • Receiving and parsing commands
    • Updating parameter values 
    • Transmitting requested information

Example 5. Receive a sample rate interval value, convert the message to a number, and update the Sample Interval property.

Figure 7. Receiving a Sample Rate Interval Value and Updating the Sample Interval Property

Heartbeat – When the heartbeat timer expires, a node briefly powers up the radio to send a heartbeat to the gateway to maintain the network connection. The timer is reset when any radio transmission occurs.

 

Communication and Debugging Methods

LabVIEW WSN provides a simple API for exchanging data between the host and the node. This includes support for sending I/O values, string-based messages, and node information, such as battery voltage. 

 

Transmitting and Receiving Data on the Node

In a LabVIEW WSN VI, on the WSN node, the Radio Messages item is used to send and receive some system information, string commands, and network status. Reading and writing to the Radio Messages item causes the radio to wake up and transmit or receive data, after execution of the current state completes. Each channel on the Radio Message terminal can only be written to only once during the execution of a state, because the data is not sent until the LabVIEW state exits. To transfer data and some other system information network shared variables will be used. If the Radio Messages item and network shared variable are not  being used, the radio is not powered on except to perform the heartbeat.

 

Figure 8. The Radio Messages item is used to transmit and receive data on the node.

 

Transmitting and Receiving Data on the Host

On the host, I/O variables are used to send and receive all data except for user and debug messages, which are communicated with a set of WSN Host VIs from a Windows PC.

Figure 9. On the host, I/O variables are used to send and receive all single-point data

 

Figure 10. String-based User Messages are sent with the WSN Host API (Windows only)

 

In most cases, the gateway is able to transfer user and debug messages between the gateway and nodes; however, delivery of user and debug messages to and from a node is not guaranteed. When a message is sent from a host to a node, it is stored in a first-in-first-out (FIFO) memory buffer on the gateway, which has room for 40 messages. The gateway then attempts to deliver each message to the appropriate node. If the FIFO is full when the host attempts to send a user message, an error is returned through the WSN Host VI. The FIFO is emptied one element at a time as each element is sent to the node. 

When user or debug messages are sent from a node to the host, they are stored in a circular buffer on the gateway. This circular buffer is shared by all nodes and has room for 40 messages. These messages are stored on the gateway until overwritten or until the gateway is rebooted.

 

Debugging LabVIEW WSN Applications

As discussed previously, LabVIEW style debugging features are not supported by the LabVIEW WSN. However, from the node, you can send debug messages to the host or monitor network shared variables to provide information about your application's state, current parameter values, warnings, and so on. To send a debug message from the node to the host, simply write to the debug message input on the Radio Messages item. You can then view these debug messages in the Node Monitor window on the host. To send information about your system using network shared variables simply change the shared variables on the node and continually monitor them on the host. 

Figure 11. To send a debug message from the node to the host, write to the debug message input on the Radio Messages item and then view these debug messages in the Node Monitor window on the host.

You also can toggle the User LED to provide information in a deployed WSN node. The User LED is located in the upper-right corner of the measurement node, next to the signal-strength LEDs. By setting the User LED at specific points in your code, you can determine when an operation has occurred. 

Figure 12. Toggle the User LED by simply negating its current state.

Nonvolatile User Memory

The LabVIEW WSN offers access to a portion of the Flash memory on NI WSN nodes, referred to as user memory. This space is designed for storing configuration data or other essential information that must persist across power cycles and firmware updates on the node. For example, you can store the desired Sample Interval in user memory, and then access these parameters in the Start case when initializing the node. Another possible use is to store sensor conversion constants. You can update the configuration data with user messages from the host.

Data logging to user memory is not recommended because Flash memory has a limited number of read/write cycles (100,000 erase cycles per sector). Though you can keep track of the number of erase cycles per sector, the Flash on a WSN node is not designed to accommodate such heavy read/write traffic. If you continuously log data to user memory, you probably will exceed the specified life of the Flash before the normal operational life of the node.  

 

Conclusion

The LabVIEW WSN features an event-based execution framework that is easily extendible using a combination of intuitive graphical programming and C. Customize the behavior of your NI WSN measurement nodes to extend battery life, increase acquisition performance, and interface with sensors.

Was this information helpful?

Yes

No