448_ASYRANZYRATIBINTIYAHYA2013
-
Upload
wasang-juwi-pracihno -
Category
Documents
-
view
7 -
download
0
Transcript of 448_ASYRANZYRATIBINTIYAHYA2013
“I hereby declare that I have read this thesis and in my opinion this thesis is
sufficient in terms of scope and quality for the award of the degree of Bachelor of
Engineering (Electrical- Electronics)”
Signature : ..................................................................
Name of Supervisor : DR EILEEN SU LEE MING
Date : 24th
JUNE 2013
PORTABLE DETECTION DEVICE FOR PATIENTS WITH SLEEP APNEA
ASYRAN ZYRATI BINTI YAHYA
A thesis submitted in fulfillment of the
requirements for the award of the degree of
Bachelor of Engineering (Electrical-Electronics)
Faculty of Electrical Engineering
Universiti Teknologi Malaysia
JUNE 2012
ii
I declare that this thesis entitled “Portable Detection Device for Patients With Sleep
Apnea” is the result of my own research except as cited in the references. The thesis
has not been accepted for any degree and is not concurrently submitted in
candidature of any other degree.
Signature : ………………………………….........
Name : ASYRAN ZYRATI BINTI YAHYA
Date : 24th
JUNE 2013
iii
To my beloved father, Yahya bin Md Nor, my loving siblings, compassionate friends
and companions and dedicated lecturers who have guided, encouraged and inspired
me throughout my journey of education
iv
ACKNOWLEDGEMENT
Alhamdulillah and thanks to Allah S.W.T for giving me the opportunity and
bless in completing this final year project. First and foremost, I would like to
express my sincere gratitude to my advisor, Dr Eileen Su Lee Ming for her
continuous support and guidance throughout this project development.
I would like to offer my earnest thanks to my family for the non-stop
encouragement that I received throughout the precious time I spent here. Without
their utmost support, it is probably impossible for me to go through the tough
journey of the campus life.
Next, I would like to thank my friends for their generous support and
willingness to go through thick and thin together. Last but not least, I would like to
thank all the staffs for their cooperation and all the lecturers for all the irreplaceable
knowledge that have been passed onto me.
Thank you very much. Without everyone contribution and support, this
thesis would not have been possible to finished.
v
ABSTRACT
Sleep apnea is a syndrome that causes a pause in breathing during night time
sleep. It is a dangerous disease as it can cause sudden death if left untreated. The
method that is widely used to detect sleep apnea is the polysomnography or sleep
test that is done by the sleep test expert. However, this method is considered as
inconvenient as the patient needs to be hospitalized with a lot of wires around the
body to get the test done. The test fee is also expensive in most hospital or sleep
clinic. The purpose of this project is to build a portable sleep apnea detection device
which is affordable and easy to use. Apart from that, the objective of this project is
to be able to interface multiple sensors and process the signals for sleep apnea
classification. The portable device was made in a way that it can detect sleep apnea
through oronasal airflow. This project implemented the use of both hardware and
software. A source code was made to make the hardware which consists of sensors
and a microcontroller to function properly. The sensors used are the OMRON
2SMPP-02 pressure sensor, Pulse Sensor and SO-MIC sound sensor. The device
was tested to check on its reliability as a detection device. The device can
successfully detect the presence of breathing and show the result on LCD display.
As a conclusion, the device can work as a detection device but there are still many
rooms for improvement.
vi
ABSTRAK
Apnea tidur adalah satu sindrom yang menyebabkan nafas terhenti seketika
ketika tidur pada waktu malam. Penyakit ini berbahaya kerana ia boleh
menyebabkan kematian mengejut jika tidak dirawat. Penyakit ini dikesan melalui
kaedah polisomnografi atau ujian tidur yang dijalankan oleh pakar tidur.
Bagaimanapun, cara ini agak menyusahkan memandangkan pesakit perlu bermalam
di hospital dan disambung dengan pelbagai wayar di seluruh tubuh untuk
menjalankan ujian. Bayarannya juga agak tinggi di kebanyakan hospital atau klinik
tidur. Tujuan projek ini dijalankan adalah untuk menghasilkan alat pengesan sleep
apnea mudah alih yang mudah digunakan dengan harga berpatutan. Selain itu,
objektif projek ini adalah untuk mengantara muka pelbagai jenis sensor dan
memproses isyarat tersebut untuk pengelasan apnea tidur. Alat mudah alih ini
dihasilkan supaya ia dapat mengesan apnea melalui saluran udara hidung dan mulut.
Projek ini mengaplikasikan kedua-dua cara perkakasan dan perisian. Satu code
sumber telah dibina bagi memastikan perkakasan yang terdiri daripada sensor and
mikropengawal berfungsi dengan betul. Antara sensor yang digunakan adalah
sensor tekanan OMRON 2SMPP-02, Pulse Sensor dan sensor bunyi SO-MIC. Alat
ini telah diuji keberkesanannya sebagai alat pengesan. Alat ini berjaya mengesan
kehadiran nafas dan memaparkan hasilnya pada paparan LCD. Sebagai konklusi,
alat ini berupaya untuk berfungsi sebagai alat pengesan tetapi masih terdapat banyak
ruang untuk diperbaiki.
vii
TABLE OF CONTENTS
CHAPTER TITLE PAGE
DECLARATION ii
DEDICATION iii
ACKNOWLEDGEMENT iv
ABSTRACT v
ABSTRAK vi
TABLE OF CONTENTS vii
LIST OF TABLES xi
LIST OF FIGURES xii
LIST OF ABBREVIATIONS xiv
LIST OF APPENDIX xvi
1 INTRODUCTION 1
1.1 Background of Study 1
1.2 Problem Statement 3
1.3 Objectives of Project 3
1.4 Scope of Work 4
viii
1.5 Thesis Outline 5
2 LITERATURE REVIEW 6
2.1 Previous Works 6
2.2 Sleep Apnea 9
2.2.1 Introduction 9
2.2.2 Common Symptoms 11
2.2.3 Diagnosing Method 12
2.3 PIC16F877A and SK-40C 13
2.4 Sensors 16
2.4.1 OMRON MEMS Pressure Sensor –
2SMPP-02
16
2.4.2 SO-MIC-MOD Digital Sound Module 18
2.4.3 LM35 Temperature Sensor 19
2.4.4 Pulse Sensor Amped 20
2.5 Software and Tools 22
2.5.1 MPLAB IDE 22
2.5.2 Hi-Tech C Compiler 23
2.5.3 PICkit2 Application 23
3 METHODOLOGY 25
ix
3.1 Introduction 25
3.2 Project Description 25
3.3 Hardware Implementation 27
3.3.1 SO-MIC Sound Module 27
3.3.2 LM35 Temperature Sensor 27
3.3.3 2SMPP-02 Pressure Sensor 28
3.3.3.1 Instrumentation Amplifier 28
3.3.4 Pulse Sensor 31
3.3.5 Completed Circuit Prototype 31
3.4 Software Implementation 32
4 RESULTS AND DISCUSSION 37
4.1 Introduction 37
4.2 Final Results 37
4.2.1 Breathing 39
4.2.2 Not Breathing 40
4.2.3 Pulse Rate 42
4.3 Discussion 43
5 CONCLUSION 44
x
5.1 Introduction 44
5.2 Conclusion 44
5.3 Recommendation 46
REFERENCES 48
APPENDIX 51
xi
LIST OF TABLES
TABLE NO. TITLE PAGE
2.1 Sleep apnea classification 10
3.1 Resistors and gain(AV) values 29
4.1 Pulse rate reading test results 42
xii
LIST OF FIGURES
FIGURE NO. TITLE PAGE
2.1 Partial and complete airway obstruction 10
2.2 PIC16F877A pin-out by Microchip 14
2.3 SK-40C 15
2.4 OMRON 2SMPP-02 pressure sensor 17
2.5 2SMPP-02 terminal arrangement 17
2.6 SO-MIC MOD sound module 18
2.7 LM35 19
2.8 LM35 pin connection 19
2.9 Pulse sensor application 21
2.10 PICkit2 application interface 24
2.11 UIC00B 24
xiii
3.1 Block diagram of project 26
3.2 Instrumentation amplifier 30
3.3 Complete project connection 31
3.4 Algorithm flowchart 32
3.5 Select Language Toolsuite window 33
3.6 MPLAB project workspace window 34
3.7 Project output 35
4.1 Project prototype 38
4.2 LCD display information 38
4.3 Result when breathe detected 40
4.4 Results when not breathing 41
xiv
LIST OF ABBREVIATIONS
LCD Liquid-Crystal Display
LED Light Emitting Diode
OSA Obstructive Sleep Apnea
CSA Central Sleep Apnea
PSG Polysomnography
EEG Electroencephalogram
AHI Apnea-Hypoapnea Index
PIC Peripheral Interface Controller
RAM Random Access Memory
EEPROM Electrically Erasable Programmable Read-Only Memory
SSP Synchronous Serial Port
SPI Serial Peripheral Interface
xv
CMOS Complementary Metal–Oxide–Semiconductor
USB Universal Serial Bus
MEMS Micro Electro Mechanical Systems
xvi
LIST OF APPENDIX
APPENDIX TITLE PAGE
A Programming Source Code 51
CHAPTER 1
INTRODUCTION
1.1 Background of Study
Advancement in technology has made it possible for human beings in
discovering many kinds of diseases, sickness and abnormalities. One of it is the
sleep apnea disorder. Not many people know about sleep apnea and what it can do
to affect our daily life. Apnea or apnoea – as it is known in Europe – is the
temporary absence or cessation of breathing. It is a condition when someone stops
breathing for a while either voluntarily or involuntarily. In this context, sleep apnea
is known as a disorder that causes a pause in breathing when a person has a night
sleep.
Sleep apnea disorder is divided into three categories which are Obstructive
Sleep Apnea (OSA) and Central Sleep Apnea (CSA). The third category is the
combination of both OSA and CSA. According to Janet MT et al, OSA is caused by
intermittent closure of airway whereby CSA happened when the abnormal messages
sent by the brain make breathing stop inappropriately. There are symptoms that can
relate to sleep apnea and that include loud snoring, restless night sleep and daytime
2
sleepiness. Most of the time, people with sleep apnea did not realize that they have
this disease as the pause happened during sleep.
Although some people might have not heard of sleep apnea, it should not be
taken lightly. Sleep apnea occurs to anyone regardless of their genders, age and
ethnicity. If it is not treated or controlled properly, it can even lead to several other
diseases which among others did include sudden death, heart attack, high blood
pressure and hypertension. There are several factors that might cause sleep apnea.
Obesity, alcohol consumption and nasal or oral airway abnormalities are some of the
factors that worth mention.
According to Datuk Dr Noor Hisham Abdullah, the Deputy Director of
Health (Medical) on 2011, the social and industrial progress led to the sleep-related
problems. In a book “Standards of Sleep Facility in Ministry of Health, Malaysia”, it
is stated that a research has been done by the University Malaya on sleep apnea,
particularly on the obstructive sleep apnea, where in Malaysia, it is estimated that the
syndrome is 9% and 4% respectively for middle aged men and women[1].
However, concerned people who feel like they do have sleep apnea can have
themselves go for a polysomnography test or sleep test at respective clinic or
hospital. Polysomnography (PSG) is the study of sleep where several conditions
such as abdominal movement, electroencephalogram (EEG) and electro-oculogram
of a patient were being monitored and analyzed. PSG can only be done by
profesional sleep technicians or doctors. Another method to diagnose this disorder is
to analyze the medical history of a patient by understanding the eating lifestyle,
smoking or drinking habit or sleeping pattern.
3
1.2 Problem Statement
Polysomnography (PSG) or the sleep test is the most accurate way of
diagnosing sleep apnea at this point of time. Patients who want to have the test are
required to spend the night at the hospital or the sleep centre where they will be
tended by profesional sleep test attendants and doctors. This can be a bit
burdensome to some people who did not like to set their feet in hospitals. There is
also a home sleep test where the patients will be given the PSG machine and have
the test at their home but in Malaysia, this method is not fully implemented yet.
Furthermore, sleep test through PSG would need the patients to be hooked up
to many wires which can be very discomforting. So, even though they get to feel the
comfort for being in their own home, the feeling of being tangled with wires is
somehow can be unpleasant. In Malaysia, sleep test can be done in government
hospital for a relatively low fee as compared to the private hospital, but the waiting
time to get the treatment can be long. Sleep test in private hospital would probably
did not take much time to wait but the fee is very costly. The PSG machine is also
huge and not portable and this would make it hard for the patients to move around
when they sleep.
1.3 Objectives of Project
For this project, there are three objectives that had to be achieved. Firstly, it
is to develop a portable diagnosing tool for patients with sleep apnea. Next, this
device is also supposed to be very affordable for the users where many people can
benefit from it with a one-time investment. The operation of this device is also had
4
been simplified so that the users can check for themselves whether they have sleep
apnea or not. The final objective is to interface and process the sensor signals for
sleep apnea classification. By analyzing the input signals from the sensors, we can
determine the severity of the sleep apnea of the users.
1.4 Scope of Work
The scope of work encompasses two areas, the hardware and software. For
hardware, it basically involved the interfacing of multiple sensors to a
microcontroller for sleep apnea diagnosis. The result would then be interpreted and
showed on the output devices. There were four types of sensors, one PIC
microcontroller and three types of output devices used for this purpose. Some
electrical components such as the Op-Amp had also been used in this project.
For software implementation, it basically involved the programming part of
the whole system. A source code was written to make sure the device works
properly. The written source code would then be compiled and download to the
microcontroller and the completed circuit.
5
1.5 Thesis Outline
This thesis had been organized into five separate chapters and each has its
own title. The first chapter is the Introduction part where it mainly explained the
background of the study. Chapter 1 also outlined the problem statements, objectives
and project scoped of this thesis.
Chapter 2 is on Literature Review. This chapter serves as the part where all
the previous work related to this project had been discussed. In-depth explanation
on each components used in this project can also be found in this chapter. In
addition, more detail on sleep apnea will also be discussed here.
The third chapter is Chapter 3 and it is about Methodology. This chapter
described all the steps taken to finish the project. It also explained how the
components had been put to use to make sure the device functions well and to ensure
the success of this project.
Next chapter is Chapter 4 and it is on the Results and Findings of the project.
Any findings regarding the prototype design of the project had been discussed here.
Not only that, the analysis on any data taken from the device can also be found here.
Finally, the fifth and the last chapter of this thesis - Chapter 5 – and it is
about the conclusion that has been made throughout the project. This chapter also
outlined some of the recommendation or suggestion of this project, should there be
any continuation to be done by other people on the same topic.
CHAPTER 2
LITERATURE REVIEW
2.1 Previous Work
As there are many concerns on the effect of sleep apnea on one’s daily life,
there have been many researches written on this topic. One of the most mentioned
subjects is on the effect of portable diagnosing for sleep apnea patients. Throughout
the years, PSG has become the primary method of diagnosing sleep apnea. Knowing
that PSG test in hospital can be very much uncomfortable, portable PSG machine for
home test has been developed. But still, the test still proves to be burdensome and
the machine is not really cheap and affordable. At this time of thesis writing, no
portable device for sleep apnea detection other than PSG machine has been
developed commercially. Even so, continuous research and studies had been done
by many individuals and organizations on the portable detection device as it is
beneficial to the public.
In 1997, Koja et. al[2] has done a research on developing portable sleep
apnea detector. On their research, they also included the verification on the
usefulness of their portable detection device for screening sleep apnea. The portable
device was made of three sensors for respiratory movements, a sensor for breath
7
detection and a data recorder. To ensure the patients’ comfort during the diagnosis,
the movement sensors were placed between the mattress and bed sheet and not on the
patients’ body. A sound sensor was used to detect breathing sound such as snoring.
The study was done and tested on 50 sleep apnea patients with average age of 47 and
consists of both genders. To compare the reliability of their device, PSG test was
also done simultaneously. For this research, it is concluded that the device is useful
for sleep apnea syndrome screening purpose.
One of the early research and study on portable sleep apnea detector was
done by Emsellem et. al[3] in 1990. For this research, they had developed a portable
device that can measure nasal/oral airflow, chest wall movement, cardiac rhythm and
blood oxygen saturation. As verification of the usefulness of the device must be
made, they had compared the data obtained from the device with the data obtained
from the standard PSG method. The study was conducted on 67 sleep apnea
patients. From the research, they had found that the device has a sensitivity of 95%
and a specificity of 96%.
In an article published by María et. al[4] in 2007, a discussion and findings
on the reliability of home diagnosis and the costs’ analysis had been done. The study
was conducted by implementing the home respiratory polygraphy on 45 patients with
sleep apnea. The results from the diagnosis had been compared to the result taken
from the PSG test to measure the accuracy of home respiratory polygraphy. For the
cost analysis, the calculation was done theoretically for a population of 1000
individuals. At the end of the study, it is concluded that home respiratory
polygraphy is a reliable method for diagnosing sleep apnea syndrome. In addition, it
was also mentioned that the method was more economical when it is compared to the
in lab PSG test.
Another article that also mentioned about portable sleep apnea detector was
done by Hida et. al[5] in a research paper published in 1995. A portable device was
8
developed with the understanding that other detection devices were deemed to be
hard for normal people to operate. The portable device developed by the team can
measure three variables which are the oronasal airflow, tracheal sound and electrical
activity of the heart. It also can store the time of apnea events, duration and R-R
intervals with a built-in microcomputer. The portable device had system’s sensitivity
and specificity if 92.5% and 87.5% respectively. In conclusion, the device is useful
and can be used for the screening of outpatients with sleep apnea syndrome.
Rotariu and Costin[6], had developed a remote monitoring system for sleep
apnea syndrome diagnosis. It is to be used both in-hospital or in-home tests. For the
research, the respiratory rate of the patient was continuously measured by using
wireless devices and the data was sent to the central monitoring station via a wireless
sensor network. The system can also activate an alert upon the detection of sleep
apnea episodes. A prototyped was made, tested and implemented and it is user
friendly. The prototype was also flexible, scalable and cost-effective. This system
had served it purpose as an alternative to medical supervision in hospital especially
for elderly who suffered sleep apnea problem.
In order to develop a portable device on sleep apnea syndrome detection, a
thorough understanding and knowledge on the related subject must be studied and
fully understood. The following sections will explain and discuss the details on the
related subjects related to this project development.
9
2.2 Sleep Apnea
This subsection will have some explanation on the introduction of sleep
apnea along with its background. Common sleep apnea symptoms are also been
discussed in this section. The next subsection will explain more on the method of
sleep apnea diagnosis.
2.2.1 Introduction
Sleep apnea is a syndrome where a person experiences a sudden pause in
breathing during a night time sleep. Guilleminault et. al[7] had defined asleep apnea
as the cessation of air flow at the nose and mouth for at least 10 seconds. Sleep
apnea can be categorized into three types with the first being Obstructive Sleep
Apnea (OSA) followed by Central Sleep Apnea (CSA). The third type comprises of
both OSA and CSA. Apnea event is further divided into two categories which are
apnea and hypoapnea. The condition when the flow of air slows during sleep – with
at least 30% - is known as hypoapnea. But when the flow of air stops completely
during sleep – for at least 10 seconds – it is known as apnea[8]. The severity of sleep
apnea can be determined by implementing the Apnea-Hypoapnea Index (AHI).
According to Bradley et. al[9], AHI is the frequency of apneas and hypoapneas per
hour of sleep and it is the measure of the severity of sleep apnea. The severity of
sleep apnea can be classified into three conditions and details were shown in the
following Table 2.1.
10
Table 2.1 : Sleep apnea classification
Severity AHI
Mild 5-14
Moderate 15-30
Severe >30
A person is considered to have OSA if the apnea and hypoapnea event that
happened are due to the collapse or blockage of the upper airway[8]. Janet et. al[11],
mentioned that an obstructive sleep apnea is caused by intermittent closure of airway.
Virend et. al[22], in their research paper had characterized OSA by repetitive
interruption of ventilation during sleep and this was caused by the collapse of
pharyngeal airway. Compared to CSA, OSA is much predominant among people.
The following Figure 2.1 is showing the condition of a person when he experience
partial or complete airway obstruction.
Figure 2.1 : Partial and complete airway obstruction
11
2.22 Common Symptoms
There are certain symptoms that can relate to sleep apnea. One of the
common symptoms that is often associated with sleep apnea is excessive daytime
sleepiness[10]. The prevalence is estimated to be 8% to 30% through
epidemiological studies. Excessive daytime sleepiness is a challenging symptom to
detect as people has difficulty to differentiate it with tiredness. According to Ramsey
et. al[10], sleepiness was described as the tendency to fall asleep, whereas fatigue
involved a task context with musculoskeletal or neurasthenic qualities. In a study
done by students of Universiti Malaysia Sarawak, they found out that daytime
sleepiness was 35.5% - for those undergoing clinical postings. Although excessive
daytime sleepiness is on of the most occurred symptoms of sleep apnea, it is rarely
used as an indication of any disease.
During breath, certain obstructions that may occur along airflow path will
lead to irregular, turbulent air movement[8]. The turbulent is co-related with the
irregular vibration of the upper airway structure and the sound that is produced from
it is what had been called as snoring. In the field of sleep apnea study, it is agreed
that snoring the most occurred symptoms that happened to sleep apnea patients.
People who always snore when sleeping are probably having sleep apnea. This is
due to the fact that snoring is a sign of increased upper airway resistance and this
somehow related to sleep apnea condition. Snoring is not a trivial matter. It has
been reported that one forth of world’s population snores and there is a percentage of
14.5% of children in Hospital Kuala Terengganu who snores[1]. Even so, there is
still some occurrence of sleep apnea among non-snoring patients.
12
2.2.3 Diagnosing Method
Numerous ways has been developed for diagnosing sleep apnea syndrome.
But the most common and accurate diagnosing method was through
polysomnography (PSG). According to Bradley et. al[9], PSG is a multichannel
electrophysiological recording of electroencephalographic, electroculographic,
electromyographic, ECG and respiratory activity to detect breathing disturbance
when sleeping. Individuals who want to have diagnosis of sleep apnea through this
method must have an all-nighter in the respective hospitals or sleep-clinic where the
PSG test is available. Normally, patients will be asked to undergo the test for at least
one time – depends on the analysis of the collected data. During the stay, profesional
sleep-test attendants will tend to the patients and installed the PSG machine to the
respective places of the patients. The behavior of the patient during the time of the
test will be monitored by the doctors or the profesional attendants. Through various
reading that has been collected through the study, the number of apnea episodes and
their length was measured[11].
Not only that, in normal sleep studies like PSG, the amount or concentration
of oxygen in patient’s blood, heart rate and abnormal body movement – particularly
eye and leg - was also measured. Patients with sleep apnea often associated with
having low concentration of oxygen in blood. While normal healthy people without
sleep apnea have oxygen level of more than 90% - normally 97% - sleep apnea
patients have a much lower oxygen level than that[8]. Lack of oxygen in blood is
due to the fact that when a person stops breathing, the lungs will stop filling air and
hence will slow the oxygen delivery to the whole body systems. This is where pulse
oxymeter comes in handy as it is widely used to measure blood’s oxygen
concentration.
Sleep studies can also be done in the patients’ home. It is available upon
request by the patients who did not want to spend the night at the clinic. For home
13
sleep test, firstly the patients will be given instruction on how to wear the machine by
the sleep experts. The patients are required to collect the data and give them to the
doctors for further analysis. Home sleep test is much favorable by some patients as
the test is done at one’s home comfort. Home sleep test in Malaysia is not fully
implemented yet so the only option is to spend the night at the clinic. But still,
diagnosing method by using PSG is far from being comfortable as the patients will
be wired up on most parts of the body. The number of connections depends on how
many data we want to analyze. Other than being uncomfortable, sleep test is costly
and the data can only be analyzed by experts.
2.3 PIC16F877A and SK-40C
PIC16F877A is a 40-pins Peripheral Interface Controller (PIC)
microcontroller manufactured by Microchip[12]. Prior to it being a PIC-typed
microcontroller, there are several advantages of 16F877A which lead to its
implementation in this project development. From the datasheet provided by
Microchip on this device, it is described as a CPU with high-performance RISC and
have only 35 single-word instructions to learn[13]. 16F877A has a data memory
capacity (RAM) of 368 bytes and 8192 words of Program Memory. Built with 33-
pins of Input and Output (I/O), this PIC has 256 bytes of EEPROM and can operate
from 2-5V voltage source. The pin-out of PIC16F877A can be seen in Figure 2.2.
14
Figure 2.2 PIC16F877A pin-out by Microchip
PIC16F877A has 10-bit Analog-to-Digital module and so it can store 10-bit
digital output data which is sufficient for this project. 10-bit resolution is compatible
for analog data conversion from various sensors that has been used in this project.
Furthermore, 16F877A has 8 analog input channels which are more than enough for
the project. 16F877A has three timer modules namely Timer0, Timer1 and Timer2
and two analogue comparators. Timer0 and Timer2 are 8-bit timer/counter while
Timer1 is 16-bit. 16F877A has synchronous serial port (SSP) with SPI (Master
mode) and I2C (Master/Slave). Some of the special feature of this PIC is that it can
withstand 100,000 erase/write cycles and has EEPROM data retention of more than
40 years. As it is developed based on CMOS technology, this microcontroller
consumes low-power usage.
With it being a PIC microcontroller, it can be found easily at a relatively low
price. Microchip, as the developer of this PIC had provided the user with free
development software with on-line tutorials which is proven to be beneficial for new
programmers. As 16F877A is a mid-range PIC, the programming is quite straight
15
forward and easier. One disadvantage of 16F877A is, it does not have internal
oscillator and so the use of external oscillator is a must. Normally, 20 MHz crystal
oscillator was used to serve this purpose.
There are three essential elements that a microcontroller needs in order for it
to work properly. Those three elements are the oscillator, power supply and reset.
The elements must be connected to the microcontroller along with other electrical
components like resistors and capacitors. Normally, users will develop their own
circuits with the needed components to use the microcontroller but nowadays there is
already a development board that is available to purchase. For this project, a PIC
development board SK-40C by Cytron was used as in Figure 2.3. SK-40C is a
development board that can be used with any 40-pins PIC microcontroller. It is a
handy and easy PIC development board for amateurs or even professionals. The
board was equipped with a connector for a programmer, USB connector, RESET
button, two push buttons, switch for power supply and many more[14]. No further
connection was needed for this board as it has already connected to a 20 MHz
oscillator and voltage regulator.
Figure 2.3 : SK-40C
16
2.4 Sensors
To achieve the objective of this research which is to interface multiple
sensors on a microcontroller, many sensors had been selected and chosen. Omron
MEMS pressure sensor, SO-MIC-MOD sound module and LM35 were used in this
project as a set of breathing sensor. Pulse sensor was used to detect patient’s pulse
and measure the heart beat. The details and explanation of these sensors can be
found on their respective subsections below.
2.4.1 OMRON MEMS Pressure Sensor – 2SMPP-02
OMRON has invented a piezoresistive MEMS pressure sensor with ultra
miniature size for various applications[15]. With only the size of 6.1 x 4.7 x 8.2mm
(L x W x H), it can withstand applied pressure with the range of 0 to 37kPa. From
the datasheet provided by OMRON, 2SMPP-02 has offset and span voltage of -
2.5±4mV and 31.0±3.1mV respectively. This surface mount sensor has low power
consumption with only 0.2mW and low temperature influence of ±1.0%FS (span)
and ±3.0%FS (offset). This piezo resistive sensor is able to detect gauge pressure
with the applicable gases being non-corrosive and dust free air.
2SMPP-02 is a MEMS-based sensor. MEMS stand for Micro-Electro-
Mechanical Systems and it is known as the miniaturized mechanical and electro-
mechanical elements. MEMS devices development involved the microfabrication
techniques. Many sensors nowadays had implemented MEMS technology in their
design as MEMS are proved to be lightweight, small and easy to use. Other sensors
that use MEMS technology alongside pressure sensors are temperature and radiation
sensors. The actual sensor can be seen in the following Figure 2.4.
17
Figure 2.4 : OMRON 2SMPP-02 pressure sensor
OMRON 2SMPP-02 is a piezoresistive-typed sensor and so, it is a solid state,
monolithic sensor that is fabricated through silicon processing. It is usually
constructed in silicon and the sensing element is actually a four element bridge.
Piezoresistive sensor worked in a way that an applied stress will cause a change in
the resistivity of a material[16]. The terminal arrangement of 2SMPP-02 can be seen
in the following Figure 2.5.
Figure 2.5 : 2SMPP-02 terminal arrangement.
18
2.4.2 SO-MIC-MOD digital Sound Module
SO-MIC is a sound module bought from Cytron Corporation[17]. It is a
microphone module that can be used for any audio detection. Operate at 3.3V to 5V
DC supply voltage; this sound module can only produce digital output. This sound
module has an on-board potentiometer so the user can change the threshold as they
like. The digital output (DO) produced will be LOW if there is sound detected and
goes HIGH when there is no sound detected. There is an LED on-board that act as
an indicator when the sound is detected. Cytron has made it easy for the user to
interface the microphone module to any microcontroller by making it a 3-pin device.
The pins are VCC, GND and OUT respectively. The OUT pin is supposedly to be
connected to the digital input pin of a microcontroller. Figure 2.6 below is taken
from the startup guide by Cytron.
Figure 2.6 : SO-MIC MOD sound module
19
2.4.3 LM 35 Temperature Sensor
LM35 is a temperature sensor developed by National Semiconductor[18]. It
is a precision centigrade temperature sensor and so the output voltage is directly
proportional to the Celsius (centigrade) temperature. This feature enables users to
directly calibrate the reading in Celsius without having to convert it from Kelvin or
Fahrenheit. It is an analog-typed sensor and has the scale factor of 10.0mV for every
°C. LM35 has low self heating which is less than 0.1°C in still air and has accuracy
of 0.5°C (at 25°C). This sensor can operate from 4 to 30V and has temperature range
of -55°C to 150°C. LM35 also comes with 3-pins which are VS, VOUT and GND. All
three pins are connected to voltage source, microcontroller input pin and ground
respectively. Since LM35 is an analog temperature sensor, the VOUT pin must be
connected to an analog pin of a microcontroller for data conversion from analog to
digital. While it does have many good features, this sensor is easily available at very
affordable price. The actual picture and pin connection can be seen in Figure 2.7 and
Figure 2.8 respectively.
Figure 2.7 : LM35
Figure 2.8 : LM35 pin connection
20
2.4.4 Pulse Sensor Amped
Pulse sensor amped was made by Joel Murphy and Yury Gitman of
PulseSensor. It is a plug-and play heart rate sensor for Arduino[19] but it can still be
used with other microcontrollers like PIC. It is made by for users to incorporate live
heart rate date into any projects. Pulse sensor can be used to detect pulse rate either
from the fingertip (Figure 2.9(b)) or earlobe (Figure 2.9(c)).
It works with voltage supply of 3 to 5V. Pulse sensor is mounted with three
connection wires for Vs, Signal and GND. As this is an analog sensor, the Signal pin
must be connected to the analog input pin of a microcontroller. Single LED that has
been used for this sensor is an LED from Avago APDS-9008 green LED and it has
the wavelength of 565nm. The following Figure 2.9(a) is the actual image of the
pulse sensor.
21
(a)
(b)
(c)
Figure 2.9 : Pulse sensor application (a) Pulse sensor (b) Pulse sensor on fingertip
(c) Pulse sensor on earlobe
22
2.5 Software and tools
This subsection is mainly discussed on the software used for this project
development. There is several software programs that have been used for this project
and each function were discussed in the following subsections.
2.5.1 MPLAB IDE
MPLAB IDE is software that runs on PC to develop applications for
Microchip microcontrollers and digital signal controllers. It is provided for free for
users[13]. IDE stands for Integrated Development Environment as it is believed to
provide a single integrated environment of code development for embedded
microcontrollers. This development system for embedded controllers is a system
running on a PC to write, edit debug and program code and it contains all the
components needed to design and deploy embedded systems applications.
There are some built-in components in MPLAB IDE and consist of project
manager, editor, assembler/linker and language tools, debugger and finally the
execution engines. The project manager provides integration and communication
between the IDE and the language tools. Editor is a text editor that is also act as a
window into the debugger. An assembler can be used alone to assemble a single file,
or used with linker to build projects from separate source file. Debugger works with
an editor and it allows breakpoints, single stepping, watch windows and many more.
Finally, there is an execution engine where it functions as software simulators.
23
2.5.2 Hi-Tech C Compiler
MPLAB IDE is designed to work with many Microchip and third party
language tools. These tools will create an executable code that can be programmed
to selected device from an application code written in assembly, C or BASIC
language[20]. Hi-Tech language tools are supported by MPLAB IDE and the tools
include the C Compiler, Assembler and linker. HI-TECH C is a compiler featuring
Omniscient Code Generation™
, whole-program compilation technology, for
Microchip Technology's 8-, 16-, and 32-bit PIC® microcontroller and dsPIC
® digital
signal controller architectures.
Hi-Tech C Compiler is a freeware compiler if it was used in Lite Mode
version. It supports PIC10, PIC12 and PIC16 series devices. It is fully compatible
with MPLAB IDE and also fully ANSI-compliant. For ease of use, Hi-Tech also
includes Library source, macro assembler, linker, pre-processor and one step driver.
2.5.3 PICkit2 Application
PICkit2 is a programmer/debugger application by Microchip. It allows the
user to program all supported devices as listed in PICkit2 Readme file. The interface
of the application can be seen from Figure 2.10.
24
Figure 2.10 : PICkit2 appilication interface
To write a program to a microcontroller, a written source code must be
compiled first and to generate a .HEX file. When the .HEX file is generated, PICkit2
must import the file first and finally the program can be load into the selected device.
But to load the program into the device – microcontroller – a help from a
programmer was needed. For this project, a programmer UIC00B by Cytron was
used. To use it, the user needs to connect the programmer to the microcontroller and
click the button Write on the PICkit2. A successful program load will be mentioned
by PICkit2. UIC00B by Cytron is small as can be seen in Figure 2.11.
Figure 2.11 : UIC00B
CHAPTER 3
METHODOLOGY
3.1 Introduction
This chapter will discuss the methodology that has been applied towards
finishing this project. For easy understanding of this project development, the
project methodology has been divided into three parts which are the introduction,
hardware and software. Both hardware and software can be found in the latter part
of this chapter.
3.2 Project Description
Figure 3.1 is the block diagram of the project. It basically tells the reader the
overview on what this project is really about and the real function of the project
prototype. Figure on the next page is the block diagram that described the flow of
the project prototype. The figure started with data acquisition process of the patients
through several sensors. The signals from the sensor will be received by the
microcontroller and the next process that takes place is the data conversion from
analog signal to digital – for analog input signal only. This was done by the built-in
26
ADC that exist in the PIC 16F877A. Following the conversion process, the newly
stored digital data was processed by the microcontroller and the result will be
represented by the LCD display, buzzer and LEDs. The last step is to analyze the
data to determine the sleep apnea condition.
Figure 3.1 : Block diagram of project
27
3.3 Hardware Implementation
Hardware section will explain more on the steps taken to build the working
circuit of project prototype. At the start of the project development, all of the
sensors had been tested for their functionality using simple circuits made up of
sensors, power supply and digital multimeter. After it was confirmed that the
sensors function properly, the complete circuit was made by interfacing the sensors
to the microcontroller. Output devices such as LCD display, LEDs and buzzer had
also been connected to the microcontroller and the sensors.
3.3.1 SO-MIC Sound Module
The pins of the sound module were connected properly to the voltage source
and ground. After it is sure that the connection is fine, the power was ON. The
sound module was tested by blowing the condenser microphone onboard the module.
The test was successful since the onboard LED of the module did light up from the
blowing. It has been showed that the SO-MIC sound module can detect sound
properly. The test was successful.
3.3.2 LM35 Temperature Sensor
The same procedures as SO-MIC sound module had been applied on the
LM35 sensor to test the device functionality. The differences were the Output pin
was connected on digital multimeter and LM35 was tested by applying body heat on
28
the sensor’s surface and the. This was done by placing fingertips onto LM35. After
the power supply is turned ON, the temperature will first detect the surrounding
temperature and display the value in Volt on the digital multimeter. When the heat
has been applied to the sensor, there will be slight changes on the voltage reading.
Since body temperature is much higher than the surrounding temperature at the point
of sensor testing, the multimeter showed an increase in reading. The reading on the
multimeter is based on the understanding that 10mV=1°C. If the reading on the
multimeter showed 0.350V, then the temperature is supposedly ±35°C. This test was
also successfully done.
3.3.3 2SMPP-02 Pressure Sensor
Device testing on the 2SMPP-02 pressure sensor is the same as the one for
SO-MIC sound module. But, to simulate the condition of breathing – exhale and
inhale – air draw in and blowing were done simultaneously. It is observed from the
digital multimeter that when the air was blown to the sensor (exhale), the reading on
the multimeter decreases. When air was drawn out of the sensor (inhale), the
reading showed an increase in voltage value. Since the pressure sensor reacted
properly, it is assumed that the test was also successful.
3.3.3.1 Instrumentation Amplifier
The sensor’s output signal is relatively small compared to the step size of the
ADC (as explained in Software Implementation section), so to make sure the signal
coming out from pressure sensor can be read properly by 16F877A built-in ADC, an
29
instrumentation amplifier circuit was built. The purpose of an instrumentation
amplifier is to amplify the sensor’s output signal so that it will be high enough for
the ADC to convert it with more accuracy. The instrumentation amplifier was built
by using several resistors and an LM324 Quad Operational Amplifier. LM324 is a
PDIP-14 low cost amplifier and can operate at various supply voltage as low as 3V
to 32V. It is a quad op-amp which means it has four amplifiers built internally as
seen in Figure 3.2 (a).
The circuit for the instrumentation amplifier was made on a breadboard and
the connection can be seen as in Figure 3.2 (b). Pin V1 and V2 were to be connected
to pin VOUT+ and VOUT- of 2SMPP-02 pressure sensor respectively. The voltage gain
was calculated by using the formula for instrumentation amplifier gain calculation.
The details of the calculated gain, AV, and the values of the resistors were tabulated
in the following Table 3.1.
Table 3.1 : Resistors and gain (AV) values
R1 10kΩ
R2 1kΩ
R3 1kΩ
RG 180Ω
AV 11
30
(a)
(b)
Figure 3.2 : Instrumentation amplifier (a) LM324 Quad Core Amplifier (b)
Instrumentation amplifier circuit connection
31
3.3.4 Pulse Sensor
Similar test also had been applied on the pulse sensor. But, unlike SO-MIC
sound module and 2SMPP-02 sensor, test on pulse sensor was only done by strap it
properly on the fingertips. The digital multimeter will produce a non-constant
voltage reading. This is because the sensor was measuring the human pulse which is
changing every few hundred millisecond. According to the developer, once the user
had put on the sensor, the output voltage should be around half of the supply voltage.
For this test, since the voltage supply was 5V DC, the readings on the multimeter
should be ±2.5V. Once there were appropriate readings displayed on the digital
multimeter, it is concluded that the sensor was working properly.
3.3.5 Completed Circuit Prototype
Once it is made sure that all the sensors were properly function, all needed
components were connected together on a breadboard. The following Figure 3.3
depicted how the connection was made.
Figure 3.3 : Complete project connection
32
3.4 Software Implementation
This section will discuss on how the process of source code creation was
made by using programming software such as MPLAB IDE, Hi Tech and PICkit2.
Before the program was written, the whole process or events must be understood
first so that a right source code can be made. A flowchart as in Figure 3.4 was made
so that we have a clear perspective on what to write in the text editor.
Figure 3.4 : Algorithm flow chart
33
When the portable detector device was power up, the system will start
running and followed by ADC initialization and ADC read. When there was an
event of breathing, only the red LED1 on the development board will light up.
However, only yellow LED2 will light up when there was no breathing event. The
system will check for the event of not breathing for time more than 10 seconds. If
Yes, then it will count up and if No, it will restart the time and return to ADC read.
In an event when the time is more than two minutes, an alarm will trigger through a
buzzer. These whole events will be turned into programing code afterwards.
By using MPLAB IDE, users can write any programming code so that they
can compile and download it into a microcontroller. For this project, C language
was used instead of assembly language as it is easier to understand and is much
shorter than assembly code. Hi Tech ANSI C Compiler needed to be used together
with this software for compiling purpose as the PIC16 was used. As such, HI TECH
Universal ToolSuite was selected as seen in Figure 3.4. As shown in the Figure 3.5,
the program was written with MPLAB IDE and as it was written in C language, the
file needed to be SAVE as .c file before it was compiled.
Figure 3.5 : Select Language Toolsuite window
34
Figure 3.6 : MPLAB project workspace window
After writing the program, it was built and compiled to see if the code is
working or not. The other purpose for compiling is for the compiler to turn the .C
file into .HEX file so it can be written into the microcontroller. A successful build
and compilation will generate an Output window that mentioned about the built
program as shown in Figure 3.6(a). A folder that will keep all the files generated
from this project was created on the computer. Take note that the .C and .HEX file
were also located here and they can be seen in Figure 3.6 (b).
35
(a)
(b)
Figure 3.7 : Project output (a) MPLAB Output window (b) File directory
36
To download the newly written source code into the microcontroller, PICkit2
with the help of a programmer was used. Firstly, the programmer must be connected
to the development board that has been installed with PIC16F877A. Then, PICkit2
must be able to detect the device before it downloads the program. Next, the .HEX
file that was generated before was loaded and written into the microcontroller by
clicking write button. A successful program writing to the microcontroller will be
mentioned through the PICkit2 window.
CHAPTER 4
RESULTS AND DISCUSSION
4.1 Introduction
This chapter will discuss on the results of this project. Any observations that
have been found throughout project development will be explained in this chapter as
well. Analysis and discussion on the collected data from the project simulation will
also be described in detail here.
4.2 Final Results
A project prototype (Figure 4.1) was successfully developed and the
functionality of the prototype had been tested as well. The portable device was
finally built with multiple sensors – OMRON 2SMPP-02, Pulse Sensor and SO-MIC
- that were interfaced to a microcontroller and have the reading displayed on the
LCD display. The breathing event indicators were represented by two LEDs that
come with the development board.
38
Figure 4.1 : Project prototype
The prototype’s test was done by simulating the condition when a person
breathing. The corresponding result will be shown on all the output devices. LCD
display will indicate the time, pulse beat per minute, the apneic event counter and the
digital output value from the signal coming from sensors. They were all represented
by T, BPM and C respectively as shown in Figure 4.2.
Figure 4.2 : LCD display information
The test on the prototype was done right after downloading the written
program into the microcontroller. From the test done on the project prototype, it is
found that the device can successfully detect breathing and display the result through
39
onboard LEDs and LCD. The buzzer also gave out an alarm when there is no
breathing event for more than two minutes.
4.2.1 Breathing
To make the device able to detect breath, two breathing conditions have been
identified which are through the nose (nasally) or mouth (orally). The sensors those
were responsible for detecting nasal airflow are the LM35 temperature sensor and
the OMRON 2SMPP-02 pressure sensor. SO-MIC sound sensor was responsible
was detecting oral airflow and the snoring sound. This is based on the earlier
understanding that when a person breathes, he will let out air through nasally or
orally. It is also implied that a person is breathing when he snores.
The first breathing test was done to detect nasal airflow through temperature
sensor and pressure sensor. It was done by placing a finger on the pressure sensor to
simulate exhaling condition. This was done due to the pressure sensor was placed
directly onto the breadboard and by placing a finger on the sensor, the pressure was
reduced and hence having the same situation as breathe out as described in Chapter 3
of methodology. In addition, the test on temperature also implements the same
finger placing technique to give heat directly to the sensor. Red LED1 was light up
whenever the fingers were placed on either of the sensors. The LCD display was
able to display the digital output reading from the sensors as well. The time on the
LCD was reset whenever the fingers were placed on both sensors and as this event
was the indicator of human breath, the counter did not count up. The result can be
seen from the following Figure 4.3.
40
Figure 4.3 : Result when breath detected
The second breathing test was done by making a sound (to simulate snore)
and blowing air to the condenser microphone (to simulate breathing through mouth).
This second test was able to yield the same result as the first breathing test as it was
able to turn on red LED1 whenever there was sound present and when the air was
blown to the sound sensor. The LCD display was also able to reset the time and did
not trigger the apneic event counter.
4.2.2 Not breathing
The condition when there was no airflow or snoring sound detected was
classified as not breathing. As there were no signals detected by the sensor, the
timer started moving to count for 10 seconds interval time. If the time is less than 10
seconds, the apneic event counter will remain the same as depicted in the Figure 4.4
(a). But if it is already 10 seconds or more, the apneic counter will start to count up
as in Figure 4.4 (b). As an alert to the user, the buzzer that existed on the circuit will
give out sound whenever the user stop breathing for a long time which is more than
two minutes. This was programmed so that the user will wake up and starts
breathing again and hopefully can avoid having brain damage.
41
(a)
(b)
Figure 4.4 : Results when not breathing (a) Not breathing for t<10s, C=0 (b) Not
breathing for t>10s, C=1
42
4.2.3 Pulse Rate
Pulse sensor was wrapped around a finger and the reading of the pulse rate
was taken from the data on the LCD display. The test on pulse sensor was done on
four female subjects. The results from the pulse sensor were compared with the
results taken from manual reading and digital pulse oxymeter. The results were
tabulated as below.
Table 4.1 : Pulse rate reading test results
Subject Pulse Sensor (bpm) Manual Reading (bpm) Pulse Oxymeter (bpm)
A 68 74 75
B 88 85 88
C 76 77 78
D 89 87 90
It can be seen from the table that the data taken from the three methods did
not differ much except from the reading of the subject A. The reading taken from
the subject through pulse sensor differed from the reading from manual reading and
pulse oxymeter. But as a whole, the pulse sensor is able to measure human pulse
rate and was working properly.
43
4.3 Discussion
During the early project development, there were many problems faced
throughout the process. First problem was regard to the pressure sensor. At first, the
sensor was not able to detect any signal when it was connected to the
microcontroller. This was due to the signal of the sensor was relatively small
compared to the step size of the 16F877A ADC which is 4.888mV/step. This
problem was solved by applying the instrumentation amplifier circuit to the sensor
before it is been connected to the microcontroller.
Aside from that, the temperature sensor was omitted from the final prototype
although it can detect temperature decently. This is because, temperature sensor has
reaction rate that is much slower than the pressure sensor. The sensor was tested
both in normal room temperature and in air-conditioned room. When tested in a
much colder environment, the reading displayed on the LCD is a little bit slow. This
might be due to the nature of the sensor which the main purpose is to detect ambient
temperature.
The next problem was related to the pulse sensor. During the early test on
the sensor, the reading varies too much and to counter the problem, a new code was
written by adjusting the time delay in the source code. Another problem with this
pulse sensor is that, the accuracy in reading human’s pulse rate is slightly influenced
by the way of wrapping the sensor around finger. The wrapping must not be too
tight or too loose for it to work properly.
For this project, the pulse sensor can only detect pulse rate as it is not made
with red and infrared LEDs like what a standard pulse oxymeter used. The pulse
sensor used a green LED with the wavelength not suitable for measuring oxygen
concentration (SpO2) in blood. Even so, there is a relationship between pulse rate
44
and SpO2 which is the higher the pulse rate, the lesser the SpO2[21]. But
unfortunately, since this device can only display the pulse beat per minute on the
LCD display it is hard to decide the apneic condition by this method.
For the final prototype of this project, it was decide that the portable device
will consist of pressure and sound sensor as the oronasal breath detector and the
pulse sensor to measure the pulse rate. From the finished prototype, it can be seen
that the device is small enough to describe it as portable.
CHAPTER 5
CONCLUSION
5.1 Introduction
Chapter 5 is the final chapter in this thesis and in this chapter, there will be a
conclusion made on this project. This project still has its loophole and for this
reason there will be some recommendation section where it will discuss on the
improvement of the project. By making this recommendation, it is hope that it will
be useful for other people to use it as a reference in developing similar projects.
5.2 Conclusion
The conclusion that is made from finishing this project is that the objectives
stated earlier in this thesis had been accomplished successfully. It is to say that, at
the end of the project development, it is found that the device is portable and can be
used to detect human breathing and measure pulse rate. The process of interfacing
multiple sensors to a single microcontroller to determine the apneic event was also
46
successfully achieved. To get an appropriate reading of the sensors, improvement on
the circuitry has also been done correctly for example in the case of pressure sensor
and the instrumentation amplifier. The device can also display the result as planned
when it was tested.
5.3 Recommendation
Throughout the development of this project, it was found out that there are
still rooms for improvements. This is due to some limitations still present in this
device. At first, there should be a data storage function for the purpose of storing the
data so that a much thorough analysis on the sleep apnea syndrome could be made.
This feature is especially useful for the pulse sensor as it cannot display the user’s
pulse pattern for analysis and comparison purpose. A new type of microcontroller
must be used since PIC16F877A is not powerful enough for a large data storing
purpose particularly in the use of SD card. Another method is to have the 16F877A
equipped with the USB function for easy data transfer to PC.
Another improvement is on the circuitry of the device. For the device to have
better accuracy, the circuit should be connected properly by building them on a
printed circuit board (PCB) instead of a breadboard. This is because the connection
on the breadboard is loose and can cause noise. Furthermore, the manual design
instrumentation amplifier can be replaced with the actual instrumentation amplifier
IC so that the there will be less glitch when it is used with pressure sensor.
47
Finally, the last recommendation is to replace the pulse sensor with another
sensor that can act like pulse oxymeter. This improvement will make it easier for the
device to identify sleep apnea by measuring the SpO2 directly. In addition, a pulse
oxymeter can be programmed to calculate pulse rate as well.
48
REFERENCES
1. Medical Development Division (2011). MOH/P/PAK/210.10(BP). Putrajaya:
Malaysia Ministry of Health.
2. Koja. S, Arakaki. H, and Ogura. C. (1997). Developing the portable type
sleep apnea detector, and verifying the usefulness of the device. Seishin
Shinkeigaku Zasshi. 99(4): 181-197.
3. Emsellem. H. A, Corson. W. A, Rappaport. B. A, Hackett. S, Smith. L. G,
and Hausfeld. J. N. (1990). Verification of sleep apnea using a portable sleep
apnea screening device. South Med J. 83(7): 748-752.
4. Maria. L. A. A, Joaquin. T. S, Jose. C. G, Monica. G. M, Luis. R. P, Jose. L.
V. B. and Angel. M. C. (2008). Reliability of home respiratory polygraphy
for the diagnosis of sleep apnea-hypoapnea syndrome. Analysis of costs.
Arch Bronconeumol. 44(1): 22-28.
5. Hida. W, Kurosawa. H, Miki. H, Go. T, Shindoh. C, Kikuchi. Y, Takishima.
T, and Shirato. K. (1995). Portable home monitoring system in screening for
sleep-disordered breathing. Nihon Kyobu Shikkan Gakkai Zasshi. 33: 46-49.
6. Rotariu. C, and Costin. H. (2013). Remote respiration monitoring system for
sleep apnea detection. Revista medico-chirurgicala a Societatii de Medici si
Naturalisti din Iasi. 117(1): 268-274
49
7. Guilleminault. C, Tilikian. A, and Dement. W. C. (1976). The sleep apnea
syndromes. Annual Review of Medicine. 27: 465-484.
8. Samuel S. Becker. (2010). Snoring and Obstructive Sleep Apnea: Patient’s
Guide to Minimally-Invasive Treatments. N.J.: The New Jersey Centre.
9. Bradley. T. D, and Floras. J. S, (2003). Sleep apnea and heart failure: part I:
obstructive sleep apnea. Circulation. 107: 1671-1678.
10. Ramsey. R, Amit. K, and Kingman. P. S. (2007). Sleep Apnea: Diagnosis and
Treatment. Stanford, C.A.: Informa Healthcare.
11. Janet. M. T, Cassio. L, and Robert. M. C. (2011). Sleep Apnea. The Journal
of the American Medical Association. 305(9): 956.
12. Microchip, “ 8/40/44-Pin Enhanced Flash Microcontrollers,” PIC16F87XA
datasheet, 2003.
13. Martin P. Bates. (2008). Programming 8-bit PIC Microcontrollers in C with
Interactice Hardware Simulation. (2nd
ed.). U.K.:Newnes.
14. Cytron, “SK40C Enhanced 40 Pins PIC Start-Up Kit,” SK-40C user guide,
Mar. 2012.
15. OMRON, “MEMS Gauge Pressure Sensor,” SMPP datasheet, 01 .
16. Smith. C. S. (1954). Piezoresistance effect in germanium and silicon.
Physical Review. 94:42-49.
17. Cytron, “Mini Microphone Module,” SO-MIC-MOD guide, Dec. 2012.
18. National Semiconductor, “Precision Centigrade Temperature Sensors,” LM35
datasheet, Nov. 2000.
50
19. PulseSensor, “Pulse Sensor Getting Started Guide,” Pulse Sensor Amped
guide, 2012.
20. ICircuit Technologies, “Hi-Tech C Compilers,” Hi-Tech C setup guide, 2009.
21. Walter. J. D, and Stuart. B. (1962). Effects of oxygen breathing on the heart
rate, blood pressure ad cardiac index of normal men resting, with reactive
hyperemia, and after atropine. Journal of Clinical Investigation. 41(1): 126-
132.
22. Virend. K. S, David. P. W, Raouf. A, William. T. A, Fernando. C, Antonio.
C, Stephen. D, John. S. F, Carl. E. H, Lyle. J. O, Thomas. G. P, Richard. R,
Mary. W, and Terry. Y. (2008). Sleep apnea and cardiovascular disease.
Journal of the American College od Cardiology. 52(8):686-717.
23. ON Semiconductor, “Single Supply Quad Operational Amplifiers,” LM3 4,
LM324A, LM224, LM2902, LM2902V, NCV2902 datasheet, Dec.
2010[Rev.24]
51
APPENDIX A
Programming Source Code
//===============================================================================
// Author : ASYRAN ZYRATI YAHYA
// Project : PORTABLE SLEEP APNEA DETECTION DEVICE
// Project description : INTEGRATED SENSOR WITH LCD DISPLAY
// Remarks : lcd.h & system.h FILES ARE COURTESY FROM CYTRON
//===============================================================================
//===============================================================================
// include
#include <htc.h>
#include "lcd.h"
#include "system.h"
__CONFIG(0x3F32);
#define CHANNEL1 0b10001001 //Use channel1
#define CHANNEL2 0b10010001 //use channel2
#define snd1 RB3
#define buzzer RB2
#define LED3 RA5
//===============================================================================
//Function prototype
void breathing(void);
void interrupt ISR(void);
void delay1(unsigned long i);
void ADC_read(void);
unsigned short read_pressure(void);
unsigned short read_pulse(void);
int j;
int k;
int x;
int y;
unsigned char counter;
unsigned char count;
unsigned long BPM;
//===============================================================================
//Main Function
unsigned short result;
unsigned short pressure;
unsigned short pulse;
void main(void)
ADRESH=0;
ADRESL=0;
ADCON1=0b10000010; //vref=vdd
TRISA=0b00000110; // set AN1 as input port
TRISB=0b00001011; // set PORTB RB0-RB2 as input
TRISD=0b00000000; // set PORTD as OUTPUT
52
GIE = 1; //Enable Global Interrupt
INTE = 1; //Enable RB0/INT external Interrupt
PEIE = 0; //Disable all unmasked peripheral interrupt
INTEDG = 0; //Interrupt on falling edge
TMR0IE=1;
T0CS=0;
T0SE=0;
PSA=0;
PS2=1;
PS1=1;
PS0=1; //set prescale 1:256
PORTA = 0; // clear PORT
PORTB = 0;
PORTD = 0;
lcd_initialize();
lcd_clear();
lcd_goto(0x00);
lcd_putstr("T:");
lcd_goto(0x40);
lcd_putstr("C:");
lcd_goto(0x45);
lcd_putstr("BPM:");
while(1)
ADCON0=CHANNEL2;
ADC_read();
pulse=read_pulse();
//lcd_goto(0x4C);
//lcd_bcd(4,pulse);
x=x++;
//lcd_goto(0x42);
//lcd_bcd(2,x);
if(x<90)
if(pulse<=516) //rise h.beat
LED3=0;
else if(pulse>516) //not beating
LED3=1; //RA5 lights on
y=y++;
else if(x==90)
BPM=4*y; //calculate for beat per minute
lcd_goto(0x49);
lcd_bcd(3,BPM);
x=0;
y=0;
delay1(25000); //delay2ms
53
//===============================================================================
//Function for breathing -breath in and out
void breathing(void)
ADCON0=CHANNEL1;
ADC_read();
pressure=read_pressure();
lcd_goto(0x0C);
lcd_bcd(4,pressure);
if((pressure<196)&&(snd1==1)) //normal breathing without snoring
LED1=1; //RB6 lights on
LED2=0;
j=0;
delay1(500);
else if((pressure<196)&&(snd1==0)) //snoring with mouth close
LED2=0; //RB6 lights on
LED1=1;
j=0;
delay1(500);
else if((pressure>=196)&&(snd1==0)) //breathing or snoring through mouth
LED1=1;
LED2=0;
j=0;
delay1(500);
else if((pressure>=196)&&(snd1==1)) //not breathing -- no heat + no sound
LED1=0; //RB6 lights on
LED2=1;
delay1(500);
//===============================================================================
//subroutine ADC INITIALIZE
void ADC_read(void)
unsigned short m;
unsigned long digital_reading=0;
for(m=5;m>0;m-=1)
GO_DONE=1; //ADGO is the bit 2 of the ADCON0 register
while(GO_DONE==1); //ADC start, ADGO=0 after finish ADC progress
result=ADRESH;
result=result<<8; //shift to left for 8 bit
result=result|ADRESL; //10 bit result from ADC
digital_reading+=result;
54
result=digital_reading/5;
unsigned short read_pressure(void)
unsigned short pressure;
pressure=result;
return pressure;
unsigned short read_pulse(void)
unsigned short pulse;
pulse=result;
return pulse;
//===============================================================================
//subroutine DELAY
void delay1(unsigned long i)
for(;i>0;i--);
//===============================================================================
//subroutine INTERRUPT TIMER0
void interrupt ISR(void)
TMR0IF=1;
counter++;
if(counter==25)
breathing();
if(LED2==1) //not breathing
j=j++;
lcd_goto(0x02);
lcd_bcd(2,j);
if(j==30)
k=k++;
lcd_goto(0x42);
lcd_bcd(1,k);
else if((j>30),(j<50))
k=k;
lcd_goto(0x42);
lcd_bcd(1,k);
else if(j>50)
k=k;
buzzer=1;
else
55
j=0;
lcd_goto(0x02);
lcd_bcd(2,j);
counter=0;
TMR0IF=0; // clear the interrupt flag