A Wearable Wireless Sensor Network Node for Prevention of Physical Injuries

Tobias Heiduk1,2, Aye Min Thike3, Peter S. Excell1,* and Ardeshir Osanlou1 1Centre for Ultra-Realistic Imaging, Wrexham Glyndŵr University, Wales, UK (p.excell‖a.osanlou)@glyndwr.ac.uk 2Ingenieurbüro Peter Pöltl, Herzogenaurach, Germany tobias.heiduk@gmx.de 3Department of Computer Science, National Research University of Electronic Technology, Russia ayeminthike52@gmail.com *Correspondence: p.excell@glyndwr.ac.uk


Introduction
The costs of healthcare continue to rise, usually above the rate of inflation. Beyond monetary considerations, however, the loss of productive time and general well-being caused by dynamic injuries (e.g. sports injuries or the results of falling in the elderly) is an additional unquantifiable drain. To address such issues it is logical to look to technological solutions, and hence an inertial sensor linked to a wireless sensor network was explored. In recent years, Micro Electro Mechanical Systems (MEMS) have grown to become an important source of low-cost accelerometer sensor devices, with the capability of being allied to a processor for detailed motion capturing and data analytics. The majority of orthopaedic injuries are related to chronic overuse, sudden displacement of an extremity and applying harmful forces to joints, muscles and tissues: motion capture some application environments. They also do not support the combination of reliability, Quality of Service (QoS), low power drain, data rate, and avoidance of interference required to address the breadth of body area network (BAN) applications. IEEE 802.15.6 is targeted at short distance extremely low power applications and is thus an excellent match for the needs of the proposed design. However, unfortunately, the development of commercial devices corresponding to this standard was still in progress during this research and, as a consequence, the chosen standard for the present work was IEEE 802.15.4.

Motion Sensors for Monitoring Body Motion
The development of Micro Electro-Mechanical Systems (MEMS) has transformed many application markets, notably that for accelerometers. These are inertial motion sensors which convert physical motion to electronic signals. To generate electrical values reflecting the acceleration experienced by the sensor a calibrated mass forms the upper plate of a capacitor: this is separated from the lower plate (substrate) by an anchor and it can swing in two directions. Capacitive change is electronically measured and can be easily converted to represent the acceleration of one sensor axis [10,11]. By combining three of these units in an orthogonal arrangement the whole system is able to measure acceleration in three degrees of freedom.
Another important MEMS-based sensor type is the gyroscope, which consists of a fork-shaped Piezoelectric crystal, which constantly oscillates in a defined motion. When the sensor is rotated, the Coriolis effect disturbs this motion and the change of motion induces a current that is equal to the angular velocity [12]. The combination of these sensors enables estimation of (for example) the angles of human limb joints by data interpretation from two sensors attached on each side of the joint. This information is of great value in physiological therapy for both the therapist as well as the patient.
The leading current producers of MEMS are STMicroelectronics [13] and InvenSense [14]. Both companies provide components with tri-axial accelerometers, gyroscopes and magnetometers, with similar features and pricing. However, the InvenSense MPU-Family additionally provides a built-in digital motion processer (DMP) which allows the conservation of processing power at the host CPU. Furthermore, other useful sensors, for example, for temperature or resistance, could be included via the auxiliary I2C port [15]. As a result the MPU-9250 from InvenSense was chosen for this work. This device is able to sense external interrupts and process them via the interrupt status register or the DMP. Further, by setting the self-test registers all units of the accelerometer and gyroscope can be tested: this is done by actuating the sensors through the built-in electronics; then, by measuring the output signal the correct mode of operation is ensured.  The MPU-9250 is a multi-chip module. Two housings, one for the accelerometer and gyroscopes, one for the magnetometer, are provided in a QFN package, having dimensions 3 x 3 x 1 mm3. The sensor includes nine 16-bit analogue-to-digital converters to digitize the data for all three axes of each of the three measurement sensor ensembles. The latest accumulated data can then be read from the sensors' read-only registers at any time or stored in the internal 512-byte built-in FIFO register and sent in burst mode. The FIFO configuration register defines which data is written into the register and the FIFO counter keeps track of the valid inserted data. The previously mentioned DMP provides its own registers, but is also able to provide the data in the FIFO register for burst transmission ( Fig.  1) [15].

