CHAPTER 5: A WSN AND SOA BASED PROCESS MONITORING
5.2 WSN Programming and Machine Interface
5.2.2 WSN Node Requirements and Programming
5.2.2.3 WSN programming
The Eclipse IDE based Jennics tool-chain (Jennic Ltd, 2010b) was used to modify the firmware code for each node.
Coordinator Node: The firmware for the Coordinator node connected to a central gateway via serial/USB connection has the following features:
Configures its own on-board Humidity and Temperature sensors At the network level
the Co-ordinator Selects the frequency channel to be used by the network (usually the one with the least detected activity)
Starts the network
Allows nodes to join the network
Provide message routing and other services
Sends its own and connected nodes data to the Universal Asynchronous Receiver/Transmitter (UART) port
Figure 5.2 The star WSN topology.
The JenNET WSN supports end-to-end, Star or Mesh topologies. In this work the star topology shown in Figure 5.2 was adopted in which a Coordinator node attached to the a central gateway acts as the central point to which Routers and End Device nodes can connect to.
Figure 5.3 The state machine for reading the on-board humidity and temperature sensors.
Router Node: One Router node was used to ensure that the two End Device nodes data is passed onto the Coordinator node. The firmware for the Routernode allows it to initially join the network created by the Co-ordinator. The Router initialises and takes readings sequentially from its on-board temperature and humidity sensors as well as the supply voltage. It also allows further sensor boards to join the network. The Router takes readings from its sensors every one second, and outputs the readings and network address to its UART (19200-8-N-1). The Router’s readings are also sent to the Co-ordinator through the network. After every set of readings, the Router pauses for one second before taking the next reading. During this pause period, the Router continues to run the JenNet stack to allow other sensor boards to send their data to the Co-ordinator.
Environmental End Device Node: One of the End Device nodes was used to monitor the temperature and humidity of the polymer industrial environment. The firmware for this node allows it to initially join the network formed by the Co- ordinator and Routers. The End Device initialises and takes readings sequentially from its on-board temperature and humidity sensors as well as the supply voltage. A state machine was implemented to read the sensor readings as shown in Figure 5.3. The implementation code for this state machine is shown in Figure 5.4. The state machine starts by sampling the humidity channel. It then goes into the next state in which it waits for the sampling to be completed and ready for reading. Once this is completed, it goes into the next state in which it reads the humidity result. It then moves onto the temperature sensor and goes through a similar sequence as before until it reads the temperature reading. The node also uses the ADC to read the supply voltage (battery or mains). Measurement is performed using a state machine similar to the one described above to ensure that it never blocks. The node sensor and supply voltage readings along with the node address are output to its UART (19200-8-N-1) as well as being sent to the Co-ordinator through the network. Once a set of readings has been taken, the End Device enters sleep mode for one second before waking to take the next set of readings. Being in sleep mode allows the End Device to conserve power when not taking readings or using the radio.
The second End Device node was used to monitor the Battenfeld Microsystem 50 µIM machine process parameters. The firmware for this node allows it to initially join the network formed by the Co-ordinator and Routers. The End Device initialises and takes readings from its on-board temperature and humidity sensors. To monitor the µIM machine process parameters a state machine shown in Figure 5.5 was implemented to read the analogue ports and convert the analogue signal into digital form using the on-board ADC. The implementation code for this state machine is shown in Figure 5.6. The nodes ADC channels are read sequentially using the state machine. When the sampling begins, the state machine starts with channel ADC1 and goes into the E_STATE_READ_ADC_START state. In this state the ADC1 channel is set to busy and the common parameters for all on-chip analogue resources are set
through the vADC_Config() function. The vJPI_AnalogueStartSample() function is used to start the ADC sampling. Theoretically a 12bit ADC should convert an analogue signal into 212 discrete values that is 4096 discrete values.
Figure 5.4 The implemented code for reading the on-board humidity and temperature sensors.
Machine End Device Node: band-gap voltage of 2.4V as a reference voltage. Therefore, a 1-bit change represents a voltage change of 586µV (2.4V/4096). After the conversion, a value of 0V should theoretically give a 0 digital output and the full 2.4V should give a value of approximately 4096. The state machine moves to the E_STATE_READ_ADC_CONVERTING state in which it tries to ascertain if the conversion has completed through a polling function. Once the sampling has been completed, it then moves into the E_STATE_READ_ADC_COMPLETE state in which (for the relevant channel) it
calculates the bit change using the resolution and internal reference voltage. Once the change has been calculated the ADC channel is reset to not busy.
Figure 5.5 The state machine for sequentially reading the four on-board ADC Channels. The state machine then goes back to the beginning to sample the next channel. It continues until it has completed sampling of all four analogue channels. The node also uses the ADC to read the supply voltage (battery or mains). Measurement is performed using a state machine similar to the one described for the on-board sensors in Figure 5.4 to ensure that it never blocks. The node outputs the on-board sensor, supply voltage, and the set of ADC channel readings along with its own address to its UART (19200-8-N-1) as well as sending to the Co-ordinator through the network. Once a set of readings has been taken, the End Device enters sleep mode for one second before waking to take the next set of readings. Being in sleep mode allows the End Device to conserve power when not taking readings or using the radio. The implemented code on each node is compiled and the resultant binary files are uploaded onto the nodes using the general methodology for programming a node firmware (Appendix A.1).
Figure 5.6 The implemented code for sequentially reading the four on-board ADC Channels.