Vous êtes sur la page 1sur 54

ABNORMAL HEART RATE DETECTOR WITH ECG SIGNAL RECORDED

NUR ZULAIKA AFNI BINTI AFRIPIN





A thesis submitted in fulfillment of the requirements for the award of the degree of
Bachelor of Engineering (Electrical-Medical Electronics)



FACULTY OF ELECTRICAL ENGINEERING
UNIVERSITY TECHNOLOGY MALAYSIA



JUNE 2013


ii


















iii









Specially dedicated to my beloved parents,
Afripin Bin Nong and Noraini binti Onan
To my supervisor,
Mdm. Ismawati Abdul Ghani
And to all of my friends that encourage me in succeeding this project.









iv





ACKNOWLEDGEMENT




Alhamdulillah, thanks to Allah for giving me enough time to complete this
final year project. I also would like to thank my supervisor, Mdm. Ismawati Binti
Abdul Ghani for her guidance and support through the project. Without her
valuable guidance and advice, I would not be able to complete this project
successfully.

Great appreciation goes to the contribution of the Medical Laboratory staff
as I am using the facilities there through the project with their help. A deep
appreciation also goes to the person whom help me either directly or indirectly
along my study here as it is very much contributing in the completion of this
project.

Last but not least, an honorable mention goes to my family and friends for
their understanding and support in completing this project. Without their help, I
would face more difficulties while completing this project.






v





ABSTRACT




Electrocardiograph or ECG is one of the most frequently used medical
devices in the health field. This device will provide an electrical conductivity of
the heart in the form of waveform. The medical staff will then analyze the
waveform and determine whether there is any abnormality in the heart activity of
that individual. The correlation between the ECG waveform and the heart rate of
certain individual is a well-known fact. The abnormality in the heart rate reading
mostly indicates certain heart failure such as tachycardia, bradycardia and also
arrhythmia. When the heart rate is faster or slower than the normal heart rate, the
ECG waveform will be affected. The aim of this project is to make an abnormal
heart rate detector with ECG signal recorder. This device will record the ECG
waveform if and only if abnormal heart rate is detected. An alarm system will
beep in order to alert the user to save the ECG waveform at that particular period.
A graphic LCD is used to display the heart rate reading and the ECG waveform.
In order to make this applicable, a program is written and embedded in a PIC
microcontroller so that the heart rate will be calculated from the ECG signal and
displayed on the LCD together with the waveform. Then, the ECG waveform will
be recorded as programmed and saved in the SD memory card.





vi





ABSTRAK




Elektrocardiogram ataupun digelar EKG adalah salah satu alat perubatan
yang paling kerap digunakan di medan perubatan. Alat ini akan memberikan
tahap konduksi elektrikal jantung dalam bentuk signal gelombang. Kemudian, staf
perubatan akan menganalisa signal gelombang tersebut dan menentukan sama ada
terdapat tanda-tanda yang tidak normal pada aktiviti jantung seseorang individu.
Hubungkait antara signal gelombang EKG dan kadar denyutan jantung sudah
lama diketahui masyarakat. Kebanyakan bacaan kadar denyutan jantung yang
tidak normal adalah tanda-tanda yang cenderung kepada masalah kegagalan
fungsi jantung seperti tachycardia, bradycardia dan juga arrhythmia. Apabila
kadar denyutan jantung terlalu laju atau terlalu lambat berbanding kadar denyutan
jantung normal, signal gelombang EKG akan terganggu. Projek ini menyasarkan
pembuatan satu alat pengesan kadar denyutan jantung abnormal di mana signal
EKG akan direkod. Alat ini akan merekod signal gelombang EKG sebaik sahaja
kadar denyutan jantung tidak normal dikesan. System penggera akan berbunyi
untuk menyedarkan pesakit agar merekod signal EKG pada detik tersebut. Satu
LCD grafik akan digunakan untuk memaparkan bacaan kadar denyutan jantung
serta signal gelombang EKG. Untuk memastikan semua ini terjadi, satu program
ditulis untuk PIC mikropengawal di mana kadar denyutan jantung akan dikira
berdasarkan signal EKG dan dipaparkan pada permukaan LCD beserta signal
gelombang EKG. Kemudian, signal gelombang EKG akan direkod seperti yang
telah diprogramkan dan disimpan dalam kad memori SD.


vii





TABLE OF CONTENTS