The Node Processor and Transceiver
The node processor has the primary tasks to initialize the motion sensor, start up the communication between the nodes and ensure the data flow between motion sensor and communication unit. For this purpose the ATmega 128RFA1 8-Bit microcontroller was chosen: this is produced by Atmel and it includes a low power ZigBee transceiver for the 2.4 GHz ISM band [16]. The built-in transceiver reduces the power consumption compared with a separate unit, plus simplification of the hardware design and hence a reduction of potential production costs, as well as improved maintainability. The processor operates with 8-bit arithmetic at 16 MHz clock frequency. The external interrupt pins are used to sense interrupts caused by the motion sensor. The internal timer is used for the PWM (Pulse Width Modulation) of the LED output signals representing the sensor values in the demonstration prototype. The microcontroller can be on-board programmed via the ISP interface.
For communication between the sensors and a host computer the ATmega 128RFA1 offers the option of sending data via the ISM 2.4GHz frequency band. However, the necessary hardware is implemented in the design and the wireless connection can be established after completing the framework for the data transmission service. For the present prototype work the UART interface was employed to transmit the sensor values to the host computer. To keep the overhead of the frames as small as possible a contention-free protocol provided by the IEEE 802.15.6 standard was used.

The Sensor Board
The sensor board is driven by two voltage regulators which deliver output voltages of 3.3V and 5V. The board provides several connectors for programming and debugging and a program switch to change the program mode. In order to build a light and compact sensor node all components were chosen to be as small as the electronic specification allowed. All resistors and capacitors are in 603 or 402 surface-mount packages [17]: a design entirely consisting of 402 package components could be realised for automated assembly. For the development board two multi-colour LEDs were provided to represent the gravity force or angular velocity, where blue refers to x-axis, green to the y-axis and red to the z-axis. If the MPU-9250 senses acceleration or a rotation the corresponding LED will be pulsed analogously to the magnitude of the measured values. The LEDs are connected to Port E0 to Port E5 and were driven by N-Channel MOSFETs in SOT-23 packages.
The driver stages are designed for low power application due to their high input resistance. To eliminate the resonant behaviour of the parasitic inductances and capacitances two 4x100 ohm resistor arrays were connected between the microcontroller output and the gates of the FETs. There are no high demands on switching speed, as the sample frequency will be between 100 Hz and 300 Hz. The program switch is represented by a simple 4-bit switch array connected to the low nibble of PORTF. This allows the user to enter different program modes. The Atmel Corporation also provides a library for multi-touch capacitive sensing input solutions that would be a more elegant realisation for the final design.
As one of the basic objectives of this work is to miniaturise the node as far as possible a further compressed PCB Layout design was created beside the evaluation board design. By using freeware www.aetic.theiaer.org programs for designing the PCB layout it was possible to reduce the size from 110 x 110 mm2 to 50 x 45 mm2 (Fig. 2). The physical realisation is shown in Fig. 3.

Software Design
In order to send properly processed data to the host processing unit the software of the sensor node has to deliver accurate data in consistent frames. The following flowcharts show the pseudocode divided into convenient blocks, to separate the main function and the called subroutines.
The main program (Fig. 4) starts by calling two initialisation routines. The first called routine is the microcontroller initialisation, followed by sensor initialisation (Fig. 5) which sets the I/O configuration of the microcontroller, initialises the Watchdog to prevent fatal software crashes and initialises the Two Wire Interface (TWI/I2C-Bus). As soon as the TWI is set the sensor requests the device ID from the MPU-9250 motion sensor. If the microcontroller does not receive the correct ID it will enter the TWI/Sensor Error routine. If the request was successful the node LEDs indicate positive initialisation of the sensor and it goes on with the sensor set up.
The MPU-9250 has a MEMS self test function to ensure failure-free operation [15]. If the sensor fails, the program moves on to the sensor error routine. To obtain the desired values, the relevant measurement range has to be selected by enabling the prescaler of the MEMS digital output. In extreme conditions, a human can accelerate body parts at over 80G which is substantially beyond the measurable range with this device. However, for most typical purposes it is sufficient to use the maximum available range of 16G linear acceleration and 2000 rad/s angular velocity.
To access the built in magnetometer AK8963 directly the I2C bypass mode has to be enabled. If the bypass is activated the magnetometer ID can be requested: if the requested ID is correct the program proceeds to the power management where the WOM (Wake On Motion) function, sample frequency and power modes are set.
In the general case, the program would now be in a pending loop until all nodes have been added to the network. The network host starts the calibration of the nodes synchronously by sending a broadcast command. When the calibration starts the user (assuming a set of body-worn sensors is being considered) has to be in a defined starting condition, e.g. standing up straight. The microcontroller activates the DMP of the sensor and receives a calibrated data set (Fig. 6). The idea of the calibration is basically to move each sensor in a particular way that results in a different output value profile for each sensor such that it can identify the mounting position of the node.

