You are on page 1of 57

DAR ES SALAAM INSTITUTE OF TECHNOLOGY

ELECTRONICS AND TELECOMMUNICATION ENGINEERING DEPARTMENT


BACHELOR OF ENGINEERING IN ELECTRONICS AND TELECOMMUNICATION
NTA- LEVEL 8
EET-013-022
SENIOR PROJECT TWO

TITLE: THE DESIGN OF THE PORTABLE ELECTROCARDIOGRAPHY DATA


LOGGER MACHINE

PROJECT TYPE: DESIGNING

NAME OF CANDIDATES: MASHIMBA SELIKO 100602G8417


EMMANUEL KAJANGE 100602G8401

MAY 2014
CHAPTER ONE
1.0 INTRODUCTION

1.1 Background Information

Electrocardiography (ECG) machine is the device used to detect and interpret


the electrical activity of the heart over a period of time, as detected by
electrodes attached to the surface of the skin and recorded by a device. The
recording produced by this noninvasive procedure is termed an
electrocardiography (also ECG or EKG). An ECG is used to measure the rate
and regularity of heartbeats, as well as the size and position of the chambers,
the presence of any damage to the heart, and the effects of drugs or devices
used to regulate the heart, such as a pacemaker. Most ECGs are performed for
diagnostic or research purposes on human hearts, but may also be performed
on animals, usually for diagnosis of heart abnormalities or research. An ECG
produces a pattern reflecting the electrical activity of the heart and usually
requires a trained clinician to interpret it in the context of the signs and
symptoms the patient presents with. (Wikipedia, 2013). Modern ECG
machines are compatible with computer that contains the special software
such as MATLAB that can be used for ECG data analysis. Also there are
ECG machines that have been incorporated with printers for printing the ECG
results on the paper that can assist the clinician to identify the problem. Also
it can give information regarding the rhythm of the heart, the balance of salts
in the blood also it can identify if the heart has been damaged in a specific
area and hence it make easier for the medical officers to determine the
problem.
The activity of taking ECG signal in our country require a patient or a person
who perform clinic routine to have directly regular visit to medical laboratory
where the laboratory technician will lead the process and the printed results
are collected to doctor for interpretation. There is the need of the portable
ECG data logger machine which can be affordable by an individual. This will
enable a person to perform self-measurement while the device logs the
measured information in the desired memory device compatible to computer.
Then the stored data can be submitted to the hospital for clinician to interpret
the measured information.

i. ECG potentials are relatively easy to measure


ii. The ECG is an extremely useful indicator for both screening and
diagnosis.
iii. Certain abnormalities of the ECG are quite well defined and can be
readily identified.

1
1.2 Problem Statement

People faces difficulties on analyzing their health status especially heart


disorders due to remote location of health facilities and shortage of the health
professionals which lead to poor health services. Also the ratio of the health
facilities and health professions to the total population is poor. (NBS,
2009).There is shortage of the Electrocardiography (ECG) machines in many
hospitals due to the fact that these machines are so expensive. There are some
heart disorders which are difficult to identify in a short period of time and
require a person to be in the hospital for long time for measurement. The
patient is asked to keep a detailed diary of their daily activates and symptoms
so that a correlation can be made between these and the heartbeat signal. For
patients having more transient symptoms it is difficult to have regular
checkup for longtime due to the fact that the ECG machine is shared by many
people, where the measurement is performed for short interval of time for
each person.

1.3 Objectives

1.3.1 Main objective


To design a portable electrocardiography (ECG) data logger machine.

1.3.2 Specific objectives

To design a system which will have an ability to acquire and process


cardiovascular system electrical activity.

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.

1.4 Scope and Limitation

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.

1.5 Significance of the Project

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.

2.1 Existing System

2.1.1 ECG embedded with printout machine


This consists of an ECG machine embedded together with the printer. After
attaching electrodes to patient, the machine takes the reading and the result
printed to the graph paper. The printed results are taken to the health
profession for interpretation. This machine may have the display for
displaying real time data. These machines are present in some hospitals in our
country mainly referral hospitals and some private hospitals but rarely
available in some district hospitals and not available in local health centers.

Fig 2.1 Block diagram of the ECG with printout machine.

2.1.2 Advantages of the ECG with printout machine