CHAPTER TITLE PAGE
DECLARATION ii
DEDICATION iii
ACKNOWLEDGEMENT iv
ABSTRACTS v
ABSTRAK vi
TABLE OF CONTENTS vii
LIST OF FIGURES ix
LIST OF ABBREVIATIONS x
LIST OF APPENDICES xi

1 INTRODUCTION 1
1.1 Background of Study 1
1.2 Problem Statement 3
1.3 Objectives of Project 3
1.4 Scope of Project 3
1.5 Gantt Chart 4
1.6 Thesis Outline 5
2 LITERATURE REVIEW 7
2.1 Electrocardiogram (ECG) 7
2.2 Heart Rate 9
viii


2.3 PIC 18F4550 Microcontroller 10
2.4 Graphic LCD 10
2.5 ECG Signal Recording 11

3 METHODOLOGY 12
3.1 Introduction 12
3.2 ECG Circuit 13
3.3 Microcontroller Programming 15
3.3.1 Analog to Digital Converter (ADC) 16
3.3.2 Heart Rate Calculation 17
3.3.3 Graphic LCD connection 17
3.4 Alarm System 18

4 RESULTS AND DISCUSSION 19
4.1 Introduction 19
4.2 ECG Circuit 19
4.3 Waveform Displayed 21
4.4 Heart Rate Reading 23
4.5 Alarm system 24
4.6 Waveform Recording 24

5 CONCLUSION 26
5.1 Introduction 26
5.2 Conclusion 26
5.3 Recommendation 27
APPENDICES 28-40
REFERENCES 41

ix





LIST OF FIGURES




FIGURE
NO.
TITLE PAGE
1.1 The heart conduction system 2
1.2 FYP1 Gantt Chart 4
1.3 FYP2 Gantt Chart 5
2.1 PQRST peak of ECG waveform [4] 8
2.2 LCD G12864E block diagram [10] 11
3.1 Block diagram of the whole project 13
3.2 ECG Circuit 14
3.3 ECG Simulator 15
3.4 Pin Diagram of PIC18F4550 16
3.5 ECG waveform (PQRST peak) 17
4.1 Differential Amplifier 20
4.2 ECG circuit with PIC microcontroller and the graphic
LCD
21
4.3 30 bpm ECG waveform 22
4.4 120 bpm ECG waveform 22
4.5 Ventricular Fibrillation 23




x





LIST OF ABBREVIATIONS




ECG Electrocardiograph
PIC Programmable Integrated Circuit
USB Universal Serial Bus
BPM Beats per minute
EEPROM Electrically Erasable Read-only Memory
SA Sinoatrial
AV Atriaventricular
ADC Analog to Digital Converter
LCD Liquid Crystal Display
GLCD Graphic Liquid Crystal Display
I/O Input/Output
GDRAM Graphic Dinamic Random Access Memory
SD Secure Digital








xi





LIST OF APPENDICES



APPENDIX. TITLE PAGE
A Coding used in the programming of the
microcontroller
28-34
B PIC 18F4550 pin I/O description 35-39
C Graphic LCD pin Description 40



















CHAPTER 1




INTRODUCTION




1.1 Background of Study

Electrocardiogram or ECG is one of the infamous medical devices that are
widely used in healthcare. From the ECG waveform, the medical staff will analyze
the data and determine the patients level of heart condition. ECG takes the reading
of electrical conductivity of the heart. The continuous pumping of the heart is a result
of the contraction initiated by the sinoatrial (SA) node (see Figure 1.1). SA node acts
as a pacemaker and is situated at the upper part of the right atrium. Once SA node
starts the heartbeat, the impulse will be passed to the atrioventricular (AV) node
situated at the junction of atria and ventricles which makes the atria contract. From
the AV node, the impulse then is passed to the AV bundle, bundle branches and
Purkinje fibres which resulted in the contraction of the ventricles. As the ventricles
contract, blood is being squeezed out of the ventricles to the aorta and the pulmonary
trunk.

The same actions are repeated automatically. That is what actually happened
during the pumping of the blood into and out of a persons heart and explained the
2

occurrence of the heartbeat. Eventhough the heartbeat is in rhythm, each individual
have different heartbeat. Furthermore, the heartbeat of a person can be rapidly
changing depending on the situation. Normally, the resting heart rate will be taken as
a reference to check whether the heart is in the right condition. If the heart rate is
faster than the normal resting heart rate, the condition is called tachycardia. For the
heart rate slower than the normal resting heart rate, the condition is called bradycardia
while arrythmia is a condition at which the heart rate pattern is irregular.
Tachycardia, bradycardia and arrhythmia are not just simple heart failure symptoms
as they may lead to fatal consequences. Before the worse condition occur, a person
with abnormal heart rate should undergo further medical checkup.



