Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 24 Next »


Introduction

 

The following document provides the necessary information for implementing a generic communication interface between the wireless board (mote) and the sensor board. Any kind of sensor board can be connected to the mote using this specification given it provides a SPI peripheral, one input pin with interrupt capability and one digital output. The sensor board must implement a special register set from which all required information can be retrieved.

Pin out

 

New sensor boards can be seamless connected to a mote if the following characteristics are available:

  • A sensor board with standard slave SPI channel SPI (MOSI, MISO, SCLK, /SS)
  • Frequency of 4MHz for communication, using 8 bits, with with least significant bit (LSB) first
  •  Polarity and Phase clock must be set in mode 0 (both zero) .

Two interrupt lines are provided for indicating critical events. One line is from sensor to mote and the other is from mote to sensor.

  • Sensor → mote interrupt line: When the mote wants to read values from the sensor it puts this line in high beforehand and waits 100ms. This signal is used to wake up the sensor from any possible energy saving mode, waiting for the communication. This line will be kept high while the mote continues to communicates with the sensor. If the sensor board does not provide any energy saving mode (always in active mode) or it can be activated quickly, this line can be ignored. In such situation, SPI chip select (/SS) will be used to detect the communication request.
  • Processor → sensor interrupt line: This line is used for urgent notifications from sensor, indicating any asynchronous event that should be handled immediately . It may be an indication of an external event that can not wait for normal read cycle or a sensor failure, for instance. The mote will read the status register to acknowledge the interrupt, detecting the type of event, like a urgent point that should be read or some sensor failure. The sensor will deactivate this line only after the status register is read and a minimum time of 500ms should be respected before making this line active again.

Power supply lines are also provided (VCC and GND). In this case, the mote should be prepared to provide energy for the sensor board or to receive energy from it. Sensor boards that are capable of providing energy will indicate such situation in their identification registry (capability field).

 

Protocol Overview

 

The proposed protocol is based on several access to a register map defined in the sensor board. All accesses are synchronous so each request must be followed by a response and a maximum timeout need to be respected. Any communication frame can not be greater than 96 bytes (TBD). The exact amount of bytes is determined after reading the device identification register and point description registers. The idea is all sensor data fits inside a unique 6LoWPAN frame.

Data types used in this documentation are described in the data types table. There is no string data type and arrays should be considered as a regular array of any basic data type. When describing a field, numbers in front of the data type indicates the array size. For instance, 4L means a sequence of four unsigned longs (16 bytes). If the quantity is omitted it must be considered as 1. All data types that are longer than one byte should be considered as little endian.

The generic request frame is below:

SizeDescription
BFrame Size (n+1 bytes) - CRC not included
BRegister Address
nBFrame Data (if any)
2BCRC

Response frames are described below. All answers must be synchronous, with 500ms of timeout. After this timeout two retries can be done, with timeouts of 1000ms and 2000ms, respectively. If sensor board continues not responding, it should be considered in failure state and the mode should try to identify the board again at each one minute.

SizeDescription
BFrame Size (n+2 bytes) - CRC not included
B

Response Status (see response code table)

BRegister Address
nBFrame Data 
2BCRC

Sensor Board Register Map

The set of registers that should be implemented are listed below:

AddressAccess RightsDescription
0x00ROSensor Board Interface Version
0x01ROSensor Board Identification
0x02ROSensor Board Status
0x03ROSensor Board Command
0x04RORead Battery Status
0x05WOWrite Battery Status
0x06RORead Battery Charge
0x07WOWrite Battery Charge
0x08WOWireless network status
0x09WOWireless network Strength (RSSI, 0 to 100%)
0x0AWODisplay (when display is available)
0x0BRO Main server address (IPv6)
0x0CROSecondary server address (IPv6)
0x0D to 0x0F--Reserved (Should not be answered) 
0x10 to 0x2FROSensor Point Description (Point 0 to 31)
0x30 to 0x4FRORead Sensor Point (Point 0 to 31)
0x50 to 0x6FWOWrite Sensor Point (Point 0 to 31)
0x70 to 0xFF--Reserved

 

Command Description

Sensor Board Interface Version (0x00)

 

In this register is stored which version of the sensor interface is implemented. At this moment, only version available is 0x00 (alpha version).

 

Request