(i) Accuracy readings


Test is taken by the professional person and hence accurate
measurements are obtained.

4
2.1.3 Disadvantage of the ECG with printout machine

(i) Time consuming


Since it require a person to have regular visit to the laboratory so as to
take the measurement. Since the machine is shared by many people at
the hospital, it will -consume a lot of time in case there are many people
waiting for measurement service.
(ii) High cost
The existing system is costly that has limited availability especially in
local hospitals and difficult to be owned by an individual. The machines
are only available in few health facilities mainly referral hospitals,
special hospitals, regional hospitals, and some district hospitals but not
available health centers.
(iii) Result storage
Since results are in printed paper it requires thorough attention on
keeping records since it is easily destroyed and difficult to duplicate. It
is important to store ECG information in electronic way since it is not
easily to be destructed and can be stored for the long time. Also the
ECG information can be transmitted in electronic way for large distance
in a short time and safely electronically, since the results are required to
submitted to the health professions for analysis.

(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.

2.1.4 Portable ECG machine

There are also portable ECG machine incorporated with the display where by
a person can perform self-measurement.

2.1.5 Advantages of portable ECG machine


(i) The machine is portable that measurement can be even taken at home or
any place rather than medical laboratory.
(ii) Simple to use that any person can take measurement.
5
2.1.6 Disadvantages of portable ECG machine

(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.

2.2 Proposed System

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.

2.2.1 Proposed system block description


The followings is the description of the blocks 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.

The heart beat raw signal have characteristics as follows:

Voltage =10uV to 5mV with normal peak volt 1mV.

Bandwidth = 1 kHz max (D. Jennings, 1995)

2.2.3 ECG unit system


The ECG system receives the electrical signal from an input, then process and
conditions it so that the signal can be used for the further systems. Signal
processing and conditioning involve filtering of the signal to the desired
frequency by using appropriate filter and amplification of the signal to the
desired level using precision instrumentation amplifier. The instrumentation

7
amplifier have large amount of gain and very high common mode rejection
ration to eliminate errors.

2.2.4 Control unit


The control unit receives signal from the ECG system and process that signal
to the desired format that can be displayed and stored in logging system.
Appropriate program is written and uploaded to the microcontroller. The
program contains commands which will instruct the microcontroller the
formats to output to the display and the logger device.

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.

2.2.6 Data logger


Data logger is the memory device that receives data from the control unit and
stores the measured data for specific period of time depending on the storage
capacity so that can -be used for further analysis. The storage unit can be
taken to the health profession for analysis.

2.2.7 Advantages of the proposed system


(i) Time saving

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

The system is portable that measurement can be taken easily in various


places such as home, working place without disturbance. The machine
portability will enable a person to take measurement at different place

8
from the medical laboratory and it is possible to perform controlled
measurement.

(iii) Easy to use

The machine is friendly use that any person performs measurement. It


does not require great knowledge to use the ECG machine.

(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:

(i) Literature review and consultation


(ii) Data collection
(iii) Data analysis
(iv) Circuit design
(v) Programming of programmable devices
9
(vi) Circuit simulation
(vii) Building prototype and testing

3.1 Literature Review and Consultation


This part described the features, operation and limitations of the existing
systems. It also explained about the proposed system including all necessary
information relating with the accomplishment of the project design. And also
this part provided the necessary knowledge and information which help
during design of the project these information’s were obtained through
reading different relevant materials, consulting our supervisors and other staff
member from DIT, consulting the bio medics engineer from the ministry of
health and social welfare and also through surfing from the internet.

3.2 Data Collection


The data collection part describes the data collected. Data collection was
done through questionnaires, reading books, surfing the internet and
consulting some experts in cardiac diseases from Muhimbili national hospital
and expert in biomedical equipment for more technical data.

3.3 Data Analysis

Data analysis and design shows how the various data that have been collected
were related to the design of the function.

3.4 Circuit Design


The design of the circuit will depend on the information from the data
collection and the data analysis and also the requirements of the system.

3.5 Programming of Programmable Devices

This includes the microcontroller programming. It will be done at the end of


the project so as to enable the system to operate properly according to the
requirement of the system.

3.6 Circuit Simulation

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

Circuit will be implemented in the board and tested if it is working properly.


In case of any problem, then some corrections will be noted and done and
then implementing the circuit on the circuit board.

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.

4.1 Primary Data

4.1.1 Number of health facilities in Tanzania and ratio of facilities


with ECG machines

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).

Type of Number Number of health professionals Shortage


facilities of Required Available Shortage percentage
facilities

Referrals/ 8 8546 4,477 4,069 48


specialized
hospitals
Regional 19 7266 2,481 4,785 66
hospitals
District 95 22,458 7,364 15,094 67
hospitals
including DDH

Health centers 331 11,916 4,908 7,008 59


Dispensaries 3,038 30,380 9,384 20,996 69

Training 72 1,711 449 1,262 74


institutions
Total 3,565 82,277 29,063 53,214 65

Table 4.2 Private health facilities by type and health professionals’


availability in Tanzania (NBS, Ministry of Finance, 2011).

Type of Number Number of health professionals Shortage


facilities of percentage
facilities Required Available Shortage

Hospitals 132 26,004 3,251 22,753 87.5

Health 150 5,400 758 4,642 86


centers

12
Dispensaries 1,641 11,487 1,842 9,645 84

Training 36 756 288 468 61.9


institutions

Total 1,959 43,647 6,139 37,503 85.9

4.1.2 ECG machines availability in Tanzania health facilities

The ECG machine availability in health facilities in Tanzania is in such a way


that, they are available from the regional hospital level to the referrals hospitals
although the number does not met requirement and the machines are least
available in the district level and not available in health center and dispensaries.

Table 4.3 ECG machines availability at different level of health facilitates

Name of facility Number of facility Availability Machine status per hospital

high medium low

Referrals and specialized hospitals 8 Yes

Regional hospitals 19 Yes

District hospitals including DDH 95 rare

Health centers 331 No _ _ _

Dispensary 3038 No _ _ _

13
Key

High Availability of ECG machine satisfy facility

Medium- availability of ECG at least satisfy the needs

Low- availability of ECG does not satisfy the needs

- ECG not available

4.1.3 Population per health professional’s ratio in Tanzania


mainland
The number of people served by one medical doctor was found to be very
high in three regions namely Kigoma (308,000), Mara (167,000) and Tabora
(132,000). The regions reported to have lowest populations per medical
doctor were Arusha (22,000), Dar-es-Salaam (24,000) and Pwani (32,000).
The national average was 64,000 persons per doctor, while the WHO
recommendation is for one doctor to serve a population of 10,000. In this
regard there is no single region which meets the WHO requirements. (NBS,
2011). The population per one medical doctor in each region is shown in
figure 4.4.

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.

4.1.4 Increase in deaths and diseases due to non-communicable


diseases
Cardiovascular diseases (CVDs) remain the biggest cause of deaths
worldwide. More than 17 million people died from CVDs in 2008. More than
3 million of these deaths occurred before the age of 60 and could have largely
15
been prevented. The percentage of premature deaths from CVDs ranges from
4% in high-income countries to 42% in low-income countries, leading to
growing inequalities in the occurrence and outcome of CVDs between
countries and populations. There are also new dimensions to this alarming
situation. Over the past two decades, deaths from CVDs have been declining
in high-income countries, but have increased at an health ministries may
spend more than half their budgets on treatment services which depend on
hospitals. As a result, a large proportion of people with high cardiovascular
risk remain undiagnosed, and even those diagnosed have insufficient access
to treatment at the primary health-care level; while evidence suggests two-
thirds of premature deaths due to NCDs including CVDs can be prevented by
primary prevention and another one-third by improving health systems to
respond more effectively and equitably to the healthcare needs of people with
NCDs. Addressing CVDs require concrete and sustained action in three areas
which represent the key components of any global or national strategy;
surveillance and monitoring, prevention and reduction of risk factors, and
improved management and astonishingly fast rate in low- and middle-income
countries (LMIC). CVDs are largely preventable. Both population wide
measures and improved access to individual health care interventions can
result in a major reduction in the health and socioeconomic burden caused by
these diseases and their risk factors. These interventions, which are evidence
based and cost effective, are described as best buys in the Global Status
Report on No communicable Diseases (NCDs) 2010. At present, public
health services in developing countries are overstretched by increasing
demands to cope with heart disease, stroke, cancer, diabetes and chronic
respiratory disease. At the same time, health care systems in many LMIC are
let down by a model based on hospital care focused on the treatment of
diseases, often centered around high-technology hospitals that provide
extensive treatment for only a small minority of citizens. Hospitals consume
huge amounts of resources, and health care through early detection and
timely treatment. (Global Atlas on Cardiovascular Disease Prevention and
Control. (S. Mendis et al, Geneva 2011)

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%

Fig 4.2 Distribution of major causes of death including CVDs (Mendis S.


World Health Organization, Geneva 2011).

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

Injuries Respiratory diseases


8%
Communicable,
maternal, perinatal
and nutritional Diabets
conditions
65%

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).

4.1.5 Time consumed in attending hospitals for taking ECG measurement

Table 4.4 Average time consumed during ECG measurement

18
Patient Time consumed during Frequency for attending
measurement (Hrs.). clinic
Condition Critical 24-48 Once per week

Non critical 1 Once per month

Normal person 1 Once per month

In the existing system, the ECG measurement require a person to attend


directly to the medical facility for taking measurement. Even though the
measurement taken are un appropriately since the exact time duration is mot
followed due to limited number of ECG machines which are shared by the
community, the portable ECG machine will enable a person to perform
measurement while continuing with normal life and also appropriate readings
will be obtained since the measurement may be enough for the health
profession to perform analysis. The table below from Fig 4.6 shows the
roughly time consumed during the measurement for both patient and normal
person performing routine clinical test.

4.1.6 ECG machines average cost

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

Company name Average cost (USD)

Phillips 4500
Ferraris Group PLC 3878
Card Guard and Group 4000

Welch Allyn Inc. 4750


19
4.2 Secondary Data Analysis

This concerning with analyzing the major components used in the design of
the Portable ECG data logger machine. The major components used are:

4.2.1 Instrumentation amplifier AD624

The AD624 is a high precision, low noise, instrumentation amplifier designed


primarily for use with low level transducers, including load cells, strain
gauges and pressure transducers. An outstanding combination of low noise,
high gain accuracy, low gain temperature coefficient and high linearity make
the AD624 ideal for use in high resolution data acquisition systems. The
AD624 does not need any external components for pretrimmed gains of 1,
100, 200, 500 and 1000. (Analog Devices, Inc., 1999)
AD624–SPECIFICATIONS (@ VS = 15 V, RL = 2 k and TA = +25C, unless
otherwise noted)

Table 4.6 Instrumentation amplifier AD624 specification (Analog Devices,


Inc., 1999).
Parameter Min. Typ. Unit
Max.

GAIN

Gain equation [40,000/Rg] ±20%

Gain Range 1 to 1000


INPUT CURRENT

Input bias current ±50 mA

Input offset current ±35 mA


Common mode Resistance 1×109 ohm
OUTPUT RATING VOUT, ±10 V
RL=2KΩ

20
TEMPERATURE RANGE
o
Specified performance -25 C
+85
o
Storage C
-65
+150
POWER SUPPLY

Power supply Range ±6 ±15 V


±18
Quiescent current mA
3.5 5

4.2.2 Microcontroller PIC18F4550

Microcontroller Core Features:


(i) High-performance RISC CPU
(ii) Interrupt capability (up to 14 sources)
(iii) Programmable code protection

PIC key features Value

Operating Frequency DC - 20 MHz

RESETS (and Delays) POR, BOR(PWRT,


OST)
FLASH Program Memory (14-bit 8K
words)
Data Memory (bytes) 368

EEPROM Data Memory 256

Interrupts 14

21
Table I/O Ports Ports A,B,C,D,E 4.7

Timers 3

Serial Communications MSSP, USART

10-bit Analog-to-Digital Module 8 input channels


Operating voltage 2.0 V to 5.0 V

Sink/ source current 25 mA

PIC18F4550 Microcontroller specification (Microchip Technology Inc. 2001)

22
Fig 4.4 PIC18F455O pin diagram (Microchip Technology Inc. 2001)

Table 4.8 PIC18F4550 PINOUT DESCRIPTION (Analog Devices, Inc., 1999)

Pin name Dip Description

OSC1/CLKIN 13 Oscillator crystal input/external clock


source input.

23
OSC2/CLKOUT 14 Oscillator crystal output.

MCLR/VPP 1 Master Clear (Reset) input or


programming voltage input

RA0/AN0 2 PORTA is a bi-directional I/O port.

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

RD0/PSP0 19 PORTD is a bi-directional I/O port or


parallel slave port when interfacing to
RD1/PSP1 20 a microprocessor bus.

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

VSS 12,31 Ground reference for logic and I/O


pins.
VDD 11,32 Positive supply for logic and I/O pins.

NC These pins are not internally


connected.

4.2.3 128 x 64 Dots Graphic LCD

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).

Table 4.9 128 x 64 Dots Graphic LCD specification (Vishay, 2002)

ABSOLUTE MAXIMUM RATING

ITEM SYMBOL STANDARD VALUE UNIT


MIN. TYP. MAX
Power
supply
VDD-VSS 4.75 5 5.25 V
26
Input V1 -0.3 - VDD V
voltage

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)