Figure 1.1: The heart conduction system


ECG is needed by the medical staff to record the abnormality of the heart
pumping actions taking place inside the body of the patient. The medical staff will
compare the ECG waveform pattern in normal condition and abnormal condition in
order to ensure whether the patient needs further treatment.

3

1.2 Problem Statement

ECG reading need to be taken for patients who are facing the abnormality in
their heart condition. They need to be admitted into the hospital in order to take ECG
reading by following the schedule made by the hospital. However, the ECG
waveform taken at that time sometimes is just a normal signal as the heart failure
symptom is unpredictable. Thus, it is not efficient to go to the hospital when the
patients heart condition is normal unless the patient is fully recovered. Rather than
travel to hospital just to take normal ECG reading, a patient should be glad to take it
themselves whenever they need especially when the symptom occur.




1.3 Objective of Project

The objective of this project is to build a heart rate detector where the ECG
signal will be recorded when an abnormal heart rate is detected. The recording of the
ECG signal is indeed very helpful for the person in need as they can just send the data
to the doctor for further analysis. Through this project, a detection of any abnormal
heart rate will initiate the program to save the ECG waveform at that particular time.




1.4 Scope of Project

The scope for this project involves two sections, hardware and software. For
the hardware, an ECG circuit is used together with the ECG simulator. ECG
simulator will be used where any abnormal reading can be simulated such as
tachycardia and bradycardia. A PIC microcontroller will be used as to convert the
4

analog signal to digital (ADC) and to calculate the heart rate before being displayed
on a graphic LCD. Then, the data of the ECG will be recorded or saved inside the SD
memory card. Software that is used in this project is Micro C programming where
the coding will be embedded into the PIC microcontroller using the PIC2 kit.




1.5 Gantt Chart

The following is the Gantt chart of the project for Final Year Project (FYP) 1
and FYP2;

Week
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Decide Topic # # # # #
Analyze Topic # #
Literature
Review
# # # # # # # # # # #
Project
Proposal
# # #
Find suitable
circuit
# # # # #
Choose the
component
# #
Seminar
Presentation
#
FYP 1 Project
Report
# # # #

Figure 1.2: FYP1 Gantt Chart
5

Week
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Simulation of
PIC coding
# # # # # #
Implement
PIC and
hardware for
overall circuit
# # # # # # # # # #
Final Report
(Draft)
# # # # # # # #
Seminar and
Demonstration
#
Submit
hardcopy &
softcopy
# #

Figure 1.3: FYP2 Gantt Chart




1.6 Thesis Outline

This thesis consists of five chapters including introduction, literature review,
methodology, result and discussion, and conclusion. Chapter 1 covered background
of study, problem statement, objective, scope of the project and Gantt Chart of the
project.

Chapter 2 covered the literature review on some aspects related to the study. The
literature review is taken from reliable sources and focusing on previous works on
electrocardiogram (ECG), heart rate, PIC 18F4550 microcontroller, graphic LCD and
ECG signal recording.

6

In Chapter 3, the methodology of the project is described. The flow of the project
will be discussed in this chapter where the heart rate will be detected from the ECG
signal recorded.

Chapter 4 covered the results of the project followed by the discussion. Finally,
conclusion will be covered in Chapter 5.




























CHAPTER 2




LITERATURE REVIEW




2.1 Electrocardiogram (ECG)

The action potential generated from the contraction of heart wall from the action
of blood pumping will creates electrical currents. The spreading of the electrical
current from the heart through the body create differences in electrical potential
between various locations in the body, and this potential can be detected and recorded
through surface electrodes attached to the skin [1]. The waveform that is produced is
called electrocardiogram (ECG).

Many kinds of diagnosis can be made from the ECG waveform. The ectopic
beats originate somewhere other than SA node (morphologies); irregular heart rate
(arrhythmia), post heart attack (myocardial infarct), cardiac muscle damage (infarcts)
and insufficient blood supply to cardiac cells (ischemic heart condition) are some of
the examples of the disease that can be detected through the analysis of the ECG [2].
That is why the ECG is frequently used by medical staff as it is very helpful in this
field.

8

