Report Link - Union College

advertisement
Heart Monitor Application
for Android
by
Craig Santangelo
*********
ECE 499: Electrical Engineering Capstone
Design Project
Advisor: Prof. Hedrick
March 1, 2012
Forward:
I believe that the purpose of a capstone design project is to take your
learning from the time spent at school and to apply this knowledge toward a
problem in everyday life. The problem that I am trying to solve is that over one
million Americans will suffer and possibly die from a heart attack every year. A
large portion of these deaths have occurred because of the fact that these victims
were not quick enough or failed to alert medical assistance. From personal
experience, I have had relatives that were put in severe danger because of this fact.
For my project, I did some thinking as to how to solve this problem. To do this, I
would need something that would call for help immediately after detecting that a
heart attack started to occur. From there, I decided to coordinate this idea with
something that everyone always has with them: a cell phone. To do this, I came up
with my project consisting of a heart monitor application for the Android. This
report will explain the steps I took and the research that was done to accomplish the
design and implementation of this system.
Summary:
The objective of this project is to decrease the number of deaths caused by
heart attacks each year by designing and creating a heart monitor to go along with
your cell phone. This monitor will analyze the heart and automatically call for help
in the event of an emergency. After completing this project, the system might be
expensive to implement at first, but using this idea I am confident that it could one
day become a product that all heart patients use at home for their safety.
2
Table of Contents
Forward………………………………………………………………………………………………………………2
Summary……………………………………………………………………………………………………………..2
Introduction………………………………………………………………………………………………………...5
Background………………………………………………………………………………………………….…6-10
Design Requirements…………………………………………………………………………………….10-13
Design Alternatives…………………………………………………………………………………….…13-15
Final Design and Implementation..………………………………………………………………...15-22
Circuit Design and Implementation………………………………………………………15-19
Heart Attack Detection………………………………………………………………………..19-22
Performance Estimates and Results……………………………………………………………….22-28
Production Schedule…………………………………………………………………………………………..29
Cost Analysis……………………………………………………………………………………………...…30-31
User’s Manual…………………………………………………………………………………...….……….31-32
Discussion, Conclusions, and Recommendations…………………………………...…….….32-33
Bibliography…………………………………………………………………………………………………34-35
Appendix………………………………………………………………………………………………………36-37
3
Table of Figures and Tables
Figure 1: ECG waveform model……………………………………………………………………………..7
Figure 2: Einthoven’s Triangle………………………………………………………………………………7
Figure 3: ST Elevation example……………………………………………………………………………..8
Figure 4: General System Block Diagram……………………………………………………………..11
Figure 5: ECG electrode placement……………………………………………………………………...15
Figure 6: Analog Circuit Block Diagram……………………………………………………………….17
Table 1: Filter Values………………………………………………………………………………………….19
Figure 1: Wavelet test with Agilent cardiac input…………………………………………………21
Figure 8: Instrumentation Amplifier test……………………………………………………………..22
Figure 9: Output Gain Stage test………………………………………………………………………….23
Figure 10: HPF frequency response………………………………………………………………….…24
Figure 11: LPF frequency response………………………………………………………………….…24
Figure 12: Circuit test with Agilent cardiac waveform………………………………….………25
Figure 13: Circuit test with human……………………………………………………………………...26
Figure 14: Program output of Agilent waveform………………………………………………….27
Figure 15: Program output of human waveform.…………………………………………………27
Figure 16: ST elevation sample…………………………………………………………………………...28
Table 2: Production Schedule……………………………………………………………………………..29
Table 3: Project Costs…………………………………………………………………………………………30
Table 4: Product Directions………………………………………………………………………………...32
Appendix 1: Analog circuit picture………………………………………………………………………36
Appendix 2: Heart Attack Detection code…………………………………………………………….37
4
Introduction
Every year about 785,000 people in America have their first heart attack.
Another 450,000 people who already have had a heart attack will have another one.
An additional 200,000 will have a heart attack without even knowing it. This means
that every 25 seconds, someone will have a coronary event of some kind and every
60 seconds someone will die from one. This is why coronary heart disease accounts
for a little over a quarter of the total deaths in the United States. This is a gigantic
percentage and is the problem my project is attempting to solve.
Clearly there are an alarming amount of deaths caused by heart attacks in the
United States, so how do we try to prevent this from happening? From research I
have learned that the most important thing to do during the course of a heart attack
is to alert paramedics as soon as it starts to happen. When an emergency medical
service (EMS) arrives, the chances of surviving a heart attack increase
tremendously. However, the person who is experiencing the heart attack may not
be able to seek help. For example, they may be home alone and cardiac arrest may
set in before he or she gets the chance to contact someone. The aim of my project is
to create a system that alerts an emergency medical service as soon as a heart attack
starts, even if you yourself cannot call for help. By accurately monitoring the heart
with a device coordinated with your cell phone, it is possible to determine when and
if a heart attack is starting and alert help automatically. This will cut down on the
time it takes to alert an EMS, and if someone cannot call for help, the device should
be able to do it by itself. Accordingly, this project when working properly should
save the lives of many people with heart problems.
5
Background
Heart attacks, or myocardial infarctions, are a large problem as well as a
common occurrence in America today. Statistically speaking, over one million
Americans have a heart attack each year. These myocardial infarctions can cause
serious damage to the tissue in the heart muscle even when they are not fatal. The
word “infarction” actually means a lack of blood supply leading to death of tissue.
Not only can the heart attack severely damage your heart, but it can also cause a
person to go into cardiac arrest, possibly resulting in death. These are the main
problems my project is going to solve.
Although it might not be as important as preventing death, heart attacks can
cause permanent heart muscle damage, which is medically very dangerous. Even if
a person survives a heart attack without getting medical help they can do serious
damage to their heart. This is common with silent myocardial infarctions, which
means that a person is undergoing a heart attack but does not even realize it. If the
victim of this heart attack does not receive medical attention within three to four
hours of the heart attack beginning, this permanent damage to their heart may
occur, which could cause even further health problems in the near future. By having
a detection system along with a heart monitor, this system will be able to prevent
this from happening even when the person does not exhibit the symptoms of a heart
attack.
I have also, in my research, learned about the signals that can be picked up
from the heart. The heart gives off a quick electrical signal about once every second
known to many as a heartbeat. Parts of these signals are very quick, almost like a
6
pulse. This signal, called an electrocardiogram (ECG), consists mainly of a P wave
and a T wave with a QRS complex in between. This is the signal that can often be
seen on monitors in hospitals and is shown below:
Figure 2: Example of ECG waveform
This electrical signal can be put on display through the use of
Electrocardiography, a non-invasive technique that is used to interpret electrical
activity of the heart in the time domain. The signal can be detected by electrodes
that are placed on the surface of the skin, usually in the chest area. Where to place
the electrodes is determined by the Einthoven’s Triangle as shown below:
Figure 3: Einthoven’s Triangle
7
Einthoven’s triangle is produced by three vectors, often referred to as leads. One
lead goes across the chest from arm to arm while the other two leads go from the
two arms down to the left leg. These vectors are put together to produce the
electrical signal from the heart in the ECG.
When it comes to the actual heart attack and its detection, we can look to the
ECG waveform. Based on research, the most common and most damaging form of a
heart attack is represented by ST elevation in the ECG waveform. This refers to the
rising of the ST segment (see Figure 1) in the waveform. An example of this is
expressed in the figure below:
Figure 4: ST Elevation example
The baseline voltage, commonly referred to as the isoelectric line or baseline, is the
term used to describe the flat portion of the line after the T wave and before the P
wave. After the QRS complex, a normal ECG signal will return to the baseline before
the T wave. During ST elevation, the ECG signal will not return to the baseline after
the QRS complex, and continues to the T wave. This is the most common way of
detecting a heart attack.
8
In terms of cost, creating a system like this is not very cheap. The actual
breakdown of the cost of parts is discussed later in the report. Despite the
expensive cost of the project, I do think that a product like this could potentially be
manufactured for a reasonable price. With the increasing advances in technology
and the possibility of mass production, it is definitely a feasible idea. There are
Android applications on the market that measure your heart rate for exercising
purposes that cost around thirty dollars. However, these devices do not collect
enough information from the heart to detect a heart attack. I think that once a heart
monitor application could get to within even ten times that price range that it could
really sell, especially when it comes to saving one’s life. Although commercialization
of a product like this is almost inevitable, I think it will be limited toward the
consumer if health insurance decides to cover it.
This product would have a minuscule effect on the environment as well as
politics. I don’t think that a heart monitor would have any negative connotations
with the government besides the issue of safety. This product would be safe as long
as certain precautions would be taken like any other electronic device. Further
details are discussed later in the report. The sustainability of a project like this is
really undetermined at this point. This device along with the application could
probably last a long time given that it is taken care of along with the cell phone. The
only downfall could be its effect on the phone’s batter
This project is completely ethical. I don’t think there could be any arguments
against a heart monitor system. The project in itself does not add a social aspect,
but it does allow for one. Instead of constantly being in the hospital because of a
9
heart condition this heart monitor application could let you stay at home or get out
and do the things you normally do. This device could be worn at almost any time
and if something with your heart did happen, medical help would be on the way
automatically.
Design Requirements
The priority of the implemented system in this project is to prevent death
from a heart attack. Therefore, the most important specifications of this project are
to pick up a quality signal that is accurate enough for detection and the detection of
the heart attack itself. The ECG signal that is needed for heart attack detection will
have to be low noise so that the peaks and troughs of the individual waves can be
identified. Also, the sampling rate during signal processing needs to be sufficient. It
has to be high enough so that the sharp peak of the QRS complex can be detected,
but we do not want to oversample by too much to conserve memory, processing
power and time. The time it takes to process the signal is also extremely important.
As I mentioned before, the key aspect in surviving a heart attack is responding
quickly. Thus it is imperative to have processing be as close to real time as possible,
preferably within seconds. That being said, the heart attack detection still has to be
accurate. If a heart attack is not detected, the priority of the system to prevent death
is compromised, but we do not want the system calling for help every minute with a
nonexistent heart attack. Another thing to be taken into consideration is the
comfort factor. Although not the most important specification, it is a determining
factor in the consumer’s decision to purchase the product or not.
10
The implemented system to achieve these specifications will consist of five
major parts: the ECG electrode sensors, signal conditioning, analog to digital
conversion, signal processing, and the actual Android application on the cell phone.
This process is illustrated in the general block diagram:
Heart
sensors
(electrodes)
Signal
Conditioning
A/D
Converter
Android
Application
Signal
Processing
Figure 5: General System Block Diagram
Because this project requires a large amount of work in several different fields, I will
mainly focus on the first four parts blocks out of the five mentioned above. I am
primarily interested in receiving a heart signal, conditioning the signal, converting it
to digital, and creating a program that will analyze this data and detect a possible
heart attack. Constructing an actual application for the Android system was an early
goal that I simply did not have time to achieve with the size of this project.
The ECG electrodes are the first part of the design. The electrical signals
given off by the heart will be in the range of a few mV or so. These electrodes will
need to be accurate enough to pick up these small electrical signals. A three lead
system will be used in this system. Three electrodes will be used in order to create
11
three vectors to simulate Einthoven’s Triangle. This will give us our input ECG
signal for signal conditioning. The three lead system will keep the system simple yet
accurate while adding an element of comfortableness.
The signal conditioning will consist of amplifying and filtering the signal that
is picked up by the electrodes. There will unfortunately be unwanted noise in the
input ECG signal due to movement and other electrical background noise. To cope
with this noise, an instrumentation amplifier with a high common mode rejection
ratio (CMRR) will be utilized. The total gain of this system should be around 1000
V/V to bring the signal into the range of a few volts and allow for decent signal
processing. As for filtering, a high pass filter and a low pass filter with cutoff
frequencies set around 1 Hertz and 150 Hertz respectively. These are the cutoff
frequencies that are used in normal heart monitor systems. Filter details will be
discussed further in the next section.
After amplifying and filtering the signal that the electrodes provide, the
signal will be converted from an analog signal to a digital signal with an analog to
digital converter (ADC). This data acquisition process with the ADC is very
important in order to go from the amplification and filtering process to the signal
processing stage (heart attack detection). The specifics of the ADC used in this
project are also discussed in Final Design and Implementation.
In order to detect an occurring heart attack on the victim, an algorithm will
be created with the following necessities. First, it will need to establish a baseline
from the waveform. This can be done by taking an average of the samples in one or
two waves or heartbeats. Next, the program will have to determine the QRS peak.
12
This won’t be too hard considering that the QRS peak is clearly the maximum value
in the ECG waveform. The program will then have to make sure the signal returns
directly to the baseline after the QRS peak. From research, we can say that the ST
segment is approximately 100 milliseconds. Therefore, we must confirm that the
signal will return to the established baseline after the S wave within that time frame.
If the signal does not do this, the program will flag the waveform, alert the patient of
the heart attack and also call 911 or another emergency hotline.
Design Alternatives:
There are a few alternatives to using a system design like this one. One
alternative is to simply be cautious. For elderly people who have had heart
problems in the past, this is a very standard procedure. Some precautions could
include being a close distance away from a doctor, taking part in stress-free
activities, and trying not to be alone as much as possible. Even so, it is unfeasible to
believe that you can have somebody at your side at all times. My project could
basically take the role of being that somebody at your side and could recognize
when you’re having a heart attack even if you couldn’t.
As mentioned before, there are heart rate detector applications on the
market already. Heart rate is a good way to measure exercise or even activity
during the day. That being said, heart rate does not give us sufficient data to detect
a possible heart attack. If a person’s detected heart rate decreases to a dangerous
level, the person can be alerted and even defibrillated with an electric device but
even then it may be too late.
13
An artificial pacemaker is a medical device that delivers electrical impulses
through electrodes in contact with the heart muscles. This device is implanted
within the chest of the patient. These electrical impulses will regulate the beating of
the heart the heart automatically. The main goal behind a pacemaker is to keep the
heart rate at an acceptable rate, but they may also be implanted with a defibrillator
to keep the heart from failing. This is good but the device may or may not be able to
detect an infarction during the actual heart attack. The defibrillation would only
come after the heart rate dropped below the pre-specified threshold. This would
probably occur toward the end of cardiac arrest, which is far too late.
A more specific device in terms of handling a heart attack is the implantable
cardioverter-defibrillator, or ICD. An ICD is an implantable device that generates an
electrical impulse to patients who oftentimes have gone into cardiac arrest.
Essentially, this is the same system that I am trying to implement, only this system is
implanted in the body. The ICD is programmed to detect heart failure and corrects
the heart through defibrillating. This is done by delivering a sudden dose of electric
energy to shock the heart back into rhythm. This device offers a strong alternative
to my device. However, looking at it from a different perspective, my device can be a
strong alternative for the ICD given certain conditions. Implanting a device through
surgery is often risky. If a patient does not want to take that risk, or has a condition
where they cannot have a surgery like this, my external system would present a
very good alternative. There are also some other complications with the IDC.
Common issues with the ICD include its psychological effect on patients. A decent
percentage of patients with ICDs have been diagnosed with conditions such as
14
anxiety and depression. This is something that patients must take into account
before surgically implanting the device.
Final Design and Implementation
As previously stated, the implemented system to achieve the main goal of the
project consists of five major parts: the ECG electrode sensors, signal conditioning,
analog to digital conversion, signal processing, and the Android application on the
cell phone (see Figure 4). The final process of designing the actual Android
application was not as important to my main objectives for the project, so I decided
to concentrate on the first four processes of block diagram. The final design of the
project was achieved by splitting the system into two major sections. The first
section consisted of the heart monitor Circuit Design and Implementation. This
would include the first two blocks of the diagram in Figure 4 (electrode sensors and
signal conditioning). The next section labeled Heart Attack Detection would focus on
the next two blocks of the diagram (ADC conversion and signal processing).
Circuit Design and Implementation:
The ECG electrode is the first process of the system design. It is critical that
the circuit have a quality signal to alter before the ADC and signal processing. For
this reason I decided to use the Kendall Q-Trace 5400 Resting ECG Electrode. These
electrodes are made up of a silver/silver chloride sensing system that comes preequipped with conductive adhesive hydrogel. The hydrogel is very necessary
because it provides a firm stick to the skin while helping to conduct a current. The
15
hydrogel also has very low impedance to help pick up clear tracings of the electrical
signal. The placement of the electrodes will be on the arms of the user as
demonstrated in the figure below:
Figure 6: ECG electrode placement
To simulate Einthoven’s Triangle (Figure 2), two electrodes can be placed on the
upper arms just below the bicep, with a reference electrode going on the lower
wrist. With the user’s arms by their side you can see how this can simulate the leads
in the Einthoven’s Triangle. This configuration should give us a decent heart signal
to work with while helping with the comfort factor by decreasing the amount of
wiring and space.
The next part of the system is the signal conditioning. A large part of this
consists of amplifying and filtering the signal that is generated and input by the ECG
electrodes. However, there are also other components that can be added to the
circuit to increase the quality of the output signal as well as the safety of the circuit.
Taking these factors into consideration and with help from Professor Buma and his
16
Biomedical Instrumentation Class (ECE-386), an analog circuit was designed and
implemented. A block diagram of the circuit is shown below:
9 Volt Battery
Optocoupler
Input
Driver
Electrodes
9 Volt Power Supply
Instrumenta
tion
Amplifier
Output
Driver
Output
Gain
Stage
Filters
Figure 7: Analog Circuit Block Diagram
The Block diagram in Figure 6 shows the entire system before the signal is
converted from analog to digital via the ADC. The input signal from the electrodes is
first passed through diodes for reverse polarization protection and then amplified
by the instrumentation amplifier, for which I used the AD620 chip. The AD620 is
very efficient because with its high CMRR, it is able to amplify signals with low noise,
low input bias current, and low power, which is ideal for conditioning an ECG signal.
It also has a differential gain of approximately 10 V/V with a gain resistor of 5.1 kΩ
that was used.
17
Safety is obviously a very significant factor in this project, especially when it
means having electrical components linked to your body. This is the reason for the
next part of the circuit: the Clare LOC 110 optocoupler with an input and output
driver. An optocoupler consists of a light emitting diode (LED) and an optical
receiver. Its main function is to use light waves to transfer an electric signal from
one point to another. This technique will be used in the circuit in order to
electrically isolate the part of the circuit connected to the user’s body. Looking at
Figure 6, the left side of the circuit is powered by a 9 Volt battery while the right
side is powered by the main power supply. The optocoupler in the middle isolates
the portion of the circuit powered by the 9V battery from the portion powered by
the main power supply. By doing so, if something went wrong with the main power
supply, the portion connected to the user would be isolated. If something backfired
with the battery, the user would only be exposed to 9 Volts. The input and output
driver are utilized to prepare the signal for the optocoupler and then return the
signal for filtering and amplification. For both drivers I used an op-amp on the
LM248n chip. Since the current transfer ratio of the optocoupler is optimal at
currents around 10 mA, the optocoupler was driven accordingly. These drivers help
prevent overshoot and also help with short-circuit recovery.
In terms of filtering, I used two second order Sallen-Key filter circuits for a
high pass and a low pass filter. Since the normal heartbeat has a frequency around 1
or 2 Hz, the filters had to have suitable cutoff frequencies to accurately filter the
signal. The filter’s cutoff frequency (fc) is determined by the following equation:
fc = 1/(2πRC)
18
With this in mind, the following filter values were determined:
Table 1: Filter Values
High Pass Filter
Low Pass Filter
R
C
fc
1.5 MΩ
100 kΩ
2.2 µF
10 nF
0.048 Hz
159.15 Hz
The high pass and low pass filter give us a nice passband from about 0.05 Hz to 160
Hz. The low pass filter will do well in getting rid of unwanted high frequencies with
its 160 Hz cutoff. Even though, the high pass filter cutoff frequency is really low the
filter is not pointless. It will get rid of any extremely low frequencies and helps
prevent a wandering baseline, which is good for our heart attack detection.
The last part of the analog circuit is the output gain stage. This is just a noninverting amplifier using one of the operational amplifiers from the LM248n chip.
The resistor values that were used were 100 kΩ and 1 kΩ in order to get a gain of
about 100 V/V. With the gain of the instrumentation amplifier, this gave us a total
gain of around 1000 V/V for the circuit. Again this was necessary to bring that
original heart signal (few mV) up to a few Volts. A picture of the entire circuit can be
found in appendix 1.
Heart Attack Detection
In the second half of the project, the analog signal needed to be converted to
a discrete digital signal. For this process I used the Personal Measurement Device™
PMD-1208FS for the ADC. I originally set out to use the Vernier SensorDAQ, which
is much better for ECG A-D conversion but I was having problems with the actual
19
data acquisition. Since I was having problems and was not used to working with the
LabVIEW program, I switched to the PMD and used MATLAB for my data
acquisition. The PMD has 8 single-ended analog inputs along with 4 more
differential inputs. It has 12-bit resolution and can sample up to 50,000 samples per
second. An ECG waveform acquisition does not require parameters this high but it
is good to have anyway.
The next part of the system was the heart detection. As stated in the Design
Requirements section of the report, in order to detect the heart attack, the system
would need a program that would detect an elevation in the ST segment of the ECG
waveform. One way to do this is to make sure that the signal returned to the
baseline before the ST segment. I came up with a program in MATLAB that would
take the waveform and do this procedure. See Appendix 2 for the MATLAB coding.
In the code, the baseline is established by taking the average value of all the
samples. Then, using wavelets in MATLAB it was possible to down sample the
signal, which allowed us to take the samples at lower frequencies. Below is a test of
the wavelets by using a cardiac input from the Agilent WG (1 Hz, 2 V):
20
Figure 8: Wavelet test with Agilent cardiac input
Here you can see that the wavelets give us a smaller amount of samples to work
with and give us the basic shape of the heart signal. Once the wavelets operation
was performed, I used the 4th order reconstructed signal to determine if a heart
attack was happening. The order of wavelets needed may vary as we go from the
Agilent WG to a real sample. Using the MATLAB code in Appendix 2, the maximum
value of the R peak was detected along with its sample number. Then, using a for
loop and an if statement, I had the program display either ‘normal’ or ‘heart attack’.
From the graph, it was determined that 4 samples was approximately the amount of
time that the S wave should cross the baseline by. It would return ‘normal’ if any of
the next 4 samples went below the baseline and it would return ‘heart attack’ if
21
none of the samples crossed the baseline. This would tell us if the user was having a
heart attack or not by examining the level of the ST wave relative to the baseline.
Performance Estimates and Results
For displaying the results for this project, I started by documenting the
components of the analog circuit. I began by using the Agilent 20 MHz Waveform
Generator to apply sine waves to each of the two amplifiers. This was to make sure
that the theoretical calculation of the gain approximately matched that of the
amplifiers. First was the instrumentation amplifier with a gain resistor of 5.1 kΩ. In
order to simulate the ECG signal, I wanted to keep the frequency as low as possible
without altering the signal. For almost all of the graphical results, time (in seconds)
is displayed as the independent variable and voltage (in volts) is displayed as the
dependent variable. The input and output for the instrumentation amplifier are
shown below:
Figure 9: Instrumentation Amplifier Test
22
At a frequency of 100 Hz, a 100 mV input sine wave gave an output of a sine wave
with an amplitude of 1 V. The amplifier is clearly demonstrating a gain of 10 V/V
and has very little noise, which is exactly what is needed. An identical test was run
on the output gain stage just to make sure of its qualities. The graphs can viewed
below:
Figure 10: Output Gain Stage Test
To avoid saturating the ADC with the output I used an input sine wave of 70 mV at a
frequency of 100 Hz. From the output we can tell that the output gain stage has an
approximate gain of 100 V/V and is working properly.
To test the filter design and implementation I decided to take the frequency
response of each filter. This could easily be done by attaching the Agilent
Oscilloscope to the input and output of the filter and entering the following
command in MATLAB:
[f, m] = sfreq(start, stop, increment)
This command, given inputs for a start and stop frequency (in Hz) and an increment,
will automatically collect data for the frequency response. It returns a vector
23
containing the frequencies and their corresponding magnitude. The following
responses were collected:
Figure 11: HPF frequency response
Figure 12: LPF frequency response
Unfortunately, MATLAB’s minimum frequency for taking frequency responses is 50
Hz. Even so, the results still match our expectations. The low pass filter attenuated
about half of the signal at the cutoff frequency of 160 Hz and has a sharp slope
24
relatively speaking. The high pass filter did not attenuate anything, which is good in
this case because of the extremely low cutoff frequency.
With every component of the analog circuit working it was time to test the
whole circuit. First, I used the Agilent Waveform Generator to produce a cardiac
wave with a normal heartbeat frequency of 1 Hz. Since the waveform generator did
not produce an amplitude as low as I wanted I used a simple voltage divider to
reduce the input down to the single digit mV range. The divider consisted of a 10 kΩ
and a 1 kΩ resistor to reduce the input by a factor of about 11. The cardiac
waveform input was run through the voltage divider into the main circuit and
produced this waveform:
Figure 13: Circuit test with Agilent cardiac waveform
The circuit did a great job with conditioning the signal and accomplished every goal.
With a 1 kHz sampling rate from the ADC, The circuit took the 1 Hz 7 mV cardiac
waveform from the Agilent generator and amplified the signal to a voltage range we
could work with. The output voltage had a baseline around -4 V but when it comes
to actually detecting the heart attack every wave and segment in the waveform is
relative to each other.
25
I then tried out the system on myself to see if I could get a good reading.
Using the previously mentioned lead placement, I put two electrodes on my arms
and one reference electrode on my wrist. I attached alligator clips from the
electrodes to the input of my circuit and took the following sample:
Figure 14: Circuit test with human
In general, the human testing with the circuit worked alright. Although there is a
little noise, you can definitely make out the QRS complex as well as the T wave. This
would allow for efficient analysis of the ST segment and heart attack detection.
Further analysis of the circuit is provided in the Discussion, Conclusions, and
Recommendations section of the report.
The next part of the system was the heart attack detection. I first tested the
MATLAB code (heart attack detection program) with the cardiac input from the
Agilent WG (1 Hz 2 V). The input was ran through a modified program of Appendix
2 to display the output waveform, the baseline, the maximum value and its index,
and either ‘normal’ or ‘heart attack. The results were the following:
26
baseline =
0.1419
maxvalue =
10.3749
I=
27
normal
Figure 15: Program output of Agilent waveform
The test of the MATLAB code was a success. The program calculated the baseline
and identified the coordinates of the R peak after the wavelet operation was done.
Since the S wave returned to the baseline, the program displayed ‘normal’.
I then tested the program with the human sample of the ECG waveform using
the same technique as above. The following graph resulted:
Figure 16: Program output of human waveform
27
The graph shows that the wavelets did a decent job in down sampling the signal.
The program also returned a baseline of about -13.8 which is close enough to the
actual baseline. It also returned the coordinates of the R peak and displayed
‘normal’ so we can conclude that it was successful.
To test out the program with a heart signal that experienced ST elevation I
downloaded a sample from the T wave alternans challenge database on
physionet.org. This gave an input heart signal with ST elevation, which is shown
below:
Figure 17: ST elevation sample
I did not use the wavelet operation in this program because the down sampling
made the R peak lower than the T wave peak. Also, because there was not enough
data to calculate an accurate baseline I manually entered the value of 0.6 which is
around where it should be. The program returned accurate coordinates of the R
peak and ‘heart attack’ like it should have.
28
Production Schedule
The setup of the Union College school year consists of three trimesters. Each
trimester is made up of 10 weeks. This project was started in the fall trimester and
finished in the winter trimester. Below is the general schedule of the project design
and implementation that was followed throughout the winter term:
Table 2: Production Schedule
Weeks
Phases of Design and Implementation
1 to 4
Continued Research from the last term, focusing
mainly on ECG circuit design and heart attack
detection.
3 to 4
Design of the ECG circuit
5 to 7
Constructing and testing of the ECG circuit
8 to 9
Continued debugging of the ECG circuit, but with
main focus on MATLAB code design for heart attack.
Started writing final report.
10
Last minute testing and debugging.
Finished final report.
A large portion of the term consisted of research on the topic of electrocardiograms
and how a heart attack can be detected from looking at the ECG. The actual
construction and testing of the ECG circuit took longer than expected. As a result, I
did not have as much time as i wanted to concentrate on the heart attack detection
in MATLAB.
29
Cost Analysis
Cost of production with this product is a big factor in whether or not it can
actually be manufactured. At first, to see the exact cost of the product that I had
built I simply made a spread sheet in Microsoft Excel and added up the prices of the
components. The table below displays the figures:
Table 3: Project Costs
System Component
Quantity
Cost
Kendall Q-Trace 5400 Resting ECG
Electrode
IDEAL Alligator Clip
Pomona Multi-Stacking Banana Cable
Utilitech 9 V Alkaline Batteries
AD620 Instrumentation Amplifier
LM248n Quad Operation Amplifier
Clare LOC110 Optocoupler
Twin Industries Breadboard
ADC Converter
Arduino Microcontroller
100-pack
3 2-packs
3
2
1
2
1
1
1
1
$8.25
$6.15
$15.30
$3.96
$6.00
$2.50
$2.85
$38.29
$150
$24.95
Total Component Cost
$258.25
___________
Labor Costs
Minimum Wage (2012)
Circuit Construction Time (approximate)
Minimum Total Labor Cost
x
$7.70
20 hours
$154.00
___________
Total Construction Cost
$412.25
This calculated cost of construction was actually less than I originally had thought it
would be. The total cost of the components was under $300, which I think is a really
30
good start for the first experimental design. With further research, there are
probably some things that could be added on to the system to make it more
effective. This would undoubtedly raise the cost of production, but if this product
became manufactured and components were bought on a large scale the price
would decrease tremendously.
One factor I did not take into account with that original component cost was
the labor costs of making a product like this. To account for that factor I estimated
the total amount of hours it took me to assemble and test my circuit. I did not
account for the time spent on the heart attack detection program because once an
efficient algorithm is perfected there is virtually no extra cost to produce it. I then
multiplied these hours by the minimum wage to see the lowest effect that labor
could have on the cost. Obviously the employees assembling a circuit like this
would not be paid minimum wage but this is just hypothetical. The added cost from
labor came out to be about $150 bringing the total cost to a little over $400. This is
not a bad price at all for a product that could save your life.
User’s Manual
The size of this project really limited the amount of time I could spend
making this system into a finished product that could be manufactured and sold. I
concentrated primarily on the theories behind each component of the system and
then put together a general implementation of these theories.
If the system was made into a finished product with a corresponding Android
application, the User’s manual would look something like this:
31
Table 4: Product Directions
Directions for use:
1. First place the electrodes on the skin in the
correct positions. Make sure the positive
(red) is placed below the left bicep, the
negative (black) is placed below the right
bicep, and the reference (green) is placed on
the right wrist. See diagram for help.
2. Make sure that the device is plugged into
the phone and the application is running.
3. The application will display your heartbeat
and run continuously until it is closed.
4. If you are experiencing a heart attack, a red
indicator will show on your display. It will
automatically dial an emergency service
unless designated otherwise by the user.
This is how all of the blocks of the general system block diagram (figure 4) would
have come together to create a working product. In reality, my system was cut into
two parts and did not involve the application.
Discussions, Conclusions, and Recommendations
Overall, I think that the project went well. The circuit as well as all of the
components in the circuit worked as intended. The goal of the circuit was to give us
a clear, accurate reading of the heart signal that could be used for heart attack
detection. The circuit completed this goal. There was a small amount of noise in the
signal but that was insignificant and could be fixed by better amplifiers and filters or
possibly a notch filter at the 60 Hz powerline. The one small problem with the final
readout on the human sample was that the ECG signal showed a little bit of ST
32
depression. This should not have been the case and could have been caused by a
small misplacement of the electrode or an electrode slightly falling off. That being
said, a small depression would not have affected the heart attack detection of the
system. One factor I did not take into account with the system was the movement of
the user. Any activity in the muscles of the user would show up on the ECG signal
and make the signal very noisy. I have not found a solution for this.
The heart attack detection and MATLAB code of the system was ok but it was
not optimal. The program was able to detect the R peak of the signal, but the
program could only complete detection for one PQRST heart wave from the sample.
This worked for the Agilent WG cardiac sample and my own sample, but I had to
manually enter the baseline for the sample that displayed ST elevation. I would
have liked to work more on this part of the project but I did not have enough time to
do so.
In conclusion, this project has led me to learn a lot about the electrical signal
that can be picked up from the heart as well as how we can obtain and condition
that signal for proper analysis. I have also gotten the chance to put my learning
from the classroom toward making a system that could possibly save a life. I did not
get to some aspects of the system but I would like to continue research on the topic
and possibly work with another student on perfecting it.
33
References
ABC News, “What does an EKG show during a heart attack?” abcnews.com. Web.
http://abcnews.go.com/Health/HeartDiseaseScreening/story?id=4223255#.T0MFe
CNWq3w.
"AD620: A Low Drift, Low Power Instrumentation Amp with Set Gains of 1 to
10000." Analog.com. Web. http://www.analog.com/en/specialtyamplifiers/instrumentation-amplifiers/ad620/products/product.html.
Arduino - HomePage. Web. http://www.arduino.cc/.
"CDC - DHDSP - Heart Disease Facts." Centers for Disease Control and Prevention. 21
Dec. 2010. Web. http://www.cdc.gov/heartdisease/facts.htm.
"ECG Feature Extraction with Wavelet Transform and ST Segment Detection Using
Matlab." Codeproject.com. Web.
http://www.codeproject.com/Articles/309938/ECG-Feature-Extraction-withWavelet-Transform-and.
"Kendall Q-TRACE 5400 Diagnostic Tab Electrodes, 100/pk." Medical Supplies. Web.
http://www.medexsupply.com/products/pid40408/KendallQTRACE5400DiagnosticTab.htm?zmam=34602484.
"IDEAL 2-Pack Alligator Clips with Insulated Barrel." Lowes.com. Web.
http://www.lowes.com/pd_44564-12704-770204L_?PL=1.
"Personal Measurement Device PMD-1208FS Offers 12-Bit Analog Inputs And
Sample Rates Up To 50 Kilosamples/Second." Testandmeasurement.com. Web.
http://www.testandmeasurement.com/article.mvc/Personal-Measurement-DevicePMD-1208FS-Offers-0001.
"Pomona B-24-0." All-Spec Industries. Web. http://www.allspec.com/products/Pomona/Test_and_Measurement%7CTesters%7CTST14/B240.html.
Kim, Helen and Choon Yik Lee, “Walking Stick with Heart Attack Detection”, Spring
2005, University of Illinois at Urbana-Champaign.
Kuangwei Hwang, Diane Limsui, Lianhan Zhao, “Wireless Heart Detector with GPS”,
Fall 2004, University of Illinois at Urbana-Champaign.
Medicine Net, “Electrocardiogram (ECG or EKG).” MedicineNet.com. Web.
http://www.medicinenet.com/electrocardiogram_ecg_or_ekg/article.htm.
34
PhysioNet. Web. http://physionet.org/.
T. Buma, class notes for ECE 386, Department of Electrical Engineering, Union
College, Winter 2012.
Spengler, R. “How does my doctor interpret my EKG,” 2002,
http://yalenewhavenhealth.org/library/healthguide/enus/support/topic.asp?hwid=tu6258abc.html.
Vernier, “SensorDAQ.” Vernier.com. Web.
http://www.vernier.com/products/interfaces/sdaq/.
35
Appendix 1
36
Appendix 2
% Heart Attack Detection Code
z = zeros(100,1);
% prevent window crossing
signal = [z;signal;z];
baseline = mean(signal)
% establish baseline of signal
[sig2,l] = wavedec(signal,4,'db4');
(downsampling)
ca1
ca2
ca3
ca4
=
=
=
=
% wavelet decomposition
appcoef(sig2,l,'db4',1);
appcoef(sig2,l,'db4',2);
appcoef(sig2,l,'db4',3);
appcoef(sig2,l,'db4',4);
%plot(ca1)
%plot(ca2)
%plot(ca3)
plot(ca4)
[maxvalue I] = max(ca4,[],1)
index
% find maximum value(R peak) with
Newbaseline = mean(ca4)
for j = I:(I+3)
if ca4(any(j)) <= Newbaseline
disp('normal')
else
disp('heart attack')
end
end
% ST elevation detection
37
Download