Table 4.10 SD Card mode pin definition

Pin Name Type Description


1 CD DAT3 I/O/PP Card detect
2 CMD PP Command response
3 VSS1 S Ground
4 VCC S Supply voltage
5 CLK I Clock
6 VSS2 S Ground
7 DAT0 I/O/PP Data bit 0
8 DAT1 I/O/PP Data bit 1
9 DAT2 I/O/PP Data bit 2

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).

5.2 Instrumentation Amplifier AD624AD

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.

Normal raw cardiovascular voltage = 4mV

Instrumentation amplifier gain = 1000

Gain = output voltage / input voltage

28
Output volt = Gain × Input volt

= 1000× 4mV

Output volt = 4V

Between the electrodes and the instrumentation amplifier we should connect


resistors which are used to limit the current back to the patient if the ECG
unit system misbehaves and hence these resistors will protect the patient from
the electrical shock

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.

Input current I< 1mA

Maximum dc voltage = 47 V

Then the value of the resistors will be as calculated below

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

5.1 Connection for a 1000 gain of AD624AD instrumentation amplifier.

5.3 Filter Circuit Design

After amplification of the signal using the instrumentation amplifier then we


need to design filters which are suitable since the cardiovascular electrical
activity has noises due to muscle artifact we need low pass filters that will
allow cut off frequency of the ECG signal Since the ECG signal may have
the maximum frequency of 100Hz but in order to obtain the pure ECG signal