However, the use of ECG has its own limitation. During resting time, normal
ECG waveform cannot point out the actual heart disease such in the case of irregular
heart rhythm that come and goes. Thus, specialized ECG recordings such exercise
ECG and ambulatory ECG is executed to overcome these hindrance. Exercise ECG
is specially executed for one who is facing the narrowing of coronary arteries
(angina) where the tracing of the ECG is taken when the patient is exercising [3]. For
the ambulatory ECG, the patients sometimes need to be admitted to the hospitals in
order to take ECG reading for about 24 to 48 hours as the occurance of the abnormal
heart rate usually cannot be predicted [3].




Figure 2.1: PQRST peak of ECG waveform [4]


Figure 2.1 shows ECG waveform of one heartbeat. The same pattern will be
repeated for a period of time to obtain a normal ECG waveform. The change of
amplitude or rapidness in the waveform may indicate problems associate with the
heart condition.


9


2.2 Heart Rate

An individual should always alert on his or her heart rate. The heart rate can
indicate whether or not the individual is in a good. The abnormal heart rate may
involve certain heart disease such as arrhythmia. Heart rate can be calculated simply
by placing both index finger and middle finger on the inner wrist. The number of
beats or pulses in 10 seconds is then counted and multiplied by 6 to get the heart rate
per minute. The other alternative in determining heart rate can be made through the
calculating of R peaks in the ECG waveform.

Resting heart rate is a heart rate taken at rest and commonly used as reference to
detect any heart disease. The normal resting heart rate can differs even by age and
lifestyle. Athletes usually have a lower resting heart rate than normal people at
around 60 beats per minute (bpm) and above. The normal resting heart rate for a
person is around 60 to 100 bpm; 60 to 80 bpm for adults, 100 to 190 bpm for infants,
and 60 to 140bpm for children of 2 until 10 years old [5]. However, for a normal
person, the resting heart rate that is lower than 60bpm or higher than 100bpm is
considered to be related with certain heart disease namely bradycardia (too slow pace)
and tachycardia (too fast pace) [6].

There are two types of heart rate meter that is used in calculating the heart rate
from the ECG waveform. The first one is averaging heart rate meter where the
determination of heart rate is made by calculating the average for the heart rate from a
count or else by estimation of number of heart rate over a period [2]. The second one
is beat to beat heart rate meter computes the reciprocal of the time interval between
two consecutive heart beats and the information of each heart beat will be updated
[2].



10


2.3 PIC 18F4550 Microcontroller

Microcontroller is an integrated electronic computing device consists of three
main components in one chip which is microprocessor, memory and I/O port. The
design of microcontroller is optimized for controlling the embedded system. One of
the commonly used microcontrollers is PIC microcontroller.

Most electronic appliance used PIC as a controller in the device because of its
low cost development tools, inexpensive, and is easily available in market [7]. There
are many types of PIC microcontroller and divided into two different type of program
storage, EPROM and FLASH. However, the one that will be used in the project is
PIC 18F4550. PIC 18F4550 have 40 pins with different function and classified as
FLASH program storage. The benefits of having a FLASH program memory for a
microcontroller are that it is re-writable even by the chip itself, faster to develop on
and can be written up to approximately 32kilobytes for PIC 18FX550 series. It has
five bidirectional I/O port, port A, port B, port C, port D, and port E. Besides, it has
thirteen input channel for 10-bit analog to digital channel [8].




2.4 Graphic LCD

LCD is one of the devices that can display the contents of the embedded system
other than 7-segment display and LEDs. Graphic LCD G12864E has a structure
128x64 dot matrix and easy to buy [9]. The graphic RAM of G12864E or GDRAM
supports 64x256 bits bit-mapped memory space where the LCD driver consists of 33
common and 64 segments to drive the LCD panel [10]. From these features, the
specifications fill the requirement needed to display the ECG waveform which is
11

quite handy to be displayed because of its details information. Figure 2.2 shows the
system of the graphic LCD inside the device.


Figure 2.2: LCD G12864E block diagram [10]




2.5 ECG Signal Recording

The flash memory of PIC microcontroller helps in the process of ECG signal
recording. It is a non-volatile computer storage chip with erased and reprogrammed
function. Flash memory is basically developed from Electrical Erasable
Programmable Read-only Memory (EEPROM) where fairly large blocks must be
erased so that new data can be written [11]. SD card memory is compatible with the
data write string which will be used in the saving data component.







CHAPTER 3




METHODOLOGY




3.1 Introduction