Testing
For initial static testing, all delicate components were first detached from the voltage regulators by removing the serial jumper resistors. After connecting the board to an external power supply the output voltage of the regulators was measured and it was ascertained that the stabilisers were working correctly. Hence, since the voltage regulators are specified for 1A output current and the board consumes a maximum of 150mA there was no noticeable voltage ripple measurable. In the next step the microcontroller was connected to the host computer via ISP to read out the chip signature. The successful read out proved that all essential supply connections to the controller were intact and the controller was programmable. To verify all remaining connections a test program was written into the microcontroller which internally generated a bit pattern, depending on the state of the switch S1. The pattern was loaded into the output register of the used ports via jumper cables: these six ports were connected to the remaining six used pins which read the bit pattern and send it to two RGB LEDs. Each bit pattern represents a certain colour pattern of the LEDs which proves the correct bonding of all used microcontroller pins. Parametric testing was represented by an endurance test which represented the actual operation of the sensor node in a real application. For three hours the microprocessor collected acceleration and gyroscope values from the MPU-9250 and sent those values via UART to the host computer. During this test all possible movements were repeatedly performed to simulate the normal operation conditions. The test showed that the operation at maximum speed caused instability of the system: the fault was traced to the TWI section of the code but it could not be narrowed down any further. However, after introducing wait intervals after every value set in transmission the evaluation board operated failure-free. As the sample time of further data processing will be about 200 Hz this wait interval will not interfere with the operation as long as it is kept shorter than 4ms.
To prove the functionality of the hardware design a basic software framework was developed. The code was divided into the main C pre-processor directives named "FlowMotion.cpp", "UART.cpp", "twimaster.cpp" and "AcquireValueSet.cpp": these perform all sensor-related functions. The "TC.cpp" sets the timer counter for the PWM function. The main function initialises the microcontroller, the TWI and the UART interface as well as the Watchdog. The Watchdog is an error routine provided by the Atmel controllers to reset the controller if the program is stuck at a particular point. If the Watchdog timer is not reset within 4 seconds the microcontroller will set the www.aetic.theiaer.org Watchdog interrupt to reset the program. If a certain program routine requires more than 4 seconds runtime the Watchdog timer has to be reset during the execution. If the internal program switch is set to zero the board is in standby state and acceleration and gyroscope LEDs are illuminated red. If the switch is set to binary 0001 the microcontroller requests the device ID from the sensor, then if this is transmitted successfully the LEDs are illuminated green; if not they are yellow. Switch setting 0010 enables plotting of the acceleration values via a program SIMPLOT. Switch state 0100 allows plotting of the angular velocity. For the plotting function the MPU_AcquireValues function is first called to store the current sensor values in the declared variables: depending on which sensor values are desired to be plotted, the function uses the acceleration or angular velocity data. The final program switch state, binary 1000, enables visualisation of the acceleration and angular velocity via the two multicolour LEDs. By using the software PWM routine, the intensity of a particular colour indicates the magnitude of the measured values.
The first function that is called, function TCSampleTimer, initialises the 8 bit Timer/Counter 0 which jumps to the Timer/Counter 0 subroutine after counting to 256. In the subroutine the virtual counter VCount will be incremented which results in a sample time of 4.096 ms, corresponding to a frequency of 244.14 Hz: When running, the interrupt status register (ISR) is called 256 times and a variable VCount is increased from 0 to 256 within 4ms. During every call of the ISR the LED ports are set to high level: the sensor values are compared with the current value of VCount and if it is greater than the compared sensor value the corresponding LED is switched off.
As negative values in binary are nominally higher than positive values a corrective function is needed to manipulate the values so that negatives are handled in the correct relationship to positives.
The range of sensor values reaches from 0x00 to 0x7F which represents +(sensor-range/2) and 0x80 and 0xFF which represents -(sensor-range/2). To get the same PWM output response for negative values as for positive values the program checks whether the sensor output value is higher than 0x7F. If that is the case an exclusive-or operation is applied to the value, toggling each bit to transform the negative value into an equal positive value (Fig. 7).

Conclusions
The system described addresses modern digitalisation of healthcare issues, such as physiological injuries, by introducing a wireless inertial sensor network which enhances monitoring of activities for constraint movement identification and injury prevention, potentially decreasing treatment costs dramatically: the applications are typically in sports for young people and fall mitigation for the elderly. A functional device which is able to measure acceleration, angular velocity and the magnetic field in three axes with nine degrees of freedom has been designed and realised as prototype hardware. The device consists of a MEMS integrated circuit for physical motion measurement (plus a magnetic field sensor), a microcontroller to gather information from the sensors and provide feedback to the user and a wireless connection unit for communication. The node acquires a constant and consistent data stream of sensor values and delivers the data to the network host. Only miniaturised components have been used to ensure that the sensor node can be realised as an unintrusive wearable device. The material costs for the prototype were around £30 (GBP), of which the motion sensor unit constitutes around one third. A reduction of the total material costs by 50% is estimated to be achievable for mass production. The unit should desirably use the IEEE 802.15.6 Body Area Network standard for wireless networking, but commercial implementations were still in development at the time of the work. As such hubs become available on the market this standard provides great potential for applications of this type as it will enable data transmission with a power consumption of less than 1mW, empowering designs to create a self-sustaining system through energy harvesting on the body.

Note
This paper is a reworking and extension of a preliminary report that was presented at a local conference in Moscow [18].