App Notes

Contents[Hide]
Download zip archive

Key Ideas

  • Health monitoring as application add-on component.
  • Resetting an eMote .NOW under program control.
  • Using NetStream to partition messages between application and health monitor.
  • Using RS232 serial to interact with health controller.

Description

Using the basic logic in the Wireless Radio Ping Pong app note, add a health monitoring component that interacts wirelessly with a health controller on another eMote .NOW. Via the controller, a user can approach an application node;  ping it to check if it's running and if so, get basic eMote information; get the current values displayed on the LCD; and cause it to reset.

You can interact with the health controller in one of two ways. Details are in the Controller Node section below.

  • You can use COM1 in the controller program along with the USB-Serial interface with a Windows PC.
  • You can use COM2 in the controller program along with an RS232 terminal or terminal emulator. This makes it convenient for the controller to be attached to a computer (not necessarily Windows) or a handheld that supports a terminal emulator over an RS232 connection.

Complexity Level

Moderately advanced. Understanding how to use NetStream to partition wireless messages between the ping-pong application and the health monitor is somewhat complex. If you choose to use the RS232 option, setting up the RS232 adapter requires soldering ability.

Setup

You'll need 3 .NOWs for this app note. Two will run the ping pong application with the health monitor component and the third will be the controller. If you use the COM2 option then you'll need RS232 shifter such as the SparkFun RS232 Shifter. If you want to use RS232 shifter on a PC then you'll also need a USB to serial adapter such as the TRENDnet USB to Serial Converter.

Wire up the .NOWs as follows.

Ping Pong Nodes with Health Monitor

These nodes run the app note's Node-PingPongHealth program. Deploy the program to each of the nodes.

For wiring, connect a jumper between J11/6 (reset) and J11/1 (GPIO). This is needed to support the reset function.

Controller Node

This node runs the app note's Node-Controller program. Deploy the program to this node.

Follow one or the other of the steps below to connect the controller node to a host computer or hand-held device. In either case, search the Node-Controller program for the SerialComm constructor and change the first argument to "COM1" or "COM2" as needed.

Using eMote COM1 with USB Serial

This is the easiest way but requires you to use a Windows PC.

Connect a USB cable from the .NOW to the PC. Make sure your PC has the serial over USB driver; see the article on How Do I Get Setup.

Using eMote COM2 with RS232 shifter and USB to Serial Adapter

This is more complicated but lets you use any host that supports a terminal emulator over RS232.

Assume that you're using the SparkFun RS232 Shifter. First, connect the .NOW to the RS232 shifter as follows.

.NOW RS232 Shifter
J12/10 (Ground) GND
J11/2 (+2v) VCC
J11/5 (COM2 transmit) Rx-0
J11/6 (COM2 receive Tx-1

You can connect the RS232 shifter to a host computer or hand-held device in several ways.

  • If the host has a serial port, connect the RS232 shifter directly to that.
  • If not, find a serial adapter that's compatible with your host. Connect the RS232 shifter to the serial adapter and plug the adapter into your host.

The pictures below show a .NOW connected to a SparkFun RS232 shifter, which in turn is connected to a TRENDNet USB to Serial Converter.

Connecting to a Computer Terminal Emulator

For illustration we'll show to do this on a Windows PC using the free open-source multi-platform terminal emulator PuTTY  but you can use the terminal emulator of your choice. After you've connected your .NOW via a serial connection to your host, check what serial port your host is using for the connection. Suppose it's COM22. Then in PuTTY, "Serial line" is COM22 and "Speed" is 115200. The default for data bits / stop bits / parity and flow control is 8 / 1 / None / XON-XOFF, which is compatible with the Node-Controller program.

Getting Started

At this point you should have two ping-pong nodes and one controller node wired up and ready to go. Power up or reset the controller node. You will see the startup messages on the terminal emulator. Next, power up or reset each of the ping-pong nodes. As each starts it reports to the controller that it is starting and the controller echoes this to the terminal emulator.

The ping pong application itself is patterned off of Wireless Radio Ping-Pong (CSMA) and Serial Ping-Pong. After the ping-pong nodes get started you will see that each one randomly chooses a 2 digit number and displays in on the LCD. As the programs proceed, they will periodically exchange their values, stabilize to the higher one, and increment it. After stabilization the nodes will always differ in their display by a value of 1.

Here is a sample log from the controller with remarks in bold italic.

Startup messages

Node-Controller Version 1.0, build 01/14/2016 13:16:38 

Commands
Ping : P
Send LCD: L
Reset: R
Help: ?

User pressed P

<< Ping 

Ping response from ping-pong nodes

>>Pong, CPU Power: 16, Radio Power: 0 
     from 27786, rssi 20

>>Pong, CPU Power: 16, Radio Power: 0
     from 18375, rssi 22

User pressed L

<< Send LCD 

Current LCD response from one node, showing value 87

>>CurrLCD <87   > 
     from 27786, rssi 20

Current LCD response from other node, showing value 88

>>CurrLCD <88   > 
     from 18375, rssi 22

User pressed R

<< Send Reset 

Now-resetting response from one node

>>Now Resetting 
     from 27786, rssi 20

>>Now Resetting
     from 18375, rssi 23

Now-starting response from one node

>>Now Starting 
     from 27786, rssi 20

>>Now Starting
     from 18375, rssi 22

User pressed ?

Commands 
Ping : P
Send LCD: L
Reset: R
Help: ?

Discussion

This app note includes two kinds of wireless messages: those intended for the main ping-pong application and those intended for the health monitor. To avoid confusion we use the notion of a network stream. Intuitively, the main application makes use of one stream and the health monitor makes use of another. Thus messages intended for the main application are seen only by the application, and similarly for the health monitor.

For wireless communication we're using the utility SimpleCSMA that simplifies configuration and management of CSMA radio communication. This is the foundation for the SimpleCSMAStream class that receives CSMA messages, decides which stream is associated with the message, and passes it on to the correct recipient. It also includes a Send method that adds the stream identification and sends it out.

In ping-pong node, the program sets things up as follows:

  • Create an instance of SimpleCSMA with the desired configuration.
  • Create an instance of SimpleCSMAStream using the SimpleCSMA instance.
  • Subscribe the main ping-pong application to the stream. To do this, it first creates a StreamCallback instance based on the application's stream ID (Common.AppStreamId, which has a value of 1) and the method that will handle the callback (AppCallback). Then it subscribes the StreamCallback instance to the SimpleCSMAStream.

Finally it initializes the health monitor, which goes through a similar subscription process but for the stream ID Common.MonitorStreamId, which has a value of 2; and of course it specifies it's own callback method for the subscription.

In the controller node the process is similar: it sets up and subscribes to the Common.MonitorStreamId.

In operation, the ping-pong nodes interact over their stream ID, not seeing any health monitor messages. Similarly the health monitor on the ping-pong node and the controller interact over their stream ID, not seeing any main application messages. When the user initiates a command such a Ping from the controller, the command is sent via the CSMANetStream Send method; on the ping-pong node, the health monitor receives the message from CSMANetStream and responds with Send back to the controller.

Suggestions

The controller program is very simple. Try modifying it (and the corresponding health monitor component in the ping-pong program) to increase functionality.

  • Let the controller reset just one node.
  • Let the controller change the power level of a node, or of all nodes.
  • Instrument the ping-pong program so that the controller can ask a node whether or not it has stabilized on a common value with the other node.