This chapter covers the step taken in the making of this project from the ECG
module to the PIC microcontroller programming, the display of heartbeat with alarm
system and lastly to the ECG data recording. The following is the block diagram of
the heart rate detector with ECG signal recorded.


13


Figure 3.1: Block diagram of the whole project

The ECG signal will be taken from the user using ECG circuit. The lead from
the ECG are attached to the users right arm and left arm. Then, signal from the ECG
output is directly connected to the PIC microcontroller where the analog signal is
converted to digital signal and the heart rate calculation takes place. PIC
microcontroller is also programmed so that the heart rate and the ECG waveform can
be displayed on the graphic LCD. When the alarm beeping indicates the abnormal
heart rate, the user can save the data and the ECG waveform will be saved in the SD
memory card. Thus, the user can bring the memory card to the doctor for further
analysis.




3.2 ECG Circuit

From the biopotential lead, the electrical signal will be amplified and passed to
the high pass filter and low pass filter (Refer to Figure 3.2). The gain used for this
14

circuit is 1000. The filters removes the noise resulted from the electrical signal of the
other muscle contraction so that only the signal from the cardiac muscle is taken.
Then, the output is connected to the oscilloscope to check the compatibility of the
waveform when the ECG circuit is connected to the graphic LCD later on.

In order to gain more standardized results of ECG waveform, an ECG simulator
DNI NEVADA as Figure 3.3 is used. This device can replace the human body in
order to obtain a desired waveform whether normal or abnormal kind of waveform.
The connection is made from the RA and LA socket of the simulator to the ECG
circuit.



Figure 3.2: ECG circuit

15


Figure 3.3: ECG simulator


3.3 Microcontroller Programming

The calculation of heart rate, the display of waveform on the graphic LCD and
the process of saving the output data need a programming to conduct the steps taken.
For that purpose, a Micro C programming is used to check whether the program
written is applicable or not and PIC2 kit will be used when embedding the program
into the PIC.
In this project, a 40 pin PIC 18F4550 is used. The program defines which ports
were used as input and output. The output of ECG circuit, pin 6 of OP97 which acts
as high pass filter was connected to the PORTA of the PIC 18F4550. PORTA will
convert the analog signal to digital signal as programmed and take PORTD as the
output. PORTD of the PIC was then connected to PORTD of the graphic LCD. The
graphic LCD which reads digital input will display the heartbeat as calculated inside
the PIC. The output data string will be read by the PIC and programmed to be saved
16

inside the SD memory card. The coding for the whole program is included in
Appendix A. Figure 3.4 shows the I/O port of PIC18F4550 which is well-known for
its high computational performance at low price.


Figure 3.4: Pin Diagram of PIC18F4550




3.3.1 Analog to Digital Converter (ADC)

PIC 18F4550 has analog feature of 10-bit, up to 8-channel analog to
digital converter (ADC). ADC need to be used to convert the ECG waveform to
digital signal so that the data can be read by the program and calculation of the
heart rate can be made. As the data had been digitalize, the plotting of the ECG
waveform on the graphic LCD will be no problem. Digital ECG data are changed
to LCD code system since ECG signal is seen as electrical signal on the LCD
screen [9].

17

3.3.2 Heart Rate Calculation


After the ECG signal pass through the ADC stage, heart rate calculation
can be made. By referring to Figure 3.5, the heart rate should be defined as:
() (

( )
)()
where this calculation will be inserted in the programming code.



Figure 3.5: ECG waveform (PQRST peak)




3.3.3 Graphic LCD Connection

Graphic LCD was used to display the results of the heartbeat calculation.
The connection of the GLCD and the microcontroller should be defined in the
programming as the use of GLCD need to be initiated so that the PIC library can
understand the data and send the desired output to the screen for display. PORTD
18

of the PIC microcontroller that had been programmed to be the digital output of
the ECG circuit is then connected to the GLCD pin.




3.4 Alarm System

The alarm system used a buzzer that will beep each time abnormal heart rate is
detected. Micro C programming has a built in sound system that will make it easier
for the user to adjust how the sound will be. In this project the buzzer was set to beep
for about 10 seconds.






















CHAPTER 4




RESULTS & DISCUSSION




4.1 Introduction

This chapter covered the results of the project and discussion regarding the
results obtained.




4.2 ECG Circuit

The ECG circuit had been built according to the circuit design and successfully
produces ECG waveform as needed when tested with DNI Nevada ECG simulator
and Tektronix Oscilloscope. This ECG circuit consists of three stages;
i. Differential Amplifier
ii. Low Pass Filter
iii. High Pass Filter