30
we need a low pass filter of a bout 35Hz cut off frequency since the pure
ECG signal has frequency below 35 Hz.

Cut off frequency fo = 1/ 2πRC

Standard capacitance value was selected to be 0.1µ F

To find the value of resistance R for the filter network

R= 1/ (2π×35 Hz×0.1µF)

R= 45.47 kΩ

The standard value of resistor was taken to be 47k

We use the cascaded filter network in order to obtain sharp cut off frequency
so as to reduce the attenuation for the passband signal.

Cut off frequency fo = 1/ 2πRC

Standard capacitance value was selected to be 1µ F

To find the value of resistance R for the filter network

R= 1/ (2π×35 Hz×1µF)

R= 4.547 kΩ

The standard value of resistor was taken to be 4.7k

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

Blue color Represent frequency response for cascaded filter network

Green color Represent frequency response for single filter network

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.

Vo= R2 / (R1 + R2)

32
2V= 180k / (R1 + 180k)

R≈680k

BAT1
9.0 V

R1
pull up resistor 680k

R2
180k
Vo

Fig 5.4 Diagram showing the pull up resistor network

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

Fig 5.5 Diagram showing ECG unit circuit

34
Fig 5.6 Diagram showing ECG unit input and output
waveforms

Scale

Yellow color ECG output volt

