Professional Documents
Culture Documents
MAY 2014
CHAPTER ONE
1.0 INTRODUCTION
1
1.2 Problem Statement
1.3 Objectives
To design a system which will have the ability to store in a memory device
and display cardiovascular data in a suitable format that can be analyzed by
health professional.
The scope of this project is to design the system that will have an ability to
acquire, process and store electrical activity of the heart.
Upon the completion of this project the following advantages will be obtained
(i) It will reduce the time for regular visiting to the medical laboratory for
checkup, since an individual will perform self-measurement while the
2
machine record the series of the measured information for further analysis
by a health professional.
(ii) It will help to reduce rate of deaths caused by the heart attacks. This is
because heart problems arise abruptly and there is an increase of number
of deaths due to heart problems.
(iii)It will enable a person to perform measurement for long time. Since the
device can be owned by an individual and is portable in such a way that
the measurement can even be taken at home.
(iv) Controlled measurement is possible. Controlled measurement is the
measurement performed under specific task assignment during
measurement and the health profession can analyze the measured
information with respect to task performed.
3
CHAPTER TWO
2.0 LITERATURE REVIEW
This chapter explains about the existing systems and proposed system with
their pros, cons and limitations.
4
2.1.3 Disadvantage of the ECG with printout machine
(iv) Portability
The machine is not portable hence measurements are taken at the
specific place. Since the machine is not portable a person is required
to take measurement under limited conditions. Person under
measurement is limited to perform any other activity during
measurement. But it is important in some cases to take measurement
while performing certain activity so as to make comparison of the
activity and the heart response.
(v) Impossible to perform controlled measurement
The existing ECG machine is not portable that a person cannot take
measurement while performing other tasks.
There are also portable ECG machine incorporated with the display where by
a person can perform self-measurement.
(i) The machine has high cost to be afforded by a person with normal
income.
(ii) The machine is not compatible with the computer. It is important to have
a machine which is compatible with the computer, hence information can
be retrieved form and hence can be stored and processed.
There is a clear need for equipment which can record the patient's heart
activity continuously over a longer period of time 24 hours or more to
accurately diagnose intermittent heart problems. Portable, easy-to-use ECG
equipment could monitor the patient, but at the same time allow them to live
a normal life and visit hospital less frequently. The proposed system will
enable any person to take measurement at any place, while the device keeps
log of the measured data for the desired time according to the memory device
used. The device can be submitted to the health profession for interpreting the
measured information. The figure below is the block diagram of the proposed
system.
Fig 2.2 Electrocardiography (ECG) data logger block diagram for proposed
system
6
2.2.2 Input
This receives signal from a person through electrodes attached on his/her body
and send them to the ECG system. ECG electrodes are available off-the-shelf
and are often made from Silver / Silver Chloride (Ag / AgCl). The Ag/Cl layer
is very unreactive yet still performs as a sufficiently good conductor. ECG
leads are seldom screened in order to reduce bulk and weight, which makes
them susceptible to receiving a lot of unwanted noise. The placement of the
electrodes depends upon the condition to be diagnosed. The simplest is the
Lead I ECG, where a single differential pair is placed on either side of the
body and an earth is placed elsewhere to help reduce the amount of air-borne
noise received. Another common form (upon which most multi-channel ECGs
are based) is Eindhoven’s Triangle, which uses three electrodes (+earth) in
differential pairs. Electrodes are placed on the left arm, right arm and left leg.
The electrode acts as the transducer where it converts chest vibrations due
heart rhythmic beating to the electrical signal. Proper placement of electrodes
will reduce error due to muscles artifacts and breathing, hence best results will
be obtained. The electrical signals are sent to the ECG machine through a
cable. Since the signal is very small in magnitude the cable should met the
specification on impedance and should be enclosed by the material that can
prevent external noise to interrupt.
7
amplifier have large amount of gain and very high common mode rejection
ration to eliminate errors.
2.2.5 Display
The unit is responsible for displaying the ECG waveforms from the control
unit. The display should have good resolution so that the waves can be visible
and analyzed.
It reduce the time for regular visiting to the medical laboratory for
medical checkup since the device is portable a person can perform self-
measurement. The measurement can be taken in any place while a
person may be performing other activities while the device continues to
store the measured information. The device will be submitted to the
health profession where the data will be retrieved for analysis.
(ii) Portability
8
from the medical laboratory and it is possible to perform controlled
measurement.
(iv) Cost
The cost of this machine will be low compared to other ECG machine.
CHAPTER THREE
3.0 Methodology
This chapter explains in details methods, steps and procedures to be taken and
followed so as to accomplish the project (that is, how to achieve the specific
objectives mentioned earlier which will lead into the succession of the
project.
This involves:
Data analysis and design shows how the various data that have been collected
were related to the design of the function.
The parts of this system as observed from the block diagram after design will
be simulated in order to observe results of each part in the block diagram
before implementing the complete circuit.
10
3.7 Building Prototype and Testing
CHAPTER FOUR
4.0 DATA COLLECTION
In this chapter data concerning the design of the portable Electrocardiography
(ECG) data logger machine are explained. Two kinds of data were collected
from different sources health related, these kinds of data are primary and
secondary data. Primary data are these data which will justify the project and
secondary data are these data which illustrate the components that will be
used in the design. Primary data were collected from the ministry of health
and social welfare bio medic’s engineer, Cardiac institute of training and
treatment and from health professions. Data collected were obtained through
interviewing and questionnaire methods. Data concerning general health
status in Tanzania, ECG machines availability at different level of health
facilities, ratio of the health professions to the available population, rate of an
increase of the non-communicable diseases (NCD), ECG machines average
cost were collected.
The health sector in Tanzania faces serious crisis on the number of facilities
which negatively affects the ability of the sector to deliver quality health
services. The crisis is at all levels but the shortage is more severe in rural
districts. The shortage is exacerbated by the expanded population. And the
present facilities faces lack of bio medic’s equipment’s especially on the
district level. ECG machines are mostly available in Special hospitals, zonal
referral hospitals, referral hospitals, and regional hospitals and rare in some
district hospitals. The table below shows the health institution by type status
2006. From the figures indicated in fig 4.1 and fig 4.2, it indicate that there is
demand in health facilities as well as health professions but to reduce the load
for the available facilities there is the need for person to attend as many times
to the hospital. The portable ECG machine will enhance person to perform
11
self-measurement that will reduce the time to visit hospital. (NBS, Ministry
of Finance, 2011).
Table 4.1 Public health facilities by type and health professionals’ availability
in Tanzania (NBS, Ministry of Finance, 2011).
12
Dispensaries 1,641 11,487 1,842 9,645 84
Dispensary 3038 No _ _ _
13
Key
14
Population(000)
Kigoma 300
Mara 167
Mwanza 144
Tabora 132
Rukwa 121
Shinyanga 115
Kagera 114
Dodoma 95
Manyara 92
Lindi 88
Mtwara 71
Singida 65
Mbeya 64
Tanga 58
kilimanjaro 58
Iringa 58
Ruvuma 57
Morogoro 56
Pwani 32
Dar es salaam 24
Arusha 22
Tanzania mainland 64
0 50 100 150 200 250 300 350
Population(000)
Fig 4.1 Population per Medical Officer and Specialized Medical Doctor
Tanzania Mainland 2006 (NBS Ministry of finance, 2011)
Due to least availability of health centers and the health professionals may
result into insufficient services, but portable ECG machine will bring the
service to personal level thus reducing the load to both health professions and
health facilities. The table from figure 1.3 shows there is least availability
medical officer and specialized medical doctor but the portable ECG machine
will help to reduce load to the medical officer and specialized medical doctor.
16
Distribution of major causes of death including
CVDs
cardiovascular
Other NCDs diseases cardiovascular diseases
33% 31%
communicable, maternal,
perinatal, and nutritional
Injuries
Other NCDs
Injuries communicable,
9% maternal,
perinatal, and
nutritional
27%
From the pie chart on Fig 4.5 it indicate that 31% of deaths are due
cardiovascular diseases. This indicate how much cardiovascular problem it is.
CVDs are responsible for over 17.3 million deaths per year and are the
leading causes of death in the world.
17
Proportinality mortality (% of total deaths, all ages)
Respiratory Diabets
diseases 2% Other NCDs
3% 7%
Cancer Communicable, maternal,
3% perinatal and nutritional
conditions
Injuries
CVDs
12%
CVDs
Cancer
Fig 4.3 Proportionality mortality (% of total deaths, all ages) (World Health
Organization - NCD Country Profiles, 2011).
The pie chart from Fig 4.3 shows the proportionality mortality by percentage
of total deaths of all ages in Tanzania. 12% of all deaths are due to
cardiovascular diseases (CVDs).
18
Patient Time consumed during Frequency for attending
measurement (Hrs.). clinic
Condition Critical 24-48 Once per week
The ECG machines cost are too high to be affordable by a normal income
person. The table below from Fig 4.7 indicate average cost of ECG machines
from major bio medic’s suppliers.
Table 4.5 ECG machines average cost from the major bio medic’s suppliers
Phillips 4500
Ferraris Group PLC 3878
Card Guard and Group 4000
This concerning with analyzing the major components used in the design of
the Portable ECG data logger machine. The major components used are:
GAIN
20
TEMPERATURE RANGE
o
Specified performance -25 C
+85
o
Storage C
-65
+150
POWER SUPPLY
Interrupts 14
21
Table I/O Ports Ports A,B,C,D,E 4.7
Timers 3
22
Fig 4.4 PIC18F455O pin diagram (Microchip Technology Inc. 2001)
23
OSC2/CLKOUT 14 Oscillator crystal output.
RA1/AN1 3
RA2/AN2/VREF- 4
RA3/AN3/VREF+ 5
RA4/T0CKI 6
RA5/SS/AN4 7
RB0/INT 33 PORTB is a bi-directional I/O port.
PORTB can be software programmed
RB1 34 for internal weak pull-up on all inputs.
RB2 35
RB3/PGM 36
RB4 37
RB5 38
RB6/PGC 39
RB7/PGD 40
RC0/T1OSO/T1CKI 15 PORTC is a bi-directional I/O port.
RC1/T1OSI/CCP2 16
RC2/CCP1 17
RC3/SCK/SCL 18
RC4/SDI/SDA 23
RC5/SDO 24
24
RC6/TX/CK 25
RC7/RX/DT 26
RD2/PSP2 21
RD3/PSP3 22
RD4/PSP4 27
RD5/PSP5 28
RD6/PSP6
RE0/RD/AN5, PORTE is a bi-directional I/O port.
RE1/WR/AN6
RE2/CS/AN7
The figure below shows the posterior view of 128 x 64 Dots Graphic LCD
25
Fig 4.5 128 x 64 Dots Graphic LCD (Vishay, 2002).
4.2.4 SD card
(i) SD cards are highly integrated flash memories with serial and random
access capability.
(ii) It is accessible via a dedicated serial interface optimized for fast and
reliable data transmission.
27
Fig 4.6 SD card block diagram (King Max Digital Inc. 2000)
CHAPTER FIVE
5.0 DATA ANALYSIS AND PROPOSED SYSTEM DESIGN
5.1 Introduction
Analyzing collected data to obtain the suitable Instrumentation amplifier
AD624AD for the ECG unit, Microcontroller unit, Graphics Liquid Crystal
Display (GLCD) and Multi Media Card (MMC).
The cardiovascular electrical activity of human heart lies between 10µV and
5mV with normal peak 1mV (D. Jennings, 1995). Signal from the ECG unit
must be amplified to reach the level which is suitable for PIC microcontroller
operation which lies between 2V to 5.5V (Analog Devices, Inc., 1999). Since
the Instrumentation amplifier is the pin programmable gain. According to the
raw cardiovascular voltage level we need a gain of a 1000 so that it can reach
to the level required for PIC microcontroller operation. For gains of 1000
short RG1 to pin 12 and pins 11 and 13 to RG2 as shown on figure 5.1.
28
Output volt = Gain × Input volt
= 1000× 4mV
Output volt = 4V
For normal operation the current that cannot affect the human body should
not be greater than 1mA and also the maximum value of the dc voltage that
can be back if the system misbehave even when the ac mains is used it is
about 47 V.
Maximum dc voltage = 47 V
V/R < mA
47V / 1mA< R
47 K < R For the standard value of the resisitors the value of R=47K was
selected
29
F
i
g
30
we need a low pass filter of a bout 35Hz cut off frequency since the pure
ECG signal has frequency below 35 Hz.
R= 1/ (2π×35 Hz×0.1µF)
R= 45.47 kΩ
We use the cascaded filter network in order to obtain sharp cut off frequency
so as to reduce the attenuation for the passband signal.
R= 1/ (2π×35 Hz×1µF)
R= 4.547 kΩ
The circuit diagrams below shows the designed cascaded filter network and
the frequency response for single and cascaded filter network. From the
frequency response of the network it shows that, for single filter network the
passband signal has gentle slope which means there is attenuation
encountered while for the cascaded filter network less attenuation is
observed.
31
Fig 5.2 Diagram showing designed filter network.
Fig 5.3 Diagram showing frequency response for the designed filter network.
Scale
And add a pull–up resistor connected to the +9 volt supply to bring the DC
level to a positive value of about 2 volts. A 680 k ohm resistor was used since
the resistance across the ADC (forming the other leg of the voltage divider)
measured to be about 180 k ohms.
32
2V= 180k / (R1 + 180k)
R≈680k
BAT1
9.0 V
R1
pull up resistor 680k
R2
180k
Vo
The below diagram shows the overall designed ECG unit. The input to the
electrodes was used signal generators for both left and right inputs with the
electrical parameters set around similar to raw ECG signal electrical parameter.
The input amplitude for the signal generators which acts as the ECG unit input
was set around 4mV with frequency 29 Hz. From the oscilloscope, the output
volt was found to be 4V which is the expected value after a 1000 voltage gain
of AD624AD amplifier and it is suitable value for PIC microcontroller
operation. The diagram below shows the designed circuit for the ECG unit with
the oscilloscope showing the input and output voltages.
33
BAT1
9.0V
C1
v+ 0.1U
7 U1
R1 C5 R5
1 6 0.1U 680K
IN+ VS- REF
3
47.0K RG2
11
G=500 C4
12 9 R3 R4
G=200 OUTPUT
v- 13
G=100
R2 16
RG1 4.7K 47k
2 10 1U
IN- SENSE
47.0K
5 14
RV1 IPNULL2 OPNULL2
4
IPNULL1 OPNULL1
15 C3
VS+ 1U
10K
8 AD624
BAT2
9.0V
C2 A
B
0.1U
C
34
Fig 5.6 Diagram showing ECG unit input and output
waveforms
Scale
The table below shows the recommended capacitor selection for crystal
oscillator
= Vdd / R
=5V/ 10kΩ
=0.5mA
The figure below shows the connection for the set-up of the master clear reset
(MCLR).
U3
2 15
RA0/AN0 RC0/T1OSO/T1CKI
3 16
RA1/AN1 RC1/T1OSI/CCP2/UOE
4 17
RA2/AN2/VREF-/CVREF RC2/CCP1/P1A
5 23
RA3/AN3/VREF+ RC4/D-/VM
6 24
RA4/T0CKI/C1OUT/RCV RC5/D+/VP
7 25
RA5/AN4/SS/LVDIN/C2OUT RC6/TX/CK
14 26
RA6/OSC2/CLKO RC7/RX/DT/SDO
13
OSC1/CLKI
33 19
RB0/AN12/INT0/FLT0/SDI/SDA RD0/SPP0
34 20
RB1/AN10/INT1/SCK/SCL RD1/SPP1
35 21
RB2/AN8/INT2/VMO RD2/SPP2
36 22
RB3/AN9/CCP2/VPO RD3/SPP3
37 27
RB4/AN11/KBI0/CSSPP RD4/SPP4
38 28
RB5/KBI1/PGM RD5/SPP5/P1B
39 29
RB6/KBI2/PGC RD6/SPP6/P1C
40
RB7/KBI3/PGD RD7/SPP7/P1D
30 R16
47.0K
8
RE0/AN5/CK1SPP
9
RE1/AN6/CK2SPP
10
RE2/AN7/OESPP
18 1
VUSB RE3/MCLR/VPP
PIC18F4550
This is the part responsible for displaying the real time wave form. By
varying resistance of the potentiometer connected to the VEE terminal
of the display will result into fluctuation of the current entering the
37
microcontroller hence the contrast. 128×64 GLCD is made up of
small element of picture known as pixels. For 128×64 GLCD it is
made up of 128 pixel rows and 64 pixel columns. The waveform are
displayed in such a way that PIC microcontroller tends to illuminate
certain pixel point. Since the microcontroller was set to 0.5ms rate
reading analog signal for reading the analog signal and illuminate the
respective pixel point. After a series of illumination of consecutive
pixels, they form a waveform which will be seen on the display. After
reaching the end of the display the clear command is called and the
operation restarted again.
38
Fig 5.8 Simulation of diplay for ECG circuit
(iv) SD Card
This is the memory device which is responsible for logging the real time
waveform. The data are logged in ASCII Hexadecimal format. Special
software will be used to retrieve the logged data in a format that can be
analyzed. Some of software applications which can convert the ASCII
Hexadecimal data format into waveform are Microsoft Excel and Matlab. The
SD card uses the SPI communication mode to the microcontroller. Since SPI
mode communication work with the 3V, we should design a mechanism that
will step down the 5V from the microcontroller to the desired volt which is
3V. The potential divider network which will divide 3V going to the SD card
and 2V to the other network was designed.
=3.3k/ (2.2k+3.3k) × 5V
=3V
39
Fig 5.9 SD card potential divider network
These SD cards are highly integrated flash memories with serial and random
access capability. It is accessible via a dedicated serial interface optimized for
fast and reliable data transmission. The SD card system is a new mass-storage
system based on innovations in semiconductor technology. All units these SD
card are clocked by an internal clock generator. The interface driver unit
synchronizes the DAT and CMD signals from external CLK to the internal
used clock signal. The communication using the SD card lines to access either
the memory field or the register is defined by the SD card standard. The card
has its own power on detected unit. No additional master reset signal is
required to setup the card after power on. It is protected against short circuit
during insertion and removal while the SD card system is power up. No
external programming Voltage supply is required. The programming voltage is
generated on card. These SD card support a second interface operation mode
the SPI interface mode. The SPI mode is active if the CS signal is asserted
(negative) during the reception of the reset command (CMD0). SPI mode is
used as the SD card. Interface SPI mode allows easy and common interface for
SPI channel. The disadvantage of this mode is loss performance, relatively to
the SD mode. The SPI bus allows one bit data line by 2-chanel (Data In and
Out). The SPI compatible mode allows the MMC Host systems to use SD card
with little change. SPI mode is byte transfers. All the data token are multiples
40
of the bytes (8 bit) and always byte aligned to the CS signal. The advantage of
the SPI mode is reducing the host design in effort. Especially, MMC host can
be modified with little change. The data logger circuit was designed in a way
that the ECG unit output was connected to the PIC microcontroller which will
convert the analog signal to the suitable format that will be logged by the
memory device and the program was designed to enhance that operation. The
designed circuit and the program software flow chart are as shown in Fig 5.9
and Fig 5.1 below. After simulation of the designed circuit the signal indicator
for the SD card data input line was blinking in pink color indicating that there
is the input signal in that line.
The results obtained are stored in the SD card in ASCII Hexadecimal format.
Special software tools will be used to convert the ASCII Hexadecimal data in
waveform, hence can be interpreted.
MMC_Din
MMC_CS
M1
R15 R11
CS
Multimedia
R10 3.3k 2.2k R12
Card
DI
R13 3.3k 2.2k R14 DO
CLK
3.3k 2.2k
RV2 MMC
10K
C8 BAT1
MMC_SCK
MMC_Dout
U2 R8
0.1uF 8 680K
9V
VS+ C2 D1
R4(1) 4 15
IPNULL1 OPNULL1
5
IPNULL2 OPNULL2
14 0.1uF D2
R4 C9 1N4148 1N4148
2 10 R6 R7
IN- SENSE
47k 16
RG1 U1
R5(1) 13 R3
G=100 4.7K 47k
12 9 1u 2 15
G=200 OUTPUT RA0/AN0 RC0/T1OSO/T1CKI
11 33R 3 16
G=500 RA1/AN1 RC1/T1OSI/CCP2/UOE
R5 3
RG2 C7 4
RA2/AN2/VREF-/CVREF RC2/CCP1/P1A
17
1 6 1uF 5 23
IN+ VS- REF RA3/AN3/VREF+ RC4/D-/VM
47k 6 24
RA4/T0CKI/C1OUT/RCV RC5/D+/VP
7 25
RA5/AN4/SS/LVDIN/C2OUT RC6/TX/CK
7 AD624 14 26
RA6/OSC2/CLKO RC7/RX/DT/SDO MMC_Din
BAT2 13
OSC1/CLKI
33 19
MMC_Dout RB0/AN12/INT0/FLT0/SDI/SDA RD0/SPP0
34 20
MMC_SCK RB1/AN10/INT1/SCK/SCL RD1/SPP1
35 21
C6 9V MMC_CS RB2/AN8/INT2/VMO RD2/SPP2
R9 36 22
RB3/AN9/CCP2/VPO RD3/SPP3
37 27
RB4/AN11/KBI0/CSSPP RD4/SPP4
100 38 28
RB5/KBI1/PGM RD5/SPP5/P1B
0.1uF 39 29
RB6/KBI2/PGC RD6/SPP6/P1C
40 30
RB7/KBI3/PGD RD7/SPP7/P1D
8
RE0/AN5/CK1SPP
MCLR
9
VDD RE1/AN6/CK2SPP
10
RE2/AN7/OESPP
18 1
VUSB VUSB RE3/MCLR/VPP MCLR
R1 PIC18F4550
1k
41
Declare the MMC module
ADC function
42
Write data to the SD card
The software comprise of two main functions which are function for
displaying the real time waveform and another function to log the
data. The software is based on mikroC language, developed by
mikroElektronika for PIC microcontrollers. The main reasons for
choosing this microcontroller are that:
43
Start
ADC function
44
The circuit diagram of the whole system after designing according to
parameters given is as shown below.
VDD
LCD1
AMPIRE128X64
J3_LCD
MMC_Din
MMC_CS
1
GND
2
VDD
3
LCD_VO
4 VCC
LCD_RS
5
LCD_RW
6
LCD_E
7
LCD_DB0
8
LCD_DB1 VDD
9
LCD_DB2 C5 GND
10 1000u
LCD_DB3
M1 11
-Vout
GND
LCD_DB4
VCC
RST
DB7
DB6
DB5
DB4
DB3
DB2
DB1
DB0
CS2
CS1
PW M_BL_LCD
R/W
12
RS
R15 R11
V0
LCD_DB5
E
13
CS LCD_DB6
Multimedia
R10 R12 14
3.3k 2.2k LCD_DB7
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
15
Card
DI LCD_CS1
R13 R14 16
3.3k 2.2k DO LCD_CS2 GND VSS
17
CLK LCD_RST
18
MMC_Dout
3.3k 2.2k LCD_VOUT_VEE
19
LCD_VOUT_VEE
LCD_E
LCD_RS
LCD_VO
LCD_RST
VDD
GND
LCD_DB7
LCD_DB6
LCD_DB5
LCD_DB4
LCD_DB3
LCD_DB2
LCD_DB1
LCD_DB0
LCD_CS2
LCD_CS1
LCD_RW
MMC BACKLIGHT
20
MMC_SCK
SIL-100-20
C8 LCD_VO
RV2 BAT1 R2
10K 0.1uF 9V 1k
RV1
Q1
53%
LCD_VOUT_VEE 1k
BD139
8 U2
R8
VS+ 680K D1
R4(1) 4 15
IPNULL1 OPNULL1 BACKLIGHT
5
IPNULL2 OPNULL2
14 D2
R4 C9 1N4148 1N4148
2 10 R6 R7
IN- SENSE
47k 16
RG1 U1
R5(1) 13 R3
G=100 4.7K 47k
12 9 1u 2 15
G=200 OUTPUT RA0/AN0 RC0/T1OSO/T1CKI LCD_RS
11
G=500 C2 33R 3
RA1/AN1 RC1/T1OSI/CCP2/UOE
16
LCD_RW
R5 3
RG2 C7 LCD_E
4
RA2/AN2/VREF-/CVREF RC2/CCP1/P1A
17
PWM_BL_LCD
1 6 1uF 0.1uF 5 23
IN+ VS- REF LCD_CS1 RA3/AN3/VREF+ RC4/D-/VM USB_DN-
47k 6 24
LCD_CS2 RA4/T0CKI/C1OUT/RCV RC5/D+/VP USB_DP+
7 25
LCD_RST RA5/AN4/SS/LVDIN/C2OUT RC6/TX/CK
7 AD624 14 26
OSC2 RA6/OSC2/CLKO RC7/RX/DT/SDO MMC_Dout
BAT2 OSC1
13
OSC1/CLKI
33 19
MMC_Din RB0/AN12/INT0/FLT0/SDI/SDA RD0/SPP0 LCD_DB0
34 20
MMC_SCK RB1/AN10/INT1/SCK/SCL RD1/SPP1 LCD_DB1
35 21
C6 9V MMC_CS RB2/AN8/INT2/VMO RD2/SPP2 LCD_DB2
36 22
VUSB
10
VDD RE2/AN7/OESPP
100u 22p 18 1
VUSB VUSB RE3/MCLR/VPP MCLR
X1
20MHz PIC18F4550
R1 C4
OSC1
1k
22p
GND VSS
CHAPTER SIX
6.0 SYSTEM TEST AND IMPLEMENTATION
After designing the system the an implementation was followed and finally
testing the results.
45
6.1 System Implementation
Fig 6.0 The diagram showing the top and bottom layer designed PCB
After designing the PCB, etching process was following. The etching
process was conducted through a series of steps which are as follows:
First the designed PCB file was printed to the thin transparent plastic
46
sheet. Then the plastic sheet was attached to the clade board on the
copper surface and placed in the UV machine for about 5 minutes and
removed. The second step is to develop the board by using
development chemical which is (Sodium Hydroxide) NaOH and wash
the board in clean water.
The last step is to cean the board using the Ammonium Hydroxide.
Then the board is ready for component placement and soldering.
The system was tested with respect to the basic parts which are ECG unit,
display unit and the logging unit.
The ECG unit simulation test was responding as the system design
where the unit was amplifying the small sgnal of about 4mV from the
generators to the desired value of about 4V. An implemented ECG
unit was tested using the computer oscilloscope software known as
Zelscope. The three ECG electrodes was placed on the left and right
side of the chest and the third electrode on the left leg. Then their
output are inserted to the ECG circuit board. An output from the ECG
unit was tapped through the jack pin and inserted to the PC. The
results was analysed using Zelscope software and are in such a way
that the signal waveform was looking similar in ECG waveform but
with weak amplitude. Factors that may cause the signal to become
weak may be due to:
The display unit was tested in both in simulation and prototype level.
During simulation the signal from the ECG unit was able to be
47
displayed on the Graphiccs LCD module. Circuit prototype
implementation is in progress.
The data logger was tested in both in simulation and prototype level.
During simulation the SD module connected to the PIC was able to log
the data from the PIC since the SD card data input line indicator from
the PIC was active meaning there are data come from the PIC into the
SD card and the clock signal line indicator was active also meaning
there is an undergoing synchonization of the memory device and the
PIC clock.
The ECG data logger was designed to take the raw ECG signal from the
human body and both to be displayed and to be logged to the multi
media card. Since the display and the logging units was designed
separately and tested to give the expected results, then both display and
the logging units was combined to work using the same PIC
microcontroller. The combination of the display unit and the logging
unit is done through combining the the designed programs for the
display and for the logging unit hence both units will share the same
PIC for their operation. The process must be done in such a way that
there must in synchronization in operation for the programs in order to
abstain PIC from confusion. The program was designed to the point that
it compiled with no error. But on the electronic design software the
uploaded hex file to the PIC generate two errors, on the KS0108B
which is the GLCD controller and the second oerror concerning PIC
ADC instructions executions. The first error which is [KS0108B]
Attempt a write operation while busy flag is set. The error indicates that
the PIC is the GLCD controller is performing a write operatioon while
there is already another execution of another instruction. The second
error is [PIC ADC] ADC conversion started before the wait time has
expired. These errors may be due to a PIC failure to operate to operate
two instructions in real time processing. The overall system prototype
test is in progress.
48
CHAPTER SEVEN
7.0 CONCLUSION AND RECOMMENDATION
7.1 Conclusion
The electrocardiography data logger machine was partitioned in three major
parts which are ECG unit which is responsible for extracting real time raw
ECG signal and to bring it to desired level appropriate for PIC operation. This
part was designed successfully with the expected results. But on
implementation the signal was found to be weak, the reason for this it might
be due to misbehave of the instrumentation amplifier. The second part which
is the display unit was also designed and tested and found to work properly.
Where the raw real time signal from the ECG unit are able to be displayed on
the graphics display. The designed circuit was implemented and it is able to
display the real time waveform. The third part is the logging unit which was
designed and tested on the simulation software. The simulation results of the
logging unit was observed and the input data line was active showing that
data are stored. The logging unit implementation is on progress. The overall
ECG data logger system will be formed by combining the ECG, display unit
and the logging unit prototypes after successfully completion the logging
unit. This project is progressive and have applications in various sectors such
as health facilities, researchers and education institutions. Other systems may
be incorporated with the portable ECG machine data logger, for example
wireless communication technology such as zigbee.
7.2 Recommendation
Portable electrocardiography data logger performs two real time operations
simultaneously which are real time display and real time data storage. The
use of high powerful microcontroller is recommended. Also for better signal
analysis the display with great resolution is recommended. Since there is the
rise of Non-communicable diseases and there is poor ratio of health
49
professions against people, we recommend introduction of tele-health system
in Tanzania. Many Non-communicable diseases require high frequency
attendance to the health facilities, thus consuming large time of an individual.
This can lead to reduction in production to our country. But tele-health can
help to reduce such amount of time.
APPENDICES
APPENDIX A: SOFTWARE PROGRAM CODE
// Glcd module connections
char GLCD_DataPort at PORTd;
50
sbit GLCD_CS1 at lata3_bit;
sbit GLCD_CS2 at lata4_bit;
sbit GLCD_RS at latc0_bit;
sbit GLCD_RW at latc1_bit;
sbit GLCD_EN at lata2_bit;
sbit GLCD_RST at lata5_bit;
//global variables
char filename[]="ECG";
unsigned char voltin[10];
unsigned short adread[140];
unsigned int ff;
unsigned int ffw;
unsigned short mmax;
unsigned short mmin;
unsigned short ifdmmin;
int mint1;
int mint2;
unsigned int freq1[2];
unsigned int freq2[2];
unsigned int freq3[2];
unsigned int freqoencc;
unsigned int maxduty[2];
unsigned short ferbit ;
unsigned int resadc ;
unsigned short dutycyclee;
unsigned int adcreading ;
char otxt1[8];
char otxt2[8];
char otxt3[8];
char otxt4[8];
char otxt5[8];
char otxt6[8];
//read analog signal from the analog input A0(signal from the ECG unit)
void read_voltin()
{
unsigned long voltin;
voltin=Adc_Read(0);
}
void main() {
adcon0=0b100000000; //Configure channel ANO as the analog to digital converter
ADCON1 = 0b00001110; //Set all pins to digital I/O except RA0/AN0.
ADCON2 = 0b000000 ; // TAD - FOSC/2
trisa=255; //configure all PORTA as input ANSELA=0x80;
51
trisa3_bit=0; //configure bit PORTA3
trisa4_bit=0;
trisa5_bit=0;
trisc=0;
trisd=0;
CMCON = 0x07; // Comparators "off"
CCP1CON = 0;
CCP2CON = 0;
SSPCON1 = 0;
PWM1_Init(5000); // '5000Hz
PWM1_Set_Duty(120); //' from 0 to 255, where 0 is 0%, 127 is 50%, and 255 is 100% duty ratio
PWM1_Start();
delay_ms(10);
ADC_Init();
delay_ms(10);
delay_ms(100);
Glcd_Init();
delay_ms(200);
Glcd_Fill(0x00);
Glcd_Set_Font(System3x5 , 3, 5, 32);
Glcd_Write_Text("3X5 FONT (V2)", 0, 0, 1);
delay_ms(500);
for ( ffw = 0 ; ffw < 1400 ; ffw++ ) {
adread[ffw]=(ADC_Read(0) / 4);
}
mmin = adread[5];
mmax = adread[5];
for ( ffw = 0 ; ffw < 1400 ; ffw++ ) {
mmin = min(mmin,adread[ffw]);
mmax = max(mmax,adread[ffw]);
}
ferbit = 0 ;
freq1[0] = 0 ;
freq2[0] = 0 ;
freq3[0] = 0 ;
freq1[1] = 0 ;
freq2[1] = 0 ;
freq3[1] = 0 ;
for ( ffw = 0 ; ffw < 140 ; ffw++ ) {
freq2[0] = ((mmax - mmin)/2) ;
freq2[1] = ((adread[ffw] - mmin)) ;
ifdmmin = 5;
if (freq2[1] <= freq2[0]) {
ifdmmin = 0 ;
}
if (ifdmmin == 0) {
if (ferbit == 0) {
++freq3[0] ;
freq1[0] = 1 ;
}
}
if (ifdmmin > 0) {
if (freq1[0] == 1) {
ferbit = 1 ;
}
}
52
if (ifdmmin == 0) {
if (ferbit == 1) {
++freq3[1] ;
freq1[0] = 2 ;
}
}
if (ifdmmin > 0) {
if (freq1[0] == 2) {
ferbit = 3 ;
}
}
}
maxduty[0] = max(freq3[1],freq3[0]);
ferbit = 0 ;
freq1[0] = 0 ;
freq2[0] = 0 ;
freq3[0] = 0 ;
freq1[1] = 0 ;
freq2[1] = 0 ;
freq3[1] = 0 ;
for ( ffw = 0 ; ffw < 1400 ; ffw++ ) {
freq2[0] = ((mmax - mmin)/2) ;
freq2[1] = ((adread[ffw] - mmin)) ;
ifdmmin = 5;
if (freq2[1] >= freq2[0]) {
ifdmmin = 0 ;
}
if (ifdmmin == 0) {
if (ferbit == 0) {
++freq3[0] ;
freq1[0] = 1 ;
}
}
if (ifdmmin > 0) {
if (freq1[0] == 1) {
ferbit = 1 ;
}
}
if (ifdmmin == 0) {
if (ferbit == 1) {
++freq3[1] ;
freq1[0] = 2 ;
}
}
if (ifdmmin > 0) {
if (freq1[0] == 2) {
ferbit = 3 ;
}
}
}
maxduty[1] = max(freq3[1],freq3[0]);
freq3[0] = maxduty[1] ;
freq3[1] = maxduty[0] ;
if (maxduty[1] > maxduty[0] ) {
dutycyclee = ((freq3[1]+0.001)/(freq3[0]))*50 ;
dutycyclee = 100 - dutycyclee ;
53
}
if (maxduty[1] < maxduty[0] ) {
dutycyclee = ((freq3[0]+0.001)/(freq3[1]))*50 ;
}
if (maxduty[1] == maxduty[0] ) {
dutycyclee = 50 ;
}
bytetostr(dutycyclee,otxt5);
if (maxduty[1]<5) {
strcpy(otxt2,"?");
}
if (maxduty[0]<5) {
strcpy(otxt2,"?");
}
resadc = maxduty[1]+maxduty[0] ;
freqoencc = ( 14000 ) / resadc ;
if (resadc>1000) {
resadc = 1000 ;
}
inttostr(freqoencc,otxt6);
// 255 / 5 = 51
mint1 = ((mmin*10)/510) ;
mint2 = ((mmin*10)%510)/10 ; // mint2 = ((mmin*10)%512)/10
inttostr(mint1,otxt1);
inttostr(mint2,otxt2);
mint1 = ((mmax*10)/510) ;
mint2 = ((mmax*10)%510)/10 ; // mint2 = ((mmax*10)%512)/10
inttostr(mint1,otxt3);
inttostr(mint2,otxt4);
for ( ffw = 0 ; ffw < 129 ; ffw++ ) {
adread[ffw]=(ADC_Read(0) / 16);
}
if (resadc > 40 ) {
if (0<freqoencc) {
if (freqoencc<100) {
resadc = (resadc*2)+(resadc/10) ;
}
}
if (freqoencc>99) {
resadc = (resadc)+(resadc/10);
}
for ( ffw = 0 ; ffw < 129 ; ffw++ ) {
adread[ffw]=(ADC_Read(0) / 16);
for ( ff = 0 ; ff < resadc ; ff++ ) {
// delay_us(10);
//asm nop ;
} }}
REFERENCES
[1] Wikipedia,Electrocardiography.(2013).en.wikipedia.org/wiki/Electrocardiograp
hy. Retrieved August 20th, 2013.
55
[2] Picotech,electrocardiography.(2012)
http://www.picotech.com/applications/ecg.html. Retrieved November 26th,
2013.
[3] D. Jennings, A. Flitch, B.C.H Turton and L.D.M Nokes. (1995). Edward
Arnolds. Introduction to medical electronics applications.
[4] F. Morris, J. Edhouse, BMJ Books. W.J. Brady, J. Conn. (2003). BMJ Books
ABC of clinical Electrocardiography.
[5] P. Davidovits. (2013). Academic Press (4th Ed). Physics in Biology and
Medicine. Retrieved from http://booksite.elsevier.com/9780123865137
[6] Mendis S, Puska P, Norrving, B editors. World Health Organization, Geneva.
(2011).Global Atlas on Cardiovascular Disease Prevention and Control.
[7] National Bureau of statistics Ministry of finance. (2011). The united republic of
Tanzania, Basic facts and figures on human settlements Tanzania mainland
2009.
[8] Analog Devices Inc. (1999). Retrieved March 13rd, 2013 from
http://www.analog.com/static/imported-
files/data_sheets/AD624SD_883B.pdf?doc=AD624pdf&po=
[9] DS30292C. Microchip Technology Inc. (2001). Retrieved November 18th,2014
from http://www1.microchip.com/downloads/en/DeviceDoc/30292c.pdf
[10] Kingmax Digital Inc. (2000). SD card specification. Retrieved February 28th,
2014 from
http://www.kingmax.com/FAQ_files/20130225_EOL%20note_%20sd.pdf
[11] I.Dogan, Microcontroller and SD Card based multichannel data logger (2008).
Retrieved March 27th, 2014 from http://www.electronicsworld.co.uk
56