ValueSizeDescription
0x01BSize
0x00BAddress
CRCSCRC

 

Response

ValueSizeDescription
0x03BSize
StatusBResponse status
0x00BAddress
VersionBInterface version implemented
CRCSCRC

 

Sensor Board Indentication (0x01)

 

This register returns the sensor identification, like serial number, name and the amount of sensor points available. The maximum number of sensor points is 32.


Request

ValueSizeDescription
0x01BSize
0x01BAddress
CRCSCRC

Response
ValueSizeDescription
0x19BSize
StatusBResponse status
0x01BAddress
Model8BEight bytes describing the model name. This field may be filled with (0x00)
Manufacturer8BEight bytes describing the manufacture name. This field may be filled with (0x00)
IDLSensor board ID
RevisionBHardware revision
PointsBNumber of points (maximum is 32
CapabilitiesBSensor capabilities (see capabilities table)
CRCSCRC
 

Sensor Board Status (0x02)

 

This register holds the sensor board status, following table sensor status table. Critical and asynchronous events may be flagged using this register.


Request

ValueSizeDescription
0x01BSize
0x02BAddress
CRCSCRC


Response

ValueSizeDescription
0x03BSize
StatusBResponse status
0x02BAddress
StatusBSensor Status Code
CRCSCRC


Sensor Board Command (0x03)

A command can be sent to the sensor using this register. Refer to the command table (TDB).

 

Request

ValueSizeDescription
0x02BSize
0x03BAddress
CommandBCommand
CRC2BCRC

 

Response

ValueSizeDescription
0x03BSize
StatusBResponse status
0x03BAddress
StatusBCommand execution result
CRCSCRC

Read Battery status (0x04)

 

If the power supply is provided by the sensor, it should report this information using the sensor capabilities field. In this case, this register is used to read the battery status. Please, refer to the battery status table.


Request 

ValueSizeDescription
0x01BSize
0x04BAddress
CRCSCRC


Response

ValueSizeDescription
0x03BSize
StatusBResponse status
0x04BAddress
StatusBBattery status
CRCSCRC

Write Battery status (0x05)

When the battery is attached to the mote, it can use this register to report battery information to the sensor board. A sensor board with display could show this information to the user.

 

Request

ValueSizeDescription
0x02BSize
0x05BAddress
StatusBBattery status
CRC2BCRC


Response

ValueSizeDescription
0x02BSize
StatusBResponse status
0x05BAddress
CRC2BCRC

Read Battery charge (0x06)

If the power supply is provided by sensor it should report this information using the sensor capabilities field. In this case, this register is used to read the battery charge.

Request 

|-------+------+-------------|
| Value | Size | Description |
|-------+------+-------------|
| 0x01 | B | Size |
| 0x06 | B | Address |
| CRC | S | CRC |
|-------+------+-------------|
Response
|--------+------+----------------------------|
| Value | Size | Description |
|--------+------+----------------------------|
| Size | B | Response size |
| Status | B | Response status |
| Charge | B | Battery charge (0 to 100%) |
| CRC | S | CRC |
|--------+------+----------------------------|

Read Battery charge (0x07)

When the battery is attached to the mote, it can use this register to report battery charge to the sensor board. A sensor board with display could show this information to the user.

Request 

|--------+------+----------------------------|
| Value | Size | Description |
|--------+------+----------------------------|
| 0x02 | B | Size |
| 0x07 | B | Address |
| Charge | B | Battery charge (0 to 100%) |
| CRC | S | CRC |
|--------+------+----------------------------|

Response

|--------+------+-----------------|
| Value | Size | Description |
|--------+------+-----------------|
| Size | B | Response size |
| Status | B | Response status |
| CRC | S | CRC |
|--------+------+-----------------|

Wireless network status (0x08)

 

This register is used to report the wireless status to the sensor board. A sensor board with display could show this information to the user. In this case, sensor capability should indicate that wireless information is required.

Request

|--------+------+-----------------------------|
| Value | Size | Description |
|--------+------+-----------------------------|
| 0x02 | B | Size |
| 0x08 | B | Address |
| Status | B | Network status (see table) |
| CRC | S | CRC |
|--------+------+-----------------------------|

Response

|--------+------+-----------------|
| Value | Size | Description |
|--------+------+-----------------|
| Size | B | Response size |
| Status | B | Response status |
| CRC | S | CRC |
|--------+------+-----------------|    

Wireless network strength (0x09)

 

This register is used to report the wireless strength to the sensor board. A sensor board with display could show this information to the user. In this case, sensor capability should indicate that wireless information is required.

Request

|--------+------+-------------------------------------|
| Value | Size | Description |
|--------+------+-------------------------------------|
| 0x02 | B | Size |
| 0x09 | B | Address |
| Status | B | Network signal strength (0 to 100%) |
| CRC | S | CRC |
|--------+------+-------------------------------------|

Response

|--------+------+-----------------|
| Value | Size | Description |
|--------+------+-----------------|
| Size | B | Response size |
| Status | B | Response status |
| CRC | S | CRC |
|--------+------+-----------------|

Display register (0x0A)

 

If the sensor has some display attached (reported in capabilities field),the mote can use it for bringing information to the user. The display need to have a way to map the ASCII information received for a specific display line. Character displays organized as 24x2 (24 columns and 2 lines) are a natural candidate but other displays can be used since a proper mapping is provided.

Request

|-------------+------+-------------------------------|
| Value | Size | Description |
|-------------+------+-------------------------------|
| 26 | B | Size |
| 0x0A | B | Address |
| Line | B | Display Line |
| Information | 24B | Display information, in ASCII |
| CRC | S | CRC |
|-------------+------+-------------------------------|

Response

|--------+------+-----------------|
| Value | Size | Description |
|--------+------+-----------------|
| Size | B | Response size |
| Status | B | Response status |
| CRC | S | CRC |
|--------+------+-----------------|

Main server address (0x0B)  

 

This register holds the server address to which the sensor data should be reported.

Request

|--------+------+--------------|
| Value | Size | Description |
|--------+------+--------------|
| 0x02 | B | Size |
| 0x0B | B | Address |
| Server | 16B | IPv6 address |
| CRC | S | CRC |
|--------+------+--------------|

Response

|--------+------+-----------------|
| Value | Size | Description |
|--------+------+-----------------|
| Size | B | Response size |
| Status | B | Response status |
| CRC | S | CRC |
|--------+------+-----------------|

Secondary server address (0x0C)  

 

When the main server is not available (register 0x09), this register holds the secondary server address to which the sensor data should be reported.

Request

|--------+------+--------------|
| Value | Size | Description |
|--------+------+--------------|
| 0x02 | B | Size |
| 0x0C | B | Address |
| Server | 16B | IPv6 address |
| CRC | S | CRC |
|--------+------+--------------|

Response

|--------+------+-----------------|
| Value | Size | Description |
|--------+------+-----------------|
| Size | B | Response size |
| Status | B | Response status |
| CRC | S | CRC |
|--------+------+-----------------|

Sensor Point Description (0x10 to 0x2F)

 

This range of registers is used to provided information about a specific point like point name, access rights, data type, unit and sampling time. It is possible to use the interrupt line and status register to indicate that a reading is pending for this point. The sampling time is specified as a multiple of 250ms and points with sampling time equal to 0 should not be read in the cyclic readings.

Request

|-------+------+------------------------------|
| Value | Size | Description |
|-------+------+------------------------------|
| 0x01 | B | Size |
| Point | B | Point Address (0x10 to 0x2F) |
| CRC | S | CRC |
|-------+------+------------------------------|

Response

|----------+------+--------------------------------------|
| Value | Size | Description |
|----------+------+--------------------------------------|
| Size | B | Response size |
| Status | B | Response status |
| Name | 8B | Point name |
| | | This field may be filled with (0x00) |
| Type | B | Point type |
| Unit | B | Point unit |
| Rights | B | Access rights |
| Sampling | L | Sampling time (x 250ms) |
| CRC | S | CRC |
|----------+------+--------------------------------------|

Read Sensor Point (0x30 to 0x4F)

 

Read the current value for some sensor point. Point description is used to determine the access rights to the point.

Request 

|-------+------+------------------------------|
| Value | Size | Description |
|-------+------+------------------------------|
| 0x01 | B | Size |
| Point | B | Point Address (0x30 to 0x4F) |
| CRC | S | CRC |
|-------+------+------------------------------|

Response

|--------+------+------------------------------------------|
| Value | Size | Description |
|--------+------+------------------------------------------|
| Size | B | Response size |
| Status | B | Response status |
| Value | - | Point value (size depends on point type) |
| CRC | S | CRC |
|--------+------+------------------------------------------|

Read/Write Sensor Point (0x50 to 0x6F)

Write the current value for some sensor point. Point description is used to determine the access rights to the point.

Request

|-------+------+------------------------------------------|
| Value | Size | Description |
|-------+------+------------------------------------------|
| 0x01 | B | Size |
| Point | B | Point Address (0x50 to 0x6F) |
| Value | - | Point value (size depends on point type) |
| CRC | S | CRC |
|-------+------+------------------------------------------|

Response

|--------+------+-----------------|
| Value | Size | Description |
|--------+------+-----------------|
| Size | B | Response size |
| Status | B | Response status |
| CRC | S | CRC |
|--------+------+-----------------|

Appendix: Tables

Data Types

Available data types

|------+---------+--------------------------------------------|
| Type | Acronym | Representation |
|------+---------+--------------------------------------------|
| 0x00 | B | Byte, 8 bits unsigned |
| 0x01 | b | Byte, 8 bits signed |
| 0x02 | S | Short, 16 bits unsigned |
| 0x03 | s | Short, 16 bits signed |
| 0x04 | L | Long, 32 bits unsigned |
| 0x05 | l | Long, 32 bits signed |
| 0x06 | Q | Long long, 64 bits unsigned |
| 0x07 | q | Long long, 64 bits signed |
| 0x08 | F | Float, IEEE 754 single precision, 4 bytes |
| 0x09 | D | Double, IEEE 754 double precision, 8 bytes |
|------+---------+--------------------------------------------|

Sensor Status

Sensor status table

|------------+---------------------------------|
| Code | Status |
|------------+---------------------------------|
| 0 | OK (normal operation) |
| 1 | Point 1 urgent reading/writing |
| 2 | Point 2 urgent reading/writing |
| 3 | Point 3 urgent reading/writing |
| ... | ... |
| 31 | Point 31 urgent reading/writing |
| 32 | Point 32 urgent reading/writing |
| 33 to 127 | Reserved |
| 128 | General sensor failure |
| 129 to 255 | Reserved |
|------------+---------------------------------|

Commands

Sensor command table

|-------+---------+--------------------------------|
| Value | Command | Description |
|-------+---------+--------------------------------|
| 0 | Reset | Performs a reset in the sensor |
| ... | ... | ... |
|-------+---------+--------------------------------|

Units

Units table (TDB, maybe a simplified version of hart data types)

|--------+---------+-------------|
| Values | Acronym | Description |
|--------+---------+-------------|

Answer Status

Answer status table

CodeStatus
0Success
1General error
2CRC error
3Value is RO
4Value is WO
5Register not implemented

Access Rights

Access rights table

|-------+---------+---------------------|
| Value | Acronym | Description |
|-------+---------+---------------------|
| 0x01 | RO | Reading only |
| 0x02 | WO | Writing only |
| 0x03 | RW | Reading and writing |
|-------+---------+---------------------|

Sensor Capabilities

Sensor capabilities table

|-----+-------+----------------------------------------------------|
| Bit | Value | Description |
|-----+-------+----------------------------------------------------|
| 0 | 0x01 | Sensor has attached battery |
| 1 | 0x02 | Sensor has attached display |
| 2 | 0x04 | Sensor wants to receive periodic information about |
| | | the wireless network status |
| 3 | 0x08 | Sensor wants to receive periodic information about |
| | | battery status (only valid whtn attached battery |
| | | flag is not set) |
| 4-7 | - | Reserved |
|-----+-------+----------------------------------------------------|

Battery Status

Battery status table

|-------+----------------|
| Value | Description |
|-------+----------------|
| 0 | Charged (100%) |
| 1 | Charging |
| 2 | Discharging |
| 3 | Failure |
|-------+----------------|

Wireless Status

Wireless status table

|-------+-----------------------|
| Value | Description |
|-------+-----------------------|
| 0 | Network not available |
| 1 | Connecting |
| 2 | Connected |
| 3 | Invalid joining key |
| 3 | ... |
| ... | ... |
|-------+-----------------------|

 

  • No labels