Pink color ECG input signal

5.4 PIC Microcontroller


PIC microcontroller it enables the analog signal from the ECG unit to be
displayed on the Graphics liquid crystal display (128×64 GLCD) and to be
logged in the memory device. Since both memory device and the display
operate with the digital signal format, PIC microcontroller is responsible for
converting the analog ECG signal to the format that is suitable for both
display unit and the memory device. For microcontroller to operate there
should supporting devices. The selection of the supporting devices was done
as follows.

(i) Crystal oscillator

The PIC18F4550 microcontroller can be operated from an external


crystal or ceramic resonator connected to the microcontroller’s OSC1
and OSC2 pins. For applications where accuracy of timing is
important, a crystal should be used. Crystal oscillator with large value
is required in our system so that the instructions executions takes
small amount of time, since frequency is inversely proportional to
time for execution (D.Ibrahim, 2008). And if a crystal is used, a
parallel resonant capacitor must be chosen, since series resonant
crystals do not oscillate when the system is first powered. The
capacitor values depend on the mode of the crystal and the selected
35
frequency. Table 2.4 gives the recommended values. 20 MHz crystal
oscillator was chosen. Since higher capacitance increases the
oscillator stability but also increases the start-up time, 22pF ceramic
capacitor was also chosen. (Analog Devices, Inc., 1999)

