Sensor Boards

TEP:109
Group:Core Working Group
Type:Documentary
Status: Draft
TinyOS-Version:2.x
Author: David Gay, Phil Levis, Wei Hong, and Joe Polastre
Draft-Created:19-Apr-2005
Draft-Version:1.1.2.1
Draft-Modified:2005-10-31
Draft-Discuss:TinyOS Developer List <tinyos-devel at mail.millennium.berkeley.edu>

Note

This memo documents a part of TinyOS for the TinyOS Community, and requests discussion and suggestions for improvements. Distribution of this memo is unlimited. This memo is in full compliance with TEP 1.

Abstract

This memo documents how sensor boards are organized in TinyOS, and the general principles followed by the components that provide access to its sensors.

1. Introduction

This document defines the default organization of a sensor board in TinyOS. There likely will be sensor boards that cannot conform to this specification, but following as closely to its spirit as possible will simplify generic applications that use a range of sensor boards.

This document assumes that sensors return uninterpreted 16-bit values, and, optionally uninterpreted, arbitrary-size calibration data. Conversion of sensor values to something with actual physical meaning is beyond the scope of this document.

2. Directory Organization

A simple example: the basic sensor board is named basicsb, it's directory is tinyos-2.x/tos/sensorboards/basicsb. It has no basicsb.h file and its .sensor file is empty. It has two components, PhotoC and TempC representing its light and temperature sensors.

3. Sensor Board Components

We have not yet selected any naming conventions for sensor board components. Please select reasonable namesldots

A sensor board component MUST provide:

A sensor board component MAY provide:

The CalibrationData interface is shown below, while AcquireData, AcquireDataNow and AcquireDataBuffered are in TEP 101. The AcquireData interface returns uinterpreted 16-bit data. This might represent an A/D conversion result, a counter, etc. The optional calibration interface returns uninterpreted, arbitrary-size data.

A sensor board component SHOULD be as lightweight as possible - it should just provide basic access to the physical sensors and SHOULD NOT attempt to do calibration, signal processing, etc. If such functionality is desired, it SHOULD be provided in separate components.

interface CalibrationData {
/* Collect uninterpreted calibration data from a sensor */

/** Request calibration data
*  @return SUCCESS if request accepted, FAIL if it is refused
*    data error will be signaled if SUCCESS is returned
*/
command result_t get();

/** Returns calibration data
* @param x Pointer to (uinterpreted) calibration data. This data
*   must not be modified.
* @param len Length of calibration data
* @return Ignored.
*/
event result_t data(const void *x, uint8_t len);
}

Some common setups for sensor board components are:

configuration Accelerometer2D {
provides {
interface StdControl
interface AcquireData as AccelX;
interface AcquireDataNow as AccelXSingle;
interface AcquireDataBuffered as AccelXMultiple;
interface CalibrationData as AccelXCalibration;

interface AcquireData as AccelY;
interface AcquireDataNow as AccelYSingle;
interface AcquireDataBuffered as AccelYMultiple;
interface CalibrationData as AccelYCalibration;
}
}

Sensor board components MUST respect the following conventions on the use of the Init, StdControl, and SplitControl interfaces. These are given assuming StdControl is used, but the behaviour with SplitControl is identical except that start and stop are not considered complete until the startDone and stopDone events are signaled. The conventions are:

  1. Init.init: must be called at mote boot time.

  2. StdControl.start: ensure the sensor corresponding to this component is

    ready for use. For instance, this should power-up the sensor if necessary. The application can call getData once StdControl.start completes.

    If a sensor takes a while to power-up, the sensor board implementer can either use a SplitControl interface and signal startDone when the sensor is ready for use, or delay dataReady events until the sensor is ready. The former choice is preferable.

  3. StdControl.stop: put the sensor in a low-power mode. StdControl.start must be called before any further readings are taken. The behaviour of calls to StdControl.stop during sampling (i.e., when an dataReady event is going to be signaled) is undefined.

.sensor File

This file is a perl script which gets executed as part of the ncc nesC compiler frontend. It can add or modify any compile-time options necessary for a particular sensor board. It MAY modify the following perl variables, and MUST NOT modify any others:

Example: mts3x0

The mica sensor board (mts300/mts310) has five sensors (and one actuator, the sounder) -- the accelerometer and magnetometer are only present on the mts310:

Name | Component | Sensor Interfaces | Other Interfaces |

+===============+===========+===================+==================+

Accelerometer | AccelC | AccelX | |
| | AccelY | |
Magnetometer | MagC | MagX | MagSetting |
| | MagY | |
Microphone | MicC | MicADC | Mic |
| | | MicInterrupt |
Light | PhotoC | PhotoADC | |
Temperature | TempC | TempADC | |

Each physical sensor is represented by a separate component. Specific sensors that have more than one axis of measurement (AccelC and MagC) provide more than one AcquireData interface on a single component. Some sensors, such as the magnetometer and microphone, have additional functionality provided through sensor-specific interfaces.

Although light and temperature are represented by separate components, in reality they share a single microcontroller pin. The two components PhotoC and TempC sit on top of the PhotoTempP component, which controls access to the shared pin, and orchestrates which sensor is currently connected to it. From a programmer's perspective, they appear as individual sensors, even though their underlying implementation is a bit more complex.

The board's mts3x0.h file contains private configuration data (pin usage, ADC ports, etc).

The mica sensor board has an empty .sensor file.

6. Author's Address

David Gay
2150 Shattuck Ave, Suite 1300
Intel Research
Berkeley, CA 94704

phone - +1 510 495 3055


Wei Hong
Arched Rock
Berkeley, CA 94704


Philip Levis
358 Gates Hall
Computer Science Department
353 Serra Mall
Stanford, CA 94305

phone - +1 650 725 9046


Joe Polastre
467 Soda Hall
UC Berkeley
Berkeley, CA 94720