20

The differential amplifier as in Figure 4.1 will take the difference in electrical
signal in Right Arm (RA) and Left Arm (LA). The use of differential amplifier is
simpler and easier to obtain the desired output than instrumentation amplifier.
However, instrumentation amplifier is more advisable to be used for biomedical
equipment. As for this project, the focus is not in the ECG circuit implementation but
the heartbeat detection and data recording. Thus, differential amplifier was used as
the ECG waveform output is more stable rather than the output when using
instrumentation amplifier which required more detail implementation which is time
consuming. When taking the signal from the body, higher gain should be considered
because the electrical signal from the body is very small. The gain use for the
differential amplifier is 1000 where this is the normal gain used for ECG circuit in
most ECG applications based on the datasheet of instrumentation amplifier AD620.


Figure 4.1: Differential amplifier

The follow up stage is low pass filter with unity gain. The corner frequency
below 60Hz was chosen to effectively remove the noise coming from the power line
interference and the frequency value is acceptable for not giving too much distortion
effects on the P and T points in the ECG waveform. High pass filter is used in the
last stage with corner frequency of 0.03Hz in order to remove the noise resulting from
the electrode movements and respiration. As this project use ECG simulator which is
not involving human respiration, the high pass filter will not be of much help for the
circuit but certainly affected the results if the human body is used in place of the
Gain =


21

simulator. Figure 4.2 shows the whole circuit of ECG together with PIC 18F4550
and the graphic LCD.




Figure 4.2: ECG circuit with PIC microcontroller and the graphic LCD




4.3 Waveform Display

There should be a difference between the ECG waveform displayed for heart
rate less than 60bpm and more than 100bpm. For heart rate less than 60 bpm, most
heart failure associate with it is said to be bradycardia. The waveform should be as
shown in Figure 4.3. From the figure, the R peaks are quite apart from each other
compared to normal ECG. In the case of heart rate more than 100 bpm or also known
as tachycardia, the waveform will be similar to Figure 4.4 where the R peaks are
more frequent than normal ECG waveform. Figure 4.5 shows the ECG output when
22

ventricular fibrillation occur. These figures were taken from the experiment using the
ECG simulator together with ECG circuit built. The output results were true when
compared with the output results of ECG module using the same scaling.



Figure 4.3: 30 bpm ECG waveform


Figure 4.4: 120 bpm ECG waveform
23



Figure 4.5: Ventricular Fibrillation




4.4 Heart Rate Reading

Heart rate reading will be displayed on the graphic LCD in beats per minute
(bpm). Normal resting heart rate for a person is 60 bpm to 100 bpm. When the heart
rate count is below 60 bpm, it is assumed to be abnormal heart rate. The same goes
for a heart rate count higher than 100 bpm. When, these abnormal heart rate counting
occur, the graphic LCD should display the ECG waveform at that time. This can be
done as the ADC inside the PIC microcontroller will change the analog signal of the
ECG output to digital signal and transferred to the input of the LCD. In this project,
the output of the ECG circuit (pin 6 of OP97 in high pass filter) is connected to the
pin RA0 of PORTA of the PIC. From datasheet of PIC 18F4550, PORTA is one of
the port that can be used to convert analog signal to digital signal. The code in the
programming will define the RA0 pin as analog signal which will be converted into
digital and take PORTD of the PIC to be the output.
24

The LCD which can read the digital signal should display it in the form of a
wave. The reason for taking PORTD of the PIC as the output is because SK40C is
used in this project where the circuit embedded had already made the connection
between PORTD of PIC and the PORTD of the LCD.
The formula used for the heartbeat calculation is
() (

( )
)(). The R to R peak interval of the ECG waveform
is defined in the microcontroller coding as the digital value of most significant figure
in the binary number of the output in PORTD of the PIC.
However, this project is not successful in displaying the waveform of the ECG
on the LCD screen just like when using the oscilloscope. The accuracy of the
waveform peak seems to be far away then the real waveform as the LCD scaling is
rather too small compared to the oscilloscope.




4.5 Alarm System

For the alarm system, a buzzer will produce a beeping sound. The alarm starts
beeping as the abnormal heart rate is detected so that the user can be alerted when he
or she need to record the ECG waveform.



4.6 Waveform Recording

The data of the ECG waveform then should be recorded. For this purpose, SD
card was used as it simply record what it is supposed to in any form that we want.
The SD card was connected to the digital output of the PIC which is the same input
pins of the GLCD. The programming for saving the data into the SD memory card
25

