sufficient stable offset (RegOffset). These steps are
shown in Figure 1 and described in the next
paragraphs.
A rejection filter evaluates each calculated offset
value to find whether it is usable for further
processing. Some values may be completely off
scale due to transient delays in the network. These
values have to be rejected. The accepted offset
values (Offset
m
) are fed into an I-regulator.
The I-regulator compares each accepted offset
value with the current stable offset (RegOffset). The
comparison is a feedback path that enables the
regulator to track the clock drift changes between
master and slave. The error is accumulated in the
regulator. The RegOffset value is calculated by
multiplying accumulated error with the integration
factor ki. RegOffset is calculated for each accepted
offset value, but its value will not change at each
calculation. The RegOffset changes so slowly that it
is usable for calculating timestamps using (4). Each
time a measurement is done its timestamp can be
converted using (4) at the cost of one integer
addition.
TM
meas
(TS
meas
) = TS
meas
+ RegOffset (4)
To speed up the I-regulator at start-up, an initial
offset (ZeroOffs) is calculated. The average of the
first 10 accepted offset values is used. An average is
needed to compensate for the delay variation in the
network. When the ZeroOffset is calculated the rest
of the accepted offset values will be fed to the
comparator.
The poll rate together with the integration factor
ki decides the responsiveness of the regulator. The
integration factor ki can be in the (0,01..0,1) range in
order to integrate over 100 to 10 samples. A small ki
will use longer time to track, and this can be
observed as a constant lag error when oscillator drift
is large. The selection of ki decides the jitter, i.e.
change of RegOffset generated for each poll. A
monotonically increasing timestamp can be achieved
by having the RegOffset peak change less than half
the measurement sample rate.
The master can be implemented using integer
math. The integer size depends on the resolution and
timespan the implementation needs to cover.
The implementation of the master can be done at
the hub node or at the sensor node. Implementation
at the hub node will leave a minimum footprint at
the sensor node. The hub mode time format can be
invisible for the sensor node. This is convenient if
the sensor node needs to be time format agnostic. As
long as the number of master instances at the hub
node not causes problem, master at hub node is the
most flexible configuration.
Implementation of the master at the sensor node will
scale better for large configurations, where the hub
node gets measurements with ready calculated
timestamps. Equation (4) need to be reordered for
this configuration since TM needs to be converted to
TS.
4 IMPLEMENTATION AND
SETUP
The experimental implementation described has a
PC as master and hub node and three embedded
microcontrollers as slaves and sensor nodes. The
setup is shown in Figure 2.
Figure 2: Setup with PC and three sensor nodes.
The master is implemented in Java running on a
MS Windows 7 PC. This is convenient for logging
of data for later analysis. Three sensor nodes using
different Bluetooth connections have been used;
Targus USB dongle with a Bluetooth host stack
running on the PC. Sensor node is using an ARM
CORTEX-M3 processors and a WT12 Bluetooth
module from BlueGiga running Serial Port Profile
(SPP) connected with a serial interface to the ARM
processor (Strisland, 2013).
Roving module with Bluetooth stack running on
module connected to the PC using FTDI serial
interface. Sensor node same as for Targus.
BlueGiga BLE112 USB dongle with Bluetooth
Smart stack running in the dongle. Sensor node is
using an ARM CORTEX-M3 processor and
nRF8001 Bluetooth Smart IC from Nordic
Semiconductor (Liverud, 2012).
The local clock for all sensor nodes is a crystal
producing 4ms ticks. All three sensor nodes have
been running simultaneously with various
measurements such as gyroscope and raw ECG. The
accuracy of the synchronization has been measured
by forcing a simultaneous rotation to the three nodes
and analysing the gyroscope measurements.
Poll sequence rate is set to 250 milliseconds and
PeerSynchronizationMethodforWirelessSensorNetworksusingHeterogeneousBluetoothSensorNodes
177