Pulse Sensor
Pulse Sensor
Pulse Sensor
MAY 2013
COPYRIGHT PAGE
i. Any material contained in or derived from this unpublished research may only be
used by others in their writing with due acknowledgment.
ii. MIIT UniKL or its library will have the right to make and transmit copies (print
or electronic) for institutional and academic purpose
iii. The MIIT UniKL’s Library will have the right to make, store in a retrieval
system and supply copies of this unpublished research if requested by other
universities and research library.
iv
DEDICATION
v
ACKNOWLEDGEMENT
The main purpose of doing this project is to fulfill the requirement to complete
the course and to gain knowledge thus applying what we have learned during classes in
our project. There were a lot of new things that I have learned during the research and
analysis for this project.
I also would like to thank the FYP coordinator of Networking Systems, Mdm
Jasrina Binti Jaffar for her guidance and support. Grateful thanks also go to Mr Sayed
Aziz Bin Syed Hussin and Mdm Jasrina Binti Jaffar my first and second reader for
taking the time to read this report. Thank you for your support, criticism, advice and
supervision and not forgetting my fellow classmates whom supported me in every way.
Finally, I really appreciate to have this responsibility to finish this project. This
task has taught a lot of lesson and knowledge which would be valuable to me in the
future.
vi
TABLE OF CONTENTS
Page no
Title Page i
Declaration page ii
Approval iii
Copyright Page iv
Dedication v
Acknowledgement vi
List of Table xi
Abstact xv
Abstrak xvi
CHAPTER I: INTRODUCTION 1
1.1 Introduction 1
1.2 Objective 2
vii
CHAPTER II: LITERATURE REVIEW 5
2.1 Introduction 5
2.7 Summary 16
3.1 Introduction 17
viii
3.4 Block Diagram 22
4.1 Introduction 33
ix
CHAPTER V: TESTING AND RESULTS 60
5.1 Introduction 60
6.1 Introduction 72
6.2 Conclusion 72
6.3 Suggestion 73
REFERENCES 74
x
LIST OF TABLES
Page no
xi
LIST OF FIGURES
Page no
xii
Page no
xiii
LIST OF ABBREVIATIONS
Abbreviation
xiv
ABSTRACT
This project consists of two subsystems, which are hardware system and software system.
Basically, the hardware system consists of microcontroller and other electronic circuits
for detecting the heart pulse rate. The heart pulse rate scanning is base on the use of
LDR sensitivity. The PIC will be able to detect the pulse change, counting the pulse per
minute, send to PC through serial data communication and also display the actual status
on LCD. The software system consists of application program that connect and receive
data through serial, display the result per minute and heart rate status information with
data logging capabilities. There are a number of methods that can be used to detect the
presence of the heart pulse. For example, the ECG wave can be used to produce a
synchronized pulse corresponding to each beat of the heart. Other techniques utilize
pressure differentials due to the pulse or optical methods that cause the pressure pulse
to interfere with a light beam. This project using super bright red LED. The LED is use
as the transmitter and the LDR is use as the receiver. Once the circuit is given a 5 Volt
DC supply, The LED will continuously flash red light onto the LDR surface. This
indicates that the circuit works and after programming the PIC it can produce output for
Heart Rate measurement. The last part of this project is to design and develop Human
Machine Interface (HMI) running on windows base platform with the capability to
display the heart beat pulse signal (digital) and the heart beat pulse per minute with
normal and abnormal status information. This project is done for the use as a future
reference for those who want to do a research on heart rate monitor system.
xv
ABSTRAK
Projek ini mengandungi dua subsistem, iaitu sistem perkakasan dan system perisian.
Umumnya, sistem perkakasan terdiri daripada mikropengawal dan litar-litar yang lain
untuk mengesan kadar degupan jantung. Pengimbasan kadar degupan jantung adalah
berdasarkan penggunaan sensitiviti LDR. PIC akan dapat mengesan perubahan nadi,
mengira nadi per minit, hantar ke PC melalui komunikasi data bersiri dan juga
memaparkan status sebenar pada LCD. Sistem perisian terdiri daripada program
aplikasi yang menghubungkan dan menerima data melalui serial, memaparkan hasil per
minit dan maklumat status kadar jantung dengan keupayaan data logging. Terdapat
pelbagai kaedah yang boleh digunakan untuk mengesan kehadiran degupan jantung.
Sebagai contoh, gelombang ECG boleh digunakan untuk menghasilkan gelombang
degupan jantung yang seragam untuk setiap degupan jantung. Kaedah lain adalah
dengan memanfaatkan kebezaan yang disebabkan oleh degupan atau kaedah optik yang
boleh menyebabkan tekanan degupan mengganggu pancaran. Projek ini menggunakan
LED merah yang sangat terang. LED digunakan sebagai pemancar dan LDR adalah
digunakan sebagai penerima. Apabila litar diberi bekalan 5 Volt DC, LED akan terus
memancarkan cahaya merah ke permukaan LDR. Ini menunjukkan bahawa litar
berfungsi dan selepas pengaturcaraan PIC ia boleh menghasilkan output untuk
pengukuran kadar jantung. Bahagian terakhir projek ini adalah merekabentuk dan
membangunkan Human Machine Interface (HMI) yang berjalan pada platform windows
dengan keupayaan memaparkan signal (digital) denyutan jantung dan denyutan jantung
per minit dengan maklumat status normal dan tidak normal. Projek ini dilakukan
sebagai rujukan di masa depan bagi mereka yang ingin melakukan penyelidikan
mengenai sistem heart rate monitor.
xvi
CHAPTER I: INTRODUCTION
1.1 Introduction
Telemedicine is the most important step in cutting costs and increasing service
quality in health care. The traditional telemedicine systems mostly enable
communication between health professionals in order to give doctors in remote locations
access to specialist’s knowledge and monitoring of patients remotely for home care or
emergency applications. Essentially, these systems provide an extension of hospital
environment and connect diagnostic equipment at home with hospitals using fixed
telephone or satellite networks. Although these systems provide many benefits for its
users there are still many limitations.
One of the main limitations is the lack of mobility that hinders their usage in
many scenarios. Besides that, a more general problem of today’s health care is the
insufficient availability of data conceding the status and medical history of the patient,
both to the medical personnel and to the patient himself. Frequent measurements of vital
signs could give indications about the current status of chronic illnesses and are
necessary for optimization of the treatment, but would incur significant cost.
1
1.2 Objective
The main objectives of this project are to design and develop hardware base on
PIC 16F877A microcontroller with the capabilities to detect heart beat pulse from
human body and transmit and receive data between PC using serial data communication
interface.
To design and develop PIC program that can calculate the heart beat pulse
receive and transmit the data to the PC for monitoring purpose. Finally to design and
develop Human Machine Interface (HMI) running on windows base platform with the
capability to display the heart beat pulse signal (digital) and the heart beat pulse per
minute with normal and abnormal status information.
Basically, the system consists of software and hardware system. The software
consists of Visual Basic program to display the output on computer. At hardware part,
system consists of heartbeat sensor module, microcontroller circuits, LCD for quick
display and MAX 232 module.
From the patient's view, the existing care system creates an uncomfortable
feeling because they cannot move freely throughout the monitoring progress. Patients
should be in the hospital and if patients with serious heart problems, they are more
limited area of within the designated wards only.
In addition, patients also need make an appointment with the doctor before the
checkup and sometimes it’s very difficult to do because of the vacancy doctors and
patients different. Patient's emotional state should also be considered during the meeting
with doctor because there is a fear or phobia patients during trips to the doctor and have
patients who are afraid to come to the hospital while giving effect to the data taken by
the doctor.
2
1.4 Project Significant
This portable system will be useful whenever there is need for a low cost and low
power monitoring system.
Hardware Controller
The heart beat scanning mechanism is base on the use of LDR sensitivity.
The PIC will be able to detect the pulse change, counting the pulse per minute, send
to PC through serial data communication and display the actual status on LCD.
2 way communications are available between hardware controller and PC.
User only needs to place his or her thumb and the controller will automatically give
the result after several seconds.
3
GUI/HMI
Receive data through serial, display the result per minute and heart beat pulse
animation signal or graph.
Heart rate status information with data logging capabilities.
The main challenge for this project is system running on power supply. If the
power supply run out of power the system is non functional.
Another challenge is the unstable and high sensitivity nature of the Light-
dependent resistor alternatively called an LDR. LDR can be sensitive to high levels of
ambient infrared light example strong sunlight. If this maybe the case try excluding the
light by covering the sensor with some dark fabric example by placing your hand inside
a cloth bag.
4
CHAPTER II: LITERATURE REVIEW
2.1 Introduction
Previously this Heart Rate Monitor project has been done by other student. The
different with this project it is embedded system where the heart rate device itself
interfacing with computer to receive data through serial, display the result per minute
and heart beat pulse signal or graph and also heart rate status information with data
logging capabilities.
In order to gain a better understanding of this project, a research was done on the
topic of this project. The research was found from journals, articles, books and web sites
from the internet.
Heart rate is the number of heartbeats per unit of time, typically expressed as
beats per minute (BPM). Heart rate can vary as the body's need to absorb oxygen and
excrete carbon dioxide changes, such as during physical exercise or sleep.
5
2.3 Types of Heart Rate Monitors
Modern heart rate monitors usually comprise two elements: a chest strap
transmitter and a wrist receiver or mobile phone (which usually doubles as a watch or
phone). In early plastic straps water or liquid was required to get good performance.
Later units have used conductive smart fabric with built-in microprocessors which
analyze the EKG signal to determine heart rate.
Strapless heart rate monitors now allow the user to just touch two sensors on a
wristwatch display for a few seconds to view their heart rate. These are popular for their
comfort and ease of use though they don't give as much detail as monitors which use a
chest strap.
More advanced models will offer measurements of heart rate variability, activity,
and breathing rate to assess parameters relating to a subject's fitness. Sensor fusion
algorithms allow these monitors to detect core temperature and dehydration.
Another style of heart rate monitor replaces the plastic around-the-chest strap
with fabric sensors - the most common of these is a sports bra for women which include
sensors in the fabric.
In old versions, when a heart beat is detected a radio signal is transmitted which
the receiver uses to determine the current heart rate. This signal can be a simple radio
pulse or a unique coded signal from the chest strap (such as Bluetooth, ANT or other
low-power radio link) the latter prevents one user's receiver from using signals from
other nearby transmitters (known as cross-talk interference).
6
There are a wide number of receiver designs, with various features. These
include average heart rate over exercise period, time in a specific heart rate zone,
calories burned, breathing rate, built-in speed and distance and detailed logging that can
be downloaded to a computer.
The pulse rate will be detected by using heart beat sensor. The data from this
module will be sent to the Analog Digital Converter to convert a continuous quantity to
a discrete time representation in digital form and will be sent to microcontroller and use
LCD for quick display before transfer data to computer via MAX 232. Finally Visual
Basic program will view the output from the devices connection.
Heart rate is one of the most frequently measured parameters of the human body
and plays an important role in determining an individual’s health. Heart rate
measurement is becoming a part of the typical consumer lifestyle, and many
electronic devices such as iPods, exercise equipment, and mobile phones are
becoming able to accurately measure heart rate. This functionality, however, does
not come without added cost. By using multifunctional devices, developers can
reduce the price of introducing new features such as these.
7
2.5.2 Electrocardiographs
The contraction and relaxation of cardiac muscles causes blood to flow in and out of
the heart. During each cardiac cycle, a group of tissue in the heart called the sino
atrial node (a.k.a. the pacemaker of heart) generates electrical impulses that spread
all through the heart and cause rhythmic contraction and relaxation of heart
muscles. These electrical impulses can be detected by placing electrodes in specific
points in human body. An electrocardiogram (ECG) captures this varying electrical
impulse so shows the overall rhythm of the heart.
This method requires placement of two or more electrodes on specific points of the
human body. The ECG signal is characterized by six peaks and valleys labeled with
successive letters of the alphabet: P, Q, R, S, T and U (Figure 2.1). The P-peak is
produced by muscle contraction of the atria. The R-peak shows the ending of atrial
contraction and the beginning of ventricular contraction. Finally, the T-peak marks
the ending of a ventricular contraction. The magnitude of the R-peak normally
ranges from 0.1 mV to 1.5 mV.
The average heart rate is calculated by first measuring the time interval, denoted RR
interval, between two consecutive R peaks and taking the average reciprocal of this
value over a fixed window, usually 15, 30 or 60 seconds. This average is then
8
scaled to units of beats per minute (bpm). R-peak is a part of the RQS complex
which represents ventricular depolarization. A typical ECG is invariably corrupted
by (i) electrical interference from surrounding equipment (e.g. effects of the
electrical mains supply), (ii) measurement (or electrode contact) noise, (iii)
electromyogram noise (muscle contraction), (iv) movement artifacts, (v) baseline
drift and respiratory artifacts and (vi) instrumentation noise (such as artifacts from
the analog-to-digital conversion process).
Before calculating the heart rate, we must processing the ECG in the analog
(amplification, common mode voltages suppression and filtering) and digital
(digital filtering) domains. Most of these functions can be performed by the
microcontroller in real time. Figure 2.2 shows an implementation of a ECG heart
rate monitor. The INSAMP rejects the CMRR and the signal is pre-amplified to
improve noise immunity.
An antiphase signal is also used. This circuit consists of a buffer amplifier (BUF
AMP) and an inverting amplifier (INV AMP) that applies an inverted version of the
common-mode signal to the hands, with the aim of canceling interference. On the
output of this circuit there is a voltage level shift to automatically detect the
moment hands are placed on the electrodes. The threshold circuit and comparator
detect this moment.
9
From the output of the INSAMP, the EKG signal passes through a high pass filter
and is buffered by the BUF AMP. Then the signal is digitized via an ADC. Later
the digitized signal passes through various filters and pulse calculation routines to
calculate the heart rate.
2.5.3 Photoplethysmography
During each cardiac cycle, the blood vessels pulsate in order to carry blood to/from
different parts of the human body. When light radiation such as infrared is passed
through a blood vessel in a finger or ear lobe, the received light signal from
finger/earlobe are periodic and vary due to the rhythmic flow and absorption
properties of blood. This optical variation is employed to make
Photoplethysmographs.
10
2.5.4 Pressure sensing method
The rhythmic contraction and relaxation of the heart exerts a change in blood
pressure along the walls of the blood vessels. As a result, the blood vessels pulsate
in rhythm to the beat of the heart. This pulsation of blood vessels can be sensed by
pressure or piezo sensors placed at appropriate places on the human body like the
wrist. This variation in pressure is used in a blood pressure monitor to measure the
heart rate. Figure 2.4 shows the pulsation of blood vessels in an arm using pressure
sensor with filtering and amplification. These pulses are called oscillometric pulses
and are measured in automatic blood pressure monitors.
The pressure signal from the blood vessel is read by a pressure sensor. The signal is
later amplified and filtered to separate the heart beat signals. Later the signal is
digitized using an ADC. A timer is used as a reference to calculate the heart rate.
11
Figure 2.5: HR monitor using pressure sensor and system on chip
2.5.5 Phonocardiograph
The opening and closing of valves in the heart produces sounds during contraction
and dilation which is normally audible through a stethoscope. These sounds are
rhythmic to heart beat and can be sensed using microphones. Apart from the normal
heart sounds (S1 and S2-Lub and Dub), abnormal sounds called murmurs can also
be recorded. Normal heart sounds are used to determine the heart rate. The normal
heart sounds and different murmurs have different spectral characteristics so with
proper filtering the abnormalities of the heart can be visualized. This acoustic
property is used in phonocardiographs to determine the heart rate. Figure 2.6 shows
normal and abnormal heart sounds.
12
Figure 2.6: Heart sounds
Heart sound signals can be detected using a sensitive microphone connected to the
diaphragm. The electrical signals from the microphone are amplified and can be
passed through a noise filter to remove external noises. Significant murmurs and
rhythmic Lub and Dub sounds can be filtered from the ADC data using digital
filters so that the Lub and Dub signals can be used for the heart rate calculation,
Figure 2.7.
13
2.6 Hardware and Software technology background
A UART is usually an individual (or part of an) integrated circuit used for serial
communications over a computer or peripheral device serial port. UARTs are now
commonly included in microcontrollers. A dual UART, or DUART, combines two
UARTs into a single chip. Many modern ICs now come with a UART that can also
communicate synchronously; these devices are called USARTs (universal
synchronous/asynchronous receiver/transmitter).
A data logger (also data recorder) is an electronic device that records data over time
or in relation to location either with a built in instrument or sensor or via external
instruments and sensors. Increasingly, but not entirely, they are based on a digital
processor (or computer). They generally are small, battery powered, portable, and
equipped with a microprocessor, internal memory for data storage, and sensors.
Some data loggers interface with a personal computer and utilize software to
activate the data logger and view and analyze the collected data, while others have a
local interface device (keypad, LCD) and can be used as a stand-alone device.
14
Data loggers vary between general purpose types for a range of measurement
applications to very specific devices for measuring in one environment or
application type only. It is common for general purpose types to be programmable;
however, many remain as static machines with only a limited number or no
changeable parameters. Electronic data loggers have replaced chart recorder in
many applications.
One of the primary benefits of using data loggers is the ability to automatically
collect data on a 24-hour basis. Upon activation, data loggers are typically deployed
and left unattended to measure and record information for the duration of the
monitoring period. This allows for a comprehensive, accurate picture of the
environmental conditions being monitored, such as air temperature and relative
humidity.
2.6.3 Microcontroller
15
2.6.4 Visual Basic
A programmer can put together an application using the components provided with
Visual Basic itself. Programs written in Visual Basic can also use the Windows
API, but doing so requires external function declarations. Though the program has
received criticism for its perceived faults, from version 3 Visual Basic was a
runaway commercial success and many companies offered third party controls
greatly extending its functionality.
The final release was version 6 in 1998. Microsoft's extended support ended in
March 2008 and the designated successor was Visual Basic .NET (now known
simply as Visual Basic).
2.7 Summary
After going throughout all this data collections, and by referring to the previous
project that have been done, it’s decided to proceed with the project. Based on the author
research and study, this HRM project benefits from other previous project also, the idea
to enhance the project can be obtained from the input from the supervisor and the reader.
16
CHAPTER III: RESEARCH METHODOLOGY
3.1 Introduction
After the topic was approved by the supervisor, the researcher has started to
gather all information needed to begin this research. There are some methods being used
for information gathering such as study, research and analysis project title. This method
can be done by referring to:
Internet
There are some websites on the Internet that can be utilized in order to obtain some
knowledge about the project.
Article
The researcher also found some articles written by other researchers from around the
world.
17
Journal
Journal can be found in an education environment such as the library whereby the
researcher could make references regarding the topic.
The structured model had been chosen as the method for this project. Structured
development is a deliverable project work elements shown in graphical display to
organize and subdivide the total work scope of a project where each phase of
development has different goals.
18
3.3.1 Planning
In the Planning phase, the objective and scope of the project is described. The design
and requirement for the project is identified and the project cost estimate is prepared.
This project initiation includes finding the background of research and problem
statement; determine the significance of research, and completing the literature
review. The methodologies used in planning phase are:
Brainstorming is the process to find the detail of the design and the
technique how to develop the system. After that, it needs to be organizing
and priority based on the results. The following basic rules for
brainstorming ensures better results:
The starting point for many projects is often similar to an existing system.
Comparable and observe products and systems contain working versions
of good ideas for gathering information to develop project title. Even if
the current systems are trying to solve slightly different problems, they
often provide valuable clues as to what need to do. The method is
outlined:
19
Read, record and analysis book, journal, article, magazine and
website about the project title to comprehend what is the Heart Rate
Monitor concept and how does it works.
Classify all of the types of information in the document. (User,
system requirements, design elements, plans, background material,
irrelevant detail).
Planning the project architecture based on research.
3.3.2 Design
In this phase, student needs to design and choose the appropriate hardware and
software to build the Heart Rate Monitor. The circuits must be built with a right
schematic so that it can connect smoothly with the computer to display the signal
output in beats per minutes. A schematic shows how electronic components are
connected in an electronic circuit.
3.3.3 Testing
The testing phase deals with issues of fuctioning each part of the hardware with the
applicable visual basic application whether its function or not, assessing whether
the objective of the project has been met or not. Testing phase stated as the process
of validating and verifying the project:
20
To meet the technical project requirements that guided its design and
development.
To work as expected.
3.3.4 Troubleshoot
In the final stage, troubleshoot the system to define the strength and weaknesses of
this project. Search for the source of a problem so that it can be solved, and the
project can be made operational again. Troubleshooting is needed to develop and
maintain the Heart Rate Monitor system in good conditions.
21
3.4 Block Diagram
Heart Beat
sensor with
OP-AMP
LM 358 PC
PIC Max 232
16F877 Interface PC
MICROCHIP circuit
Reset MICRO
Button CONTROLLER
Selector
Switch MODE
Capable to detect heart pulse base on illumination change during blood pressure. The
LDR then will detect this change and the output at pin 7 of LM358 will also change.
At every heart beat pulse, there will be a change in output voltage generated by the
LM358
PIC 16F877A
40 pins Microcontroller unit (microchip): main CPU in order to calculate the pulse
rate, LCD display and data communication between PC
22
Max 232 Interface
Used as interfacing unit for data exchange between PIC and PC as the characteristic
of the serial data signal are different at both side (PIC and PC).
Reset Button
Switch MODE
Used to switch mode either in EMG mode or PC mode. EMG for the emergency
mode where user can monitor heart beat without any connection to PC using LCD
display but cannot save the data. For the PC mode user can use the Heart Rate
Monitor interface with display the result per minute, heart beat pulse animation
signal or graph and heart rate status information with data logging capabilities.
23
3.5 GUI/HMI Flowchart
Start
NO
Display “No Heart Serial Data
Beat Detected” received?
YES
YES
NO
YES
NO
End
24
3.6 Hardware Requirements
The hardware part will be explained first as this project comprise of several
important hardware and the fact that the hardware part are designed and built first before
anything else. Below show the hardware that was used to build this project:
PIC 16F877
LDR sensor
Regulator LM7805
LED
Max232 Interface IC
DB9 male/female
Capacitor
Resonator 4Mhz
IC base socket 40 pin/18 pin
PCB board
LM 358
LCD 2x16
Resistor/Variable Resistor
Diode 1N1001
Introduction to Sensors
25
Factors to consider when choosing a sensor:
Concept of LDR
Circuit Operation
This project using super bright red LED. The LED is use as the transmitter and
the LDR is use as the receiver. Once the circuit is given a 5 Volt DC supply, The LED
will continuously flash red light onto the LDR surface. This indicates that the circuit
works and after programming the PIC it can produce accurate output for Heart Rate
measurement.
The LED emits infrared light to the finger of the subject. The LDR detects this
light beam and measures the change of blood volume through the finger artery. This
signal, which is in the form of pulses is then amplified and filtered suitably by
26
Operational Amplifiers (Op-Amps) and is fed to a low-cost microcontroller for analysis
and display. The microcontroller counts the number of pulses over a fixed time interval
and thus obtains the heart rate of the subject. Several such readings are obtained over a
known period of time and the results are averaged to give a more accurate reading of the
heart rate. The calculated heart rate is displayed on an LCD in beats-per-minute.
Microcontroller
This powerful (200 nanosecond instruction execution) yet easy to program (only
35 single word instructions) CMOS FLASH-based 8-bit microcontroller packs
Microchip's powerful PIC architecture into an 40 or 44-pin package and is upwards
compatible with the PIC16C5X, PIC12CXXX and PIC16C7X devices. Features of the
device:
27
synchronous serial port can be configured as either 3-wire Serial Peripheral Interface
(SPI™) or the 2-wire Inter-Integrated Circuit (I²C™) bus
Universal Asynchronous Receiver Transmitter
For programming this project use PIC 16F877A. The reason why choose to use
this type is because of the low cost and wide availability, large user base, extensive
collection of application notes, availability of low cost or free development tools, and
serial programming (and re-programming with flash memory) capability. PIC 16F877A
has 40 pins which suite enough for the project.
MAX232
28
For this project the MAX232 module functions as an interfacing unit between the
microcontroller and the computer. By using MAX232, it enables communication
between the computer and the microcontroller via serial port.
MPLAB
Why use assembly language for this project? Table 3.1 shows assembly language
versus other high level language.
29
Visual Basic
30
3.8 Budget and Costing
Table 3.2 below shows the estimated budget to buy all the equipments needed in
order to initiate the project.
31
3.9 Project Timeline
The duration for this project is one year. Every phase has been identified and
planned systematically to ensure the project will meet the dateline. The Gantt chart is
developed to guide and keep track of the project progress. For further description on the
project schedule, refer to the Gantt chart as provided in Appendix A.
32
CHAPTER IV: PROTOTYPE/PRODUCT DEVELOPMENT
4.1 Introduction
Based on the methodology explained in Chapter III, it is shown that are many
aspects of the project which need to be carefully considered before moving to the
development stage. This chapter explains the prototype development for Heart Rate
Monitor software and hardware. It explains the prototype modules and system interface
used in this development.
The graphical user interface describes anything that application displays to the
user. It is the primary way to interact with the user and allow him or her to interact with
it. Creating great GUI's is something Visual Basic is amazing at. It can create
professional interfaces with minimal effort.
The installer of Visual Basic 6.0 software is downloaded from the official
website. Figure 4.1 shows the installation of Visual Basic 6.0 (Start the installation by
clicking “Next”) and Figure 4.2 shows Custom Server Setup Options.
33
Figure 4.1: Start the installation
34
From Figure 4.3 show to choose the location of the files that are common among
Visual Studio 6.0 applications. Figure 4.4 shows Visual Basic 6.0 Enterprise setup in
progress.
35
Figure 4.5 shows that Visual Basic 6.0 Enterprise Setup need to restart Windows
to complete the installation.
36
4.3 Software Tools to Write Program.
The installer is downloaded from the internet and installed in the personnel
computer. Figure 4.6 shows the installation MPLAB tools first run of it. Start installation
with click button “Next”.
37
From Figure 4.7 shows Setup Type. User need to select a setup type “Complete”
where all program features will be installed. Figure 4.8 setup will install MPLAB Tools
v8.66 in the following folder.
38
Figure 4.9 below shows the program installing files and updating the registry.
This program will install HI-TECH C Compiler for the PIC10/12/16 MCUs version
9.81. From Figure 4.10 shows HI-TECH C Compiler for the PIC10/12/16 MCUs version
9.81 has been successfully install.
39
Figure 4.11 shows setup has finished installing MPLAB Tools v8.66 and ready
to use.
40
4.4 UART Setting
Data Bits = 8
Parity = None
Flow Control = None
Stop Bit = 1
Com Port number can be set according to the USB to serial port number. The
settings have to be done using programming language of the microcontroller. As an
example, for PIC microcontroller, developer has to use assembly language or C
language to configure these settings.
41
PIC Flowchart
Figure 4.12 shows the step of how the PIC system is working.
Start
Initializing Process
(LCD & UART function)
YES
Start Counting Pulses Heart Beat Pulse
detected?
NO
NO Timer Out? LCD Display No INPUT
YES
End
42
4.5 Programming the Microcontroller
MPLAB software: Development tools use to develop the PIC program for the
hardware controller heart rate monitoring system.
Download Hex
To Microcontroller IC
High level Compiled
Language
(C, Basiq and etc)
Compiler
Figure 4.13 shows the stage of process to program the PIC microcontroller.
The first step is to install the software, featuring on how to setup MPLAB and
boot loader for the purpose of programming and burning the program into the
microcontroller. Assembly language is used as the programming language for the
microcontroller.
Before start, new folder in drive C has been created and the folder been rename
accordance to project name or title. This folder is now become project folder for ASM
code project.
43
Open MPLAB IDE free download from www.microchip.com. This step also
valid for any lower version of MPLAB software, from Figure 4.14 shows step one by
select devices. Choose the right devices base on project development. Figure 4.15 shows
step two by select language tool suite.
44
From Figure 4.16 shows step three by Browse where to locate new MPLAB
project and write a name for the project. Recommended: select the project folder that has
created. Figure 4.17 shows step four where user need to select existing assembly
code/project (the assembly code) and click “add” to insert to new MPLAB project.
45
Figure 4.18 below shows Project wizard is now completed. Check the summary
and click “Finish”. From Figure 4.19 shows one of the program codes for PIC
microcontroller using MPLAB IDE software. The program is in “.asm” file. The “.asm”
file program can be edited. The source code is based on assembly language
programming.
46
Figure 4.20: Build succeeded
Figure 4.20 show that PIC coding for HRM build succeeded. Program written in
assembly language, a low level programming language that can be converted to machine
language, may be edited with a text editor and run using an assembler program. To build
new project, go to menu “Project” and click on “Build All”. Click on “Absolute” and it
will show the succeeded result after Build process. Hex File generated after succeeded
build. (This is the machine code for the project). After succeeded build, by using PIC
boot loader device it will transfer the Program to PIC Microcontroller. Figure 4.21
below shows the hardware that is used to program the PIC microcontroller.
47
4.6 Data Transmit
Data transmit from PIC to PC monitor by 3rd party serial monitoring software
running on windows platform Super Term 2.21 (super terminal). Figure 4.22 shows data
“X,1” represent Heart Beat Signal detected. Figure 4.23 data receive from PC and
display to LCD.
48
Transmit data test by using 3rd party serial monitoring software. Figure 4.24
shows Data from PC was successfully received and display to LCD.
*123NORMAL/
“*” and “/” represent start and stop byte.
49
4.7 Printed Circuit Board (PCB) Layout and Schematic Design
Proteus PCB design combines the ISIS schematic capture and ARES PCB layout
programs to provide a powerful, integrated and easy to use suite of tools for professional
PCB Design.
All Proteus PCB design products include an integrated shape based auto router
and a basic SPICE simulation capability as standard. More advanced routing modes are
included in Proteus PCB Design Level 2 and higher whilst simulation capabilities can be
enhanced by purchasing the Advanced Simulation option and/or micro-controller
simulation capabilities.
The products are offered at a number of levels which offer increasing levels of
functionality and design capacity.
Firstly we need to design the Schematic of the PCB. It will show how the
component will be connected to each other. Figure show the complete design of the
schematic.
From Figure 4.25 shows the schematic of heart beat sensor consist 8 resistors and 1
variable resistor, 1 IC LM358 (OP-Amp circuit), 3 LED's including 1 super bright
LED, 3 capacitors and 1 Light Dependent Resistor (LDR). Figure 4.26 shows
schematic design main circuit using Proteus software.
50
Figure 4.25: Schematic Design Heart Beat Sensor
51
4.7.2 Design of the Printed Circuit Board (PCB)
After completing the first phase which is designing the schematic design of the
circuit, we will move to the second phase. The next phase is to design the PCB by
referring to the schematic that have been complete.
52
From design Figure 4.27 and Figure 4.28 we can see the microcontroller (PIC) was
placed at the center of the PCB because the PIC itself will work as the brain of the
circuit. Then there are two outputs from the PCB which goes to the LCD and
MAX232 use as interfacing unit. Then it also showed a few component including
LEDs, resistors, switch and others in the right place.
After completing the designing for the schematic and the Printed Circuit Board, it is
time to go to the next phase which to complete the circuit. It including to etching
the circuit and all the soldering process. Etching is a printmaking process that dates
back 500 years. The etching process involves sheets of metal, usually made of
copper or zinc, and acid used to etch the print onto the metal. The artist can use
complicated methods to create different effects, but always relies on acid to etch the
plate. The more complicated the etching, the more time consuming and expensive it
will be.
53
4.8 Monitoring System (Visual Basic)
For the monitoring system GUI, the software that will be use is Visual Basic 6.0.
In VB, a programmer can put together an application using the components provided
with Visual Basic itself. Though the program has received criticism for its perceived
faults, from version 3 Visual Basic was a runaway commercial success and many
companies offered third party controls greatly extending its functionality.
The monitoring system will be done as a simple monitoring system, where user can
monitor their own heartbeat.
54
There are 2 forms that being use to create graphic user interface for Heart Rate
Monitor project they are Form 1 and Form 2. Figure 4.29 above show Form 1 or
Main Form that consist some function, one of the function is to display the result
per minute.
Comm Setting
Command Button used for show Form 2. It is enable setting for communication
port.
Used Label to display time and date. It is one of the additional functions. Format for
date "dd/mm/yyyy" and time "hh:mm:ss".
Beat Test
Another one of additional function is Beat Test. Command Button used to test the
functional of Heart Rate Monitor GUI without input data from hardware device.
Beat/Min
Using Text Box to display heart beat per minute in digital form. Text setting used
“000”.
Picture Box used for real time graph animation on heartbeat signal.
55
Heart Beat Status
Shape and Label are used to display either Heart Beat Detected or No Heart Beat
Detected. If reading not equal empty or “000” then display Heart Beat Detected.
Manual Save
Command Button used to manual update for data logging. Record data path is
“\Result.log”.
Recording Time
Indicator
Using Shape and Label to show status of heartbeat either Abnormal if rate < 50 and
if rate > 100 (Red Indicator) or Normal if rate > 50 and if rate < 100 (Green
Indicator). Else set as No Input.
Label and List Box are used to create Table Result. Date and time, BPM and heart
beat status can be saved automatically based on the Recording Time setting.
56
4.8.2 HRM Communication Port Form
Comm Settings
Form 2 where it enables serial communication port setting on GUI. The interfaces
have 4 option of Baud Rate to used 9600 bps, 19200 bps, 38400 bps and 57600 bps.
Baud Rate used for this project is 9600 bps.
The coding for the Heart Rate Monitor system will be provide at The Appendix
57
4.9 Complete Product
After completing all the process, put aside the complete circuit to get a picture of
it. Then the complete circuits were put in the Heart Rate Monitor model that was made
from two small boxes, one for the main circuit including PIC and others, and the other
one for the sensor circuit. The assembling process didn’t need any screw or nail because
it just done by a glue and tape.
From the Figure 4.31 it shows picture of the complete circuit of the project. From
the picture HRM circuit is divided into 2 boards of circuit including the main circuit
which consist the microcontroller (PIC), LED, resistors, MAX232 with RS232 DB9
for PC mode, LCD for EMG mode, selector switch mode and also a reset button.
The other circuit board is for the LDR sensor, it built in separate way because it is
58
for comfort the user with flexible sensor device when it will be use for measuring
heart beat from the finger and it need the user in relax condition.
After complete the circuit, the circuit needs to be put in the model box. As shown in
figure above, we can see that there are 2 boxes separate with 2 different circuits,
main circuit and sensor circuit. The LCD is for EMG mode.
Beside the model, there is a laptop which is used as the monitoring system (Heart
Rate) GUI in VB. The laptop was connected to the design model through the
MAX232 by a serial data cable.
59
CHAPTER V: TESTING AND RESULTS
5.1 Introduction
This chapter discusses the testing method employed in the development of Heart
Rate Monitor system. Various testing method relevant to the project are discussed.
Result analysis where the analysis includes all the selected guidelines considered
relevant to the prototype quality. Testing is important since the primary purpose is to
detect software and hardware failures such that the defects may be uncovered and
corrected.
Heart beat sensor is design to give digital output of heart beat when finger is
placed on it. The IR LED is use to illuminate a human finger with infrared light. The
light intensity is then modulated by blood pressure changes within the finger before
striking the photo resistor or LDR. The sensor then converts the changing light intensity
into a proportional voltage containing two components below:
When the heart beat detector is working, the beat LED flashes in synchronization
to the human heart beat. It works on the principle of light modulation by blood flow
through finger at each pulse. In order to make sure that the heart beat sensor was
successfully design and developed, 2 method of testing have been done as shown in the
picture below.
60
a. From Figure 5.1, Using Digital Multimeter to get output voltage. Voltage test on the
output pin 7 of LM358. DC power supply used 9 volt to 12 volt.
b. Figure 5.2 below show that finger is place between LED and LDR sensor and the
LED flashing in synchronization with the human heart beat.
61
a. Figure 5.3 shows multimeter reading input voltage at Diode. 9VDC to 12VDC
incoming: Power Supply base on LM7805 regulator unit.
62
c. Figure 5.5 and 5.6 shows 5VDC operating voltage from LM7805 supply to VDD pin
of PIC16F877A (pin 11 and pin32).
63
d. From Figure 5.7, 5.8 and 5.9 shows 5VDC operating voltage from LM7805 supply
to VCC pin of 2x16 LCD and MAX232 interface circuit.
64
Figure 5.9: Checking IC MAX232 operating voltage at pin 16
65
5.4 System Operating Test
The main function of the PIC controller are to detect the pulse rate signal
generated by the heart beat sensor LM358, counting the pulse in order to get the BPM
result and transmit the data to the PC through MAX232 serial interfacing circuit. Then,
the reply status from PC will be display to LCD unit.
66
From Figure 5.11 shows LCD message during start up and Figure 5.12 shows
“No Input” message on LCD when there is no finger placed at the sensor unit.
a. Figure 5.13 shows Serial Communication Port Setting on GUI for Heart Rate
Monitor. Setting used as below:
Com Port number can be set according to the USB to serial port number
67
b. Figure 5.14 shows Main Form display result during no heart beat input on Heart Rate
monitor GUI.
c. Figure 5.15 shows Main Form display result during heart beat Input detected. Heart
beat signal animation was successfully generated base on heart beat signal received
from PIC controller. Heart beat status can be save automatically base on the
Recording Time setting.
68
d. Figure 5.16 shows data logging table result on VB. Its record all data input from
sensor.
e. Figure 5.17 below show that the GUI display is running in synchronization with the
PIC controller reading. Normal result with 72 BPM value and Indicator turn to green
color.
69
Figure 5.18: Normal result with 66 BPM.
Figure 5.18 above shows Normal result with 66 BPM value and Indicator turn to
green color. Formula use to calculate BPM: Sample time = 10s Counting how many
beat detected within 10s then: BPM = Total Beat x 6.
From Figure 5.19 above shows line charts result for heartbeat record every 10
seconds in BPM from 3 random persons.
70
Table 5.1: Functionality Testing
Table 5.1 shows the functionality tested for this project. All the test functionality
was tested thoroughly. During the 3rd test, there were defects found in connection
between computer and circuit hardware functionality. The computer was trying to
connect to circuit hardware using USB to serial data converter were failed. Problem
detected, having issue or conflict with Communication Port. Errors while making
connection at Ports (COM&LPT) and test were conduct by configure setting
Communication Port for serial communications (COM1) result error. Next test 2
configure setting (COM2) still Communication Error. Test 3 problem solve with
Advanced Port Settings set COM Port Number to COM10 result no error. On the 1st, 2nd
and 5th test all the steps tested were passed. 4th test, data transmit from PIC to PC monitor
by 3rd party serial monitoring software fail. Problem detected LDR and LED soldering
loose. Solution solders back LDR and LED.
71
CHAPTER VI: CONCLUSION AND SUGGESTION
6.1 Introduction
This chapter discusses the suggestion of future work for the project and
conclusion will be made according to the project development. This thesis has discussed
the development of the sensor module, main circuit and interfacing with computer.
6.2 Conclusion
The design of a low-cost microcontroller based device for measuring the heart
pulse rate has been described. The device has the advantage that it can be used by non-
professional at home to measure the heart rate easily and safely. With this system the
patient will be more proactive with their doctor because it appears prevention is better
than cure. Here I can say that this Heart Rate Monitor project have achieved all of its
objectives.
An important factor to finish this project is the overall processes that have been
considered. Enough knowledge is required along the process. Earlier preparation is
needed for the components that are limited. More components should also be ready as a
precaution from unpredictable situation such as components burned and not in good
condition. Some suggestion has been made for the limitation of heart beat sensor
accuracy due to the LDR mounting and light exposure (sensitive to light).
Lastly, taking into account issues related to the completion of the project, it is
hereby suggested that the project be continued and further developed in the area of
software and hardware enhancement.
72
6.3 Suggestion
In order to improve the project function and implementation in the future, several
suggestions are proposed:
1. Use of mobile phone to replace personal computer. There are many types of
mobile phone with Bluetooth features. Research should be done to find new
method in order make this system functions using mobile phone. If the mobile
phone replaces the computer, the system will be more convenient and practical.
2. Use of different types of techniques to detect the heart rate. There are number of
methods and technique to detect the heart rate, for example ECG and optical
sensor. This kind of method is more accurate than this project method. But the
main problem is that, this method is more difficult to design and implement.
73
REFERENCES
[2] Peter Spasov (2005), Microcontroller Technology, Fifth edition, Sir Sandford
Fleming College: Prentice Hall.
[4] Home Patient Monitor by Idriah Safriza UniKL BMI in Medical Electronics
Engineering and Legenda Group of Colleges in Higher National Diploma
Electrical and Electronics Engineering.
http://idriah-safriza.blogspot.com
[5] Design Standard for Rigid Printed Boards and Rigid Printed Board Assemblies.
IPC. September 1991. http://classes.soe.ucsc.edu
74
[9] Universal Asynchronous Receiver/Transmitter (UART)
http://www.quicklogic.com/assets/pdf/data_sheets/QL_UART_PSB_DS_RevC.p
df
[10] Sana M. Ceesay., Adrew M. Prentise., & Keeneth C.Day. (2002). The use
of heart rate monitoring in the estimation of energy expenditure a validation
study using indirect whole-body calorimetry, 175-186
[11] Juul Achten., & Asker E. Jeukendrup. (2003). Heart Rate Monitoring. Vol
33, Issue 7, pp 517-538.
[12] John, E. S ., Stephan , A. and David, C. (1993) Pulse Oximetry Through Spectral
Analysis, University of South Florida Department of Anesthesiology, University
of South Florida Center for Microelectronics Research.
[14] Microsoft Visual Basic 6 Deluxe Learning Edition Michael Halvorson (Author),
Microsoft Press (Publisher)
[15] (2004). Max232, Max 2321 Dual EIA-232 Drivers/ Receivers, Texas Instruments
Incorporated
http://www.ti.com/lit/ds/symlink/max232.pdf
75
[17] Wendy.B., (2012). Heart Rate Monitor
http://walking.about.com/od/prpedometer/fr/dashtrak.htm
76
APPENDIX A: GANTT CHART
APPENDIX B: PROJECT POSTER
APPENDIX C: PIC16F87XA DATA SHEET
APPENDIX D: HEART RATE MONITOR CODING
Communication Port Form Coding
Form2.Hide
Call Form1.openCom(Val(txtPort.Text))
Form1.Show
Unload Form2
End Sub
End Sub
'If reading not equal empty or 000 then display "HEART BEAT DETECTED"
hd_Beat = True
hd_draw = True
BeatCal.Text = Val(BeatCal.Text) + 1
Private Sub UPDATE2() 'Data logging for heart beat reading and status
lstLateRecord.Clear
Open App.Path & "\Result.log" For Input As #1
Do Until EOF(1)
Line Input #1, tmpVar
lstLateRecord.AddItem (tmpVar)
Loop
Close #1
End Sub
Private Sub Timer1_Timer()
'set time and date
lblDate.Caption = Format(Now, "dd/mm/yyyy")
lblTime.Caption = Format(Now, "hh:mm:ss")
If Rate > 100 Then 'Heart beat normal and abnormal setting
Indicator.BackColor = &HFF&
LblStatus.Caption = "ABNORMAL"
MSComm1.Output = "*" & Rate & "#" & LblStatus & "/"
Exit Sub
End If
Indicator.BackColor = &HFF00&
LblStatus.Caption = "NORMAL"
MSComm1.Output = "*" & Rate & "#" & LblStatus & "/"
Exit Sub
End If
list p=pic16f877a
include p16f877a.inc
__config 0x1E72
errorlevel -302 ;Suppress bank warning
;-------------------------------------------------------------------------------------------------------------------
---
;Declare variable use to store memory data
;-------------------------------------------------------------------------------------------------------------------
---
CBlock 0x20
N ; Delay registers.
N1
count1
counta
countb
countc
FIXDELAY
visdelay
dataL
COUNTER1
COUNTER2
A1
A2
A3
rxtime1
rxtime2
M1
M2
TH
TL
TXSW
RXD
A0
TmmerXX
Pcounter
PcounterTemp
ENDC
;-------------------------------------------------------------------------------------------------------------------
---
;Program Start
;-------------------------------------------------------------------------------------------------------------------
---
org 0x00
movlw A'0'
movwf A1
movwf A2
movwf A3
movwf A0
;-------------------------------------------------------------------------------------------------------------------
---
;Start Of Main Program
;-------------------------------------------------------------------------------------------------------------------
---
LP
call CLRDATA ;Clear all LCD data
btfss PORTA,1 ;Check for MODE SWITCH??
goto SelfRunning ;INDIVIDUAL MODE??? then jump to
"SelfRunning
;----------------------------PC MODE--------------------------------------------------------------------------
------
call DisBPM ;PC MODE?? then proceed next instruction
call visualdelay
;-------------------------------------------------------------------------------------------------------------------
---
EndDisplay
movf A0,w ;Finalize data received
xorlw A'0'
btfss STATUS,Z
goto ProceedDis
movf A1,w
xorlw A'0'
btfss STATUS,Z
goto ProceedDis
movf A2,w
xorlw A'0'
btfss STATUS,Z
goto ProceedDis
call CLRDATA
call DisBPM ;If value = 000 then display NO INPUT
call visualdelay
goto SendP ;Go to Send Data to PC
ProceedDis
call DisLCD ;Display BPM reading
call nextline
LoopData
call receive ;Wait for Status reply from PC
movwf RXD
movf RXD,w
xorlw A'/'
btfsc STATUS,Z
goto EndDisplay1
movf RXD,w
call PUTCHAR
goto LoopData
EndDisplay1
call visualdelay
goto SendP ;Send beat signal to PC
;-------------------------------------------------------------------------------------------------------------------
---
SendP
btfss PORTA,0 ;Check for Heart Beat signal.
goto LPx ;No?? go back to LPx to check data from PC
call SendPulse ;Yes detected....then send data to PC
goto LPx
SendPulse
movlw A'X'
call transmit
movlw A','
call transmit
movlw A'1'
call transmit
call Delay_T
return
BacktoMAIN
call clrscreen
call DisPCMode
call SECOND_1
goto start
;-------------------------------------------------------------------------------------------------------------------
---
;Self Running MODE
;-------------------------------------------------------------------------------------------------------------------
---
SelfRunning
call clrscreen ;Clear All Data
call DisEMGMode
SelfR
call SECOND_1
movlw A'0'
movwf A2
movwf A1
movwf A0
movlw d'40'
movwf TmmerXX
movlw d'0'
movwf Pcounter
call DisLCD
call visualdelay
call SECOND_1
LoopSelfRunning
call Delay_T
btfsc PORTA,1 ;Check for MODE switch again??
goto BacktoMAIN
btfss PORTA,0 ;Check for Beat Signal??
goto skipcount
call IncPulse ;Calculate Total Beat within 10s
skipcount
decfsz TmmerXX,1
goto LoopSelfRunning
goto BPMRESULT
IncPulse
incf Pcounter,1
return
BPMRESULT
movlw A'0'
movwf A2
movwf A1
movwf A0
movf Pcounter,w
movwf PcounterTemp
movlw d'6'
movwf TmmerXX
call CLRDATA
LoopBPMR
call INCPlse
decfsz PcounterTemp,1
goto LoopBPMR
decfsz TmmerXX,1
goto LoopAgainx
goto DisBPMx
LoopAgainx
movf Pcounter,w
movwf PcounterTemp
goto LoopBPMR
return
;--------------------------------------------------------------------------------
return
Dec3x decf F2,1
movlw A'9'
movwf F1
movwf F0
return
;--------------------------------------------------------------------------------
SEND
return
;-------------------------------------------------------------------------------------------------------------------
-----
; END OF MAIN PROGRAM-------------------------------------------------------------------------------
--------------------
;-------------------------------------------------------------------------------------------------------------------
-----