Project Supervisor - Aidglobal.net

fullfattruckMobile - Wireless

Dec 10, 2013 (3 years and 6 months ago)

119 views

National University of Computer and Emerging Sciences,

Peshawar Campus.


Degree Program
:
Bachelors of Electrical Engineering


Year of Submission
:

201
3






Group Members

Mujeeb ur Rehman

(09
-
6389
)

Haris Khan

(0
9
-
6328
)

Munawar Babar (09
-
6423
)



“MobiCardio
-

Implementation of a Portable Telecardiac System”


Project Supervisor

Ahmad Saeed Qazi


“This project is solely the work of the authors and is submitted in partial
fulfillment of the requirements of the Degree of Bachelors of

Electrical
Engineering
.”

ii


DECLARATION

It is to certify that no portion of the work presented has been submitted for
award of degree in this institution or elsewhere. Any material used in this
report has properly been acknowledged in the text and references

given.




Mujeeb ur Rehman (09
-
6389)






Haris Khan (09
-
6328
)




Munawar Babar (09
-
6423
)









iii


CERTIFICATE



Dated: ___________


Final Approval


It is certified that the project report
submitted by
Mujeeb ur Rehman, Haris Khan

and
Munawar Babar

for the partial fulfillment of the requirement of
“Bachelors Degree in
Electrical

Engineering”

is approved.


COMMITTEE



Head of Department
:






Signature:
____________________

Mr. Ahmad Saeed Qazi




Supervisor:







Signature:
____________________

Mr. Ahmad Saeed Qazi




Head Project Committee:

Signature:
____________________

Mr. Ahmad
Saeed Qazi












iv











Dedicated to

Almighty Allah,

Faculty for their help

And Our Parents for their support and care.











v


ACKNOWLEGEMENT


All praises for ALLAH All Mighty who enlightened us with the requisite knowledge
on portion of this subject enabling us to accomplish this extremely challenging
and gigantic task.


We could not have been successful in our endeavors without the providentia
l and
able supervision of our project
supervisor Mr. Ahmad Saeed Qazi
.

We are also very thankful to our colleague Taimoor Khan Mehmand for providing
us with his expertise and sincere help.

Our project was selected and funded by ICT, Gov. of Pakistan as one

on of the
best research project on bachelor’s level.

It will be prudent here to thank the staff and all my colleagues for their
motivation and assistance. Finally this work would not have seen the light of the
day had it not been for the humble and sincer
e prayers and wishes of our family,
friends and well wishers.












vi



ABSTRACT


This project gives specifications in the design and implementation of a low cost
wearable ECG system. A detailed explanation of the various modules of the
design and their implementations is provided. Each module was successfully
simulated and then impleme
nted.

The system design aims to provide solutions to the problems encountered in
acquiring signal from the body, as well as providing remote transmission, of ECG
data. A remote device is attached to the person being monitored. The remote
device acquires t
he raw ECG data from the Leads which are placed in predefined
areas of the body. The data is digitized through a PIC programmed as an ADC
UART device. The data is transmitted wirelessly using a Bluetooth technology
(Bluegiga device in our case) to an andro
id enabled cell phone which loads the
data through the GPRS technology to a website. The reconstruction of the
sampled digitized ECG is performed at the website side.

The access rights of the web site are with the hospital where the doctor can
monitor the

ECG of the patient at home.

The complete design is dissected into various modules which are discussed
individually.










vii



TABLE OF CONTENTS


Contents

CHAPTER 1
………
........................................................................................
...................................... 1

INTRODUCTION
.....
….
...................................................................................................................... 1

1.1 Project definition ......................................................................................................
......... 1

1.1.1 Project Survey .................................................................................................
......... 1

1.1.2 Project Objectives ....................................................................................................

2


1.2 Project Scope .....
......................
.............................................................
....................... 3

1.3 Project Limitations ...
.......
.
.................................................................................................. 4

1.4 Platforms Used .........................................................................
......................................... 4

1.5 Project life cycle ......................................................................................................
........... 5

CHAPTER 2
……….
..........................................................
................................................................... 6

LITERATURE REVIEW

.
........
.......
.....................................................................................................
6

2.1 ECG Hardware .............................
..................................................................................... 6

2.1.1 Heart activity .......
.....
.
................
............................................................................... 6

2.1.2 PQRS Sequence ..............
......
.....................
............................................................... 7

2.1.3 Three Lead ECG ....
.......
...................
..............
............................................................ 8

2.1.4 ECG Data Acquisition ......
...................
......................
................................................. 8

2.1.5 ECG Interference Sources ................
.....................
................................................... 9

2.2 Digitization of ECG signal (PIC

18f
452) ....................
.
....
..............
.................................... 11

2.2.1 Sampling Frequency ....................
.....................
...................................................... 12

2.2.2 Nyquist Requirement ................
.....................
........................................................ 12

2.2.3 Asynchronous Serial Communication and Data Framing ......
....
.
.................
........... 13

2.3 Bluegiga ..........
.
..................................
................
............................................................. 14

2.3.1 Bluetooth Communication ..............
.
...................
...
................................................ 15

2.3.2 Bluetooth Profile (v2.1+EDR) ...........
.
...
....
................
.............................................. 16

2.3.3 Advantage

....................
.......................................................................................... 17

2.4 Android ..............
.
...........................
....
............
................................................................. 17

2.4.1 Important Android Components...
.
...........
.....................
......................................... 18

2.4.3 Activities and Layouts ..........
.
...................
....................
.......................................... 19

2.4.4 Activities and Lifecycle ...........
.
................
....................
........................................... 20

2.5 Web Designing .......
.
..................
................
..
.................................................................... 21

2.5.1 Xampp .......................................
.....................
........................................................ 21

2.5.2 Notepad ++ .................................
......
.....................
................................................ 25

2.5.3 DreamWeaver
….
...................................
...................
.............................................. 25

2.5.4 Html

.......
.........
..
.............................
.....................
.................................................... 26

2.5.5 PHP
..................
.
....................................
....................
.............................................. 27

2.5.6 CSS ...
..............
..
....................
.........................
.......................................................... 28