The table below shows the recommended capacitor selection for crystal
oscillator

Table 5.1 Recommended capacitor selection for crystal oscillator (Analog


Devices, Inc., 1999).

(ii) Master Clear Reset

The power-on reset is generated automatically when power supply


voltage is applied to the chip. The MCLR pin should be tied to the
supply voltage directly or, preferably, through a resistor. The MCLR
pin provides a method for triggering an external Reset of the device.
A Reset is generated by holding the pin low. These devices have a
noise filter in the MCLR Reset path which detects and ignores small
pulses. The resistor value must be less than 40 kΩ, it is recommended
to make sure that the voltage drop across the resistor does not violate
the device’s electrical specification. Microcontroller maximum
current sunk by all ports is 200mA. (Analog Devices, Inc., 1999).

Supply voltage Vdd =5V


36
Limiting resistor R =10kΩ

Current through microcontroller

= Vdd / R

=5V/ 10kΩ

=0.5mA

This value 0.5mA has no harm to the microcontroller, hence 10kΩ


resistor will be used in the master clear reset circuit.

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

Fig 5.7 Master clear reset setup

(iii) 128×64 Graphics Liquid Crystal Display (GLCD)

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.

The results obtained after circuit simulation of the data logger


machine was displayed on the Graphics display as shown below.

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.

Volt from PIC =5V

From the potential divider network

Volt to the SD card = R16 / (R16 + R17)

=3.3k/ (2.2k+3.3k) × 5V

=3V

Volt to the SD card =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

Fig 5.10 The designed circuit for data logging unit

41
Declare the MMC module

Set analog input channel

ADC function

Initiate the SPI bus

Initiate the MMC module

Set SPI parameters

Create the file and assign


the its name

Read the analog signal

Convert to digital format

42
Write data to the SD card

Fig 5.11 Flow chart for the logging unit

(v) The software

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:

(i) MikroC is a very sophisticated C language compiler


(ii) MikroC supports SD card functions which makes the development
of SD card based projects relatively easy
(iii) MikroC supports software, as well as hardware based SPI bus
functions. The SD card operates in SPI mode and uses PORT C of
the microcontroller.

The software created was basing on the following flow chart


below:

43
Start

Function to read analog

ADC function

Call function to read


analog signal followed
by the ADC function

Display dot on the


LCD from the digital
value
Wait for 2 sec and clear
the display

Call the ADC function


and write the digital
data to SD Card
Fig 5.12 Designed software flow chart

vi. The designed system

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

R9 RB3/AN9/CCP2/VPO RD3/SPP3 LCD_DB3


37 27
RB4/AN11/KBI0/CSSPP RD4/SPP4 LCD_DB4
100 38 28
RB5/KBI1/PGM RD5/SPP5/P1B LCD_DB5
0.1uF 39 29
RB6/KBI2/PGC RD6/SPP6/P1C LCD_DB6
40 30
RB7/KBI3/PGD RD7/SPP7/P1D LCD_DB7
C3 8
RE0/AN5/CK1SPP
9
OSC2 RE1/AN6/CK2SPP
C1
MCLR

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

Figure 5.13 Diagram showing the circuit of the ECG data


logger

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

During system implementation there are series of steps undertaken to


implement the prototype. The following are steps which was being passed
through to implement the system.

(i) Designing the system PCB

This was achieved by using Express PCB software. This is an application