was written in the coding of PIC microcontroller. But, when the full circuit was
tested in order to check whether the data can be successfully recorded or not, the
memory card seems to reject the data transfer as there is no data saved when checked
on the computer. This is possibly caused by the improper connection of the SD card
with the PIC PORT.





























CHAPTER 5




CONCLUSION




5.1 Introduction

This chapter will cover on the conclusion of the whole project whether the
objective of this project had been achieved or not. Some recommendation for the
future work is also included in this chapter.




5.2 Conclusion

An ECG circuit had been successfully built where it show the real time ECG
waveform of the user. From the ECG waveform, the heartbeat of the user was
calculated and shown on the LCD display. The process of saving ECG waveform
data using the SD memory card is the correct way in handling digital data but it was
not successful. The interface between the output memory of the LCD and the
memory card may not be correct. The soldering of the ECG circuit does not affect
27

much in the process of saving data. This is because the soldered ECG circuit had
been tested separately with the ECG simulator and the results of the ECG waveform
were satisfying when compared with the KL-75001 ECG module provided by the
Medical Laboratory. Thus, the connection between the SD card and the PIC 18F4550
was suspected as the cause of the problem in saving the ECG data. In order to
overcome this problem, it is recommended to use better interface for the SD card.




5.3 Recommendation

For a better future related work, there are some recommendations that can be
made to improve the project. First, the display of ECG waveform on the LCD display
should have a scale so that the clinician can used the data saved as one of the main
reference when diagnosing the patients health.

Besides, the memory size of the SD memory card should be sufficient for
recording the ECG waveform more than once. 8 GigaBytes of memory card that was
used in this project is recommended for future use, but the alert system for informing
the user if the data is already full should be made.










28


APPENDIX A



//PIC coding for heartbeat calculation, analog to digital converter,
//and saving data in SD card

//input built-in SK40C
#define SW1 PORTB.F0
#define SW2 PORTB.F1

//output built-in SK40C
//LED
#define LED1 PORTB.F6
#define LED2 PORTB.F7

// glcd pinout settings
char GLCD_DataPort at PORTD;

sbit GLCD_CS1 at RB0_bit;
sbit GLCD_CS2 at RB1_bit;
sbit GLCD_RS at RB2_bit;
sbit GLCD_RW at RB3_bit;
sbit GLCD_EN at RB4_bit;
sbit GLCD_RST at RB5_bit;

sbit GLCD_CS1_Direction at TRISB0_bit;
sbit GLCD_CS2_Direction at TRISB1_bit;
sbit GLCD_RS_Direction at TRISB2_bit;
sbit GLCD_RW_Direction at TRISB3_bit;
29

sbit GLCD_EN_Direction at TRISB4_bit;
sbit GLCD_RST_Direction at TRISB5_bit;

// SD Memory card module connections

sbit Mmc_Chip_Select at LATC0_bit; // for writing to output pin always use latch
sbit Mmc_Chip_Select_Direction at TRISC0_bit;

//define characters used in the programming
unsigned int temp_res;
char i = 1;
unsigned int RtoRinterval;
char j = 60;
char txt1[] = "";

char stringData[512] = "";
unsigned long k, size, m = 0;
char Buffer[512] = "";
char CSD[16] = "";
char CID[16] = "";

void init(void)
{
ADCON0 = 0;
ADCON1 = 0x0f; // ADC - set portB ANx pins to digital i/o
CMCON = 0x07; // Comparators "off"
CCP1CON = 0;
CCP2CON = 0;
SSPCON1 = 0;
}

30

// Write string with soft uart
void writeString(char stringData[])

{

// Get string length
m = strlen(stringData);

for(k = 0; k<m; k++)

{

Soft_UART_Write(stringData[k]);

}

Soft_UART_Write(0x0D);
Soft_UART_Write(0x0A);

}


void main(){ //18F4550

init();
Glcd_Init(); // Initialize GLCD
Glcd_Fill(0x00); // Clear GLCD

// Initialize UART1 module
UART1_Init(19200);
TRISB.B7 = 1;
31

TRISB.B6 = 0;
TRISC.B0 = 0;
TRISB.B0 = 1;
TRISB.B1 = 0;
TRISC.B7 = 0;

Soft_UART_Init(&PORTB, 6, 7, 19200, 0);

Delay_ms(10);

// Initialize SPI1 module

SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64,
_SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);