viii


2.5.7 Webhosting .........
.
........................
....................
...................................................... 29


C
hapter 3
.............
.........
..................................................
................
.............................................. 31

DESIGN AND DEVELOPEMENT

........
.......
..................
...............
.....................................
................ 31

3.1 ECG Hardware ...........................................
.................
..................................................... 31

3.1.1 ECG Measurement ................
....................
...
.
......................................
................... 31

3.1.2 ECG Frequency Bandwidth............
................
.
...........
.............................................. 31

3.1.3 ECG Front End ................................
...............
.
.....
................................................... 32

3.1.3.1 Instrumentation Amplifier ....
.
.....................
.
.......................................... 33

3.1.3.2 Filtering Stage .......
..
.................
..........
................................
.................... 35

3.1.3.3 Right Leg Driver
..
.........................
.....
...................................................... 35

3.2 Digitization of ECG (
PIC 18F452) ...............
...................................................................... 35

3.2.1 Setting the Clock Frequency ............
...
.........................
...................
........................ 36

3.2.2 ADC Module

..................................
.
.....
..
...................
.............................................. 38

3.2.3 PIC18F452 ADC Fe
atures

...............
.
......................
......................
............................ 39

3.2.4 UART Module of The PIC 18F452 ....
.
.......................
.........
....................
.................. 40

3.2.5 Baud Rate Settings

............................
.
...
.....................
............................................ 41

3.3 Bluegiga ....
.
...........................................................
......
................
.................................... 42

3.3.1 Applications

...............
..
.................................
.....................
..................................... 43

3.3.2 IWRAP .........................
.
.......................
.....
....................
.......................................... 44

3.3.3 iWRAP Modes ..............
.
.......................................
....................
.............................. 45

3.3.3.1 Command Mode ....
.
..........................
.....
...................
............................. 46

3.3.3.2 Data Mode ..............
.
..............................
............
.................................... 46

3.3.3.3 Multiplexing Mode .......
.
........................................
...........
...
................... 47

3.3.4 Interfacing ............................
....................
............................................................. 48

3.3.5 UART Module ......................
..
.
.............
................................................................... 48

3.3.6 RISC Processor .......................
.
.........
....................
................................................... 50

3.3.7 Bluetooth Profiles .............................
........
.....................
........................................ 50

3.3.8 Serial Port Profile ..................
.
...................
....................
......................................... 51

3.3.9 ASCII Commands To Control Iwrap

⸮⸮⸮⸮⸮⸮⸮⸮.⸮.⸮⸮⸮⸮⸮⸮⸮⸮.⸮
⸮⸮.⸮⸮⸮.⸮⸮⸮..
⸮⸮.⸮⸮⸠.2

3⸳⸱0⁆楲m睡w攠啰g牡re‮⸮⸮⸮⸮⸮.⸮⸮⸮.⸮⸮.
.
.⸮⸮⸮.⸮⸮⸮..
⸮⸮.⸮⸮⸮⸮⸮⸮⸮.
⸮⸮⸮⸮.⸮⸮⸮.⸮⸮⸮.⸮⸮⸮⸮⸮⸠.3

3⸳⸱1⁆楲m睡w攠啰T慴攠睩瑨⁓敲楡汄䙕‮⸮
.
⸮⸮⸮⸮⸮.⸮⸮.
⸮.⸮⸮⸮⸮
⸮⸮⸮⸮.⸮⸮⸮.⸮⸮.
⸮⸮⸮⸮.⸮⸮⸮⸮⸮⸮‵4

3⸳⸱2⁂ ⁔敲m

⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮
.⸮⸮.

⸮⸮⸮.⸮⸮⸮.
⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮.⸮⸮⸮.⸮⸮⸮.⸮⸮⸮.⸮⸮⸮⸮⸮⸠.7

3⸳⸱2⸱⁓䕔⁅v敮瑳

