View
62
Download
7
Category
Tags:
Preview:
Citation preview
Ambient Activity Monitoring System using a Tri-axial
Accelerometer
by
Keith Connaughton
This Report is submitted in partial fulfilment of the requirements of the
Honours Degree in Electrical and Electronic Engineering (DT021) of the
Dublin Institute of Technology
May 31st, 2013
Supervisors: Dr. Ted Burke and Dr. Damon Berry
Ambient Activity Monitoring System
i
Abstract
This project presents a prototype of a wireless activity monitoring system for human
activity classification. The system consists of two main parts; the first is the wireless
activity monitoring sensor (WAMS), which consists of a tri-axial accelerometer, a
microcontroller (dspic30f4011) and wireless XBee communications module. The
second is the activity classification program (MATLAB), which is used to identify
human activity using the accelerometer data from the sensor. The system has
wireless communication capabilities and the network topology includes a base
station connected to a personal computer.
The prototype sensor is adaptable to household furnishings to monitor human
activity in a nonintrusive way. For this project, the wireless sensor is attached to an
office chair to measure human activity. The system uses a classification algorithm
that employs a neural network model for recognising a set of human activities on an
office chair. This algorithm is capable of distinguishing three human activities on an
office chair (sitting, getting up and unoccupied).
Ambient Activity Monitoring System
ii
Declaration
I hereby declare that this thesis is my own work and effort and that it has not been
submitted anywhere for any award. Where other sources of information have been
used, they have been acknowledged.
Signature: ……………………………………………………
Date: ……………………………………………………..
Ambient Activity Monitoring System
iii
Acknowledgements
I would like to thank my supervisors, Dr. Ted Burke and Dr. Damon Berry for their
guidance and support during my project and study at Dublin Institute of Technology.
Ted and Damon were always accessible and willing to help with my research,
making the project experience a smooth and a rewarding one. I want to sincerely
thank Dr. Ted Burke for his blog on dspic microcontrollers (Batchloaf WordPress)
which was an invaluable resource for programming microcontrollers (dsp30f4011).
Ambient Activity Monitoring System Table of Contents
iv
Table of Contents
1.1 Introduction .................................................................................................... 1
1.2 Project Concept and Objectives ..................................................................... 2
1.3 Thesis Structure ............................................................................................. 4
2.0 Literature Review ........................................................................................... 5
3.1 Hardware Design ........................................................................................... 6
3.1.1 Three-axis Accelerometer (MMA736L) ................................................. 7
3.1.2 Microcontroller dsPIC30F4011 ............................................................. 7
3.1.3 Wireless Communication ...................................................................... 9
4.0 Software Design and Algorithms .................................................................. 10
4.1 Microcontroller (dsPIC30F4011) Program ................................................... 10
4.2 Classification Algorithm ................................................................................ 12
4.2.1 FIR Low-pass Filter............................................................................. 15
4.2.2 Feature Extraction Techniques ........................................................... 16
4.3 MATLAB Program ........................................................................................ 18
5.0 Testing and Validation ................................................................................. 20
5.1 Data Description .......................................................................................... 20
5.2 Feature Extraction ........................................................................................ 22
5.3 Human Activity Classification Model for Office Chair ................................... 24
Chapter 1 1
Chapter 2 5
Chapter 3 6
Chapter 4 10
Chapter 5 20
Ambient Activity Monitoring System Table of Contents
v
6.0 Discussion.................................................................................................... 25
6.1 Conclusion ................................................................................................... 26
Appendix A – Activity Monitoring Sensor Schematic.......................................... 28
Appendix B – Microcontroller Program (dsPIC30F4011) ................................... 29
Appendix C – MATLAB Program ....................................................................... 32
Appendix D – Zero-crossing() MATLAB Function .............................................. 35
Appendix E - Training Data Results ................................................................... 36
Chapter 6 25
Bibliography 27
Appendices 28
Ambient Activity Monitoring System Table of Figures
vi
Table of Figures
Figure 1.1: System Block Diagram ............................................................................. 3
Figure 3.1: Sensor Prototype and System Overview .................................................. 6
Figure 3.1.3: XBee Series 2 Schematic ...................................................................... 9
Figure 4.1: Control Flow Diagram for the Microcontroller Program .......................... 12
Figure 4.2: Block Diagram for Classification Algorithm ............................................. 14
Figure 4.2.1: Filtered Accelerometer Data ................................................................ 15
Figure 4.3: Accelerometer Data ............................................................................... 19
Figure 5.1.1: Accelerometer Data for Unoccupied Office Chair ................................ 21
Figure 5.1.2: Accelerometer Data for Sitting Activity on Office Chair ....................... 21
Figure 5.1.3: Accelerometer Data for Getting-up Activity on Office Chair................. 22
Figure 5.2: Feature Extraction Data for Human Activity on an Office Chair .............. 23
Figure 5.3: Feature Extraction Data with Linear Neural Network Model ................... 24
Figure E.1: Accelerometer Data for Unoccupied Office Chair .................................. 36
Figure E.2: Accelerometer Data for Unoccupied Office Chair .................................. 36
Figure E.3: Accelerometer Data for Unoccupied Office Chair .................................. 37
Figure E.4: Accelerometer Data for Unoccupied Office Chair .................................. 37
Figure E.5: Accelerometer Data for Unoccupied Office Chair .................................. 38
Figure E.6: Accelerometer Data for Unoccupied Office Chair .................................. 38
Figure E.7: Accelerometer Data for Sitting Activity on Office Chair .......................... 39
Figure E.8: Accelerometer Data for Sitting Activity on Office Chair .......................... 39
Figure E.9: Accelerometer Data for Sitting Activity on Office Chair .......................... 40
Figure E.10: Accelerometer Data for Sitting Activity on Office Chair ........................ 40
Figure E.11: Accelerometer Data for Sitting Activity on Office Chair ........................ 41
Figure E.12: Accelerometer Data for Sitting Activity on Office Chair ........................ 41
Figure E.13: Accelerometer Data for Getting-up Activity on Office Chair ................. 42
Figure E.14: Accelerometer Data for Getting-up Activity on Office Chair ................. 42
Figure E.15: Accelerometer Data for Getting-up Activity on Office Chair ................. 43
Figure E.16: Accelerometer Data for Getting-up Activity on Office Chair ................. 43
Figure E.15: Accelerometer Data for Getting-up Activity on Office Chair ................. 44
Figure E.16: Accelerometer Data for Getting-up Activity on Office Chair ................. 44
Ambient Activity Monitoring System Chapter 1
1
Chapter 1
1.1 Introduction
Human activity monitoring has become a huge area of research in recent years. It is
a prominent and difficult field that can support many novel applications. Typical
applications are smart homes, home healthcare, elderly fall detection systems and
office ergonomics. Activity monitoring is a research area that involves technologies
such as machine learning and human computer interaction.
The objective of an activity monitoring system is to identify the activities of its user in
an none intrusive way. For example, an activity monitoring system in a home
environment can monitor a user’s activities to remind them to perform forgotten
activities or actions such as taking medicine or encourage them to act more safely
(1). Activity recognition systems in hospital environments could be utilized to remind
doctors or nurses to perform certain tests before operating (2).
The ability to recognize different activities seems to be easy and natural for people
but it involves the difficult task of sensing, learning and interfacing (2). Moreover,
identifying different human activities is a difficult challenge for automated activity
monitoring machines and systems and it will require the system to sense the ambient
environment changes, learn from experiences and to classify the activity correctly.
Therefore, the aim of the ambient activity monitoring system is to enable machines to
have similar capabilities as people for identifying human activities (2).
Ambient Activity Monitoring System Chapter 1
2
1.2 Project Concept and Objectives
The objective of this project is to design an ambient recognition system that can
automatically recognize human activities using a 3-axis accelerometer. The
proposed system is designed to be none intrusive to the user and it should allow the
sensor to be attachable to household furniture, doors and medical cabinets for
human activity monitoring.
The system consists of two main parts; the first is the wireless activity monitoring
sensor (WAMS), which consists of a three-axis accelerometer, a microcontroller
(dspic30f4011) and wireless XBee communication module. The second is the activity
monitoring algorithm (MATLAB) which is used to monitor and train the sensor.
The system is implemented for multi-user activity monitoring. Multi-user activity
monitoring means training the system based on observed data to classify different
human activities (e.g. someone opening a door or someone sitting on an office
chair), more than one user can train the system for multi-user activity monitoring.
Initially, the system is trained by the user to identify different human activities but
once the algorithm has been trained, it uses the raw data from the sensor to classify
the action or activity.
Figure 1.1 shows a block diagram of how the data is processed in the system. A
laptop is used for data acquisition and analysis. An office chair is equipped with the
activity monitoring sensor. Raw accelerometer data is sent from the sensor to the
laptop wirelessly using XBee modules. The laptop will be equipped with a XBee USB
dongle in order to create the wireless communication link between the sensor and
the MATLAB application. Once the system has been trained to detect three classes
of human activity (sitting down, unoccupied and getting up) on the office chair, the
MATLAB program will receive the raw accelerometer data from the sensor and it will
provide the user with the activity classification.
Ambient Activity Monitoring System Chapter 1
3
0 5 10 15-0.2
0
0.2
Time (sec)
X Accelerometer Data
0 5 10 15-0.5
0
0.5
Time (sec)
Y Accelerometer Data
0 5 10 15-1
0
1
Time (sec)
Z Accelerometer Data
Figure 1.1: System Block Diagram
Ambient Activity Monitoring System Chapter 1
4
1.3 Thesis Structure
The subsequent chapters of this thesis are organized as follows:
• The literature review in Chapter 2 discusses different ambient and wearable
activity monitoring systems and it describes the systems used to classify
human activity.
• Chapter 3 describes the hardware architecture of the ambient activity
monitoring system and its various components.
• Chapter 4 gives an in-depth description of the software implementation, the
software algorithms, the digital signal processing and the activity monitoring
classifications (Neural Network).
• Chapter 5 explores the testing of the system for an office chair, explaining the
strategies used and the results obtained.
• Chapter 6 finishes with a discussion and a conclusion followed by a list of
references and a complete set of appendices. The code written for the
microcontroller and the MATLAB program are in the appendices of the report
and they are referred to throughout this thesis.
Ambient Activity Monitoring System Chapter 2
5
Chapter 2
2.0 Literature Review
Human activity monitoring can be categorized into ambient monitoring systems and
wearable monitoring systems (3). Since these techniques require actual human
observations or video cameras or measuring devices worn by the user, these
techniques can be grouped in a direct way to record human activity.
The activity monitoring system described by (4) is made up of three cameras. They
operate either as a set of three static cameras or as a set of one fixed camera and
an active binocular vision system. The human activity is monitored by extracting
several features that are useful for the activity classification. The system has a
database, which allows the type of activity to be identified.
The activity monitoring system described by (5) provides a way of monitoring and
identifying elderly people’s activities in the home environment. The system consists
of sensors attached to household furnishings and video cameras to record the
different activities. This system combines the data provided by the video cameras
with the data provided by the sensors to recognise the daily activities of the elderly
people.
The environmental sensor based system described by (6) is achieved by distributing
a number of ambient sensors, especially binary on-off state sensors, throughout the
subject’s living environment. The data gathered by these environmental sensors can
be used to adapt to the user’s environment. The sensors passively monitor the
occupants every day, therefore require no action on the part of the user to operate.
The ambient sensors transmit data wirelessly to a local PC where the data is
processed and the activity is logged to a database.
Ambient Activity Monitoring System Chapter 3
6
Chapter 3
3.1 Hardware Design
The Wireless Activity Monitoring Sensor (WAMS) provides ambient activity
monitoring using a 3-axial accelerometer. The main reason why an accelerometer
was chosen compared to other sensors (Passive Infra Red, etc) was its versatile
capabilities. An accelerometer can measure both dynamic and static acceleration (tilt
angle) making it adaptable to many activity monitoring applications. The prototype
sensor is housed in a plastic enclosure and it has four main components. They are a
3-axis accelerometer (MMA7361L), a microcontroller (dspic30f4011 Microchip), a
XBee (Series 2) wireless communication module and a AA battery pack. The activity
monitoring sensor has a supply voltage of 3 volts and it draws 100mA when
transmitting data continuously. A laptop is equipped with a XBee USB dongle to
receive data from the sensor. Figure 2.1 shows an overview of the system
components.
Figure 3.1: Sensor Prototype and System Overview
Microcontroller XBee Module
3 V Supply Accelerometer
Wireless Communication Network
XBee USB Dongle
Ambient Activity Monitoring System Chapter 3
7
3.1.1 Three-axis Accelerometer (MMA736L)
The MMA736L is a small, thin, low power, three-axis analog accelerometer with
signal conditioned voltage outputs, all on a single monolithic integrated circuit. This
device is set to measure acceleration at +/- 1.5g with a sensitivity of 800 mV/g. The
MMA736L accelerometer uses a single structure for sensing the X, Y and Z axes. It
can measure the static acceleration of gravity in a tilt-sensing application as well as
dynamic acceleration resulting from motion, shock or vibration.
The output signals X, Y and Z are analog voltages that are proportional to
acceleration. The MMA736L accelerometer has an operating voltage between 2.7-
3.4 volts.
3.1.2 Microcontroller dsPIC30F4011
The dsPIC30F4011 microcontroller is an inexpensive single-chip computer that has
I/O circuitry and peripherals built-in, allowing it to interface with real-world devices.
The microcontroller contains a CPU, RAM, ROM, discrete I/O, serial and parallel
ports, timer interrupts, analog-to-digitals and digital-to-analog converters. The
dsPIC30F4011 was chosen for this project for the following reasons:
• Supply voltage range (2.5-5.5V)
• 9 analog input channels (10-bit)
• 2 UART channels
• Multiple digital I/O (inputs and outputs) pins
• Cheap and reliable
• C programmable
Ambient Activity Monitoring System Chapter 3
8
The clock speed for the microcontroller is set to 20 MIPS (Million Instructions Per
Second). An external 10 MHz crystal oscillator was used to provide a stable CPU
clock frequency. This allows the A/D channels to be sampled at precise time
intervals using a timer interrupt. A serial communication link was established
between the microcontroller and the XBee module using UART (Universal
Asynchronous Reciever Transmitter).
UART is a piece of hardware that translates data between devices. The UART
converts bytes of data to bits and it transmits the data. At the destination, a second
UART converts the bits into bytes. For this project, the baud rate is set to 57600 bits
per second.
MMA736L, a three axis accelerometer provides analog voltages on three axes X, Y
and Z, which are proportional to acceleration. As the accelerometer generates
analog voltages, it is interfaced to the analog pins of the dsPIC30F4011. The X, Y
and Z pins of the accelerometer are connected to the AN0, AN1 and AN2 of the
microcontroller. The microcontroller samples the analog voltages on the three A/D
channels and converts the analog signal to a 10-bit digital number. This data is then
transmitted serially to the XBee module.
The A/D converter on the microcontroller has a unique feature of operating in sleep
mode by using the conversion clock from the A/D internal oscillator. This is a useful
feature for power saving when the sensor is not active. This would allow the overall
power consumption of the sensor to be reduced.
Ambient Activity Monitoring System Chapter 3
9
3.1.3 Wireless Communication
Various protocols for wireless communications are available to transfer data from
microcontrollers such as Bluetooth, ZigBee and MiWi. For this project, a ZigBee
protocol is used because it adds additional routing and networking functionality.
XBee (Series 2) is a wireless transceiver that has the ZigBee protocol embedded in
its firmware. Interfacing with the XBee requires the use of the UART protocol. Bytes
of data will be sent out from the microcontroller to the remote XBee transceiver The
XBee transceiver will send the data to its corresponding XBee transceiver (USB
XBee dongle) at the Laptop. XBee was chosen because it has low power
consumption (1mW) and it has a range of 50 metres. It operates at a voltage range
of 2.9 to 3.3 V DC. The transceivers are configured as a point-to-point wireless
topology but it can be configured as point-to-mulipoint topology when more sensors
are integrated into the system. The software used for programming XBee modules is
X-CTU. This software allows the user to configure the XBee modules. Both XBee
modules have a baud rate of 57600 bits/sec. Figure 2.1.3 shows the schematic
diagram for the XBee module.
Figure 3.1.3: XBee Series 2 Schematic
Ambient Activity Monitoring System Chapter 4
10
Chapter 4
4.0 Software Design and Algorithms
The full commented MATLAB and dsPIC30F4011 code can be found in Appendix B
and C respectively. The code for the dsPIC microcontroller includes functions to
configure 3 AD channels, UART and a timer interrupt. The MATLAB code includes
serial port configuration, digital signal processing of accelerometer data and the
activity monitoring algorithm.
4.1 Microcontroller (dsPIC30F4011) Program
The microcontroller is programmed in C. The two main peripherals used are the ADC
and UART. These peripherals along with the algorithm for sending the accelerometer
data to the laptop will be discussed.
There are two main functions that were created for the microcontroller program:
configure_pins and read_analog_channel. The main function enters an infinite while
loop after executing the configure_pins function. The configure_pins function sets the
initial values of the I/O ports of the microcontroller and it configures the UART
settings, baud rate (57600 bits/sec), the analog inputs and the timer interrupt service
routine.
The three analog channels connected to the accelerometer are converted into a
digital number. The analog voltage is read through the read_analog_channel
function. The channel is defined in the function variable and is sampled, converted
and returned as a 10-bit integer value. Therefore, the AD range is 0 to 1024 on a 3v
scale which results in 2.9 mV resolution.
Ambient Activity Monitoring System Chapter 4
11
Branching off the infinite while loop, there is a timer Interrupt Service Routine (ISR)
that samples the three AD channels and transmits the data to the XBee module
using UART. To ensure the AD channels are sampled at regular time intervals, the
timer interrupt service routine is invoked every 5ms (200Hz). Figure 4.1 shows the
control flow diagram for the microcontroller program.
Ambient Activity Monitoring System Chapter 4
12
Figure 4.1: Control Flow Diagram for the Microcontroller Program
4.2 Classification Algorithm
A classifier is an algorithm that analyses an observation (e.g. set of measurements
from the accelerometer) and assigns the observation (accelerometer data from
human activity) to one of a number of classes. For instance, the classifier for this
project is human activity monitoring on an office chair and the classes relating to the
classifier are sitting, getting up and unoccupied.
Feature extraction is a term used in signal processing and it refers to a process of
obtaining different signal attributes such as mean, standard deviation, peak to peak
amplitude, zero crossing, frequency content, maximum Root Mean Square (RMS)
amplitude and maximum peak amplitude.
Ambient Activity Monitoring System Chapter 4
13
Feature extraction techniques obtain specific information and are used to build
classification models (Neural Network). These techniques can be used to
discriminate different human activities from the accelerometer data. Two techniques
were chosen to identify human activity. They are RMS amplitude and zero crossing
using the tri-axial accelerometer data.
For this project, accelerometer data is used to recognize human activity types. The
classification algorithm was developed to identify human activity on an office chair
with a tri-axial accelerometer. Training was done on a small set of data collected
from observational testing of the accelerometer sensor. The classification algorithm
was trained to distinguish between three activity classes thought to be common to
office chair occupancy: sitting, getting up and unoccupied chair.
Figure 4.2 shows the prototype system for human activity classification. First the
accelerometer measures movement on the office chair. Next, the accelerometer’s
signals are filtered in MATLAB without losing relevant information. Two features are
extracted from the filtered data using digital signal processing techniques (zero
crossing and RMS peak amplitude).
A neural network model was created in MATLAB with the accelerometer training
data. The neural network has a two input/output model. The two features (zero
crossing and peak RMS) are passed to the neural network model and it determines
the class (e.g. unoccupied chair) based on the accelerometer training data. Once the
class has been identified, the neural network outputs two binary numbers that
represents the identified class.
Ambient Activity Monitoring System Chapter 4
14
0 5 10 15-0.2
0
0.2
Time (sec)
X Accelerometer Data
0 5 10 15-0.5
0
0.5
Time (sec)
Y Accelerometer Data
0 5 10 15-1
0
1
Time (sec)
Z Accelerometer Data
Figure 4.2: Block Diagram for Classification Algorithm
Ambient Activity Monitoring System Chapter 4
15
4.2.1 FIR Low-pass Filter
Given a finite duration of nonzero input values, a FIR filter will always have a finite
duration of nonzero output values, and that is how FIR (Finite Impulse Response)
filters got their name. The FIR non-recursive difference equation is shown below.
[ ]M1
K 10
y[n] = b x n-K where M is finiteK =
∑
The signals (X, Y and Z) coming from the accelerometer contains noise interference.
If the signal features are to be extracted from the accelerometer data, the signals
needs to be filtered first or else the data used will be erroneous. The FIR filter allows
low frequency signals pass through the filter and it blocks high frequency signals.
Figure 4.2.1 shows the raw accelerometer signal compared to the filtered
accelerometer signal. Clearly, the high frequency noise has been eliminated leaving
a smooth accelerometer signal.
FIR Low-pass Filter Design Specifications:
• Pass Band Frequency: 35 Hz
• Stop Band frequency: 45 Hz
• Sampling Frequency 200 Hz (200 samples/second)
Figure 4.2.1: Filtered Accelerometer Data
0 5 10 15-0.2
-0.15
-0.1
-0.05
0
0.05
0.1
0.15
Time (sec)
X-axis Accelerometer Data
Am
plit
ud
e (G
s)
0 5 10 15-0.1
-0.05
0
0.05
0.1
Time (sec)
Filtered X-axis Accelerometer Data
Am
plit
ud
e (G
s)
Ambient Activity Monitoring System Chapter 4
16
4.2.2 Feature Extraction Techniques
Zero crossing and RMS (Root Mean Square) are used to extract signal information
from raw accelerometer data. In addition, these metrics are used as preprocessing
steps to select key signal features for the neural network model. These techniques
are used to measure human activity levels on an office chair.
The root mean square (RMS) of a signal Xn represents a sequence of n discrete
values is obtained using the following equation:
2 2 2
1 2 + + = n
RMS
x x xX
n
For further processing, the acceleration vector of the three axis are combined to give
the RMS acceleration for the office chair. The RMS equation for the three axes is
shown below where XAcc, YAcc and ZAcc are the corresponding office chair
acceleration vectors.
2 2 2RMS = + Y + ZAcc Acc AccX
Zero-crossing is the points where the signal passes through a specific value
corresponding to half of the signal range. The reference value can be either the
mean value of the accelerometer (gravitational offset) or the extracted mean value (0
reference). The extracted mean value is used to give a reference of zero. The
number of times the signal crosses the reference value is the number of zero-
crossings. A MATLAB function (zero_crossings) was created to count the number of
zero-crossing in the accelerometer data.
In order to calculate the acceleration of the individual axes, the 10 bit digital number
(A/D microcontroller) is converted into an analog voltage in the MATLAB program.
These analog voltages are scaled to engineering units (g-force acceleration) using
the accelerometer sensitivity value and reference voltage.
Ambient Activity Monitoring System Chapter 4
17
10BV
BV
BV
B B B
2
(X * 3)X = (3 volt supply and 2 = 1024)
1024
(Y * 3)Y =
1024
(Z * 3)Z =
1024
X ,Y and Z are the binary values read through the serial port on the laptop
mAcceleration Calculations ( )sec
Accelero
VAcc
VAcc
VAcc
meter sensitivity = 0.8 V/g
voltage_ref = 1.5 volts
(X - voltage_ref)X =
Accelerometer sensitivity
(Y - voltage_ref)Y =
Accelerometer sensitivity
(Z - voltage_ref)Z =
Accelerometer sensitivit
Acc Acc Acc
Acc Acc Acc
Acc Acc Acc
y
Subtract tilt offset
X = (X - mean(X )) * 9.8
Y = (Y - mean(Y )) * 9.8
Z = (Z - mean(Z )) * 9.8
Ambient Activity Monitoring System Chapter 4
18
4.3 MATLAB Program
MATLAB was chosen to develop the activity monitoring algorithm because it
provides toolboxes for data analysis, serial communication, data visualization,
algorithm development and system models. Some of MATLAB’s toolboxes are signal
processing, neural networks, data visualization and data acquisition.
Initially, the user is prompted to enter the number of accelerometer samples. Once
the user specifies the number of samples, the program configures the serial port for
the XBee USB dongle which is connected to the USB port on the Laptop. COM 5 is
configured to have a baud rate of 57600, 8 data bits, 1 stop bit and no parity bit.
The serial port is opened so that a communication link can be established between
the wireless activity monitoring sensor and the laptop. The program receives the
accelerometer data from the sensor on COM 5 and stores the data into a CSV data
file. The accelerometer data is taken from the CSV file and filtered. Preprocessing
techniques (RMS and zero-crossing) are used to extract signal information from the
filtered accelerometer data.
A neural network model was created in MATLAB with the accelerometer training
data. The two features (zero crossing and peak RMS) are passed to the neural
network model and it determines the class (e.g. unoccupied chair, sitting etc). Once
the class has been identified, the neural network outputs two binary numbers that
represents the identified activity (sitting, getting up and unoccupied office chair). The
program displays the identified activity in the command window and it plots the three
axial accelerometer data (X, Y and Z). Figure 4.3 shows the accelerometer data for
the X, Y and Z axes.
Ambient Activity Monitoring System Chapter 4
19
Figure 4.3: Accelerometer Data
0 5 10 15-1
0
1A
cce
lera
tion
(m
2/s
)
Time (sec)
X Accelerometer Data
0 5 10 15-1
0
1
Acce
lera
tion
(m
2/s
)
Time (sec)
Y Accelerometer Data
0 5 10 15-2
0
2
Acce
lera
tion
(m
2/s
)
Time (sec)
Z Accelerometer Data
Ambient Activity Monitoring System Chapter 5
20
Chapter 5
5.0 Testing and Validation
This section discusses the testing and validation and it elaborates on the activity
detection, feature extraction and classification of the system. It analyzes the dataset
used and it discusses the accuracy of the system in identify human activity on an
office chair.
5.1 Data Description
The data used for training the Neural Network was collected while conducting
experimental tests on the office chair. The data was collected in a supervised
approach where the subject was given explicit instructions about what activity to
perform on the office chair (sitting or getting-up from the office chair). The data
corresponds to 5 subjects (3 women and 2 men) with different heights and weights.
Accelerometer data was recorded with a 15 second window and the subject would
perform the activity within this period. This data was then labelled with the performed
activity and it was used to build the activity classification model for the office chair.
The data was collected from a tri-axial accelerometer that was fixed to the back of
the office chair. The accelerometer was sampled at approximately 200 Hz. Figures
5.1.1, 5.1.2 and 5.1.3 illustrates the recorded activities.
Ambient Activity Monitoring System Chapter 5
21
Figure 5.1.1: Accelerometer Data for Unoccupied Office Chair
Figure 5.1.2: Accelerometer Data for Sitting Activity on Office Chair
0 5 10 15-0.01
0
0.01
0.02
g-f
orc
e
Time (sec)
X Accelerometer Data
0 5 10 15-0.01
-0.005
0
0.005
0.01
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.02
-0.01
0
0.01
g-f
orc
e
Time (sec)
Z Accelerometer Data
0 5 10 15-0.1
0
0.1
0.2
0.3
g-f
orc
e
Time (sec)
X Accelerometer Data
0 5 10 15-0.2
-0.1
0
0.1
0.2
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.2
0
0.2
0.4
0.6
g-f
orc
e
Time (sec)
Z Accelerometer Data
Ambient Activity Monitoring System Chapter 5
22
Figure 5.1.3: Accelerometer Data for Getting-up Activity on Office Chair
5.2 Feature Extraction
Once the raw data was recorded from the experimental tests, two features were
extracted from the data. They were zero-crossing and maximum root mean square
amplitude. Figure 5.2 illustrates the projection of these features onto a two
dimensional plot that explicitly shows the three classes (unoccupied, getting-up and
sitting) for human activity classification on an office chair . Clearly, it can be noticed
that the features for sitting and getting-up have very similar results which shows
some inaccuracies in distinguishing between the two activities. Table 5.2 shows the
experimental data set values for the feature extraction.
0 5 10 15-0.05
0
0.05
g-f
orc
e
Time (sec)
X Accelerometer Data
0 5 10 15-0.4
-0.2
0
0.2
0.4
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.2
0
0.2
0.4
0.6
g-f
orc
e
Time (sec)
Z Accelerometer Data
Ambient Activity Monitoring System Chapter 5
23
Figure 5.2: Feature Extraction Data for Human Activity on an Office Chair
Class 1: Sitting Class 2: Getting up Class 3: Unoccupied
Zero-cross. Max RMS Zero-cross. Max RMS Zero-cross. Max RMS
23 0.52 19 0.42 221 0.041
15 1.08 27 0.94 220 0.041
13 0.94 17 0.40 204 0.048
11 1.172 25 0.40 201 0.042
11 1.87 19 0.66 174 0.043
11 0.77 28 0.54 203 0.0421
9 1.13 27 0.53 151 0.0432
9 1.69 21 0.81 237 0.0461
14 0.78 18 0.72 258 0.0512
18 0.98 17 0.54 204 0.0553
Table 5.2: Training Data Results
0 50 100 150 200 250 3000
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
Ma
x R
MS
Am
plit
ud
e
Zero-crossing
Feature Extraction Data
Class 1: Sitting Down on Office Chair
Class 2: Getting-up from Office Chair
Class 3: Unoccupied Office Chair
Ambient Activity Monitoring System Chapter 5
24
5.3 Human Activity Classification Model for Office Chair
A neural network model was created using the training data results. Once the
network was trained, it was able to determine the best linear match for the three
classes (sitting, getting-up and unoccupied) based on the training data provided. The
linear lines in figure 5.3 represent the neural network model approximation. The
network model was trained using the MATLAB neural network toolbox (nntool).
In order to validate the classification model, it was very important to test the system
with measured real time data from the accelerometer. Subjects were given explicit
instructions about what activity to perform on the office chair and the classification
algorithm displayed the measured activity in the MATLAB command window. The
system had a 70 percent success rate using the neural network model. The neural
network model had trouble distinguishing between sitting and getting up on the office
chair because the feature extraction values were very similar for both activities.
To improve the success rate of the system, an additionally control parameter (min
and max RMS amplitude for each activity class) was added to the classification
algorithm to ensure the correct activity was identified. This enabled the system to
detect human activity on the office chair with a 90 percent success rate.
Figure 5.3: Feature Extraction Data with Linear Neural Network Model
0 50 100 150 200 250 3000
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
Ma
x R
MS
Am
plit
ude
Zero-crossing
Feature Extraction Data
Class 1: Sitting Down on Office Chair
Class 2: Getting-up from Office Chair
Class 3: Unoccupied Office Chair
Class 1
Class 2
Class 3
Ambient Activity Monitoring System Chapter 6
25
Chapter 6
6.0 Discussion
Due to similarities between different human activities (sitting and getting up) on the
office chair, the system was unable to identify the activities consistently (70%
accuracy). This may be due to the fact that the neural network was trained with a
small data set. In order to improve the system’s reliability, an additionally control
parameter (min and max RMS amplitude for each activity class) was added to the
classification algorithm. This improved the accuracy of the system to 90 percent.
The first issue that needs to be addressed in future work is distinguishing between
“sitting” and “getting-up” more precisely. This problem can be easily solved by
embedding a digital switch into the seat of the office chair. Another aspect that could
be improved is adding body posture among the classes being classified. This would
be advantageous for office chair ergonomics.
Main hardware concerns are related to obtaining a smaller size sensor, low power
consumption, low cost, high sensitivity and consistency of the system. Improvements
in low power consumptions for the wireless sensor were investigated but were not
implemented due to time restraints. The A/D converter on the microcontroller has a
unique feature of operating in sleep mode by using the conversion clock from the
A/D internal oscillator. This could be a useful feature for power saving when the
sensor is not active. This could reduce the overall power consumption for the sensor.
Ambient Activity Monitoring System Chapter 6
26
6.1 Conclusion
This project presented a prototype of a wireless activity monitoring system for data
acquisition and human activity classification. The prototype sensor, which uses an
accelerometer to measure human activity, is adaptable to household furnishings.
The proposed system aims to serve as a powerful tool for monitoring human activity
without attaching any sensors to the user. It allows data to be collected and analyzed
in a nonintrusive manner. In the preliminary tests, the system has proved to be
working with high accuracy and robustness. As the system has only used the
accelerometer data to derive a human activity classifier, future work may include the
use of other sensors (gyroscope and magnetic sensor) to determine other useful
data for human activity monitoring.
Ambient Activity Monitoring System Bibliography
27
Bibliography
1. D. W. McDonald, N.Schilt and J. Yang. Activity Recognition for the Digital Home.
2008.
2. Human Activity Recognition Using A single Tri-axil Accelerometer. Khan, Adil
Mehmood. Korea : Kyung Hee University, 2011.
3. Yamana, Himabindu. Embedded System for Monitoring Human Activities using
3-Axis Accelerometer. Texas : The University of Texas at Arlington, 2007.
4. Peixoto, Paulo, Batista, Jorge and Helder, J Araujo. Real-time Human Activity
Monitoring Exploring Multiple Vision Sensors. s.l. : IEEE, 2001.
5. An Activity Monitoring System for Real Elderly at Home: Validation Study. Zouba,
N. France : IEEE, 2010.
6. Activity Recognition in the Home using Simple Unbiquitous Sensors. E. M. Tapia,
S. S. Intille, and K Larson. Berlin/Heideberg : IEEE, 2004.
Ambient Activity Monitoring System Appendices
28
Appendices
Appendix A – Activity Monitoring Sensor Schematic
Ambient Activity Monitoring System Appendices
29
Appendix B – Microcontroller Program (dsPIC30F4011)
Ambient Activity Monitoring System Appendices
30
Ambient Activity Monitoring System Appendices
31
Ambient Activity Monitoring System Appendices
32
Appendix C – MATLAB Program
% Written by Keith Connaughton and last updated 21/05/2013 % This function takes accelerometer data from the serial port and it stores % the data in a text file (.csv). It also plots the X,Y and Z axis data
from the % accelerometer. function Acc_Serial_Data()
clear all; clc;
% Load neural network model NN = load('nerualnetwork.mat');
% Initialise parameters samp_freq = 200; samp_interval = 1/samp_freq;
% Request the number of samples from user disp('Enter the number of samples to be taken from the serial port'); samples = input(''); SamPeriod = samples*samp_interval; disp(['Sampling period = ',num2str(SamPeriod),' seconds']);
% Create and open a text file for storing the data fid=fopen('AccData.csv', 'w+'); % Configure serial port ser = serial('com5'); ser.Terminator = 'CR'; ser.BaudRate = 57600; fopen(ser); fprintf(fid,'%8s %8s %8s %8s\n','T_Stamp','X','Y','Z');
% Take data in on serial port and store it to the text file for i = 1:samples accdata = fgetl(ser); data = sscanf(accdata,'\nX%dY%dZ%d'); b = all(size(data,1)==3); if b == true Time = timestamp(); fprintf(fid,'%8s %8d %8d %8d\n',Time,data(1),data(2),data(3)); end end
% Close serial port fclose(fid);
fclose(ser);delete(ser);clear ser;
fid = fopen('AccData.csv'); C = textscan(fid,'%8s %8s %8s %8s');
Ambient Activity Monitoring System Appendices
33
%Format data into X, Y and Z (accelerometer axes) Xacc = C{1,2}; Yacc = C{1,3}; Zacc = C{1,4};
Xacc(1) = []; Yacc(1) = []; Zacc(1) = [];
Xacc = cellfun(@str2num,Xacc); Yacc = cellfun(@str2num,Yacc); Zacc = cellfun(@str2num,Zacc);
% Accelerometer sensitivity g_voltage_ref = 1.5; % 800mv/g accelerometer sensitivity sensitivity = 0.8;
% Data conversion Xvol = (Xacc.*3)./1024; Yvol = (Yacc.*3)./1024; Zvol = (Zacc.*3)./1024;
Xacc = (Xvol - g_voltage_ref)./sensitivity; Yacc = (Yvol - g_voltage_ref)./sensitivity; Zacc = (Zvol - g_voltage_ref)./sensitivity;
% Remove tilt offset from accelerometer data Xacc = Xacc - mean(Xacc); Yacc = Yacc - mean(Yacc); Zacc = Zacc - mean(Zacc);
% Root Mean Square calculation RMS = max(sqrt((Xacc.^2)+(Yacc.^2)+ (Zacc.^2)))
% Filter data (moving average) Xacc = smooth(Xacc,10,'moving'); Yacc = smooth(Yacc,10,'moving'); Zacc = smooth(Zacc,10,'moving');
% Zero crossing Xzero = zero_crossings(Xacc) Yzero = zero_crossings(Yacc) Zzero = zero_crossings(Zacc)
minzero = min([Xzero Yzero Zzero])
% Feature extraction data (RMS and zero-crossing) P = [minzero;RMS]
% Neural Network output result (activity classification) result = sim(NN.net,P)
Ambient Activity Monitoring System Appendices
34
% Activity displayed to user if(result(1)==0 && result(2)==1) disp('User sat down on chair'); elseif(result(1)==1 && result(2)==1) disp('User got up from chair'); elseif(result(1)==1 && result(2)==0) disp('Unoccupied chair'); else disp('Unknown Activity'); end
% Plot accelerometer data tx = (1:size(Xacc)).* samp_interval; ty = (1:size(Yacc)).* samp_interval; tz = (1:size(Zacc)).* samp_interval;
subplot 311, plot(tx,Xacc), ylabel('G Force'),xlabel('Time (sec)'),
title('X Accelerometer Data'); subplot 312, plot(ty,Yacc),ylabel('G Force'),xlabel('Time (sec)'),
title('Y Accelerometer Data'); subplot 313, plot(tz,Zacc),ylabel('G Force'),xlabel('Time (sec)'),
title('Z Accelerometer Data');
end
function ts = timestamp() % % TIMESTAMP returns the current system time.
TempTime=clock; ts = [ num2str(TempTime(4),'%02.0f') ':' num2str(TempTime(5),'%02.0f') ':'
num2str(TempTime(6),'%02.0f')]; end
Ambient Activity Monitoring System Appendices
35
Appendix D – Zero-crossing() MATLAB Function
function zerocount = zero_crossing(signal) % Count the number of zero-crossings from the time-domain % signal.
% initial value zerocount = 0;
signal = signal(:);
num_samp = length(signal); for i=2:num_samp
if((signal(i) * signal(i-1)) <= 0) zerocount = zerocount + 1; end
end
Ambient Activity Monitoring System Appendices
36
Appendix E - Training Data Results
Figure E.1: Accelerometer Data for Unoccupied Office Chair
Figure E.2: Accelerometer Data for Unoccupied Office Chair
0 5 10 15-5
0
5
10
15x 10
-3
g-f
orc
e
Time (sec)
X Accelerometer Data
0 5 10 15-0.02
-0.01
0
0.01
0.02
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.02
-0.01
0
0.01
0.02
g-f
orc
e
Time (sec)
Z Accelerometer Data
0 5 10 15-0.01
0
0.01
0.02
g-f
orc
e
Time (sec)
X Accelerometer Data
0 5 10 15-0.01
-0.005
0
0.005
0.01
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.02
-0.01
0
0.01
g-f
orc
e
Time (sec)
Z Accelerometer Data
Ambient Activity Monitoring System Appendices
37
Figure E.3: Accelerometer Data for Unoccupied Office Chair
Figure E.4: Accelerometer Data for Unoccupied Office Chair
0 5 10 15-0.01
-0.005
0
0.005
0.01g
-fo
rce
Time (sec)
X Accelerometer Data
0 5 10 15-0.01
0
0.01
0.02
0.03
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.02
-0.01
0
0.01
g-f
orc
e
Time (sec)
Z Accelerometer Data
0 5 10 15-0.01
-0.005
0
0.005
0.01
g-f
orc
e
Time (sec)
X Accelerometer Data
0 5 10 15-0.01
-0.005
0
0.005
0.01
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.01
0
0.01
0.02
g-f
orc
e
Time (sec)
Z Accelerometer Data
Ambient Activity Monitoring System Appendices
38
Figure E.5: Accelerometer Data for Unoccupied Office Chair
Figure E.6: Accelerometer Data for Unoccupied Office Chair
0 5 10 15-0.01
-0.005
0
0.005
0.01g
-fo
rce
Time (sec)
X Accelerometer Data
0 5 10 15-0.01
-0.005
0
0.005
0.01
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.01
-0.005
0
0.005
0.01
g-f
orc
e
Time (sec)
Z Accelerometer Data
0 5 10 15-0.02
-0.01
0
0.01
g-f
orc
e
Time (sec)
X Accelerometer Data
0 5 10 15-10
-5
0
5x 10
-3
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.02
-0.01
0
0.01
g-f
orc
e
Time (sec)
Z Accelerometer Data
Ambient Activity Monitoring System Appendices
39
Figure E.7: Accelerometer Data for Sitting Activity on Office Chair
Figure E.8: Accelerometer Data for Sitting Activity on Office Chair
0 5 10 15-0.1
-0.05
0
0.05
0.1
g-f
orc
e
Time (sec)
X Accelerometer Data
0 5 10 15-0.5
0
0.5
1
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.5
0
0.5
1
g-f
orc
e
Time (sec)
Z Accelerometer Data
0 5 10 15-0.1
-0.05
0
0.05
0.1
g-f
orc
e
Time (sec)
X Accelerometer Data
0 5 10 15-0.2
0
0.2
0.4
0.6
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.2
0
0.2
0.4
0.6
g-f
orc
e
Time (sec)
Z Accelerometer Data
Ambient Activity Monitoring System Appendices
40
Figure E.9: Accelerometer Data for Sitting Activity on Office Chair
Figure E.10: Accelerometer Data for Sitting Activity on Office Chair
0 5 10 15-0.1
-0.05
0
0.05
0.1g
-fo
rce
Time (sec)
X Accelerometer Data
0 5 10 15-0.1
-0.05
0
0.05
0.1
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.2
-0.1
0
0.1
0.2
g-f
orc
e
Time (sec)
Z Accelerometer Data
0 5 10 15-0.05
0
0.05
g-f
orc
e
Time (sec)
X Accelerometer Data
0 5 10 15-0.4
-0.2
0
0.2
0.4
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.2
0
0.2
0.4
0.6
g-f
orc
e
Time (sec)
Z Accelerometer Data
Ambient Activity Monitoring System Appendices
41
Figure E.11: Accelerometer Data for Sitting Activity on Office Chair
Figure E.12: Accelerometer Data for Sitting Activity on Office Chair
0 5 10 15-0.2
-0.1
0
0.1
0.2g
-fo
rce
Time (sec)
X Accelerometer Data
0 5 10 15-0.2
0
0.2
0.4
0.6
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.1
0
0.1
0.2
0.3
g-f
orc
e
Time (sec)
Z Accelerometer Data
0 5 10 15-0.1
0
0.1
0.2
0.3
g-f
orc
e
Time (sec)
X Accelerometer Data
0 5 10 15-0.4
-0.2
0
0.2
0.4
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.2
-0.1
0
0.1
0.2
g-f
orc
e
Time (sec)
Z Accelerometer Data
Ambient Activity Monitoring System Appendices
42
Figure E.13: Accelerometer Data for Getting-up Activity on Office Chair
Figure E.14: Accelerometer Data for Getting-up Activity on Office Chair
0 5 10 15-0.1
-0.05
0
0.05
0.1g
-fo
rce
Time (sec)
X Accelerometer Data
0 5 10 15-0.05
0
0.05
0.1
0.15
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.2
-0.1
0
0.1
0.2
g-f
orc
e
Time (sec)
Z Accelerometer Data
0 5 10 15-0.1
0
0.1
0.2
0.3
g-f
orc
e
Time (sec)
X Accelerometer Data
0 5 10 15-0.2
-0.1
0
0.1
0.2
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.2
0
0.2
0.4
0.6
g-f
orc
e
Time (sec)
Z Accelerometer Data
Ambient Activity Monitoring System Appendices
43
Figure E.15: Accelerometer Data for Getting-up Activity on Office Chair
Figure E.16: Accelerometer Data for Getting-up Activity on Office Chair
0 5 10 15-0.4
-0.2
0
0.2
0.4g
-fo
rce
Time (sec)
X Accelerometer Data
0 5 10 15-0.05
0
0.05
0.1
0.15
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.2
-0.1
0
0.1
0.2
g-f
orc
e
Time (sec)
Z Accelerometer Data
0 5 10 15-0.2
-0.1
0
0.1
0.2
g-f
orc
e
Time (sec)
X Accelerometer Data
0 5 10 15-0.1
0
0.1
0.2
0.3
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.1
0
0.1
0.2
0.3
g-f
orc
e
Time (sec)
Z Accelerometer Data
Ambient Activity Monitoring System Appendices
44
Figure E.15: Accelerometer Data for Getting-up Activity on Office Chair
Figure E.16: Accelerometer Data for Getting-up Activity on Office Chair
0 5 10 15-0.4
-0.2
0
0.2
0.4g
-fo
rce
Time (sec)
X Accelerometer Data
0 5 10 15-0.05
0
0.05
0.1
0.15
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.2
-0.1
0
0.1
0.2
g-f
orc
e
Time (sec)
Z Accelerometer Data
0 5 10 15-0.1
-0.05
0
0.05
0.1
g-f
orc
e
Time (sec)
X Accelerometer Data
0 5 10 15-0.05
0
0.05
0.1
0.15
g-f
orc
e
Time (sec)
Y Accelerometer Data
0 5 10 15-0.1
0
0.1
0.2
0.3
g-f
orc
e
Time (sec)
Z Accelerometer Data
Recommended