HEAD MOVEMENT DETECTION SYSTEM USING RABBIT MICROPROCESSOR Jigar Sheth

advertisement
HEAD MOVEMENT DETECTION SYSTEM USING
RABBIT MICROPROCESSOR
Jigar Sheth
B.E., Gujarat University, India, 2008
PROJECT
Submitted in partial satisfaction of
the requirements for the degree of
MASTER OF SCIENCE
in
ELECTRICAL AND ELECTRONIC ENGINEERING
at
CALIFORNIA STATE UNIVERSITY, SACRAMENTO
SUMMER
2011
HEAD MOVEMENT DETECTION SYSTEM USING
RABBIT MICROPROCESSOR
A Project
by
Jigar Sheth
Approved by:
__________________________________, Committee Chair
Jing Pang, Ph.D.
__________________________________, Second Reader
Preetham Kumar, Ph.D.
____________________________
Date
ii
Student: Jigar Sheth
I certify that this student has met the requirements for format contained in the University
format manual, and that this project is suitable for shelving in the Library and credit is to
be awarded for the Project.
__________________________, Graduate Coordinator
Preetham Kumar, Ph.D.
Department of Electrical and Electronic Engineering
iii
________________
Date
Abstract
of
HEAD MOVEMENT DETECTION SYSTEM USING
RABBIT MICROPROCESSOR
by
Jigar Sheth
This project presents head monitoring movement system. It has potential
application for monitoring patients head after surgery and operations. Sometimes it is
very important to monitor patient’s head position after surgery not to have movement of
more than certain angle. Head movement detection system helps by placing very small
accelerometer on head which serves as a motion detector and storing the head movement
angles generated continuously to web database. This helps to retrieve old values at any
time.
The system in this project uses wearable tilt accelerometer. The accelerometer
provides tilt movement. Tilt angle calculation, communication interface, and processing
are done by microprocessor. Rabbit microprocessor is a very powerful embedded tool
which is used as an interface between accelerometer and the developed database.
Communication between Rabbit microprocessor and database is done by using Ethernet.
The developed computer software automatically plots graph that helps analyze the
changes in head position.
iv
This monitoring system is helpful in many ways .It measures the current position
of head and outputs movement compared to original position. The head position system is
useful in multiple applications including study of correlation between external and
internal markers during Image-Guided Radiation Therapy (IGRT) [11] and for navigation
in virtual environments.
_______________________, Committee Chair
Jing Pang, Ph.D.
_______________________
Date
v
ACKNOWLEDGMENTS
Before I start discussing my project report, I would like to thank all people who
have helped me complete this project successfully. I owe my deepest gratitude to Dr. Jing
pang for providing me such a wonderful opportunity to work on this project. I would not
have completed this project without her direction, assistance, and guidance. I would also
like to extend my gratitude to Dr. Kumar for reviewing my project.
Special thanks should also be given to Mr. Ikraj Singh, who has worked with me
on this project. His experience and knowledge has played a vital role in this project.
Last but not least, I am very thankful to all my family members and friends for
providing strength and immense support. My special thanks to Mr. Ankit Sheth for
guiding me in every possible way to complete my graduation successfully.
vi
TABLE OF CONTENTS
Pages
Acknowledgments.............................................................................................................. vi
List of Figures .................................................................................................................... ix
List of Tables ...................................................................................................................... x
Chapter
1. INTRODUCTION .......................................................................................................... 1
1.1
Overview .............................................................................................................. 1
1.2
Goals of the Project .............................................................................................. 3
1.3 Organization of Report ............................................................................................. 4
2. COMMUNICATION WITH WEARABLE ACCELEROMETER ............................... 5
2.1 Types of Serial Interface ........................................................................................... 7
2.2 Synchronous Interface .............................................................................................. 7
2.2.1 SPI ...................................................................................................................... 7
2.2.2 Inter Integrated Circuit (I2C) ............................................................................ 10
2.3 433 MHz ISM Band ................................................................................................ 11
2.4 CRC16 Error Checking ........................................................................................... 13
3. DIGITAL ACCELEROMETER ADXL345................................................................. 15
3.1 Introduction ............................................................................................................. 15
3.2.1 Digital Accelerometer ...................................................................................... 16
3.2.2 Tri axial MEMS Accelerometer....................................................................... 17
vii
3.2.3 Resolution and Sensitivity ................................................................................... 17
3.2.4 Acceleration Sensor Unit ..................................................................................... 18
3.2.5 FIFO Buffer ..................................................................................................... 19
3.2.6 Serial Communication with External Master Device ...................................... 21
4. DESIGN HARDWARE SYSTEM ............................................................................... 27
4.1 Rabbit 3000 ............................................................................................................. 28
4.2 System Architecture ................................................................................................ 30
4.3 Sampling Frequency of Measurement .................................................................... 34
4.4 Power Consumption Consideration ........................................................................ 35
4.5 Design Consideration .............................................................................................. 36
4.5.1 Calibration........................................................................................................ 36
4.5.2 Filtering ............................................................................................................ 37
4.6 Design Flow Chart .................................................................................................. 38
4.6.1 Initialization ..................................................................................................... 38
4.6.2 Reading and Storing Values in Rabbit 3000 .................................................... 41
4.7 Simulation and Results ........................................................................................... 43
5. CONCLUSION AND FUTURE EXPANSION ........................................................... 48
5.1 Conclusion .............................................................................................................. 48
5.2 Future Expansion .................................................................................................... 49
Reference……………………………………………………………………………….. 50
viii
LIST OF FIGURES
1.
Figure 2.1: Organization of Frame……………………………………………….. 6
2.
Figure 2.2: Master and Slave Hardware Connection for SPI.................................. 8
3.
Figure 2.3: Hardware Connection between Master and Slave for I2C………...... 11
4.
Figure 3.1: Internal Hardware Architecture of Digital Accelerometer..………... 17
5.
Figure 3.2: Angle showing Independent Deflection……………………………. 24
6.
Figure 4.1: Rabbit 3000 Microprocessor……………………………………….. 28
7.
Figure 4.2: RCM3365 Image………………………………………………........ 29
8.
Figure 4.3: Hardware Connection Between ADXL345 and Rabbit 3000……… 30
9.
Figure 4.4: Rabbit 3000 Placement onto RCM3365 Development Board...…… 32
10.
Figure 4.5: RCM3365 Development Kit……………………………………….. 32
11.
Figure 4.6: Head Movement Detection System…...………………………......... 33
12.
Figure 4.7: Design Flow Chart…………………………………………………...39
13.
Figure 4.8: Head Position – Straight……………………………………………. 43
14.
Figure 4.9: Head Position – Risky Head Position…………………………......... 44
15.
Figure 4.10: Graphical Display of Values Stored in Database– Deflection in X
Direction...……………………………………………………………………… 46
ix
LIST OF TABLES
1.
Table 2.1: CRC-16 Error Checking Accuracy…………………………………. 14
2.
Table 3.1: Conversion from LSB to Degree and Different Possible Combinations
of Sensor Positions ………………………………………………………………26
3.
Table 4.1: Web Database Storing Values into Excel Files.…………………….. 45
x
1
Chapter 1
INTRODUCTION
In the era of technological revolutions, more advanced and developed techniques
are required for sensing applications. The sensing techniques are used a lot in many
applications. For example, in medical applications, accelerometer can be used in
equipments to detect the position of some part of body. It is integral part of design in
gaming and mobile device as a motion detector. And, it is also useful in navigation
devices and hard drive protection. In accordance with microprocessors, accelerometer is
used to detect movement of a particular object which can be helpful in many applications.
With ever growing popularity and use of internet in day-to-day life, web based
storage systems are also used extensively to store the data. The continuously stored
position of body parts on the web database can be easily accessed for further processing
which is useful for many applications.
1.1 Overview
This project presents head movement detection system which has potential to be
used for medical applications. For example, after special medical operation called
Vetrictomy, it is very important to detect movement of head. This measured movement is
important as blood circulation may get affected if more than certain angle of movement is
detected. It will also increase recovery period, if care is not taken. So, accurate and
precise angle measurement of patient’s head movement is very important.
As explained in the report, the head movement monitoring can be successfully
done by using digital MEMS accelerometer and microprocessor. Digital accelerometer
2
was chosen as it internally converts analog value into digital format and outputs digital
value to microprocessor. The microprocessor usually inputs and outputs digital data. The
accelerometer helps measure tilt sensing. It can measure both static and dynamic
accelerations. The measurement using two axes is not good enough as device needs to be
put in horizontal direction to work. So, tri axial accelerometer which can detect
movement of 360 degrees in all three directions was chosen. For head movement, only
static acceleration is required. The influence of dynamic acceleration is usually of short
period and it can be reduced by adding low pass filters. After careful consideration of
parameters such as data transfer speed, sensitivity, resolution, and noise margin
ADXL345 accelerometer was selected.
The accelerometer data output are further processed by microprocessor through
which they are being stored on the web database. Web interface is very important
parameter for selecting microprocessor. As internet is very convenient way of
communication, it would be very effective to use microprocessor which has Ethernet
capability. RCM3365 is a board with Rabbit 3000 microprocessor which has RJ 45
Ethernet port. Using this port, the data accessed from the accelerometer can be
transferred to the database through web. This improves performance because it removes
need of any other extra web or wireless device for internet access. This microprocessor
development board is ideal for network-enabling security and access systems. As Rabbit
3000 supports both serial and parallel data transfer, it gives flexibility in choosing an
accelerometer in terms of communication. Another reason for using this microprocessor
3
is the large number of I/O ports. This has advantage of adding any other device and/or
application to the current fixture for future development.
It is very hard to detect the difference between postoperative disturbances caused
by clinical factors and those caused by head movement. By using accelerometer to
monitor the head movement, the above problem can be solved. Providing real time angle
can be very useful because it can give instant alarm indication if head movement is
incorrect. Computer software can be used to perform both diagnostics and analysis. The
results can be made more accurately by using low pass filter.
1.2 Goals of the Project
This project discusses the application of Rabbit Microprocessor and
accelerometer in medical and surgical world to improve security by designing a
monitoring system using web interface. It gives position of head with high resolution
which helps in analyzing the outcome of particular surgery and reduces chances of post
surgery anti effect. Rabbit Microprocessor is one of the widely used microprocessor in
embedded design. This application extends its use and effectiveness in remote monitoring
of head movement.
Dynamic C which is extension of C is used for Rabbit design. It is more flexible
and has added functionality over C. ADXL345 accelerometer is connected to Rabbit
microprocessor which generates values based on the accelerated force on sensors in each
direction. Microsoft Visual C# creates webpage and web database which stores the value
transferred from Rabbit Web. The design method to implement the functionality will be
explained in detail in coming chapters.
4
1.3 Organization of Report
Chapter 2 explains serial communication and different types of available
interface. It also talks about the reason to choose serial interface for this project.
Chapter 3 consists of detailed information about accelerometer. It explains
selection of ADXL345 accelerometer. It also describes features and operations of
accelerometer.
Chapter 4 contains detailed explanation of system design. The design algorithm is
given using flow chart which improves readability. It also describes how to set up the
system for use. Moreover, both simulation results and waveforms are provided in this
chapter.
Chapter 5 concludes the report by discussing future plans to improve the result of
the project.
5
Chapter 2
COMMUNICATION WITH WEARABLE ACCELEROMETER
This chapter provides detailed description of communication interface for
accelerometer. It explains the types of serial communication and different methods such
as SPI and I2C to perform synchronous serial transmission. Moreover, it provides
overview of RF wireless transmission and error detecting protocols.
Serial communication can be defined as serially transmitting electronic data from
one device to another device. In digital electronics, the digitally encoded command
and/or data can be communicated to another device either through serial communication,
where data is transferred bit by bit, or through parallel communication, where data is
transferred by single byte or multiple bytes at a time. Serial communication requires a
single wire and is often used either to control or to transfer data from/to embedded
microprocessor.
Serial communication is a popular means of transmitting data between a computer
and a peripheral device such as a programmable instrument or even another computer.
The accelerometer uses serial interface as a communication protocol to transfer data
between accelerometer and microprocessor. It uses a transmitter to send data, one bit at a
time, over a single communication line to a receiver. It is used for data transfer over long
distance at lower rates. Serial communication is popular because most computers have
one or more serial ports, so no extra hardware is needed other than a cable to connect the
instrument to the computer or two computers together.
6
There are several possible ways to transfer data between two peripheral devices.
But, the basic parameters of serial communication are as following:

Baud Rate

Number of data bits for encoding character

Number of stop bits

Presence or absence of parity bit
Each character is packed in a frame which consists of start bit, stop bit, data bit, and
optional parity bit.
Figure 2.1: Organization of Frame
As shown in figure 2.1, start bit and stop bit are used to synchronize serial
receivers. Data byte is always transmitted Least Significant Bit (LSB) first followed by
optional parity bit for error checking. This completes 1 character frame or packet of serial
communication. The receiver differentiates frame based on the start bit and the stop bit.
The rate of transmission is fixed by setting the baud rate. Baud rate is defined as symbols
per second.
7
2.1 Types of Serial Interface
Both synchronous and asynchronous interfaces are possible with serial
transmission. On an asynchronous bus, data is sent without the timing clock. However on
synchronous bus, data is sent with the clock. Asynchronous communication embeds the
clock information into the data stream. For devices to communicate with each other, they
need to agree on the same transmission speed and the same protocol including number of
data bits, stop bits, parity, and so on while constantly synchronizing with the clock
embedded into the data stream.
2.2 Synchronous Interface
Unlike asynchronous interface, the synchronous interface uses a separate clock
signal that provides a separate timing signal. The transmission protocol sends separate
clock signal along with the data signal from master to slave. Master is a device which
generates clock signal. The slave device shifts in or out of data using master’s clock.
2.2.1 SPI
Serial Peripheral Interface (SPI) is a communication protocol which was
developed particularly for communication among Integrated Circuits (IC) on the same
printed circuit board. Motorola designed SPI to allow microprocessors to communicate
with peripheral devices. The implementation is very simple. Shift registers are used to
shift the data out and in [11]. SPI is widely used for accessing data from EEPROM,
ADC, DAC, Flash, FPGA, ASIC, and many other manufacturers of IC.
8
SPI is a 4-wire interface where 3 wires are used for data transfer and 1 wire is
used for specifying a slave device connected to the master. The three wires used for data
transfer are SCLK (Serial Clock), MOSI (Master Data Out, Slave In), and MISO (Master
Data In Slave Out). Serial Clock generates master clock which synchronizes data to or
from the master. Slave Select (SS) is another control signal that selects each slave to be
controlled by master. MOSI is the data signal which transmits the data out from slave to
master. Due to multiple slave and single master configuration, only one slave is allowed
to transfer data at particular time. MISO is the data signal that transmits data from master
to slave. It transmits data from master’s output to slave’s input. The following figure
shows the hardware connection for SPI. Since SPI operates on higher clock frequency, it
does not require any pull up resisters on the data lines.
SCLK
MASTER
SS
SLAVE
MOSI
MISO
Figure 2.2: Master and Slave Hardware Connection for SPI
SPI does not have an acknowledgement protocol to confirm reception or
transmission of data. SPI has full duplex communication capability and data rates ranging
from low to very high, up to a few megabits per second. SPI standard does not have its
own maximum data rate. The data rate depends on the clock speed and varies in
proportion to the clock changes. However, data rates vary with the peripherals and
9
microcontrollers as sometimes the slave cannot operate on the same speed with master
and it slows down the transfer.
Along with those four signals, SPI also has another two parameters called Clock
Phase (CPHA) and Clock Polarity (CPOL). These parameters decide when the active
clock edge occurs [11]. They are very important for ensuring successful communication
between master and slave. CPOL determines whether SCLK idles high (CPOL = 1) or
low (CPOL = 0) when it is not switching. CPHA determines on which SCLK edge data is
shifted in and out. With CPOL = 0, setting CPHA to 0 shifts data into the slave on the
SCLK rising edge. The two CPOL and CPHA states allow four different combinations of
clock polarity and phase; each setting is incompatible with the other three. Both the
master and the slave must be set to the same CPOL and CPHA states to communicate
with each other [8].
SPI also has a 3-wire interface in addition to the 4-wire interface described above.
One way of implementing this is by combining MOSI and MISO into 1 data pin called
SISO(Slave In/Slave Out).
SPI supports two different configurations. One is one master and multiple
independent slaves. Another option is daisy chain configuration where rather than having
individual slave select signal for each slave, common SCLK and SS are used to connect
all slave devices. All slave device data signals are connected in serial. For example, the
first slave output is connected to the second slave input. During the second group of clock
pulses, the SPI port of each slave sends out the same copy of what it received during the
first group of clock pulses
10
SPI interface is better suited for applications where communication between two
devices is in form of full duplex data stream. With advantage of speed, it is more
applicable in Codec (Encoder – Decoder), analog to digital converters, and digital signal
processor. Though SPI can be used with multiple slaves, it is more preferable for point to
point communication as the pin counts increases with increase in slaves.
2.2.2 Inter Integrated Circuit (I2C)
Inter Integrated Circuit (I2C) is a simple 2 wire interface invented by Philips. It
was developed to connect small number of devices on a single card. Standard mode I2C
bus speed is 100 kbit/s. And low-speed mode supports 10kbit/s with arbitrarily low clock
frequencies. Recent revisions of I²C allows Fast mode with 400 kbit/s, fast mode plus or
Fm+ with1 Mbit/s, and high speed mode with 3.4 Mbit/s. Unlike SPI, I2C works in half
duplex mode with bi-directional interface for complete transmission and reception of data
between master and slave.
I2C has only 1 data signal and 1 clock signal for communication. The clock
(SCLK) is always generated by master, but the data (SDA) can be transferred in either
direction. The direction is chosen by microcontroller. In this protocol, microcontroller
selects whether it will operate as a master or as a slave. This can be changed at any time,
but only microcontroller can do any modifications.
11
Figure 2.3: Hardware Connection between Master and Slave for I2C
As shown in figure 2.3, master is connected to multiple slaves sharing common
clock bus and data bus. Each device connected to the bus is differentiated by unique
address. The number of slaves is limited by the capacitance of the line and maximum
allowable capacitance in I2C standard is 400 pF. I2C operates on the 7-bit protocol.
Hence, without extending the maximum capacitance value, up to 127 devices can be
attached to 1 master. I2C requires pull up resistors to be connected on both clock and
data lines as they operate on low frequency.
2.3 433 MHz ISM Band
This project describes wire transmission between microprocessor and computer.
Wireless communication is another efficient way of transmitting data. It permits services
such as long range communication and high speed data transfer which is impossible with
the use of wires. Wireless operations can be done in a variety of forms such as radio
12
frequency, laser light, and Bluetooth. Cordless phones, wireless computer networks, and
microwave ovens are some examples of applications of radio frequency communication.
Radio frequency ranges from 3 KHz to 300 GHz. It corresponds to frequency of
radio waves. This spectrum is divided into several ranges which can be used for different
applications. ISM (Industrial, Scientific and Medical Band) is part of the radio frequency
spectrum that can be used by anybody without license. Unlicensed RF products operating
in the range between 300 MHz and 2.5 GHz in United States and European nations are
called ISM-band products. It is allocated for industrial, medical and scientific purposes
other than communication. ISM is an unlicensed Sub-GHz radio frequency band which is
useful for many short range, low data-rate, and low-power wireless applications [12]. It is
ideal for use in home, business, automation, and medical applications. It is a license-free
operating range which still follows regulation and procedures defined by ITU-R
(International Telecommunication Union- Radio Regulations) but it does not need an
individual license from ITU. Individual country’s use of the bands differs due to variation
in national radio regulations.
With development of integrated circuits, ISM band single chips ICs’ for radio
frequency have been used in many applications. For example, ATA5428, which has high
receive sensitivity, low power consumption, phase locked loop oscillator, and radio
frequency control signals, can be used as a transmitter and receiver in head movement
detection system. It can work on 431.5 MHz ~ 436.5 MHz with center frequency of 433
MHz. This is exactly what is required for ISM. Hence, 433 MHz ISM-Band is a very
convenient way of performing wireless communication.
13
2.4 CRC16 Error Checking
Communication is always prone to error. It is not possible to have 100% accurate
transmission and reception of data. Due to external and internal parameters such as noise,
interference between two communication channels, distance between transmitter and
receiver, and electrical disturbance, the receiver may not receive same transmitted data
every time. For example, if two devices are separated by long distance, noise or weaker
signal strength may change value of some of the bits of the frame. In this case, a receiver
cannot decode data correctly. CRC (Cyclic redundancy Check) is a multi byte error
checking protocol.
In CRC, the transmitted data is treated as a binary number which is modulo-2
divided by another binary number called polynomial. The reminder of the division is
appended to the transmitted packet. When this packet is received by the receiver, it is
modulo-2 divided by the same number. If reminder generated is 0x00, the received data is
deemed to be correct. However, if the resulting CRC is not equal to zero, error is detected
and all data are discarded.
CRC16 appends 2 bytes (16-bits) of information to the original packet.
CRC-16 16 bit CCITT polynomial is as following:
χ16 + χ15 +χ2 +χ1...............
The following chart shows CRC -16 error checking accuracy.
(2.1)
14
Single Bit & Double Bit Errors
100 percent
Odd-Numbered Errors
100 percent
Burst Errors Shorter than 16 bits
100 percent
Burst Errors of Exactly 17 bits
99.9969 percent
All Other Burst Errors
99.9984 percent
Table 2.1: CRC-16 Error Checking Accuracy [3]
As shown in table 2.1, CRC-16’s accuracy is very high. CRC-16 rejects whole
packet when an error is detected. CRC-16 is implemented in both hardware and software.
The hardware calculation is performed with shift registers and XOR gates. Every bit of
data is shifted into flip flop after being XORed with the most significant bit of CRC.
Software implementation of CRC is performed by either Loop Driven or Table
driven CRC implementation. Loop Driven CRC is similar to hardware method. Table
driven CRC uses different approach compared with Loop Driven method. Instead of
calculating value run time, it uses pre computed bytes. These bytes are XORed with the
data.
CRC-16 is mostly used for transfer over wireless communication or local area
internet where large data are transmitted.
15
Chapter 3
DIGITAL ACCELEROMETER ADXL345
This chapter describes features and working operation of ADXL345
accelerometer which is used for the head movement system. It also covers calculation of
tilt angle from integer value generated by accelerometer.
3.1 Introduction
Accelerometer was invented in the bustling period of innovation in the last
century. As the name suggests, it simply measures acceleration.
This invention was commercialized and marketed in mid 1930s to make it very
popular. It was that time when scientists and engineers started thinking more about the
development and use of accelerometers. And even today also, they are used everywhere.
In engineering world, they are used in automobile industry, mobile applications, gaming,
hard drive protection, personal computers, and various other fields. They are extremely
useful in vehicle design and in linear position sensor construction [6]. They play vital
roles in internal mechanism of breaking, and acceleration of vehicle. Nowadays, they
have also expanded their uses in medical industry and in biology where they are used to
detect and understand muscular movement. By measuring static acceleration due to
gravity, tilt angle respective to the earth can be detected. Dynamic acceleration is useful
to analyze the way the device is moving. As medical technologies are also growing, the
use of accelerometer has risen rapidly in those areas as well. In the computing world,
some companies have even started using accelerometer for hard drive protection where
accelerometer detects sudden free fall of the device.
16
There are numerous accelerometers available in the market which, can be
implemented in a system that detects velocity, position, shock, vibration, or the
acceleration of gravity to determine orientation. The accelerometer is selected based on
the number of factors such as type of output data, resolution, sensitivity, range, data rate,
baud rate, etc. After considering all these parameters, ADXL345 was selected for this
project.
3.2 Features of ADXL345
3.2.1 Digital Accelerometer
When the output from the accelerometer is in the binary format, it is called digital
accelerometer. These accelerometers convert the displacement, detected by the capacitors
connected to the sensor of each direction, to digital format by using internally ADC
converter. Digital accelerometers usually use Pulse Width Modulation (PWM) for their
output. It means that the output will be a square wave of certain frequency, and the
amount of time the voltage is high is proportional to the amount of acceleration. It also
involves timing analysis and calculation to get the acceleration from the waveform.
Following figure explains basic functionality of digital accelerometer. As
explained earlier, sensors use capacitors converting the displacement offset to the voltage
format. Analog to Digital Converter converts the voltage into binary format where digital
filter is used to reduce the effect of noise. This output is then transferred to the output
pins of the accelerometer where it can be interfaced to different hardware.
17
SENSOR
ADC
Digital
Serial I/O
Digital
Filter
Output
Figure 3.1: Internal Hardware Architecture of Digital Accelerometer
3.2.2 Tri axial MEMS Accelerometer
ADXL345 is a tri axial accelerometer which means that it has sensors to detect
acceleration in X, Y, and Z direction.. This quality makes it very useful as it does not
have to be at any particular position to detect motion as in any bi axial accelerometer.
Using tri axial accelerometer, 360 degree circular movement is detected in all three
directions.
Earlier, accelerometers used to be very big in size, but after development of Micro
Electromechanical Systems (MEMS) the size has reduced considerably. Due to reduced
size of MEMS, accelerometer has increased its applications in many different areas such
as mobile application, pocket drive, weapon etc. They are also used in wireless game
controllers or mice. MEMS has also increased accuracy of the output data which helps
use accelerometer in real time applications such as monitoring satellite and aero space
weapons.
3.2.3 Resolution and Sensitivity
ADXL345 is a tri axial accelerometer which means that it has sensors to detect
acceleration in X, Y, and Z direction. This quality makes it very useful as it does not have
18
to be at any particular position to detect motion as in any bi axial accelerometer. Using tri
axial accelerometer, 360 degree circular movement is detected in all three directions.
Earlier, accelerometers used to be very big in size, but after development of Micro
Electromechanical Systems (MEMS) the size has reduced considerably. Due to reduced
size of MEMS, accelerometer has increased its applications in many different areas such
as mobile application, pocket drive, weapon etc. They are also used in wireless game
controllers or mice. MEMS has also increased accuracy of the output data which helps
use accelerometer in real time applications such as monitoring satellite and aero space
weapons.
3.2.4 Acceleration Sensor Unit
‘g’ is unit of acceleration equal to earth’s gravity at sea level (9.81 m/s2). Earth’s
gravity is at 1g level while space shuttle is at 10g level. Following are some of the sensor
terminology:
+ 1g: Output of the sensor with base connector pointed up
0g: Output of the sensor with base connector horizontal
- 1g: Output of the sensor with base connector pointed down
MEMS accelerometers are available in ‘g’ ranges reaching up to thousands. It is a
tradeoff between sensitivity and maximum acceleration that can be measured. ADXL345
can range up to +/- 16g. So, it is most sensitive to tilt in the 0g mode. A 1 degree of tilt in
the 0g position creates an output error equivalent to a 10 degree tilt in the +1g or -1g
position.
19
3.2.5 FIFO Buffer
To extend functionality of accelerometer, FIFO (First in First Out) mode is added
into the accelerometer. It is useful to provide further power savings, and increase system
performance with reducing need for host processor. This FIFO buffer of ADXL345 can
store 32 data samples. The stored data in buffer can be read from the data register.
One thing which needs to be taken care of is the rate at which the data is stored in
the buffer and the data is read from the FIFO. If user stores the data at higher speed
compared to the read speed, then it is possible to lose old data.
FIFO has four modes: Bypass, FIFO, Stream and Trigger. Each mode is selected
by the settings of the FIFO_MODE bits (Bits [D7:D6]) in the FIFO_CTL register
(Address 0x38) [5].
(1). Bypass Mode
As name explains, FIFO is not operational, and so that FIFO remains empty. It
works like regular accelerometer as FIFO does not store any value.
(2). Stream Mode
In this mode, data from all three axes are stored in FIFO. When the number of
samples in the FIFO buffer equals to the number specified in the register, watermark
interrupt is set and FIFO keeps storing the data. FIFO stores the latest 32 data and
discards the old data as new data arrive. The watermark interrupt continues occurring
until the number of samples in FIFO is less than the value stored in the sample bits of the
FIFO_CTL register.
20
(3). FIFO Mode
FIFO is activated and data are stored in the FIFO memory. When the number of
samples in the FIFO buffer equals to the number specified in the register, watermark
interrupt is set and FIFO stops collecting new data once it is filled with all 32 locations.
The watermark interrupt continues occurring until the number of samples in FIFO is less
than the value stored in the sample bits of the FIFO_CTL register.
(4). Trigger Mode
FIFO collects samples and stores the latest 32 samples while discarding others.
After a trigger event occurs and interrupt is sent to the INT1 or INT2 pin (determined by
the trigger bit in the FIFO_CTL register), FIFO keeps the last n samples (where n is the
value specified by the sample bits in the FIFO_CTL register) and then operates in FIFO
mode, collecting new samples only when FIFO is not full [5].
FIFO can store 32 values. In this project, the I2C sampling frequency is 400 KHz
and the output data rate is 400 Hz. If the rate for data to be stored into database is less
than 400 Hz, the old data will be lost. Rabbit microprocessor which controls all the
operation of transferring data, needs to sample old data from FIFO buffer to its own
database for permanent storage. In this project, FIFO is not used. Instead, the HTTP
interface of RCM3365 helps transfer 50 values to the web interface of Rabbit web at one
time. The web database which is generated using Visual Studio and C# can only sample
data at 10 Hz which is very low compared to 400 Hz. Due to this frequency mismatch,
not all data values stored into FIFO can be retrieved. So, the use of FIFO will not
improve the performance for the current application.
21
3.2.6 Serial Communication with External Master Device
ADXL 345 can interface with outside world using serial communication. Both I2C
and SPI serial protocols are supported. In both cases, ADXL 345 operates as a slave [4].
I2C mode is selected when CS pin is connected to the power supply.
By setting Bit 6 of the DATA_FORMAT register, 3 – wire or 4 – wire SPI mode
is selected. The maximum clock speed of 5 MHz is possible with SPI. I2C interface can
work only up to 400 KHz of data rate. And the device cannot give output data rate of
more than 400 Hz. This limitation can be overcome by using SPI interface and then the
output data rate of 1600 Hz or 3200 Hz is possible with SPI. Operation at an output data
rate of more than 400 Hz in I2C may result in undesirable effect on acceleration data,
including missing samples and additional noise [4]. This higher data rate in SPI comes at
a cost of complexity. I2C is very simple due to only 2 wire interface and it can also be
connected to more than one slave.
As the final data will be displayed on the web, head movement does not require
higher speed. Because even if the sample is transferred at higher data rate using SPI, it
cannot be stored in the web database at more than certain speed as the web transfer is not
as fast as serial communication. Previous calculations revealed that the web data transfer
speed is much slower than I2C. So, I2C serial interface scheme is used for the movement
detection application.
22
3.3 Theory of Operation – ADXL345 Accelerometer
Accelerometer works on the fundamental of force exerted by the movement on
each sensor. The values are in the analog format. It measures both static acceleration in
tilt detection application and dynamic acceleration caused by motion or shock [4]. As it
can measure deflection in both manners, it gives reasonably accurate data whenever there
is a movement detected.
ADXL 345 has internal sensors for each X, Y, and Z direction. The sensors are
made up of poly silicon structure which is mounted on top of silicon wafer. Deflection
can be detected using the different differential fixed plate capacitors connected to the
moving mass. In proportion to the movement, the mass disturbs the fixed plate capacitors
and unbalances them. The output voltage is generated on the proportion of the mass
deflection.
Also, ADXL 345 allows the ‘g’ range to be set from +/- 2g to +/- 16g, where ‘g’
is gravitational force. +/ - 2g cannot detect movement as far as +/- 16g can do. It is very
useful as for some application only small range of g is required while other may need
increased range with more force. But, the sensitivity is reduced while increasing ‘g’ range
from 2g to 16g. For example, ADXL345 has higher sensitivity of 256 LSB/g at 10-bit
resolution but the sensitivity reduces to 32 LSB/g with +/- 16g of range and 13-bit
resolution.
23
3.4 Tilt Angle Calculation
The advantage of using tri axial accelerometer is that it has 3 sensors in each X,Y,
and Z direction. It becomes very useful to accurately find the angle of a particular
position. By using three sensors, it is also possible to measure the values at high
sensitivity. When third axis is introduced into accelerometer, the orientation of the sensor
can be determined in a complete sphere. The output of accelerometer is in LSB/g unit
which is movement based on the acceleration in gravity. It is hard to understand
movement in this format. So, it needs to be converted into degree to measure the exact
position of head. The angle can be calculated using two methods: “atan” and “arctan”.
First step in “atan” method is to normalize the acceleration vector which can be
used as a denominator to calculate any angle. By assuming that motion is only due to
gravity, denominator can be replaced with constant for all angles. Now, angles with
respect to X and Z axis can
be calculated by using following equations.
Ѳ  tan
1
Ф  cos
1
(
X
) …………….
Y
(Z
X
2
 Y 2  Z 2 ) ……………