嬵[

⸮⸮⸮⸮⸮.
⸮⸮.⸮⸮
.
⸮⸮⸮⸮.⸮⸮⸮.⸮⸮⸮
.⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮.⸮⸮⸮.⸮⸮⸮.⸮⸮⸮‵7

3.4 Android ........................................................................
.................
.................................. 68

3.4.1 Creating Java Project In Eclipse .....................
.......
............
.................................... 68

3.4.2 Create Java Class .......................................
....................
....................................... 70

3.4.3 Adding External Library (.jar ) to the Java Classpath ................
.....................
........ 72

3.5 Web Designing ..................................................
..................
............................................. 72

3.5.1 Website Architecture ..........
....
........................
................
.....
................................. 72

3.5.2 Designing Web Layout
.............
.....
........
....
............................
................................. 73


ix


3.5.3 Webhosting ...............................
.....
.............
...............
..............
............................. 74


CHAPTER 4

.................
.......
..............................................
.................
............................................ 76

PROJECT ANALYSIS AND EVALUATION
…….
...............................................
...............
................... 76

4.1 ECG hardware .
...................................
....................
.
........................................................ 76

4.1.1 Buffer Stage And Differential

Amplifier ......
.
..................
....................
.................... 76

4.1.2 Low Pass Filter.........................
..................
.
...
.......................................................... 77

4.1.3 Right Leg Driver .....................
...........
..........
.
..........
................................................. 78

4.2 Digitization of ECG (PIC 18f4
52) ...........................
..............................
.................
............ 78

4.2.1 Programming the ADC module .........
...................
....
.............
.................
................ 78

4.2.2 Steps In Programming The A/D Converter.......
...
.........
...................
........................ 83

4.2.3 UART module programming .................................
........
..............
............................ 84

4.2.3.1 TXSTA (Transmi
t Status and Control register) ...............
.
.........
............... 84

4.2.3.2 TXIF ...........................
.
...........................
...........
................................
....... 85

4.2.3.3 Steps In Programming The UART Module

⸮⸮⸮⸮⸮⸮⸮⸮⸮.
⸮⸮⸮⸮⸮..
⸮⸮⸮⸮⸮⸮‸6

4⸲⸴⁍䥋剏䌠Prog牡rm楮g‮⸮⸮⸮⸮⸮.
.
⸮⸮.⸮⸮⸮.⸮⸮⸮.⸮⸮⸮
.⸮⸮⸮⸮⸮⸮⸮⸮⸮.
⸮⸮⸮.⸮⸮⸮.⸮⸮⸮.⸮⸮⸮⸮⸮⸮‸6

4⸲⸴.1⁓ 数猠⸮e⸮.
⸮⸮⸮⸮⸮
.
⸮⸮.
.
⸮⸮⸮⸮.⸮⸮⸮.⸮⸮⸮.⸮⸮⸮.⸮⸮⸮.⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮.⸮⸮⸮.⸮⸮⸮.⸮⸮⸮.86

4⸲⸴⁐rot敵猠卩浵污瑩tn‮⸮⸮⸮
⸮⸮.
.
⸮⸮⸮.⸮⸮⸮.⸮
⸮⸮.⸮⸮⸮.⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮.⸮⸮⸮.⸮⸮⸮.⸮⸮⸮.⸮⸮⸮⸮⸮⸮‸8

4.3 Bluegiga
.........................
....
.
............
................................................................................ 89

4.3.1 Commands to Bluegiga ..........................
....................
........................................... 89

4.3.2 Cr
eate a Text File and Pu
t the Data in It and Transfer To Remote Device
.
...........
. 96

4.3.3 Master
-

Slave Connection .
..............
......
.....
...............
............................................. 97

4.3.3.1 SPP Master

.........................
..
..........
...........
............................................. 97

4.3.
3.2. Choice of Master and Slave

...
..
...................................
..................
......... 99

4.3.3.3 SPP Slave

.......................
..........
..
.
.......................
................................... 101

4.4 ANDROID ......
...............................
.....................
..................
............................................103

4.4.1 Thread .........
................
.
....
..................................
.................................................. 104

4.4.2
Advantages over Multiprocessing

.........
.
.
......................
....................................... 105

4.4.2.1 Extending Thread Class ......
.
.......................
.......................
....
............... 106

4.4.3 Life Cycle of Activity

...........................
..
..
..................
............................................ 106

4.4.4 Description of Classes

.............
..............
..
......
.......................................
................ 108

4.4.4.1 Telecardio Class
...
...........................
..............
...................
..................... 108

4.4.4.2 BluetoothService

..........
..........................
......
...............
......................... 109

4.4.4.3 Threads Cr
eated in BluetoothService Class ....
.
.............
........................ 110

4.4.5 Handler

.................................
..............................
..........
..
...................................... 111

4.5 Web Designing .
......
.............
......
................................................................................... 113

REFERENCES

......
.......
..............................................
................
....................................................116

APPEN
DIX A
................
.......
...............................
..................
.........................................................118

Codes
.

...
..
.............
.......
.
.................
.......................
..................
..........................
...............118

PIC 18F452 ....
..........
.........................
.........
.......................
...............................................119

WEBSITE END CODING. ...
..........
......
.........
..
........................
.............................................120


x


JAVA AN
DROID ...............
........
........
..........
.....
................
..................................................129

APPENDIX B

.........
.......
.......................................................
.................
........................................158

USER MANUAL
........
.
.
.....
...................................................
.................
.........................................158



xi



LIST OF FIGURES


Figure
…..............…………………………………………………………………………………………………….
Page Number

1
-
1: Life cycle of project ......................
......
..................................................................
................... 3


2
-
1: Normal heart activity .................
.......
....................................................................
.................. 4


2
-
2: Sampling and quantization ...
.......
.............
.
.....................................
....................
.................... 7


2
-
3: Xampp

..............
......
..............................
.
............................................................
................. 1
3

3
-
1: Three Operational Amplifier Differential Amplifier
..............................................
................. 19


3
-
2: PIC 18f452 .....................................................................
..
...
.....
....................
.......................... 21

3
-
3: Crystal

Oscillator circuit
...................................................
......
.............................................. 22

3
-
4: UART working flow .............................................................
.....
.............................................
24


3
-
5: BLU
EGIGA ..........................................................................
.......
............................................
25


3
-
6: Bluetooth module with iWrap firmware ………………………………....……………………………………….
26

3
-
7 Mode transition in Bluegiga ..........
............................................
......
.......................................
27


3
-
8 : WRAP THOR Bluetooth module ................................................
......
......................................
29


3
-
9: SPP connection between two
systems ........................................
.....
.....................................
31


3
-
10
: BG term Layout ........................................................................
........
...................................
32


3
-
11
: Creating a new

project ................................................................
.......
.................................
38


3
-
12
: Creating new java class ...............................
......................................
.................................
39


3
-
13
: Executing file ............................................................................
........
...................................
40

4
-
1: ECG sensor circuit diagram .........................................................
.......
...................................
42


4
-
2: Low pass filter response ..............................................................
.......
...................................
43


4
-
3: Low pass filter circuit diagram ........................................
.............
......
...................................
43


4
-
4 : Right leg driver ..............................................................................
......
.................................
44


4
-
5: Compiled code in mikroC .......................
........................................
......
.................................
50


4
-
6: UART ADC module code ..................................................................
.......
...............................
50


4
-
7: Proteus simulation of parallel A
DC ..................................................
......
...............................
51


4
-
8: Proteus UART simulation ...................................................................
.......
............................
51


4
-
9: Bluegiga ready
prompt .........................................................................
......
..........................
52


4
-
10: Commands given to Bluegiga .............................................................
......
..........................
52


4
-
11 : S
DP profiles for Motorola ....................................................................
......
.........................
53


4
-
12 : SDP profiles for Samsung ....................................................................
......
.....................
....
54


4
-
13 : AUTO call response of BLUEGIGA .........................................................
......
........................
55


4
-
14 : Connection established in BLUEGIGA ....................................................
......
.......................
56


4
-
15

: Master commands in BLUEGIGA ......................................
....................
.......
...................
.
...
59


4
-
16

: Slave commands in BLUEGIGA ......................................
........................
....
...
...........
.
..........
60


4
-
17

: Life cycle of activity ....................................................................
............
.......
.......
.
.............
63


4
-
18

: Home page of the website ...................................................
...............
....
.......
....................
68


4
-
19
:
Layout of login page

.............................................
....................
...............
..
.......
.................
68


4
-
20
: A
n

ECG plot

..
…………….


………………………………………………………………………………....
..
.
.
..

..

69



xii



List of Tables



Table
……………………………………………………………………………………................………………… Page Number

3
-
1: Capacitor specifications ..........................................
.......
.......................................................
22


3
-
2: P
age modes of Bluegiga .........................................
.......
.......................................................
33


3
-
3:
Features of 000webhost [website]

......................
......................................
.
...
............
............ 61

4
-
1:Bit values of PIC register ..........................
......
........................................................................
44


4
-
2: Bit values of ADCON1 and ADCON0 ........
............
.....
.............................................................
46


4
-
3: Configuration of I/O pins .....................................
.......
..........................................................
46


4
-
4: Activity life cycle in java ..
........................................
.......
...........................................
..
..........
64



















xiii


List of abbreviations


ECG
-


ElectroCardioGram

DFU
-


Device Firmware Upgrade

HTML
-

HyperText Markup Language

OSC
-


oscillation

BT
-

Bluetooth

OP AMP


Operational Amplifier

PIC
-


Programmable Integrated Circuitry

CSS
-


Cumulative Style Sheet

PHP
-


PHP: Hypertext Preprocessor

SQL
-


Structured Query Language

FTP
-


File Transfer Prottocol

SPP
-


Serial Port Profile














1


CHAPTER 1

INTRODUCTION


This chapter provides a brief overview of the project MobiCardio


Implementation of a
Portable Telecardiac System. It gives a brief overview and background and then explains the
limitations and life cycle. The project timeline is given at the end of this
chapter.


1.1 Project definition

1.1.1 Project Survey

In order to determine the demands of recent cardiologists, the group conducted a survey to
HMC (Hayatabad Medical Complex). Meetings with various doctors were held and multiple
options were discussed
. Cardiologists did not actually want the alarms to be passed on
incase of abnormal rhythm. They wanted full transmission of ECG. The reason being, that
cardiac diseases are so diverse and complicated that a mere miss of beat cannot indicate
heart attack o
r angina attack. Even arrhythmia has hundreds of types that can be found out
by observing ECG of few minutes and not by a few beats. So a very complex algorithm will
be required.

1.1.2 Project Objectives

Research objectives:

a)

