Upload
others
View
4
Download
0
Embed Size (px)
Citation preview
Industrial Attachment Program (IAP)
AY2011 Sem 2
Development of Wearable Sensor
Final Report
Chua Wang An S10078666G
Project Supervisor: Professor Toshiyo Tamura, Mr. Rigoberto Martinez Méndez
Liaison Officer: Mdm Tan Peck Ha
Alternate LO: Mr. Chua Tji Leng
Page | 2
Table of Contents 1. IAP Information ................................................................................................................................... 4
2. Summary ............................................................................................................................................. 5
3. Company Profile .................................................................................................................................. 6
3.1 Introduction to Chiba University .................................................................................................... 6
3.2 Location of workplace in the campus ............................................................................................. 7
3.3 Tamura’s Laboratory Introduction.................................................................................................. 8
3.4 Facilities in Tamura’s laboratory..................................................................................................... 9
3.4.1 Experimental room ................................................................................................................. 9
3.4.2 Hardware development room ................................................................................................. 9
3.5 Staff directory .............................................................................................................................. 10
4. Abstract ............................................................................................................................................. 11
5. Project introduction........................................................................................................................... 12
5. 1 Description ................................................................................................................................. 12
5. 2 Objective .................................................................................................................................... 14
5. 3 Specifications .............................................................................................................................. 14
5. 4 Visualization of final product ....................................................................................................... 15
6. Project planning................................................................................................................................. 16
6.1 Work Breakdown Structure (WBS) ............................................................................................... 16
6.2 Responsibility Assignment Matrix (RAM) ...................................................................................... 17
6.3 Precedence list ............................................................................................................................ 18
6.4 Schedule Chart............................................................................................................................. 20
6.5 System Block Diagram .................................................................................................................. 21
7. Job specification and Details .............................................................................................................. 22
8. Projects ............................................................................................................................................. 25
8.1 Laboratory and equipments ......................................................................................................... 25
8.2 MITS PCB maker machine ............................................................................................................ 26
8.2.1 Introduction to MITS PCB maker machine ............................................................................. 26
8.2.2 Problem encountered with the PCB maker machine .............................................................. 27
8.2.3 How to operate the PCB maker machine ............................................................................... 28
8.3 Reflow soldering oven.................................................................................................................. 35
Page | 3
8.3.1 Introduction to reflow soldering oven ................................................................................... 35
8.3.2 Different operating mode ...................................................................................................... 36
8.4 Oscilloscope (probe calibration) ................................................................................................... 37
8.5 Project preparation ...................................................................................................................... 38
8.5.1 Components overview .......................................................................................................... 38
8.5.2 Step up regulator (power supply) .......................................................................................... 39
8.5.3 dsPIC30F3013 connections .................................................................................................... 40
8.5.4 Soldering of modular cable for MPLAB ICD 3 ......................................................................... 41
8.5.5 MPLAB Integrated Development Environment (IDE) .............................................................. 43
8.5.6 Blinking of LED by manipulating dsPIC30F3013 ...................................................................... 44
8.6 Project Implementation (Hardware)............................................................................................. 46
8.6.1 Component amendments ...................................................................................................... 46
8.6.2 Bread-boarding Sensors board .............................................................................................. 53
8.6.3 Bread-boarding Receiver board ............................................................................................. 54
8.7 Project Implementation (Software) .............................................................................................. 55
8.7.1 Serial communication (GUI) ................................................................................................... 55
8.7.2 Live-graph (GUI) .................................................................................................................... 64
8.8 Project results .............................................................................................................................. 70
8.8.1 Step-up regulator waveform ................................................................................................. 70
8.8.2 Crystal oscillation waveform.................................................................................................. 71
8.8.3 I2C communication between micro-p and Gyroscope (L3G4200D) ........................................ 72
8.8.4 I2C communication between micro-p and Accelerometer (LSM303DLH) ............................... 73
8.8.5 nRF2401a Packets error rate test .......................................................................................... 74
8.8.6 Overall performance of power usage .................................................................................... 76
8.8.7 Final Product ......................................................................................................................... 78
8.8.8 System error ......................................................................................................................... 79
8.8.9 Computation with Excel ........................................................................................................ 80
8.8.10 Computation with Live-graph (GUI) ..................................................................................... 82
8.9 Conclusion ................................................................................................................................... 83
9. Appendices ........................................................................................................................................ 84
10. References....................................................................................................................................... 85
Page | 4
1. IAP Information
Title Development of wearable accelerometer with wireless receptor
Author
Chua Wang An (S10078666G)
Supervisor
Professor Toshiyo Tamura
Mr. Rigoberto Martinez Méndez
Liaison officer
Mdm Tan Peck Ha
Alternate liaison officer
Mr. Chua Tji Leng
Affiliation
Ngee Ann Polytechnic
School of Electrical and Computering Engineering
Department of Biomedical Engineering
Chiba University of Engineering
Graduate School & Faulty of Engineering
Department of Medical System Engineering
Page | 5
2. Summary
I was attached to Chiba University, Japan. I was here for researching and learning of
wearable sensors in Tamura’s laboratory and thereafter developing one wearable
sensor to serve as an educational purpose project. I was in Chiba University-Tamura’s
laboratory for a period of approximately 6 months during the Industrial Attachment
Program.
My Job Scope:
To experience and learn about wearable sensors
To develop a wearable sensor to assist in diagnosis of targetted area
To learn to work effectively and efficiently as a team to complete the task
Learning Japanese Language
Supervision and guidance are given by my supervisor Rigoberto Martinez Méndez. He
is here to impart me with knowledge and skills and also to guide me out of the many
obstacles which I encountered during the term of doing the project.
During my time here, I am provided with Japanese Language course and met other
international students from all over the world which greatly deepen my understanding of
the world through the exchanging of different cultural values.
This report presents the work which I have done and also the skills which I had acquired
through the accomplishment and the process of completing the project.
Page | 6
3. Company Profile
3.1 Introduction to Chiba University
Chiba University was founded in 1949, unifying several regional former national
colleges and schools such as Chiba Medical College and Chiba Normal School. Its
fundamental mission since then has been, as encapsulated by the inscription on the
University Bell, ad altiora semper (always toward the higher), to equip students with the
ability to make mature and informed judgments while nurturing and guiding their
creativity. Pursuing these goals of excellence has resulted in Chiba University becoming
one of the leading academic research centers of Japan.
Currently, Chiba University consists of nine faculties, the university library, the university
hospital and other educational and research facilities. With 11,179 students in the
undergraduate program, it has long been one of the largest universities in Japan. As for
the graduate school, there are about 2,354 students in ten master's programs and 1,220
in nine doctoral programs [1].
Page | 7
3.2 Location of workplace in the campus
This is the place where I worked in. Inside the campus of Chiba University, Nishi-Chiba,
the science and technology division building no.1
The Tamura’s laboratory facilities are located in the 5th and 7th storey of this building.
Location: Science and Technology Building No.1 (自然 -1) [2]
Page | 8
3.3 Tamura’s Laboratory Introduction
In Tamura’s laboratory, we research mainly on assistive technologies and devices
related to life maintenance and improving Quality Of Life (QOL)[3].
Some of the topics investigated in the lab include:
Design and development of wearable electronic devices for healthcare related
applications
Devices for measurement of exercise and metabolic energy consumption.
Development of airbag systems for prevention of falls.
Diagnostic techniques using electric, magnetic and heat flow systems.
Development of nursing and rehabilitation systems including an amusement
factor.
Here are some of the researches and developments being carried out in the lab:
Wearable Motion Analysis System:
Quantitative evaluation of the body movements is believed to
greatly contribute to the efficiency of rehabilitation training,
preventing care for self-reliance life and to evaluate the risk of
falling. Therefore, a small and easy-to-use system for
quantitative evaluation of movements such as standing up and
walking is developed.
Wireless Sensor Network:
In order to manage the healthcare inside the home, the
development of a wireless network system which is easy to
install and configure by using small and wireless terminals.
Using this wireless sensor network is possible to monitoring
the body activity among other variables.
Page | 9
3.4 Facilities in Tamura’s laboratory
3.4.1 Experimental room
This room is dedicated for experiments and measurement purposes. Overviews of the
equipment are:
Running treadmill
3D movement sensors based on magnetic technology
EMG sensors
Force platforms
Pressure sensors
Metabolic measurement systems
3.4.2 Hardware development room
This room has machines and electronic devices for development of prototypes.
Overviews of the machines and equipment are:
MITS PCB maker machine
MDX-40 Automatic milling machine for fast prototyping and 3D designs
Manual milling machine
Bench drill
Circular saw
Microscope
Function generators
Oscilloscopes
Power supplies
Multi-Meters
Temperature controlled soldering stations
Electronic consumables (resistors, condensers, wires, weld, LEDs, breadboards,
screws, nuts, etc)
Page | 10
3.5 Staff directory
Professor
Toshiyo Tamura
Secretary
Asami Tsuruhama
Assistant Professor
Masaki Sekine
Students
PhD:
Yuka Maeda (3rd year)
Nor Aini Zakaria (1st year)
Rigobetro Martinez Méndez
Master programme:
Yasuaki Obara
Shun Kokubo
Yu Takachiho
Tayayuki Numata
Masataka Matsumoto
Yuki Suda
Soichiro Maeno
Undergraduate:
Mari Hayashi
Page | 11
4. Abstract
Activities of daily living are important for assessing changes in physical and behavioral
profiles of the general population over time, particularly for the elderly and patients with
chronic diseases, such as arthritis and osteoporosis. Although accelerometers are widely
integrated with wearable sensors for activity classification, the positioning of the sensors
and the integration with wireless communication module still pose interesting research
challenges. This report presents the record of work and research acquired from
developing wearable sensor with accelerometers and wireless communication module.
Page | 12
5. Project introduction
5. 1 Description
Nowadays, it is very important for wireless devices to be small, light and have low power
consumption. Furthermore, it is especially important for wireless devices related to
ubiquitous monitoring, such as gait monitoring, smart house sensor and many more.
In order to assess the physical and behavioral profiles of the general aging population
particularly the elderly, accelerometer sensor is chosen to diagnose the chronic diseases
present or to assist in diagnosis of other abnormal anatomy structure.
The accelerometer is integrated with a Gyroscope and also wireless communication
module more easily displaying, processing and storing of data signal.
Four types of technologies are mainly available and considered for the wireless
communication:
Technology Signal rate Frequency
band
Computational
cost
Max
Range
Cost
WiFi 54 Mbps 2.4GHz; 5GHz High 100 m High
Bluetooth 3 MBps 2.4 GHz Medium 100 m Medium
Zigbee 250 Kbps 2.4 GHz Medium 100 m Medium
Radio frequency (RF) 1Mbps 2.4 GHz low 100 m Medium
Comparing the four types of wireless communication technologies, radio frequency is a
more viable choice as its power consumption is relatively low compared to the other
three wireless communication technology. Modules with chip antenna included are
available for purchase directly.
Page | 13
The Micro-Miniature 2.4GHz Transceiver – uMiRF module using the nRF2401a device is
designed for ultra low power wireless communication device. It has the advantages over
the other wireless communication devices based on its price and computational power
consumption. Furthermore, it can act as and transmitter and receiver which is very
convenient for swapping its function whenever needed.
Page | 14
5. 2 Objective
To develop an accelerometer sensor capable of transmitting, receiving, storing and
displaying of data coming from RF wireless signals using the nRF2401 modules. It will
be able to operate at the maximum rate possible from the maximum number of devices
allowed.
5. 3 Specifications
1. Design an accelerometer sensor
2. Design a ultra low power wireless network
3. Design a transmitter which will transmit RF signal to the receiver
4. Design a receiver that will receive the RF signal and communicate with a
computer through a micro-controller
5. Able to set instruction to the devices through the micro-controller
6. Design a micro-processor for overall control
Page | 15
5. 4 Visualization of final product
There will be an accelerometer sensor device which will be attached to the patient for
measurement and there will be a transceiver transmitting the measurement data
wirelessly to the receiver. Following that, the host computer will receive the data signal
through the receiver node with the aid of a micro-controller. To aid hospital staffs in
logging and storing of data easily.
Page | 16
6. Project planning
6.1 Work Breakdown Structure (WBS)
Resources Requirements Comments
1 Project Planning and preparation
1.1 Understand the Micro-MIRF
module, using nRF2401
Internet, reference books Online Research
1.2 Project proposal Microsoft Office
1.3 Purchase components
2 Hardware Design & Implementations
2.1
Design/implement of
Accelerometer & Gyroscope
LSM303DLH + L3G4200D
3-axis accelerometer
and 3-axis
magnetometer
2.2 Design/implement of Micro-
controller
dsPIC30F3013
2.3 Design/implement of
Transmitter
1. nRF2401a
2. Microsoft Visual Studio
Wireless with Chip
Antenna under
nRF2401a
2.4 Design/implement of receiver
with micro-controller
1. nRF2401a
2. dsPIC30F3013
3. Eagle 5.10.0
Wireless with Chip
Antenna under
nRF2401a + micro-P
2.5 User Interface – Computer
serial communication
Microsoft Visual Studio / Visual
Basic
Build with C#
2.6 Integration of all components Eagle 5.10.0 Finalize product
3 Software implementation
3.1 Programming of micro-
controller and wireless receptor
Microsoft Visual
Studio / Code
Composer Studio
3.2
Troubleshoot the program
Microsoft Visual
Studio / Code
Composer Studio
Page | 17
6.2 Responsibility Assignment Matrix (RAM)
This table shows the responsibility assignment matrix which depicts the role of my
teammate ZiChuan and I on how are we going to approach on the project.
Primary : P
Supporting: S
No. Tasks WangAn ZiChuan
1 Project Planning and preparation
1.1 Understand the Micro-MIRF module, using nRF2401 P P
1.2 Project proposal P S
1.3 Purchasing of components S P
2 Hardware design and implementation
2.1 Design/implement of Accelerometer & Gyroscope S P
2.2 Design/implement of Micro-controller P S
2.3 Design/implement of Transmitter P S
2.4 Design/implement of receiver with micro-controller S P
2.5 User Interface – Computer serial communication P S
2.6 Integration of all components S P
3 Software implementation
3.1 Programming of wireless receptor P P
3.2 Programming of micro-controller P P
3.3 Troubleshoot the program P P
Page | 18
6.3 Precedence list
The following table is precedence list which shows the approximate draft of time that we
are going to use for each part of the project.
Task
code Work Product Description Prerequisite Duration(day)
1 Project Preparation
1.1 Understand the Micro-MIRF module, using
nRF2401 - 12
1.2 Project proposal After 1.1 2
1.3 Purchasing of components After 1.2 60
2 Hardware Design and implementation
2.1 Design/implement of Accelerometer After 1.2 14
2.2 Design/implement of Micro-controller After 2.1 7
2.3 Design/implement of Transmitter After 2.2 14
2.4 Design/implement of receiver with micro-
controller After 2.3 5
2.5 User Interface – Computer serial
communication After 2.4 7
2.6 Integration of all components After 2.5 7
3 Software Design and Implementation
3.1 Study of Micro-p dsPIC30F3013 After 2.2 5
3.2 Programming dsPIC30F3013 After 3.1 3
3.3 Testing and troubleshooting After 3.2 1
4 Implementation of Accelerometer
4.1 Calculation & Measurement of the capacitor
and resistor value After 1.2 3
4.2 Draft-up for accelerometer After 4.1 3
Page | 19
4.3 Breadboard testing of accelerometer After 4.2 1
4.4 New improve design of accelerometer After 4.3 2
4.5 Breadboard testing of improved
accelerometer After 4.4 1
4.6 Troubleshooting After 4.5 2
4.7 Design of schematic and PCB After 4.6 3
5 Implementation of Micro-controller
5.1 Circuit design After 2.2 3
5.2 Calculation of resistor and capacitor value
values to use After 5.1 3
5.3 Implementation of Micro-p After 5.2 3
5.4 Testing and troubleshooting After 5.3 5
5.5 Design of schematic and PCB After 5.4 3
6 Implementation of Transmitter & Receiver
6.1 Circuit design After 2.3 3
6.2 Breadboard testing After 6.1 3
6.3 Testing with overall integrated circuit After 6.2 3
6.4 Troubleshoot After 6.3 4
7 Design of overall schematic and PCB
8 Overall Troubleshoot After 6.4 4
9 Overall Integration After 7 4
10 Final Review
10.1 Final report After 9 -
10.2 Final Presentation preparation After 9 -
Page | 20
6.4
Sch
ed
ule
Ch
art
Page | 21
6.5 System Block Diagram
Page | 22
7. Job specification and Details
I have to learn, do research and understand the purpose, specification and operation of
the project. I am also required to apply what I have learnt during the time in school and
also what my supervisor and colleagues taught me. In order to develop the equipment
that is required of me. This project is a team project which consists of my teammate
ZiChuan and me. Thus, I need to work efficiently and effectively as a team player
together with him to work towards completion of this project.
This is the office where I will be
working in everyday. The board
shows the attendance of who is
present on that day and who is
out of school (not present).
Page | 23
This is in the office where there are computers and reference books on the bookshelf for
us to refer. As most of the text and books are in Japanese, so I cannot really use much
of them except to scan through for relevant information or pictures that I need.
Page | 24
My personal desk and
desktop computer which I
am being provided with.
Me sitting in front of my
computer typing report
Page | 25
8. Projects
8.1 Laboratory and equipments
The hardware development room
This is where I will be developing
the hardware of the project in. It has
a lot of equipments which I will be
going into at the next part of this
report.
This is the Laboratory where the
running thread-mill, robots and
hospital bed are located. This
room is for the purpose of
experiment which requires the
feature of these machines.
Page | 26
8.2 MITS PCB maker machine
8.2.1 Introduction to MITS PCB maker machine
This is the MITS PCB make machine that is available in Tamura’s laboratory for us to
use. As the method of fabricating PCB here is totally different from what I have done
back in NP, I had to acquire this new skill in order to make PCB here.
Initially, I thought that by using the user manual, it will guide me on how to operate the
PCB fabricating machine. However, things were not going as smoothly as I planned. I
encountered several obstacles like the complexity of the operation of the machine, and
also having to read the user manual in Japanese with limited screen shots and photo to
guide me along. It took me quite awhile exploring the machine before I decided to seek
help from my supervisor Rigo.
Page | 27
8.2.2 Problem encountered with the PCB maker machine
Photo of the user manual which are all in Japanese language
While having the guidance from Rigo, I know that I have to make some notes of the
instruction on how to operate the PCB maker so that in the future when he is not around,
I can still follow the instructions to operate the PCB maker myself. Thus, I have made
some personal notes on the usage of the PCB maker machine.
User manual that I wrote myself
Page | 28
8.2.3 How to operate the PCB maker machine
Step 1
This is the start-up screen of the program when first enter into Flash for windows
application.
This is the program that I will be
using to control the MITS PCB
maker machine. As this
program has cease to operate
from 2005 onwards by MITS,
thus the resources online for
this program is scarce, so I
cannot really find information or
its user manual online
Page | 29
Step 2
This option from the top right hand corner switches the mode between CONVERTER
and CAM-Circuit2.
CONVERTER is the mode whereby the files are being imported from PCB design
software. The files from the PCB design software are being “converted” for the use of
this program.
CAM-Circuit2 mode is whereby it controls the PCB maker machine in real-time, thus
fabricating the PCB in the process.
Page | 30
Step 3
After importing and converting the files from eagle designer into flash for windows, the
PCB looks like the picture shown below
After being converted, this file is ready to be fabricated into a PCB. We can then switch
the mode from CONVERTER to CAM-Circuit2 mode at the top right hand corner for the
fabrication process.
Page | 31
Step 4
Inside the CAM-Circuit2 mode, the program is communicating real-time with the MITS
PCB maker machine.
Next, we need to click the drill-like icon to key in the setting that we want.
After clicking the button, a pop-up will occur:
I have added four of the several
options which I am going to use
in this PCB assignment.
The first 2 options that I chose
are for drilling holes.
The third option is for the
connection lines (copper track)
And finally the last one is for the
cutting of the dimension of the
board.
Page | 32
Step 5
After selecting OK from the previous step, we will come to this interface:
After setting all the parameters, the configurations are fixed and the machine will
fabricate the PCB automatically.
The Graphic User Interface
(GUI) control for the PCB maker
machine, it can control the
movement and action of the drill
bit of the machine.
Page | 33
Step 6
This is the final step whereby the drill bit needs to be change after each of the required
task has been done.
This is for cutting of the copper
track to make connection lines.
Both of this drill bits are for
drilling of hole. 0.5mm and 2mm
hole respectively.
For cutting out the dimension of
the PCB
Page | 34
8.5.1 Component amendments pg47
The overall system for PCB
fabrication
This is the first batch of PCBs
that I have done using this MITS
PCB maker machine.
Consist of the Micro-Controller,
Accelerometer and Gyroscope
Page | 35
8.3 Reflow soldering oven
8.3.1 Introduction to reflow soldering oven
A reflow oven is a machine used primarily for reflow soldering of surface mount
electronic components to printed circuit boards (PCB) [4].
As I am not familiar on how to operate the oven, thus I seek help from my colleagues
and Rigo.
The oven that I will be using to
solder the surface mounts
components onto the PCB
The oven is heating up with
the thermo-resistor picking up
the temperature and reflecting
it on the external display
The micro-controller controlled
circuit, to time the oven and
display the current temperature
Page | 36
8.3.2 Different operating mode
The four main operating modes of the reflow soldering
oven
Page | 37
8.4 Oscilloscope (probe calibration)
By pressing the probe check
button, it will shows whether the
probe is calibrated or un-calibrated
by showing a square wave
This shows that the probe is un-
calibrated as the square wave is
distorted
This photo showing me calibrating
the probe with a screw-driver by
fine tuning its capacitance
After fine tuning it, it will be a
well calibrated probe with
accurate measuring capability
Page | 38
8.5 Project preparation
8.5.1 Components overview
The list below is a summary of the hardware components that I used in this project.
Components Company Model
Gyroscope STMicroelectronics L3G4200D
Accelerometer STMicroelectronics LSM303DLH
Step-up regulator (1.5V – 3.3V)
STMicroelectronics L6920DB
Micro-Controller Microchip dsPIC30F3013
Wireless module Nordic Semiconductor nRF2401a
RS232-USB logic shifter FTDI chip FT232R
Development Kit Microchip MPLAB ICD 3
Page | 39
8.5.2 Step up regulator (power supply)
As we needed 3.3v as the main supply for the micro-controller, sensors and the wireless
modules, we needed to implement a step-up regulator from 1.5V which is the L6920DB
regulator.
8.8.1 Step-up regulator waveform pg 70
The L6920DB consists of fixed-
positive-output, low dropout
regulators with an output current
of 500 mA (max). In response to
the need for low voltage
devices, the series offers
devices with low output voltages
of 3.3V.
It comes with the MSOP8
Package which will be suitable
in minimizing PCB size.
1.5V
3.3V
Page | 40
8.5.3 dsPIC30F3013 connections
After spending vast amount of time and effort to figure out the connections of the micro-
controller, I manage to patch up the connection on the breadboard and ready to test it
with some software code to see if it is working.
As the micro-controller has already been patched up, I needed to program the micro-
controller using a computer through a development kit known as MPLAB ICD 3.
8.6.2 Crystal oscillation (Waveform) pg72
8.4.5 Blinking of LED by manipulating dsPIC30F3013 pg45
Patching up of the micro-controller
with the DIP packaged component
Page | 41
8.5.4 Soldering of modular cable for MPLAB ICD 3
As I will be using breadboard for testing purposes, I cannot directly use the modular
cable to connect to the micro-controller chip and then to this development kit.
Below shows the modular cable with the modular connector head which we will not be
using:
MPLAB® ICD 3 In-Circuit Debugger
System is Microchip's most cost effective
high-speed hardware
debugger/programmer for Microchip
Flash Digital Signal Controller (DSC) and
microcontroller (MCU) devices. It debugs
and programs PIC® Flash
microcontrollers and dsPIC® DSCs with
the powerful, yet easy-to-use graphical
user interface of MPLAB Integrated
Development Environment (IDE).
Page | 42
Thus, I needed to make my own modular connector with the wires so that I will be able to
connect my breadboard connection to the development kit (MPLAB ICD 3).
After tedious troubleshooting and lots of effort put in, I managed to finish the modular
cable and make it usable with the breadboard.
Page | 43
8.5.5 MPLAB Integrated Development Environment (IDE)
I then started to test the micro-controller through the program MPLAB Integrated
Development Environment (IDE). I started by trying to control some LED and learning on
how the micro-controller operates.
Screen shot of the MPLAB IDE
Page | 44
8.5.6 Blinking of LED by manipulating dsPIC30F3013
This program that I had developed which uses the while loop to loop infinity. So I keep
making the LED on and off and an interval of 100ms (making the LED blinks).
//Program to flashing a LED connected in the PB0.
//Xtal speed 20MHz in pin (6-7).
#include <30F3013.h>
#FUSES HS2_PLL8
//The xtal freq is divided by 2 and multiplied by 8 (maximum using 20MHz xtal)
#FUSES NOWDT // NO Watch Dog Timer
#FUSES PR_PLL //Primary Oscillator
#FUSES NOCKSFSM
//Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOWRT //Program memory not write protected
#use delay(clock=80000000)// 20MHz/2*8=80MHz=80000000
void main() {
while(1){ // Loop forever
output_high(PIN_B0); // LED B0 High
delay_ms(100);
output_low(PIN_B0); // LED B0 Low
delay_ms(100);
} //end while
} //end main
Page | 45
The micro-controller
dsPIC30F3013 driving
the LED to blink which
is generated by the
code above
Blinking at 1 sec interval
Page | 46
8.6 Project Implementation (Hardware)
8.6.1 Component amendments
After getting familiarize with the equipments needed to fabricate and solder the PCB and
components together, the next step is to start implementing the micro-controller together
with the Gyroscope.
During the period of week three, I have done the PCB of gyroscope and accelerometer
which looks like this.
However, after consultation with my colleague, I learnt that there may be some problem
as the isolation for the connection lines is not enough and which may cause serious
problem when in use. Therefore I need to re-do the PCB for the components.
Previously we made each of the individual pin connected to a header pin so that it can
be easily tested on a breadboard; however, we feel that it will make the PCB bigger.
Thus we decided to rout the connection on the PCB and connect the remainder
necessary pin to the header pin. Below shows the comparison for past Gyroscope
routing and newer updated Gyroscope routing.
Completed Gyroscope
and Accelorometer
Page | 47
Gyroscope modification
Schematic of the first attempt
Modifications and improvements
made
The numbers of
Pins are greatly
reduced after the
modifications:
From 16 pins to
just mere 8 pins
needed!
Page | 48
Finally, the board was reduced from 30mm X 25mm to 17mm X 17mm which is a great
improvement! Plus with lesser number of pins, which made the connections and at the
later part troubleshooting, easier!
Instead of routing all
the individual pins
to header pin, I
made internal
connections on
PCB and minimize
the pinout at the
same time
minimizing the size
of the board too.
Connections as shown above at
the schematic
Page | 49
The completed gyroscope board
size is smaller as compare to
the previous design and also
the connection lines are fully
isolated without the risk of
shorting occurrences.
Page | 50
Accelerometer modification
Schematic of the first attempt
Modifications and improvements
made
The numbers of
Pins are greatly
reduced after the
modifications.
Page | 51
After the modifications, the board was reduced from 31mm X 40mm to 22mm X 22mm!
New improved
routings are made
Page | 52
The completed accelerometer
board size is smaller as
compare to the previous design
and also the connection lines
are fully isolated without the risk
of shorting occurrences.
Page | 53
8.6.2 Bread-boarding Sensors board
Page | 54
8.6.3 Bread-boarding Receiver board
Page | 55
8.7 Project Implementation (Software)
8.7.1 Serial communication (GUI)
8.7.1.1 Control panel v1.0
By using C# WPF as our core language, we developed this control panel.
This version basically sends command through to the sensor side by the computer serial
communication interface and receives back the data then print it to the textbox.
Page | 56
8.7.1.2 Control panel v2.0
For this version 2.0, I edited the button features and added in more of them. There is
also an added changing of sensitivity function. At the same time, I removed the receive
text box as I wanted to use the function from Tera term (another serial logging program)
because the feature suits this project more than the receive function from the version 1.0.
Additionally, the delay from this transmission to the sensor had improve dramatically
after this update and lots of other unhandled exceptions which causes the program to
crash had also been solved.
Page | 57
Overview of Control panel v2.0
Version button: To check the last software version and to check for
hardware acknowledgement (hardware test)
Start button: To start the sensor and start receiving incoming data of the axis.
Stop button: Stop the sensor
About button: Credits
Logger button: Start up the serial communication logger program (Tera term)
Reset button: Stop all the sensor activities and reset all parameters and settings to
default
Connecting the COM
Port of the sensor
Tera Term: A Program
that receives or transmits
data then display it from
the serial port
Page | 58
Demo of Control panel v2.0
The tera term pop out and after connecting it to the COM port that my receiver side is
connected to, I can use my control panel to control my sensor.
After clicking the
logger button,
Tera term pop
out and we will
use it as a logger
for our project
Page | 59
Start & Stop button
After logging the file and saving it into a directory, I can then use excel to open it and plot
it by graph and to further analyze it.
After triggering my
sensor to start
transmitting data,
the digital data can
then be logged by
Tera term
Page | 60
Page | 61
8.7.1.3 Control panel v3.0
Basically, I added in the feature of the receive box, so that I do not have to use another
program such as the Tera term to receive the data. I have also integrated the save
feature which works the same as the Tera term logging function but it works faster than
Tera term. Additionally, I removed the need to select COM port, as it will automatically
connect to the COM port my sensors are connected to.
The logger button had also been substituted with a graph button, as I will be doing live
graph plotting from the serial port next week, where the program will be plot the axis in
real-time.
Page | 62
Overview of Control panel v3.0
Changes
1) Automatic connection to the
sensor COM port.
2) Independent program
without the need for external
program (Tera term)
3) Save feature with auto
naming function
4) Able to clear data in a click
Page | 63
Save feature
The name will automatically be saved as the sensitivity mode, and time of the instance
when the save button is being clicked.
Page | 64
8.7.2 Live-graph (GUI)
After the completion of the serial communication control panel GUI, I started to research
on how to plot real-time graph for my sensors. I came upon a website which is called d3
dynamic data display.[8] I research more into it and finally able to make myself a real-time
graph to plot the axis.
The next section depicts the several changes that I have made for this GUI.
Page | 65
8.7.2.1 Live-graph v1.0
First version
The first test that I made only comprises of 3-axis. And it plots from a saved file from the
computer directory rather than from the serial-port. Thus, I need to make my program
save the data at intervals so that the graph will be able to continue to plot it. However it’s
not very viable.
Moreover this graph is not a rolling graph. Meaning all the previous plotted point will not
disappear for as long as this program is not closed.
Page | 66
8.7.2.2 Live-graph v2.0
Second version
The second version is a leap step. It has vast amount of improvements as compared to
the previous one. I have added another graph coupled with some interfaces.
This graph is able to plot the 6-axis data. However it plots from a saved file rather than
directly from the serial port as I need more time to research on how to plot directly from
incoming serial port data. I have also added checkbox so that the graph can be toggle to
start or stop. However that function is still under testing currently in this phase.
Page | 67
8.7.2.3 Live-graph v3.0
Third version
In this version, rolling feature was added to its interface. The starting of the graph will be
automatically pull out of the screen but not stuck at the front.
Page | 68
8.7.2.4 Live-graph v4.0
Fourth version
I have added colour scheme for this program. The checkbox is also working which can
be toggled to start or stop the graph from plotting.
Page | 69
8.7.2.5 Live-graph v5.0
Fifth version
In this version, I have integrated it with the main control panel. I have also edited the
toggle of graph function.
The program looks like this:
The button at the side can be use to toggle the graph, whether to trigger it to plot or not
to plot. This version also directly plots from incoming data from the serial port rather than
a saved file in the computer. The graph plotting is also being smoothened as compare to
the previous version whereby plotting of the points are very sharp and rigid.
Page | 70
Before
Stepping up
After
Stepping up
8.8 Project results
8.8.1 Step-up regulator waveform
The voltage waveform straight
from the power supply (battery)
The voltage waveform after the
step down regulator
Page | 71
8.8.2 Crystal oscillation waveform
The voltages at EXTAL and
XTAL are usually distorted sine waves approximately 180 degree out of phase.
These sine waves swing symmetrically around the
supply voltage/2. Below shows the waveforms of the crystal
XTAL IN and XTAL OUT.
XTAL IN
XTAL OUT
Page | 72
8.8.3 I2C communication between micro-p and Gyroscope (L3G4200D)
1 1 0 1 0 0 0 0 Start W
ACK
The I2C bus of the micro-controller
transmitting 0xD0 (1101 0000) which
is writing to the Gyroscope for
acknowledgement.
/*A section of code from appendices (Final code > Gyro + Acc +
nRF2401a)*/
//Pin Config, SA0=0 (Ground)
//Initialise Label and Configuration value
#define GYRO_ADDRW 0xD0 //Gyro address for I2C write
#define GYRO_ADDRR 0xD1 //Gyro address for I2C read
#define SC 0xE796 //Interrupt timer, interrupt at
every 10ms
#define BYTE_DATA0 6 //define BYTE_DATA0 = 6
#define LED_IR PIN_B7 //define LED_IR = PIN_B7
#define LED_POWER PIN_B6 //define LED_POWER = PIN_B6
SDA
SCL
Page | 73
8.8.4 I2C communication between micro-p and Accelerometer (LSM303DLH)
SDA
SCL
Start 0 0 1 1 0 0 0 0 W ACK
The I2C bus of the micro-controller
transmitting 0x30 (0011 0000) which
is writing to the Accelerometer for
acknowledgement.
/*A section of code from appendices (Final code > Gyro + Acc + nRF2401a)*/
//DEFINE--------------------
//Initialise Read and Write address for each Sensor
#define ACC_ADDRW 0x30 //LSM303DLH,ACC Slave Address (Write)
#define ACC_ADDRR 0x31 //LSM303DLH‚ACC Slave Address (Read)
Page | 74
8.8.5 nRF2401a Packets error rate test
For packet loss measurements, we program the device to send from a range of 100
packets to 1500 packets at a range of 5 meters. As 5 meters is the average room
distance, and normal diagnosis test happens mostly in room condition.
Additionally, we tested it base on 100, 500, 1000 and 1500 packets at different distances
ranging from 1 meter to 20 meters.
From this structured test, I can conclude that within the distance of up to 15 meters, the
nRF2401a can retain an accuracy of up to 90%. Thus, the nRF2401a is suitable for
working range of up to 15 meters.
And the results are shown on the graph below.
Page | 75
Test based on 5 meters range and different packets
Test based on different distance and packets
0
2
4
6
8
10
12
0 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600
Pack
et e
rro
r ra
te (
%)
Packets
PER (%)
0
2
4
6
8
10
12
14
16
0 5 10 15 20
PER
[%]
Distance (metre)
100 Packets
500 Packets
1000 Packets
2000 Packets
Page | 76
8.8.6 Overall performance of power usage
Choosing the right battery can determine the success or failure of a wireless sensor
networking project. Thus, in this project, we primarily use the Energizer
Alkaline/manganese LR03 AAA battery for our test. The benefits of this battery are high
voltage response, stable during most of the lifetime of the application and easy
integration into compact system as the cell is of AAA size.
Energizer LR03 AAA
Below is a table which shows the breakdown of current consumption of the components
in this project. By having the following parameters, I then went on to use the battery and
tested it practically on the circuit to test for its battery life.
Step-up regulator 100mA
Micro-controller 30mA
Gyroscope 6mA
Accelerometer 1mA
nRF2401a (wireless module) 13mA
TOTAL 150mA
Type ULTRA+ AAA
Manufacturer Energizer
Voltage 1.5V
Type IEC/USA LR03/AAA
Material Alkaline/manganese
Capacity 1230mAh
Shelf life 7 Year
Temperature Range
-18...+55 °C
Page | 77
Battery lifespan
The 4 tests above are conducted base on different output power mode of the nRf2401a.
The different output power mode will affect the signal penetration and strength. If the test
is to be conducted at a longer distance, then the higher output power should be chosen
for packets handling to be more reliable. However, if the test is base on very close
distance, then the lowest output power mode can be chosen to minimize the current
consumption and thus, maximizing the battery life.
Page | 78
8.8.7 Final Product
The final product comprises of the Accelerometer and Gyroscope sensors is integrated
into a case with the function of 6-axis motion sensing coupled with wireless module
nRF2401a with the capability to pick up 20 movements in 1 second (20Hz sampling rate).
It is powered by a single triple-A battery which provides long battery life and accurate
motion measurements.
Page | 79
8.8.8 System error
This is a deliberate test to show
that if there is connection
problem with the I2C wires
module, or the gyroscope is
malfunctioning, the result will be
shown on the output as shown
below.
If there is hardware error occurring from
the gyroscope, The L3G4200D_WAI
(Gyroscope Who Am I) acknowledgment
will fail.
Thus it will return a result of 255 (0xFF)
If everything is working smoothly, the
Gyroscope acknowledges it and will
return a value of 211 (0xD3).
Page | 80
8.8.9 Computation with Excel
Page | 81
This motion is to simulate a sudden trip or kick by the patient
Blue graph: Accelerometer
Green graph: Gyroscope
Page | 82
8.8.10 Computation with Live-graph (GUI)
After clicking the graph
button, the live graph
plotter will pop out
and directly plot from
the incoming data.
Page | 83
8.9 Conclusion
This internship has been an amazing learning experience for me. During the course of
this internship, not only have I been working solely on this project. I have met a lot of
different internationals from all over the world; I had the chance to have lots of cultural
exchange during the course.
Additionally, I am being provided with intensive Japanese language lesson. I had the
chance to learn a fourth conversational language, which will really aid me in any future
endeavors. Initially when I reach here, I could not even order the food which I want,
without knowing the language, ordering food seems to be an awful chore. This made me
realize that by learning more languages, it will really improve on my individual life skills
and broadening my experience and view of the world outside of Singapore, thus in the
process making me more hungry to learn new knowledge and skills.
This internship also requires a lot of self-discipline and motivation, because the working
ethic of Japanese is totally different from the working ethic of that in Singapore. I need to
be really early for work and goes back home late into the night. Although this criterion is
not mandatory, however it is the work ethics that better be abide by.
All in all, this internship has been an amazing learning experience for me while
encountering lots of difficulty and having to find means and ways to solve it. Through this
internship, I have gained more knowledge on the field and my skills in life which will
definitely aid me in my future endeavors.
Page | 84
9. Appendices Please refer to the disc attached.
Page | 85
10. References [1] http://www.chiba-u.ac.jp/e/about/history/index.html, About Chiba University, Brief History.
[2] http://www.chiba-u.ac.jp/e/about/campus/nishichiba/tour_nishichiba.html, http://www.chiba-u.ac.jp/e/about/campus/nishichiba/img/popup/3d_ph_nishichiba_43.jpg,
Nishi-Chiba Campus Tour, Science and Technology Building No.1 (自然 -1), Chiba University, 2011.
[3] http://www.tms.chiba-u.jp/~tamura/eng/index.html, Tamura Laboratory, Welcome to Tamura Laboratory, 2011.
[4] http://en.wikipedia.org/wiki/Reflow_oven, Reflow oven, From Wikipedia, the free encyclopedia, 2011.
[5] http://www.robot-electronics.co.uk/acatalog/I2C_Tutorial.html, I2C tutorial, From ROBOT electronics, 2011.
[6] http://www.societyofrobots.com/microcontroller_xtal.shtml, how to use crystals on your microcontroller, society of robot, 2011.
[7] http://www.sparkfun.com/products/152#, Transceiver nRF2401A with Chip Antenna, Sparkfun Electronics, 2011.
[8] http://dynamicdatadisplay.codeplex.com , Codeplex, open source community, 2011.