writeString("SPI started, low speed mode");

m = Mmc_Init();

if(m == 0)
{
writeString("Mmc_Init terminated successfully (0)");
}

else
{
writeString("Mmc_Init() terminated unsuccessfully (not 0)");
}

// reinitialize spi at higher speed

32

SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4,
_SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);

writeString("SPI re-initialized into high speed mode. ");

m = Mmc_Read_Cid(CID);

if(m == 0)
{
writeString("Mmc_Read_Cid terminated successfully (0):");
writeString(CID);
}

else
{
writeString("Mmc_Read_Cid terminated unsuccessfully (not 0)");
}

m = Mmc_Read_Csd(CSD);

if(m == 0)
{
writeString("Mmc_Read_Csd terminated successfully (0):");
writeString(CSD);
}

else
{
writeString("Mmc_Read_Csd terminated unsuccessfully (not 0)");
}

33

writeString("Read sector address 5859375 to prove that it toggled upon toggling of
_MCLR:");

Mmc_Read_Sector(5859375, Buffer);

writeString(Buffer);

writeString("Dumping boot sector and first file structure sector (0, 1)");

Mmc_Read_Sector(0, Buffer);

writeString(Buffer);

Mmc_Read_Sector(1, Buffer);

writeString(Buffer);



Delay_ms(100); // Make a break in hex stream

writeString("End of dumping file information sector.");


writeString("Writing message to sector...(toggle _MCLR to see message change)");

writeString("");

Mmc_Read_Sector(5859375, Buffer);

Mmc_Write_Sector(5859375, "The End!");
34


if(Buffer[0] == 71)

{

Mmc_Write_Sector(5859375, "Start!");

}

TRISA = 0xFF; // PORTA is input
TRISD = 0; // PORTD is output
TRISC=0; // PORTC is output
do
{
temp_res = ADC_Read(0); // Get 10-bit results of AD conversion
PORTD = temp_res; // Send 8 bits to PORTD
PORTC = temp_res >> 7; // Send 1 most significant bits to RC1

RtoRinterval = temp_res>> 7;
i = i * temp_res /j; // (1 * R-R interval)/60 = BPM;
FloatToStr(i, txt1); // char --> string array
Glcd_Fill(0);// Clear screen
Glcd_Write_Text("Your heart beat is:", 0, 0,3);
Delay_ms(2);
Glcd_Write_Text(txt1, 10, 2, 1);
}
while(1) ;
}



35

APPENDIX B

PIC 18F4550 pin I/O description















REFERENCES

36



37








38






39










40

APPENDIX C

Graphic LCD pin description




41


REFERENCES



1. Joseph J.C and John M.B (2001). Electrocardiographs. Stephen Helba (Ed).
Introduction to Biomedical Equipment Technology (4
th
Edition). (pg 197-198). Upper
Saddle River, New Jersey: Prentice Hall.
2. Neil Townsend Michaelmas (2001). C3B Medical Electronics - ECG
Instrumentation. [Online]. Available:
http://www.robots.ox.ac.uk/~neil/teaching/lectures/med_elec/
3. Colin Tidy (11
th
October 2012). Electrocardiogram (ECG). [Online]. Available:
http://www.patient.co.uk/health/electrocardiogram-ecg
4. Soumyan Ranjan Mishra & K.Goutham (2009-2010). Realtime Classification of
ECG Waveforms for Diagnosis of Diseases. (pg 5). National Institute of Technology
Rourkela.
5. Nur Sabrina Binti Risman (2011-2012). Design an Alarm System Using
Electrocardiography (ECG). (pg 12). Universiti Teknologi Malaysia.
6. American Heart Association. Heart and Stoke Encyclopedia. [Online]. Available:
http://www.heart.org/HEARTORG/Encyclopedia/Heart-
Encyclopedia_UCM_445084_Encyclopedia.jsp
7. Yeong Che Fai & Eileen Su Lee Ming. PIC Microcontroller Hands-on.
8. Microchip Technology Inc (2001). PIC 18F4550 Datasheet.
9. Sadik Kara, Semra Kemaloglu & Samil Kirbas (2006). Low Cost Compact ECG
With Graphic LCD and Phonocardiogram System Design (Research). Erciyes
University.
10. Tinsharp. G12864E Graphic LCD Datasheet.
11. Steve Collins & Jullian Silva (1998). Flash Memory (Flash RAM) (pg1-10).

Vous aimerez peut-être aussi