To revitalize the tele
-
medica
l industry in Pakistan.

b)

To achieve self reliance on indigenous developments.

c)

To pursue import substitution and cost effectiveness.

d)

To ensure high quality research related to telemedicine.

e)

To conceive specialized Wireless Sensor Networks and indigenousl
y develop a flexible
reconfigurable medical application.

To develop a system that will be dynamically adapt to the changes in its architecture and is
capable of transmitting data in real time.


Industrial Objectives

a)

To provide low cost solution as compared to immobile heavy equipment that serve
same purpose in hospitals.

b)

To provide an indigenously developed prototype of WSN for specific medical
application, to cause indigenous production of multipurpose applications
of medical
surveillance.

c)

To revitalize sensor networks with dynamic environment of constant monitoring of any
parameter of the critical patient.




2


Academic Objectives

a)

To cover all the aspects of application development by covering all the areas ranging
from hardware development to software designing.

b)

Acquisition of ECG signals through a cost effective method.

c)

To utilize existing resources for developing a platform for

WSN (Wireless Sensor
Networks).


1.2 Project Scope

The project has a scope Wireless Sensor Network with a fully fledged medical application. It
can be built by integrating medical sensors for complete surveillance of all health
parameters of patients. T
he data sets can be made and transmitted using our presented
architecture. There have been multiple architectures presented for WSN all over Pakistan.
However our architecture is diverse in terms of learning and technology since it includes
Bluetooth, J2ME
, Web Services and PHP. The architecture also is flexible enough to be
Integrated with Windows OS Mobile phone. Wi
-
Fi Transceiver chip can also be incorporated
in parallel. EDGE can be used to access web services instead of Wi
-
Fi technology.

This project
strengthens the concept of Mobile Cardiac Hospital. Where doctor an access
patients data from anywhere in the world . Patient can keep a wearable easy
-
to
-
carry ECG
sensor and is not bound to stay in hospital.

1.3 Project Limitations

The architecture that
we followed incorporated mobility by including cell phone. The
operating system that we used is Android. The application built on this OS can’t be executed
in other OS based cell phones.

The ECG sensor that we developed is serving primary purpose of mobil
ity and wearability.
This has been done by making 3 lead ECG sensor. However, in hospitals 12 lead ECG is used.
3 lead serves the purpose of clearly observing the pulses and there is slight difference in
accuracy of it as compared to 12 lead ECG.

In order

to incorporate serial port

communication. The resolution

used was 2^8. 8 bit values
are transmitted. As a future work, resolution of signal can be improved. Although the
present resolution of ADC samples the highest occurring frequency in ECG accurately.

1.4 Platforms Used

The ADC we developed was of 8 bit resolution and sampling rate of 1920Hz. Its
programming was done in

C language.

Proteus has been used in order to test the working of ADC. Reconstruction of signal was
successfully tested using Proteus.

In order to develop java android application Eclipse environment was used. It has capability
to develop java projects, android proje
cts, web servlets etc. Emulator as well as
Configurations can be set on Android handset for testing.


3


Net beans was used to develop web services and serving classes to be run on Web Server
Tomcat Apache.

XAMPP has also been used for same purpose to make sa
me application.

MySQL has been used to develop data base where the data coming from user end will be
thrown by web application and accessed whenever required. The maintaining of database is
done by MySQL.


1.5 Project life cycle

The life cycle of our pro
ject has been explained here. It has been executed in two stages.

Before the first interim presentation, we had completed the hardware layers of our project.
The communication link between sensor and Bluetooth programmable chip was
implemented. The sensor