(3.1)
(3.2)
This method does not give very accurate result and calibration becomes necessary
to improve result.
For this project “arctan” method is used. The values of the angles are determined
individually for each axis of the accelerometer from a reference position. The reference
position is set in the accelerometer such that, the values of X and Y axis are in the 0g
field and the values of Z axis are in 1g region. It means that the X and Y axis are in the
24
plane of the horizon while Z axis is orthogonal to the horizon. If the horizon is considered
as a reference, then positive value after inversion corresponds to movement pointing
above horizon while negative value corresponds to movement pointing below horizon for
respective axis.
In figure 3.2, the accelerometer position can be determined by three angles: Ѳ is
the x-axis angle, Ѱ is the Y–axis angle and Ф is the Z-axis angle. As shown in the
following figure, X axis and Y axis are in 0g and Z axis is in 1g position.
+Z
+Z
Ф
+Y
+Y
Ѳ
+X
Ф
Ф
+Z
+Y
Ѱ
+X
+X
+Y
Ѱ
+X
Ѳ
1g
+Z
1g
Figure 3.2: Angle showing independent deflection
Using trigonometry, following equations can be use to change the value to angle:
Ѳ  arctan ( X 2
Y 2  Z 2 ) ………………..
(3.3)
Ѱ =  arctan (Y 2
X 2  Z 2 ) ………………
(3.4)
25
Ф =  arctan ( X 2  Y 2 Z 2 ) …………………
(3.5)
These values have unit of radian. It can be easily converted into degree by
multiplying with (180/π). This completes whole process of tilt angle calculation. Though
the values vary from -90 to +90 degree for each axis, it can be converted to measure 360
degree movement using simple geometry. By monitoring the sign of the input, the
quadrant of the angle can be determined. If the angle is in 1st quadrant, no further steps
need to be taken. If the angle is in 2nd quadrant then 180 is added to the original result.
When the angle is in 3rd quadrant, the angle is subtracted by 180 degree to give correct
output. The angle is correctly displayed when 360 is added to the angle generated in 4th
quadrant.
As explained earlier, inversion of operand in equation of Ф is due to orthogonal
position (1g) of Z axis with respect to the reference position. Using this method, the
incremental sensitivity remains constant and the angle can be accurately measured for all
points around sphere.
Following is an explanation which shows X, Y, and Z values for 0, and +/- 90
degree angle. This table is used to find the approximate range of X,Y, and Z values from
one extreme to another extreme point.
26
X
Y
Z
Ѳ
Phi
Ф
integer integer integer
(X
(Y
(Z
value
value
value Angle) Angle) Angle)
0
5
227
0
1.1
5.6
261
5
227
89.31
1.1
5.6
2
308
-267
0.432
87
-8.2
-254
0
308
-20
-267
18
-85
0
87
-5
-8.2
85.85
261
-20
18
89.31
-5
85.85
2
-262
-61
0.432
-89
-76
-254
-262
-61
-85
-89
-76
Result ( Position of sensor
with respect to earth surface)
X and Y axes parallel
Z axis perpendicular
X and Z axes perpendicular
Y axis parallel to earth
X axis parallel
Y and Z axes perpendicular
X,Y,Z axis perpendicular
X,Y, and Z axes parallel
X axis perpendicular
Y and Z axis parallel
X,Z axis parallel
Y axis perpendicular
X and Y axes perpendicular
Z axes parallel
Table 3.1: Conversion from LSB to degree and different possible combinations of sensor
positions
As shown in above tables, the values of X and Y are approximately equal ranging
from -270 to +270 for -90 to +90 degree change. But, this change is exactly inverse for Z
axis. This confirms earlier explanation of X and Y axis in 0g region while Z axis is in 1g
region. Using these values, the exact angle of point can be found in total 360 degree
sphere.
27
Chapter 4
DESIGN HARDWARE SYSTEM
This chapter contains detailed explanation of main design procedure required to
perform successful operation, design and power considerations, and methods to improve
acquired result. The design results and graphs are also attached which can verify the
discussion.
There are many different microprocessors available in the market each used for
different applications in different field. It is very important to select an appropriate
microprocessor which meets the specification and project requirement. RCM 3365 is a
development kit which has Rabbit 3000 microprocessor, RJ 45 ethernet port, 16 MB
NAND Flash, and 512 K each of programming and data memory. These features make it
ideal for this project as it would be feasible to expand it in future, if required.
The main part of the project is transferring data from accelerometer to Rabbit
3000. As already explained earlier, Rabbit 3000 and ADXL345 have both I2C and SPI
serial interfaces. So, any one from these two serial communication protocols can be used.
I2C is a 2-wire interface with clock and data pins. So, I have used I2C communication
interface between ADXL345 and RCM 3365 for its simplicity and ease to control. Rabbit
3000 is a master which generates clock signal and sends commands to ADXL345.
ADXL345 works as a slave which receives clock generated by master and performs
read/write according to the commands given by master.
28
4.1 Rabbit 3000
Rabbit 3000 is a high performance microprocessor with low electromagnetic
interference which is designed and used specifically for embedded system, control, and
communication applications [1]. It is fast as it can run up to 55.5 MHz frequency. This 8bit microprocessor supports 8 bit architecture. It has totally 6 serial ports and 56 I/O lines.
Other features of the Rabbit 3000 include PWM, quadrature decoder, battery back-able
real time clock, low power modes, and interrupt priority. The supply voltage ranges from
1.8 V to 3.6 V.
Figure 4.1: Rabbit 3000 microprocessor
The architecture of 20 bit address bus and 8 bit data bus outperform even most
16-bit architecture without losing advantages of 8-bit architecture. Along with data bus
and address bus, 3 chip select lines, write enables and output enable lines can be
interfaced with up to 6 memory devices.
It also has 2 timers with timer A consisting of ten 8-bit counter and timer B
consisting of 8-bit counter with 2 match resistors and 2 step resistors [1]. The important
features are explained in detail later.
29
Rabbit 3000 has seven 8-bit parallel ports, port A to G comprising of more than
56 digital I/O pins. These ports have primary functionality as well as alternate output
functions. All ports are byte wide with each bit programmable as input or output. Parallel
port A can also be used as an external I/O data bus to serve as slave data bus. By setting
Slave Port Control Register, Port B can be configured to extend its functionality as Slave
port and external I/O. Port C has 4 input lines and 4 output lines. Port D is a special port.
By setting Port D Data register, alternate pins of Port D can be used to communicate
either serial or parallel data. 4 pins of Port E are also used as interrupt pins.
The following picture is the image of RCM3365 development board which is used
for this project:
Figure 4.2: RCM3365 Board
30
4.2 System Architecture
Interfacing between Rabbit 3000 and ADXL345 requires certain hardware
connections which are shown in figure 4.3.
Figure 4.3: Hardware Connection between ADXL345 and Rabbit 3000
In the above figure, Pin 6 and Pin 7 of Port D of Rabbit 3000 are used as Serial
Clock (SCL) and Serial Data (SDA). I2C requires pull up resistors on both clock and data
lines. In case of missing any of the resistors, I2C may not be able to detect response from
master and/or slave device. The resistors can be of any value from 1k to 47k. I have used
2k ohms for both pins. Unlike RCM 3365 which works on 5 V power supply,
accelerometer needs only 3.3 V. Despite of this voltage difference, Rabbit 3000 can
31
correctly detect the voltage level and hence the data from the accelerometer, which
eliminates voltage converter between two devices.
When Chip Select (CS) is connected to VDD or Vcc, ADXL 345 is in I2C mode.
As shown in figure 4.3, SCL and SDA of Rabbit 3000 are connected with Pin 14 and 13
of ADXL 345 respectively. I2C is only 2 wire interface. So, it does not require Chip
Select (CS) and Alternate Address (SDO) as part of communication protocol as SPI does.
But, to make it work correctly, CS should be connected to Vcc and Alternate Address
should be connected to either ground or power supply. The command for 7-bit device
address followed by Read/Write bit for I2C is 0x1D if SDO is connected to Vcc and 0x3A
with SDO pin low.
The serial programming cable connects RCM 3365 board with the computer to
download and run the program. This cable has RS 232 level voltage converter which
converts the voltage generated from the prototyping board into the TTL level compatible
with computer. This cable can be used for “PROG” mode as well as “DIAG” mode.
When connected in “PROG” mode, the programming cable can run and debug the
program. The “DIAG” connector on the programming cable makes the port to be used as
a regular serial port. This cable can be directly connected to the serial port. But most of
the laptops do not have serial port. So, Serial to USB converter is used to connect
programming cable to the computer. A 3-pin AC adaptor is connected to the prototyping
board which provides power supply. This prototyping board also supplies power to the
RCM3365.
32
Before doing any hardware connection, mounting of RCM3365 on the
prototyping board is done. Following figure is taken from the manual of RCM 3365 kit
showing the connection of RCM 3365 module to the prototyping board.
Figure 4.4: Rabbit 3000 placement onto RCM3365 development board
This connection is tricky and user needs to be very careful. All the header pins are
supposed to be matched before the boards can be mounted on each other. The header pins
from J3 and J4 go into headers JA and JB. Mounting does not require hard pushing
otherwise it might break the header socket. The following figure shows the RCM3365
development kit after mounting is done.
Figure 4.5: RCM3365 Development Kit
33
Fig. 4.6 shows the exact hardware connection between Rabbit 3000 and
ADXL345. Accelerometer is stationed on a cap as it is being used for head movement
detection. It is placed in such a way that the initial angle position in all three axes is
approximately 0. The accelerometer is very small in size and easily concealed by
mounting it on a cap.
Figure 4.6: Head movement detection System
34
4.3 Sampling Frequency of Measurement
While specifications of operable frequency range and data rate vary with each
device, it is very important to make sure those values are compatible to both devices. So,
the values are chosen in such a way that efficient communication is obtained without
affecting performance of head movement system. Rabbit 3000 works as a master and
ADXL345 is a slave.
Rabbit 3000 can work in both SPI and I2C interface. ADXL345 transmits data to
Rabbit 3000. In this project, sampling frequency is selected based on the configuration of
accelerometer. ADXL345 has clock frequency of 5 MHz for SPI. But, due to operating
limitations of I2C, it can only operate from 100 KHz to 400 KHz. By selecting 400 KHz
sampling frequency, the output data rate is 400 Hz. Output data rate is simply the rate at
which data is sampled. After considering delays and clock stretching pulse,
approximately 200 values of each axis are received by Rabbit 3000 every second.
The tilt angles calculated from received integer values are stored into the database
through Rabbit web. Not all the values are being stored into database. So, 10 data points
of X,Y, and Z axis per second are stored into external database. This can be changed
easily anytime. But, usually it is not required to store 200 values every second. This
makes frequency of data transfer between Rabbit web and website database 10 Hz.
35
4.4 Power Consumption Consideration
Head movement system might be used on the patient’s head continuously for
more than a day also. That’s why it becomes mandatory to have low power consumption
otherwise it may have adverse effect on patient’s body and also on the accelerometer.
RCM3365 needs from 3.15 V to 3.45 V regulated power supply. RCM3365 with
no loading at the outputs operating at 44.2 MHz typically draws 250 mA [2]. It does not
have internal battery but it has support to add external battery for back up. It allows
SRAM to store data when regular power supply from RCM3365 is down. A Lithium- Ion
battery with nominal power supply of 3~3.3 V is chosen. The drain on the battery is
estimated to be 6 µA when no other power is supplied. With 165 mAh battery, the life of
the battery is estimated to be 3 years (165mA/6µA). Sometimes it also has a battery backup circuit which ensures that current can flow only out of RCM3365 to stop charging the
battery itself.
ADXL345 draws current from 23 µA to 140 µA when operating at frequency
from 0.1 Hz to 3.2 KHz in regular power mode. With additional low-power mode,
ADXL345 has low power consumption and it goes into auto sleep mode when it is not
being used. Only when it is used, it wakes up and outputs the data. In this mode, internal
sampling rate is reduced and as a result, output data rate ranges from 15 Hz to 400 Hz.
This reduces current consumption to 90 µA which is smaller than 140 µA for normal
operation. It also increases life of the external battery.
36
The added advantage of low power mode is reduction in heat dissipation which
eventually improves performance of the whole system and it can be used for longer time
without any interference and disturbance.
4.5 Design Consideration
Certain design considerations are necessary before analyzing any output signal.
Use of calibration and external filter is important for precise calculation of output. A
faster sampling frequency rate reduces error due to the fact that more number of samples
are taken in each time period [13]. This requires more hardware and timing
considerations. The timing between each sample should be same otherwise errors can be
generated [13].
4.5.1 Calibration
Nowadays, accelerometers are usually factory calibrated, allowing the user to
avoid any further calibration. But, in order to achieve more accuracy and preciseness of
data, calibration becomes necessary. Calibration removes the acceleration offset
component in the sensor output due to earth’s gravity. The ideal accelerometer should
have zero offset and good sensitivity as specified in the datasheet. But, due to mechanical
nature of the sensors and noise interference, it is not possible to have zero offset when
there is no movement in the accelerometer. This can sometimes result in error which is
beyond the range of acceptable limit making calibration necessary for accurate
applications such as head movement detection system.
Calibration is performed when device is not being used. It averages samples when
the accelerometer is in a no movement condition. More accurate calibration results can
37
be achieved by using more samples. The output of offset obtained in no movement
condition is considered as a zero point reference.
……….......
(4.1)
Where, Aact is the real acceleration value in unit g after calibration, Aout is accelerated
value before calibration, Aoff is zero offset bias or calibration factor, and Gain is the gain
of accelerometer.
The accelerometer output varies from 0 to Vdd. ADXL345 has voltage range
from 0 to 3.3V which means that zero value is near 1.65 V. The calibrated value obtained
is affected by static acceleration. If the value obtained is close to 1.65 V, the
accelerometer is perfectly parallel to the earth’s surface. This is called zero offset value
which is subtracted from the original acceleration value to get correct position of g with
respect to earth’s surface. But, usually single sample is not very accurate. So, more
number of samples are taken and averaged to obtain zero offset value. Following
equation shows the actual calculation of ADXL345
By calculating, calibration using above method, accuracy of the result can be
improved in such a way that the results can have angular resolution as high as 0.1
degrees.
4.5.2 Filtering
The output signal is never noise free. So, digital filter should be used to reduce
noise. ADXL345 accelerometer does not have capability to add analog filter but use of
38
any digital filter improves the result by a huge margin. One of the filtering techniques is
averaging more samples taken in a single time frame.
Another method that can be implemented in ADXL345 to improve result of the
head movement detection is oversampling. It increases resolution and decreases effect of
noise by sampling analog signal at much higher rate than required. This improves result
because total noise remains same for same bandwidth but taking more number of samples
reduces the effect of noise. This signal is filtered within the original bandwidth and thus
the total quantization noise is reduced.
4.6 Design Flow Chart
There are several steps in the design to follow starting from the power on
sequence to the angles being stored in the database. All these steps follow certain design
rules and procedures.
4.6.1 Initialization
Before starting data transfer, initialization is needed for both accelerometer and
Rabbit 3000. If either of the devices is not properly initialized, the output data from
accelerometer might be incorrect. In other words, initialization wakes up accelerometer
from auto sleep mode which becomes important as failing to wake up any of the device
may lead to misinterpretation of command and/or data.
4.6.1.1 Rabbit 3000
Rabbit 3000 requires initialization of I2C interface before establishing connection
with accelerometer. It can be done by setting default values and normal function for I2C
pins on Port D. I2C pins are PD6 =SCL (Clock) and PD7 = SDA (Data).
39
Figure 4.7: Design Flow Chart
40
Following steps are performed for initialization:

Set PD6 and PD7 pins to normal function. As pins of all the ports also
have alternate functions, setting of 0 to both pins ensures that they are set to serial
transmission mode. This can be done by setting 0 on bit 6 and 7 of PDFR ( Port D
Function Register).

Next step is to set input direction. By default, both PD6 and PD7 are set as
outputs. Setting 0 on bit 6 and 7 of Port D Data Direction Register (PDDDR)
changes its default function to input.

Both configurations of input and output directions are necessary for
communication. Port D Drive Control Register (PDDCR) corresponding bit are
set to logic 1 to allow open drain output

In case of standard output, the default value of output is set to 0. Another
register called Port D Data Register (PDDR) is used to set output values.

Frequency division is required as I2C cannot work in same speed as SPI.
This completes initialization of Rabbit 3000 for I2C.
4.6.1.2 ADXL345
After initializing Rabbit 3000 for I2C transaction, the next step in the design is to
initialize ADXL345 accelerometer for transmission. Accelerometer has a number of
registers to set baud rate, data transfer, interrupt, etc. In total, it has 57 registers and
registers 1 to 28 are reserved for future use. According to specification, ADXL345
requires 2 ms delay before changing value of any register. 5 ms of delay is added in the
beginning.
41
Power on sequence is needed before starting any read or write transaction:

Write 0x0B in Data register (0x31). By setting 0x0B value, the range is +/-
16g (full range) and full resolution is set. This register value determines the
maximum g range and scale factor [4].

Write 0x0C in BW-Rate Register (0x2C). 0x0C value sets output data rate
to 400 Hz and sets baud rate.

Write 0x08 in Power Control Register (0x0D). It is used to set bit 3 which
is a measure bit. If this bit is reset, then it does not perform correct read and write
transaction. To start reading values form accelerometer, the measure bit is set.
Along with initialization of Rabbit 3000 and ADXL345, HTTP
initialization is also performed which sets the buffer size and the number of
maximum servers for this communication. It also initializes HTTP handler which
is later used for rabbit web.
4.6.2 Reading and Storing Values in Rabbit 3000
This step of the design is reading the values from the accelerometer and
temporarily storing them in Rabbit 3000 for further processing.
There are two registers to store data of each axis. So, totally there are 6 registers
from which the values are being read to Rabbit 3000. 0x32 and 0x33 store the value of x
axis while 0x34, 0x35 and 0x36, 0x37 store the values of Y and Z axes respectively. To
read values from ADXL345 using I2C communication, certain procedures need to be
followed to get correct result. They are as follows.
42

I2C communication starts with Start bit which is then followed by Slave
Address for write (0xA6, as SDO is connected to ground). The communication
starts with Master. As Rabbit 3000 is a master and ADXL345 is slave device, all
the commands of read or write are transferred through Rabbit 3000 only. After
receiving acknowledgement from the slave, master transfers register address (any
address between 0x32 and 0x37) to the slave which corresponds to the master by
sending another acknowledge signal. The communication does not move forward,
if the acknowledge is not received from the slave. For clear communication, each
signal is being sent multiple times depending on the clock stretching period.
Communication is aborted and error command is displayed only after not
receiving ack signal in finite clock stretching period from slave.