special for designing the circuit board. The designed circuit board is shown in
the below figure. The diagram shows both top and bottom layer.

Fig 6.0 The diagram showing the top and bottom layer designed PCB

(ii) PCB etching

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 third step is to apply etchant to the board so as to remove free


copper places. The etchant chemical used was Iron (III) Chloride and
washing the board using the clean water.

The last step is to cean the board using the Ammonium Hydroxide.
Then the board is ready for component placement and soldering.

(iii) Component placement and soldering

Components were inserted to their respective position and soldered on


the copper surface.

6.2 System Test

The system was tested with respect to the basic parts which are ECG unit,
display unit and the logging unit.

(i) ECG unit test

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:

a. Intstrumentation amplifier distortion


b. Misfunction of the ECG electrodes

(ii) Display unit test

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.

(iii) Data logger unit test

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.

(iv) Overall system test

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;

//GLCD module direction


sbit GLCD_CS1_Direction at TRISa3_bit;
sbit GLCD_CS2_Direction at TRISA4_bit;
sbit GLCD_RS_Direction at TRISc0_bit;
sbit GLCD_RW_Direction at TRISc1_bit;
sbit GLCD_EN_Direction at TRISa2_bit;
sbit GLCD_RST_Direction at TRISa5_bit;
// End Glcd module connections
//mmc module connection
sbit mmc_Chip_Select at LATB2_bit;
sbit mmc_Chip_Select_Direction at trisB2_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 ;
} }}

for ( ffw = 0 ; ffw < 200 ; ffw++ ) {


adread[ffw]=63-(adread[ffw]);
}
Glcd_Fill(0x00);
for ( ff = 15 ; ff < 128 ; ff++ ) {
// Glcd_Dot(ff, adread[ff],1);
Glcd_Line(ff, adread[ff], ff+1 ,adread[ff+1], 1);
}
54
strcpy(otxt1,Rtrim(otxt1));
strcpy(otxt1,ltrim(otxt1));
strcpy(otxt2,Rtrim(otxt2));
strcpy(otxt2,ltrim(otxt2));
strcpy(otxt3,Rtrim(otxt3));
strcpy(otxt3,ltrim(otxt3));
strcpy(otxt4,Rtrim(otxt4));
strcpy(otxt4,ltrim(otxt4));
strcpy(otxt5,Rtrim(otxt5));
strcpy(otxt5,ltrim(otxt5));
strcpy(otxt6,Rtrim(otxt6));
strcpy(otxt6,ltrim(otxt6));
Glcd_Write_Text("OFFSET", 0, 0, 1);
Glcd_Write_Text(otxt1, 0, 1, 1);
Glcd_Write_Text(".", 7, 1, 1);
Glcd_Write_Text(otxt2, 10, 1, 1);
Glcd_Write_Text("PEAK", 0, 2, 1);
Glcd_Write_Text(otxt3, 0, 3, 1);
Glcd_Write_Text(".", 7, 3, 1);
Glcd_Write_Text(otxt4, 10, 3, 1);
Glcd_Write_Text("DUTY", 0, 4, 1);
Glcd_Write_Text(otxt5, 0, 5, 1);
Glcd_Write_Text("FREQ", 0, 6, 1);
Glcd_Write_Text(otxt6, 0, 7, 1);
delay_ms(1000);
// call the function that read anaolg signal from channel0 AN0
read_voltin();
//initialize the spi bus
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV16,_SPI_DATA_SAMPLE_MIDDLE,_SPI_CLK_I
DLE_LOW, _SPI_LOW_2_HIGH);
// Initialise the SD Card
// use fat16 quick format instead of init routine if a formatting is needed
if (Mmc_Fat_Init() == 0) {
// reinitialize spi at higher speed
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE,
_SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
}
// Start the A/D converter, get ecg readings every 20ms
//and then save in a NEW file
Mmc_Fat_Assign(&filename,0x80); // Assign the file
Mmc_Fat_Rewrite(); // Clear
Mmc_Fat_Write("ecg signal to be stored after every 20ms\r\n",43);
for(;;)
{
Mmc_Fat_Append();
Read_voltin();
Mmc_Fat_Write(voltin,9);
Delay_ms(20);}}

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

You might also like