was made, digitization was done and it was sent to Bluetooth
radio via serial port. Meanwhile, the planning of software layers was done. The platform for
android application development was established The next round is a complete new
iteration. Before th
e final implementation, software part was emphasized and its
integration and testing with the hardware developed in previous evaluation. The procedure
of planning and analysis was the same for software just like in hardware. Deployment,
debugging and testi
ng was done as final steps.





Figure 1
-
1: Project Life Cycle










4


CHAPTER 2

LITERATURE REVIEW


2.1 ECG Hardware

2.1.1 Heart activity

The heart has a natural pacemaker that regulates the pace or rate of the heart. It sits in the
upper portion of the right atrium (RA) and is a collection of specializes electrical cells known
as the SINUS or SINO
-
ATRIAL (SA) node. Like the spark
-
plug of an

automobile it generates a
number of "sparks" per minute. Each"spark" travels across a specialized electrical pathway
and stimulates the muscle wall of the four chambers of the heart to contract (and thus
empty) in a certain sequence or pattern. The upper
chambers or atria are first stimulated.
This is followed by a slight delay to allow the two atria to empty. Finally, the two ventricles
are electrically stimulated. The heart normally beats at around 72 times per minute and the
sinus node speeds up during
exertion, emotional stress, fever, etc., or whenever our body
needs an extra boost of blood supply. In contrast, it slows down during rest or under the
influence of certain medications. Well trained athletes also tend to have a slower heart
beat.










Figure 2
-
1: N
ormal heart curve

2.1.2 PQRS Sequence

The sequence of electrical activity within the heart is displayed in the figure. As the SA node
fires, each electrical impulse travels through the right and left atrium. This electrical activity
causes the two upper chambers of the heart to contract. This
electrical activity and can be
recorded from the surface of the body as a "P" wave" on the patient's EKG or ECG
(electrocardiogram).

The electrical impulse then moves to an area known as the AV (atria
-
ventricular) node. This
node sits just above the ventr
icles. Here, the electrical impulse is held up for a brief period.
This delay allows the right and left atrium to continue emptying it's blood contents into the
two ventricles. This delay is recorded as a "PR interval." The AV node thus acts as a "relay

5


st
ation" delaying stimulation of the ventricles long enough to allow the two atria to finish
emptying.

Following the delay, the electrical impulse travels through both ventricles (via special
electrical pathways known as the right and left bundle branches).

The electrically stimulated
ventricles contract and blood is pumped into the pulmonary artery and aorta. This electrical
activity is recorded from the surface of the body as a "QRS complex". The ventricles then
recover from this electrical stimulation and

generate an "ST segment" and T wave on the
EKG.


2.1.3 Three Lead ECG

The electrical activity can be represented as a dipole (a vector between two point charges).
The placement of the electrodes on the body determines the view of the vector as a
function

of time. Figure
2.
1 represents the most basic form of the electrode placement
which is based on Einthoven’s triangle. This theoretical triangle is drawn around the heart
with each apex of the triangle representing where the fluids around the heart connect

electrically with the limbs. Lead I measure the differential potential between the right and
left arms, Lead II between the right arm and left leg, and Lead III between the left arm and
left leg.

The data acquisition being performed in this project is th
at of lead I where the left arm is
taken as the positive reference with respect to the right arm and the right leg loop is used as
a feed back to remove the common mode noise from the circuit.


2.1.4 ECG Data Acquisition

An ECG is a measurement of the ele
ctrical activity of the cardiac muscle as obtained from
the surface of the skin. As the heart performs its function of pumping blood through the
circulatory system, the result of the action potentials responsible for the mechanical events
within the heart
is the generation of a certain sequence of electrical events.


2.1.5 ECG Interference Sources

As mentioned previously the ECG signals are typically in the millivolt range, and are hence
susceptible to large amounts of interference, from a variety of sourc
es. The interference
sources can be divided into 3 distinct groups:



Noise originating from sources external to the patient




Interference originating from the patient



Unwanted Potentials as well as interference originating from patient
-
electrode
contact
.

Noise originating from electrostatic sources

When a charged body is brought up close to an uncharged one, an equal &

opposite charge
develops on the uncharged body. For example if an unearthed body is close to any
electronic device that is connected to the mains supply voltage, the body will develop a

6


surface charge of equal & opposite potential even though no current i
s flowing between the
two bodies. This phenomenon is commonly known as ESD (Electrostatic Discharge). As the
mains potential has a frequency of 50 Hz, the induced potential will also have this
frequency. Other sources of electrostatic charge include the op
erating table, other persons,
electronic equipment.


Noise due to electromagnetic induction

An interference that occurs in the vicinity of wires carrying AC currents. Due to the
generation of a magnetic field by the flow of a current, all conductors carr
ying mains
currents are surrounded by electromagnetic fields. The 50 Hz mains interference is a
difference in potential, relative to ground, that is impressed upon any patient/subject in
proximity to the wire carrying alternating (50Hz) main supply current
; the patient takes on a
potential that is neither that of ground, nor that of the mains, but rather, somewhere in
between. Since the mains current is fluctuating (AC), the induced voltage of the subject is
also fluctuating. The effect is however minimized

by the fact that the electromagnetic field
generated by the live wire is to a large degree cancelled out by the neutral cable flowing
adjacent to the live cable but in the opposite direction.

Noise originating from patient

An electromyogram (EMG) measure
s the electrical activity of muscles at rest and during
contraction. Analysis of the EMG shows that the frequency (Hz) components of both the
EEG & ECG both lie within the same band. The EMG signal however is typically five times
larger (up to 30mV) than t
hat of the ECG signal. Muscular activity (especially shivering) can
lead to large interference in any ECG signal since they occupy the same frequency band.


Noise originating from patient
-
electrode contact

ECG electrodes do not act as a passive non
-
invasi
ve conductor. The placement of any metal
adjacent to an electrolytic solution (gel on ECG pads combined with surface of skin)
produces an electrochemical half
-
cell, similar to (although a lot less complex) than that of a
battery, resulting in potentials on

the surface of the skin. If a differential amplifier is
connected to a pair of such electrodes it will amplify any difference in potentials. Ideally if
the cells are identical the output will be zero. If the potentials however are not identical,
any diffe
rence between the two electrodes will be amplified.