Master sends another start signal followed by read command to slave
device. It indicates the beginning of read cycle. Each register reads 8 bit of data.
So, this entire read operation is repeated 6 times by storing all the values into
Rabbit 3000 for further processing.

ADXL345 reads the value 0g when gravity is 9.81 m/s2. Out of generated
totally 16 bits for three axes, 13 bits are used based on the resolution which is set
earlier in the initialization stage. The values are stored then converted into degree
angle format for future use.

Using “atan” method to convert integer values into degree, output varies
from -90 degree to +90 degree. Due to tri axial accelerometer, it is possible to
detect 360 degree movement in all three directions. Using trigonometric and
43
mathematical calculations, angles in all three directions vary from 0 to 360 degree
and they accurately reflect movement in accelerometer.
4.7 Simulation and Results
The software consists of two parts. The first part displays the head position on
webpage. The other part transfers data through rabbit web for permanently storage. The
following figure is a screen shot displaying head position on internet through rabbit web.
Figure 4.8: Head Position - Straight
The above results display straight position of head with respect to accelerometer’s
position with head. The range for straight angle with respect to each axis is between 350
degree and 10 degree angle. Head movement detection has potential to be used for
medical applications to display changes when head movement exceeds threshold angle.
The ophthalmologist determines maximum allowed deviation from the optimal position
and this value is known as angular threshold [8]. The message showing risky position is
44
also displayed on the screen along with angles on occurrence of threshold angle
detection. Figure 4.9 is the screen shot showing risky position of head. Just to make sure,
these readings are not taken on the head position and it is not advisable. The
accelerometer was placed on the hand and set up to behave like it was on the head.
Figure 4.9: Head Position – Risky
The accelerometer was placed such a way that head position was more tilt than
perpendicular while head is moved more than 90 degree on the back side. This makes it
very risky as it can damage neck.
The web storage database application of accelerometer website created using
visual studio stores values eventually into Microsoft excel database. Following is a table
45
displaying the values stored into excel database and also graph which shows movement
in X, Y, and Z axis continuously:
X
Y
Z
39.381389
77.688911
312.079193
39.381389
77.688911
312.079193
39.381389
77.688911
312.079193
45.12324
79.68121
314.1235
45.12324
79.68121
314.1235
46.1233
76.2343
311.2342
46.1233
76.2343
311.2342
……
.....
……
.
.
.
.
.
.
79.14540
77.68891
309.1242
76.24355
74.12343
309.1242
78.54354
74.12343
309.1242
Table 4.1: Web database storing values into Excel files
46
Figure 4.10: Graphical display of values stored in database– Deflection in X direction
The graph is plotted using the values collected from Table 4.1. This graph shows
movement in direction of X-axis with both Y and Z axes almost remaining constant.
Similar results can be analyzed for other plots and all correctly verify results with head
movement. This is just an example plot. The movement can vary from 0 degree to 360
degree.
The function of the monitoring device can be set by parameters such as sampling
period, storing period, improper head position time before alarm activation and proper
head position time to terminate alarm signal. These parameters are user configurable. In
this project sampling frequency is 400 Hz and storing frequency is 10 Hz. The webpage
47
stores 50 values at one time. So, it takes about 5 sec to activate the alarm signal on
exceeding angular threshold. This can be easily changed to 1 sec by just changing storing
frequency to 50 Hz. Another important parameter is alarm signal activation time. It is
minimum time of improper head position before alarm is turned on. This is required as it
reduces false alarm probability.
The communication interface downloads data onto the database which can be
used for data analysis. 50 sample angles are stored in 1 excel file. This is also user
configurable and number of samples to be stored in an excel file can be easily changed, if
required.. The displayed graph can be improved for efficient assessment of data by
adding any of the parameters such as start and end of monitoring time, out of threshold
time, overall monitoring time and threshold angle.
48
Chapter 5
CONCLUSION AND FUTURE EXPANSION
5.1 Conclusion
Rabbit microprocessor is useful for many applications especially those require
high speed data transfer through Ethernet. This project can monitor head movement. It
has potential usage for medical applications especially applicable where more accuracy
and position related to three tilt axes are required.
Angular resolution of approximately 0.5 degree was achieved using this design
but it can be improved by introducing better calibration and filtering techniques. This
resolution is sufficient for medical procedures and gives enough accurate result to detect
problem, if any. Another criterion which was fulfilled in this project was storing data
anytime. But, to store data onto web database requires Ethernet support. This makes it
convenient for medical applications as doctors can have access to any data at any given
time. It becomes very useful for applications such as post surgery diagnostics.
In conclusion, goals of the project were achieved successfully.
49
5.2 Future Expansion
Due to more than 50 I/O lines available on Rabbit 3000, it can be embedded with
different applications. This will be a cost effective solution for many problems. Many
devices can be implemented and communicated with Rabbit 3000 simultaneously which
can certainly help reduce manufacturing cost as well as design time.
Moreover, the results can be more accurate by using filter which will reduce the
effect of noise. Also, the design procedure can be altered in a way that accelerometer
gives output of angle with respect to original starting position. So, the angles displayed
will be the difference between initial position and ending position. Instead of using wire
communication (ethernet), wireless communication makes it even more convenient and
easier to interface at any time at any place. So, doctors can have continuous update on
patient’s head movement without being with them all the time. This will certainly help
doctors as they can treat patient and guide them in better way.
RCM 3365 development kit also support CMOS camera. It can also be used in
security system where along with accelerometer which detects movement, cameras store
pictures which may help in improving security.
50
REFERENCE
[1]
Rabbit International Inc., “Rabbit 3000 User Manual”, December 2005.
[2]
Rabbit International Inc., “RCM 3365 User Manual”, July 2005.
[3]
A. Tanenbaum, “Computer Networks”, Prentice-Hall, 2003.
[4]
Texas Instruments, “Accelerometers and how they work”, Application note, 2005.
[5]
Analog Devices, “ADXL345 Accelerometer Datasheet”, May 2011.
[6]
A. Noton, “A Brief History And Overview Of The Accelerometer”, June 2011.
[7]
Basic
of
Accelerometers,
[ONLINE]
Available:
http://sensorwiki.org/doku.php/sensors/accelerometer
[8]
P. Cech, J. Dlouhy, M. Clzek, I. Vichar, J. Rozman, “ Head Position Monitoring
System”, 20th Intl. Conference Radioelektronika, Czech Republic, April 2010.
[9]
C. Fisher, “Using an Accelerometer for Inclination Sensing”, AN-1057,
Application note, Analog Devices, 2010.
[10]
Technical Tutorial, “Introduction to Serial Communication”, June 2002.
[11]
P. Myers, “Interfacing using Serial Protocols Using SPI and I2C”, June 2007.
[12]
M. Cizek, J. Dlouhy, I. Vichar, J. Rozzman, “Electronic Monitoring of Head
Position after Vitrectomy”, IFMBE Proceedings, 1, Volume 22, 4th European
Conference of the
International
Federation
for
Medical
and
Biological
Engineering, Part 11, Pages 1758-1761, 2009.
[13]
K. Seifert, O. Camacho, “Implementing Positioning Algorithms Using
Accelerometers”, Freescale Semiconductor, February 2007.
Download