2.2 Digitization of ECG signal (PIC 18f452)

Analog
-
to
-
digital conversion is an electronic process in which a continuously variable
(analog) signal is changed, without altering its essential content, int
o a multi
-
level (digital)
signal.


7


The input to an analog
-
to
-
digital converter (ADC) consists of a voltage that varies among a
theoretically infinite number of values. Examples are sine waves, the waveforms
representing human speech, and the signals from a

conventional television camera. The
output of the ADC, in contrast, has defined levels or states. The number of states is almost
always a power of two
--

that is 2, 4, 8, 16, etc. The simplest digital signals have only two
states, and are called binary.

So there are two steps involved in analog to digital conversion. First is the sampling that is
digitizing the time domain and the next step is quantization that is defining definite voltage
levels.






Figure 2
-
2: S
amplin
g and Q
uantization


Digital signals propagate more efficiently than analog signals, largely because digital
impulses, which are well
-
defined and orderly, are easier for electronic ci
rcuits to distinguish
from noise, which is chaotic. This is the chief advantage of digital modes in communications.


2.2.1 Sampling Frequency

An analog signal is continuous in both time and amplitude, a digital signal is discrete in both
time and amplitud
e. To convert a signal from continuous time to discrete time, a process
called sampling is used. The value of the signal is measured at certain intervals in time. Each
measurement is referred to as a sample.

When the continuous analog signal is sampled at

a frequency F, the resulting discrete signal
has more frequency components than did the analog signal. To be precise, the frequency
components of the analog signal are repeated at the sample rate. That is, in the discrete
frequency response they are seen
at their original position, and are also seen centered
around +/
-

F, and around +/
-

2F, etc.


2.2.2 Nyquist Requirement


8


If the signal contains high frequency components, we will need to sample at a higher rate to
avoid losing information that is in the signal. In general, to preserve the full information in
the signal, it is necessary to sample at twice the maximum frequenc
y of the signal. This is
known as the Nyquist rate. The Sampling Theorem states that a signal can be exactly
reproduced if it is sampled at a frequency F, where F is greater than twice the maximum
frequency in the signal.

If the signal is sampled at a fre
quency that is lower that the Nyquist rate then When the
signal is converted back into a continuous time signal, it will exhibit a phenomenon called
aliasing
. Aliasing is the presence of unwanted components in the reconstructed signal.
These components wer
e not present when the original signal was sampled. In addition,
some of the frequencies in the original signal may be lost in the reconstructed signal.
Aliasing occurs because signal frequencies can overlap if the sampling frequency is too low.
Frequencie
s "fold" around half the sampling frequency
-

which is why this frequency is often
referred to as the folding frequency. Sometimes the highest frequency components of a
signal are simply noise, or do not contain useful information. To prevent aliasing of t
hese
frequencies, we can filter out these components before sampling the signal. Because we are
filtering out high frequency components and letting lower frequency components through,
this is known as low
-
pass filtering.


2.2.3 Asynchronous Serial Communic
ation and Data Framing

The data coming in at the receiving end of the data line in a serial data transfer is all zeros
and ones. It is difficult to make a sense of the data unless the receiver and sender agrees on
a set of rules, a protocol, on how the da
ta is packed. How many bits constitute a character
and when the data begins and end. Asynchronous serial data communication is widely used
for character oriented transitions , while clock oriented data transfer use the synchronous
method. In the asynchrono
us method, each character is placed between start and stop bits.
It is called framing. In data framing for asynchronous communication, the data, such as
ASCII characters, are packed between a start bit and stop bit. The start bit is always one bit
but the
stop bit can be one or two bits. The start bit is always a 0 (low) and the stop bit(s) is
1 (high). For example as below, the ASCII character A (8 bit binary 0100 0001) is framed
between the start bit and the single stop bit. Notice that the LSB is sent ou
t first.


2.3 Bluegiga

Bluetooth is an open wireless technology standard for exchanging data over short distances
(using short length radio waves) from fixed and mobile devices, creating personal area
networks (PANs) with high levels of security. it was
originally conceived as a wireless
alternative to RS
-
232 data cables. It can connect several devices, overcoming problems of
synchronization.

Bluetooth uses a radio technology called frequency
-
hopping spread spectrum, which chops
up the data being sent an
d transmits chunks of it on up to 79 bands of 1 MHz width in the

9


range 2402
-
2480 MHz This is in the globally unlicensed Industrial, Scientific and Medical
(ISM) 2.4 GHz short
-
range radio frequency band.



2.3.1

Advantage

The introduction of Bluetooth in
project architecture introduces an added factor of mobility
in remote monitoring system. Bluetooth required will be of high data rate to cope up with
the real time continuous data input from the sensor.


2.4 Android

Android is an operating system based on

Linux with a Java programming interface. It
provides tools, e.g. a compiler, debugger and a device emulator as well as its own Java
Virtual machine (Dalvik Virtual Machine
-

DVM). Android is created by the Open Handset
Alliance which is lead by Google.

Ev
ery Android applications runs in its own process and under its own user id which is
generated automatically by the Android system during deployment. Therefore the
application is isolated from other running applications and a misbehaving application cannot
easily harm other Android applications.


2.4.1 Important Android Components

An Android application consists out of the following parts:

Activity
-

Represents the presentation layer of an Android application, e.g. a screen which
the user sees. An Android

application can have several activities and it can be switched
between them during runtime of the application.

Views
-

The User interface of an Activity is build with widgets classes which inherent from
"android.view.View". The layout of the views is man
aged by "android.view.ViewGroups".


Services
-

perform background tasks without providing an UI. They can notify the user via
the notification framework in Android.


Intents
-

asynchronous messages which allow the application to request functionality from
other services or activities. An application can call directly a service or activity (explicit
intent) or ask the Android system for registered services and applications for
an
intent
(implicit intents). For example the application could ask via an intent for a contact
application. Application registers themself to an intent via an IntentFilter. Intents are a
powerful concept as they allow creating loosely coupled applications
.


R.java, Resources and Assets
-

The directory "gen" in an Android project contains generated
values. "R.java" is a generated class which contains references to resources of the "res"

10


folder in the project. These resources are defined in the "res" directo
ry and can be values,
menus, layouts, icons or pictures or animations. For example a resource can be an image or
an XML files which defines strings.


2.4.3 Activities and Layouts

The user interface for Activities is defined via layouts. Layouts are at ru
ntime instances of
"android.view.ViewGroups". The layout defines the UI elements, their properties and their
arrangement. A layout can be defined via Java code or via XML.

XML based layouts are defined via a resource file in the folder "/res/layout". This

file
specifies the view groups, views, their relationship and their attributes for a specific layout.
If a UI element needs to be accessed via Java code you have to give the UI element an
unique id via the "android:id" attribute. To assign a new id to an
UI element, use
"@+id/your value". By conversion this will create and assign a new id "your value" to the
corresponding UI element. In your Java code you can later access these UI elements via the
method findViewById(R.id.yourvalue).

Defining layouts via
XML is usually the preferred way as this separates the programming
logic from the layout definition. It also allows defining different layouts for different devices.
You can also mix both approaches.


2.4.4 Activities and Lifecycle

The operating system

controls the life cycle of the

application. At any time the Android

system may stop or destroy the

application, e.g. because of an incoming call. The Android
system defines a life cycle for an activities via pre
-
defined methods. The most important
methods

are:



onSaveInstanceState()
-

called if the activity is stopped. Used to save data so that
the activity can restore its states if re
-
started




onPause()
-

always called if the Activity ends, can be used to release re source or
save data




onResume()
-

cal
led if the Activity is re
-
started, can be used to initialize fields

The activity will also be restarted if a so called "configuration change" happens. A
configuration change for examples happens if the user changes the orientation of the device
(vertical
or horizontal). The activity is in this case restarted to enable the Android platform
to load different resources for these configuration, e.g. layouts for vertical or
horizontal
mode.

2.5 Web Designing

Tools employed for our website development include:




Xampp



Notepad ++



DreamWeaver


11




HTML



PHP



CSS



Webhosting

2.5.1 Xampp

For any web developer it is mandatory to have a platform where initial designing and final
editing is done prior to hosting the web pages on a server. For this purpose the platform
we
used is Xampp. XAMPP is a free and open source cross
-
platform web server package,
consisting mainly of the Apache HTTP Server, MySQL database, and interpreters for scripts
written in the PHP and Perl programming languages.

Xampp is avai
lable for all ope
rating
systems

Li
nux, windows, Mac, Solaris etc.

Figure 2.3

shows the layout of the Xampp control
panel ones launched after installation.





Figure 2
-
3:

Xampp control panel


2.5.2 Notepad ++

Notepad++ is a free source code editor and Notepad replacement that supports several
languages. Basically the codes for web page development is written on notepad++ and
when saved (in C:
\
xampp
\
htdocs ) Its execution can be viewed in localhost at the same
t
ime.


2.5.3 DreamWeaver

Dreamweaver allows users to preview websites in locally installed web browsers. It provides
transfer and synchronization features, the ability to find and replace lines of text or code by
search terms and regular expressions across the entire site, and a t
emplating feature that

12


allows single
-
source update of shared code and layout across entire sites
without server
-
side
scripting.


2.5.4 Html

HTML, which stands for Hyper Text Markup Language, is the predominant markup language
for web pages. It provides a

means to create structured documents by denoting structural
semantics for text such as headings, paragraphs, lists etc as well as for links, quotes, and
other items.

HTML elements form the building blocks of all websites. HTML allows images and objects t
o
be embedded and can be used to create interactive forms. It provides a means to create
structured documents by denoting structural semantics for text
.
It can embed scripts in
languages such as JavaScript which affect the behavior of HTML WebPages.


2.5.5

PHP

PHP is a general
-
purpose scripting language originally designed for web

development
.

PHP is
the most popular language to create web sites. PHP is an interpreted language and is
executed on server side (just like CGI or ASP scripts) contrary to script
s executed on client
side (a JavaScript or a Java applet executes on your computer ). It is usually associated with
Apache and MySQL database.


2.5.6 CSS

Cascading Style Sheets (CSS) is a style sheet language used to describe the presentation
semantics (t
he look and formatting) of a document written in a markup language. Its most
common application is to style web pages written in HTML and XHTML, but the language
can also be applied to any kind of XML document, inc
luding plain XML, SVG and XUL.


2.5.7 Webhosting

A web hosting service is a type of Internet hosting service that allows individuals and
organizations to make their own website accessible via the World Wide Web. Web hosts are
companies that provide space on a server they own or lease fo
r use by their clients.

The scope of web hosting services varies greatly. The most basic is web page and small
-
scale
file hosting, where files can be uploaded via File Transfer Protocol (FTP) or a Web interface.
The files are usually delivered to the Web
as is or with little processing. Many Internet
service providers (ISPs) offer this service free to their subscribers. People can also obtain
Web page hosting from other, alternative service providers. Personal web site hosting is
typically free, advertisem
ent
-
sponsored, or inexpensive. Business web site hosting often has
a higher expense.





13


Chapter 3

DESIGN AND DEVELOPEMENT













REFERENCES










14





References


1.

Small wireless ECG with Bluetooth™ communication to a PDA by Martin Ekström

2.

A Wireless System for Monitoring of Children with Suspected Cardiac Arrhythmias

3.

A Reconfigurable, Wearable, Wireless ECG System Borromeo S, Rodriguez
-
Sanchez C,
Machado F, Hernandez
-
Tamames JA, de la Prieta R .Electronics & Bioengineering Group.
Rey Juan
Carlos University.


4.

An Intelligent Telecardiology System Using a Wearable and Wireless ECG to Detect Atrial
Fibrillation Chin
-
Teng Lin, Fellow, IEEE, Kuan
-
Cheng Chang, Chun
-
Ling Lin, Chia
-
Cheng
Chiang, Shao
-
Wei Lu, Shih
-
Sheng Chang, Bor
-
Shyh Lin, Hsin
-
Yue
h Liang, Ray
-
Jade Chen,
Yuan
-
Teh Lee, and Li
-
Wei Ko, Member, IEEE


5.

Bluegiga WT
-
12 datasheet

6.

An Ultra
-
Wearable, Wireless, Low Power ECG Monitoring System Chulsung Park and Pai
H. Chou University of California, Irvine, CA 92697
-
2625 USA Ying Bai, Robert Ma
tthews,
and Andrew Hibbs Quantum Applied Science & Research (QUASAR), Inc.


7.

Fabric
-
Based Active Electrode Design and Fabrication for Health Monitoring Clothing
Carey R. Merritt, H. Troy Nagle, Fellow, IEEE, and Edward Grant, Senior Member,
IEEE


8.

Datashee
t of PIC 18f452













15

















APPENDIX A

Codes










16





PIC 18f452:

int temp_res1;

int i, start=0;

int EKG_1;

void main()

{

ADCON0 = 0x81; // Configure analog inputs and Vref

ADCON1=0XCF; //right justified, fosc/64, an0 =analog

TRISA = 0xFF; //FF all AN is input // F1 an1
-
an3 output an0&an7 analog
input

//TRISB = 0x00; // Pins RB1, RB0 are outputs

UART1_Init(19200); //Serial port configuration with 19200 baud rate

while(1)

{

temp_res1 = ADC_Read(0); // Get results of AD conv
ersion input AN0 EKG

EKG_1=temp_res1/4; //Shift the 2 LSB

//Delay_us(500); //wait 0.25 ms

UART1_Write(EKG_1); // send channel 1 8 bit result via serial UART

//Delay_us(500);

}

}
















17





Website End Coding:

Index Page (Home):

<!DOCTYPE html
PUBLIC "
-
//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http
-
equiv="Content
-
Type" content="text/html; charset=utf
-
8" />

<link rel="stylesheet" type="text/css" href="style.c
ss" />

<title>MobiCardio</title>

</head>


<body>


<div id="page">





<div id="header">



<h1>MobiCardio</h1>


<ul>





<li><a href="http://mobicardio.site90.net">Home</a></li>



<li><a
href="http://mob
icardio.site90.net/main_login.php">Log in</a></li>


<li><a href="#">The Project</a></li>


<li><a href="#">About</a></li>


<li><a href="#">Contact</a></li>


</ul>


</div>




<div id="mai
n">





<div class="main_top">



<h1>About MobiCardio</h1>


</div>





<div class="main_body">


<p>
This project gives specifications in the design and
implementation of a low cost wearable ECG system. A detailed explanation
of the various modules of the design and their implementations is
provided. Each module was successfully simulated and then impleme
nted.
</p>




<p>The system design aims to provide solutions to the
problems encountered in acquiring signal from the body, as well as

18


providing remote transmission, of ECG data. A remote device is attached to
the person bein
g monitored. The remote device acquires the raw ECG data
from the Leads which are placed in predefined areas of the body. The data
is digitized through a PIC programmed as an ADC UART device. The data is
transmitted wirelessly using a Bluetooth technology
to an android enabled
cell phone which loads the data through the GPRS technology to a website.
The reconstruction of the sampled digitized ECG is performed at the
website side. </p>




<p>The access rights of the web site are

with the hospital
where the doctor can monitor the ECG of the patient at home.</p>


</div>





<div class="main_bottom"></div>




</div>








<div id="footer">


<p>



Copyrights MobiCardio 2013


</p>


</div>




</div>

</body>

</html>


Main Login Page:

<table width="300" border="0" align="center" cellpadding="0"
cellspacing="1" bgcolor="#CCCCCC">

<tr>

<form name="form1" method="post"
action="checklogin.php">

<td>

<table width="100%" border="0" cellpadding="3" cellspacing="1"
bgcolor="#FFFFFF">

<tr>

<td colspan="3"><strong>Member Login </strong></td>

</tr>

<tr>

<td width="78">Username</td>

<td width="6">:</td>

<td width="294"><input
name="myusername" type="text" id="myusername"></td>

</tr>


19


<tr>

<td>Password</td>

<td>:</td>

<td><input name="mypassword" type="text" id="mypassword"></td>

</tr>

<tr>

<td>&nbsp;</td>

<td>&nbsp;</td>

<td><input type="submit" name="Submit" value="Login"></td>

</tr>

</table>

</td>

</form>

</tr>

</table>


Log in Success Page:

<?php

session_start();

if(!session_is_registered(myusername)){

header("location:main_login.php");

}

?>


<html>

<body>

Login Successful

<br>

<br>

Click <a
href="http://mobicardio.site90.net/data_ecg1.html">Here</a> to
view the ECG

</body>

</html>


Graph Plotting Applet:

<applet code="LineGraphApplet.class" archive="Linegraph.jar" width="2000"
height="300" mayscript>

<PARAM name="chartproperties" value="con
fig_final.htm">

<PARAM name="chartdata"
value="http://mobicardio.site90.com/dataecg_final1.htm">

</applet>

<div id="loginform">

<form method="post" action="values_ecg_data.html" name="form2">

<input type="submit" name="submit" value="Refresh" />

</fo
rm>


20


</div>




// Close the socket


















Appendix B

User Manual










21




Connecting the ECG hardware:

1. Remove the plastic covering of the electrodes.

2. Place the three electrodes in the following configuration:



3. Connect the electrode cables to the electrodes on body,

4. Connect the battery.


Establishing the Bluetooth connection:

1. Turn off the power of ADC module.

2. Launch android application “Telecardroid”. It asks for permission to turn on Bluetooth if
it is
powered off. Click yes





22



3. If the device is not paired. Select connect to a device. And select the device from the
appearing list.




4. If the device is already paired. Select the device from the list already existing.




5. Once the
device is connected. Power on the ADC module. The data will start transmitting.


23




6. If the patient wants to close the connection of Bluetooth. Type “off” or “close” in the text

area and click send to Bluegiga.





Website end:


1. Go to url mobicardio
.site90.net

2. Click on Log in.






24


3. Enter username and password. Click login



4. Click on ‘View ECG’ to plot the data being transmitted from the cell phone.