Beruflich Dokumente
Kultur Dokumente
By
Bill Leece
Sofoklis Nikiforos
ECE 345
Section G
TA: Ajay Patel
August 2, 1999
Project # 1
ABSTRACT
The heart rate monitor consists of biopotential electrodes that are placed on the patient. Body
fluids conduct electrical signals from the surface of the heart to the electrodes. Measurements are taken
as the difference between two electrodes, while a third electrode is used as a reference. The ECG
amplifier circuit then amplifies the signal and sends the information to a PC (via a data acquisition
circuit). The information is then analyzed and processed by a LabVIEW program. The user-friendly
interface allows for the cardiologist to analyze the patient’s electrocardiogram. The LabVIEW program
goes beyond that of a regular ECG in that it provides information such as heart rate, caloric expenditure,
and minimum and maximum target heart rates for optimal calorie burning.
ii
TABLE OF CONTENTS
1. INTRODUCTION……………………………………………………………………………………..1
2. DESIGN PROCEDURE……………………………………………………………………………….4
3. DESIGN DETAILS………………….……………………………………………………………….11
4. DESIGN VERIFICATION….………………………………………………………………………..17
5. COST Analysis…………………………….…………………………………………………………19
6. CONCLUSION…………………….…………………………………………………………………20
7. Appendix……………………….……………………………………………………………………..22
8. REFERENCES……………………….………………………………………………………………23
iii
iv
INTRODUCTION
Many hospitals and health clinics use monitoring devices to ensure patients will receive the
proper care. Electronic medical devices provide a vast array of medical information while allowing the
patient to have a user-friendly interface. The heart rate monitor built for the ECE 345 Senior Design
Project demonstrates this trend in medical technology towards easier and more effective tools for health
care. The project is based on the ECG, which is a simple monitor that displays the electric signals from
the heart.
The heart rate monitor receives its input from physiological signals from the electrical pulses of
the heart. The signals are fed into a system that implements both hardware and software to displays and
amplified and filtered version of the signal while performing real time calculations to display pertinent
information related to heart rate. The hardware for the system includes three Silver/Silver-Chloride
designed to minimize common mode gain, which should be within about thirty percent of signal
variation. The preamp and the difference amplifier are designed to provide a dc-coupled stage gain of
approximately 25 1% when cascaded in series. This minimizes the chance of the amplifiers saturating
in the power amplification stage by any offset voltages produced by the electrodes. The software
acquires data from the output of these amplifiers continuously. LabVIEW then stores the information in
buffers, while simultaneously displaying and processing the signal. When these design considerations
are undertaken, the heart rate monitor is a reliable and marketable product.
The figure 1.1 on the next page shows the block diagram of the system and its major subsections.
The four subsections and their function are discussed in detail below.
1
In p u t S i g n a l f r o m N I- D A Q L a b V IE W
E C G A m p lifie r
E le c tro d e L e a d s (P C In te rfa c e ) S o ftw a re
The first stage of the system consists of the three Ag/AgCl electrode sensors. These electrodes
produce a voltage related to the electric field produced by the beating of the heart.
The second stage of the system consists of the amplifier hardware, which takes the
electrocardiogram signal from the electrodes as its input. The signal is amplified and filtered to provide
a meaningful output. The hardware diagram on the next page (figure 1.2) shows the three stages of the
amplifier, and a driven right leg circuit. The output signal from this stage is then sent to the NI-DAQ
which in turn sends this analog data to LabVIEW for data processing.
Input Right
from Leg
Right Circuit
Leg
Bandpass
Input Pre Filter Output
from Am and to
Electrodes p Power PC
Amplifier
2
The fourth and final stage of the system is the software implementation, using the NI-DAQ board
and LabVIEW software. The NI-DAQ sends data from the ECG amplifier to a PC. The LabVIEW
software is then able to process this data. VIs (virtual instruments) are graphical programs that are
implemented to graph the data, and to process it (to make calculations for heart rate and caloric
expenditure ). The front panel of a LabVIEW program is a GUI that takes user profile inputs and uses
3
DESIGN PROCEDURE
Electrode Theory
An interface is necessary between the body and the electronic measuring device when recording
potentials and currents in the body. Biopotential electrodes produce small voltages directly related to
the changing electric field produced by a beating heart.. The Ag/AgCl electrode is a practical electrode
refers to the freedom of ions to pass through the electrode-electrolyte interface to be transduced into an
electrical current. The electrode converts the ionic current produced by the body into a voltage, and the
The electrode-electrolyte interface is the junction where the ionic transfer occurs. A temporary
current is induced in the electrode from the changing electric field of the beating heart. This current
causes electrons and anions to move across the electrode-electrolyte interface in the direction opposite to
the flow of the current, and for cations to migrate across this interface in the direction of the current.
This temporary separation of charge produces a temporary potential. This potential is created from a
current induced from the heart and is thus directly related to the changing electric field produced by a
beating heart. The ECG circuit hugely amplifies the potential, and the output gives the electric
Another sensor that was considered was the piezoelectric sensor. Piezoelectric materials
generate an electric potential when mechanically strained. During a heart beat, the pressure in the blood
vessels is higher than when the heart is in its resting stage. This higher blood pressure causes a physical
4
deformation in the skin, and thus a piezoelectric sensor can produce an electic potential during every
heartbeat. The principal reason why the piezeoelectric sensor is less than ideal is that it is pressure
sensitive. In order to pick up a signal the nurse or doctor would have to press the sensor hard against the
patient which could cause a permanent deformation of the piezoelectric material This information,
combined with the fact that hospitals across the nation use Silver/Silver Chloride sensors, made it
obvious that the silver-silver chloride sensors were the best to use for this project.
The hardware design for this project consisted of building an electrocardiograph (ECG) amplifier
circuit. The Silver/Silver Chloride electrodes produce induced voltage signals from the heart and the
ECG circuit amplifies and filters these signals. Furthermore, the ECG circuit should be able to correctly
amplify signals from a patient, even though the patient might not be grounded due to displacement
The ECG circuit has a number of component parameters that must be met in order for it to
operate effectively. First, an important factor for amplifiers is that the first stage (the preamplifier) must
have high input impedance and low input bias current. High input impedance is necessary in an
amplifier circuit to minimize loading effects. Loading occurs when the gain of the second stage of an
amplifier affects the gain of the preamplifier. A low input impedance can cause loading, thereby
affecting the characteristics of biopotential electrodes. This loading can result in a distortion of the
output signal.
Another factor that can cause the distortion of the output signal is the input bias current of the
op-amps. Input bias current is the amount of current that flows into the op-amp. Ideally, the input bias
current is zero, but in practice there is always a small input bias current. Low resistance between the op-
5
amp inputs compared to the feedback resistance can cause bias currents, so large resistors are placed
between op-amp inputs to minimize this current. Furthermore, the input bias current of the 741 op-amp
was found to be significantly higher (800 nA) when compared to the 411 op-amp (200 pA).
For this reason, 411 op-amps were used in the ECG circuit instead of the more traditional 741 op-amps.
Another important characteristic of the ECG amplifier circuit is that it must have a high gain
since biopotentials are usually on the order of millivolts. These signals must be amplified to a degree
such that they are capable of being effectively displayed on recording devices. This means that the
signals will have to have a magnitude on the order of volts, so gains of approximately 1000 are need for
Finally, the ECG circuit must have the ability to filter out low and high frequency noise. Since
biopotentials signals from the heart are in the range of 0.05-150 Hz, the final stage of the ECG amplifier
should contain a bandpass filter suited to pass these frequencies but to cut off all others. This frequency
response can be achieved by adjusting resistor and capacitor values in the third stage of the amplifier
fc = (2RC)-1 (1)
The design of the ECG amplifier was modeled after the amplifier presented in Medical
6
Figure 2.1 ECG Amplifier
The actual design of the ECG amplifier differed slightly than the one presented by Webster in
that resistors and capacitors were added in parallel to the non-inverting terminals of the preamplifier in
order to reduce electromagnetic noise and to minimize input bias currents, and thus minimize loading.
The figure doesn’t include electrode impedance, which was a factor in the output. It was decided after
some experimentation and research that some important high frequency effect should be displayed by
7
the ECG, so the high frequency cutoff was brought up to 121.3 Hz from 106.1 Hz (see table 2-1 below).
Furthermore, to eliminate some low frequency noise, the low frequency cutoff was raised from 0.05 Hz
to 1 Hz (see table 2-2). It should be noted that the Design Adjusted ECG cutoff frequencies are only
theoretical; in practice, variations in the actual impedance of resistors and capacitors can lead to cut off
From Webster
Design Adjusted 160 k 8200 pF 1.3 s 121.3 Hz
ECG amp
From Webster
Design Adjusted 150 k 1 F .15 s 1.06 Hz
ECG amp
The overall gain of the ECG circuit can be calculated by multiplying the gain of each individual
The differential gain of the voltage followers (first stage) of the ECG circuit is:
8
The gain of the differential amplifier (stage 2) is:
G d = R5 / R 4 (3)
Thus we see that low frequency signals are amplified in the final stage, while high frequency
signal pass through without amplification. The results of these equations (calculated by hand) were
verified by PSPICE.
instead of HPVEE because LabVIEW is a very versatile programming language that is based on C.
LabVIEW is a graphical programming language specially suited for data acquisition applications
because it contains libraries for DAQ card data acquisition, as well as for serial port and GPIB. The
LabVIEW programming language was also selected because it is very easy to debug due to the fact that
is a graphical (as opposed to text) programming language, and the programmer can actually watch data
“flow” through the LabVIEW software “circuit” and see where any programming inconsistencies might
lie. Finally, one of the authors is very familiar with LabVIEW, thus making it the logical choice for
The first version of the LabVIEW data acquisition program used the AI Sample Channel VI from
the National Instruments Analog Input Data Acquisition Library. After some testing it was discovered
that this was an inefficient data acquisition program since it would only acquire new data from the DAQ
once all the software functions in the data acquisition program had been completed. Since it takes a
finite amount of time for the software to run for each loop, it was discovered that using the AI Sample
Channel VI only allowed for data acquisition at a rate of about 30 samples/sec. Since the bandwidth of a
QRS complex is about 35 Hz, sampling at least 70 Hz was necessary to recover this complex, and
sampling at 242.6 Hz was necessary to prevent any type of aliasing in the 1.06 Hz – 121.3 Hz passband.
For this reason, the AI Read VI was selected for data acquisition since when used in conjunction with
the AI Config VI and the AI Clear VI, circular buffers could be set in memory that would allow the AI
Read VI to continuously acquire data. Thus data can be obtained without waiting for other software
operations to complete since new data could be written to the circular buffers in memory even if the
software is at a bottleneck. As such, the sampling rate can be easily set to 242.6 Hz (it is actually set to
A NI-DAQ AT-MIO-16 board is a 16-bit data acquisition device that is used as an interface
between the hardware ECG amplifier and the LabVIEW software that runs on a personal computer. The
NI-DAQ board allows analog input data to be written to the LabVIEW software. The only input channel
utilized was analog input channel 0. The figure .2.2 shown below is the pinout of the AT-MIO-16.
DESIGN DETAILS
The ECG was designed so that it would pass frequencies from 1 Hz - 125 Hz. In order to obtain
a bandpass filter with these characteristics, the actual values for the resistors and capacitors were
11
obtained and are listed in the high-pass characteristics listed in table 3.1, and low-pass filter
characteristic listed in table 3.2, using equation (1). As previously mentioned, the actual frequency
cutoff differs from the theoretical values due to the fact that resistors and capacitors are non-ideal and
Furthermore the final gain of the ECG amplifier was set to 1815.34 thus enabling the ECG
circuit to amplify biopotential signals on the millivolt range to the volt range. The gain of stage one
was 12.13 obtained by using equation (2). The differential amplifier (stage two) had a gain set to 4.73
as calculated from equation (3). Finally, the gain of the bandpass filter (stage three, power amplifier)
was found to be 31.63 verified from equation (5) and the fact that the gain equation for the bandpass
Finally, the CMRR of the differential amplifier was maximized by setting R5 to 47 k This
value for R5 that maximizes the CMRR was experimentally determined using the equation CMRR = Gd /
Gc where Gd is the differential gain and Gc is the common mode gain. A variable resistor was used to
12
determine the value that minimized Gc and therefore maximized the CMRR. The value for R5 that
caused Gc to be minimized was 47 k Figure 3.1 shows the output of the difference amplifier of the
Webster circuit with the inputs having a common voltage (1 V p-p sine wave).
The differential gain Gd = 25.352 and the common-mode gain Gc = 151.54 E-6. The common-mode
rejection ratio is simply CMRR = Gd / Gc = 1.673 E5 (a high-quality biopotential amplifier should have a
LabVIEW is a hierarchical programming language where the highest level Virtual Instruments
(called VIs) calls lower level VIs (referred to as subVIs). In order to view the LabVIEW programs used
for this project, access the project web page where the programs have been posted.
13
HRM Front Panel VI
The highest level VI is the HRM Front Panel VI. The user enters their age, weight, and resting
heart rate on the front panel of this VI. The user then presses “Continue”, which liberates the age,
weight, and resting heart rate data from the While Loop on the left, allowing to travel into the While
Loop on the right. At this point a message appears on the front panel informing the user of their
minimum and maximum target heart rate for maximum calorie burning. Once the user presses “OK” on
the message box, the age and weight information is liberated from the right While Loop and it “flows”
The ECG Calorie Counter VI performs three functions. First, it performs real time graphing of
ECG data. Secondly, it is able to count the rising edges of a QRS complex from the heart. Finally, this
VI can also tell time, and is thus able to divide the number of heartbeats (found from the rising edge
detector) by the time that the program has been running. This results in data that can be scaled to give a
value for a patient’s heartbeats per minute. A final trivial point is that this VI can take age, weight, and
The ECG Calorie Counter VI is able to display ECG information by continuously acquiring data
from the DAQ. Once the hardware has been configured and a buffer set by the AI Config. VI and the AI
Start VI begins the buffered analog input information, the AI Read VI can read the buffered
input data. The output of the AI Read VI is a 2-dimension array of data that is graphed on a strip chart
in real time. Once the data acquisition process is complete, the AI Clear VI stops the data acquisition
so that data can be written to the buffer while the graphing process is executing. This way, data can be
acquired at the fastest possible rate, and thus no data is lost. For this program, the sampling rate was set
to 256 samples/sec. and the buffer size was set to 512. As a general rule, the buffer had to be about
As stated earlier, the ECG Calorie Counter VI also is able to keep time with the help of the
Timing Circuit2 VI. This VI makes use of the Tick Count (ms) function, which returns relative time
values in the software circuit. Thus the Tick Count function in the outermost While Loop can not tell
time, but the relative time difference between when it first executes and when the Tick Count function in
the inner While Loop allows differential time calculations to occur. Once data enters the outer While
Loop, its Tick Count is set, and the Tick Count value on the inner While Loop decrements with each
iteration of the While Loop. This gives a convenient measure of the time it takes for the inner While
Loop to execute. Once data exits the inner While Loop (this will occur whenever its Boolean Control
evaluates to false), the Tick Count of the outer While Loop will be initialized to a new value.
Timing Circuit2 VI
The Timing Circuit2 VI is able to keep the program “on time” but multiplying the total scan time
(which is determined by dividing the number of samples by the sampling rate) by the result the iteration
number divided by the number of points in a scan. This value is referred to as the goal time. The goal
time is then compared to the “differential time” determined by the Tick Count functions. If the program
is ahead of schedule, it will slow down by the amount that the program is ahead of schedule. If the
program is behind schedule, the amount of time that it is behind schedule can be added to the goal time
to give an “apparent time” that is correct. Thus, whether the scan parameters are difficult for the
15
program to meet or if they are easily met, the output “apparent time” will always be correct, even if the
program is unable to keep up. This allows the ECG Calorie Counter VI to calculate the heart rate in
beats per minute regardless of the fact that there may be certain experimental parameters that do not
Counter VI
The Counter VI counts rising edges of the QRS complex to give beat count information needed
for BPM calculations. The Counter VI is able to effectively count noisy data by determining if the
average of a variable number of data points in an array are above a threshold voltage set for counting,
and if the average of the same number of previous data points is below this threshold. It was
experimentally determined that the maximum number of data points that could be averaged for counting
It isn’t surprising that more data points can be used in averaging if there are more data points in a scan
since the ECG Calorie Counter VI samples the data that is sent to the strip chart. The data is a sampled
set of data of data that is a sampled from the output of the ECG circuit (at 256 Hz), so in effect, it is
sampled twice. With more data points, there is higher resolution in the sampled data, and thus more data
points can be looked at for threshold detection. If the number of data points to be looked at for threshold
detection is too high, then the criteria for counting will never be meet, and the heart beat counter will
always be zero.
One further criterion for counting is that heartbeats should only be counted after a FALSE
TRUE transition. This is due to the fact that it is possible for the average of a certain number of points
is above the threshold level and the same number of previous points is below the threshold for multiple
16
interations of the While Loop. Thus, as shown in the Counter VI Diagram, heart beats will only be
counted when the threshold criteria has been meet and there is a FALSE TRUE transition on
One question that still needs to be answered is why setting a finite number of points for array
operations is even necessary. The answer to this quesition is that if a very large number of array points
was set (100,000 for instance), and the outer While Loop of the ECG Calorie Counter VI was removed,
the VI would execute very slowly because it has a difficult time handling large numbers for array
operations. Furthermore, the program would have a finite run time before it would fail. In other words,
once all the array slots were filled, the program would no longer be able to count. Now the reason for
even having the outer While Loop becomes evident. With it, the programmer is able to set array sizes
that LabVIEW can easily handle (the default for the program is 2048 points) and these arrays reinitialize
every time the While Loop executes as many times as there are array points. Thus the advantage of this
system is that it allows for counting of rising edges of the QRS complex (since array data is needed to
look at past data and thus to assure the proper counting of heart beats) without slowing down the
software, and it also has the advantage that it can run indefinately.
One final point to mention about the ECG Calorie Counter VI is that the heart rate display in
BPM is the average of the BPM value over 256 iterations of the inner While Loop. This is done so that
the BPM output is readable since it may change on each While Loop iteration. When this happens the
output data appears to flicker on the screen since its value is changing every few milliseconds. With the
array averaging algorithm in place, the BPM output can only change every few seconds, making it much
easier to read.
17
DESIGN VERIFICATION
Due to the fact that the license for PSPICE expired on Aug. 1st, it is impossible to access pictures
of the final ECG circuit and of the frequency response. Hardcopies of this data will be provided to the
TAs. From the Bode plot, it is simple to see that the gain of the ECG circuit is approximately 2,000
since a 1 V sine wave was applied as the input and the output magnitude peaks at approximately 2,000
V. Furthermore, from the Bode plot one can see that cutoff frequencies are at approximately1 Hz and
125 Hz. The calculated frequency responses and gains for each of the biopotential amplifiers that are
required according to their respective physiological input signals were given in chapter 2.2. Bode plots
After each major section of the software was completed, a patient was connected to the ECG
amplifier to see if the components funtioned properly. The first component of the software to be
completed was the real time graphing of the ECG data. As previously mentioned, when the first version
of this program was tested, it was discovered that software bottlenecks only allowed for sampling at 30
Hz, so the output was highly distored. This problem was solved, as explained earlier, by use of circular
The next major software component to be tested was the timing circuit. The timing circuit was
tested by running the program and a stopwatch simulaneaously and comparing the output of the two
timing devices after several minutes. The timing circuit was acurate to a value less than the human
18
The final major software component to be tested was the counter. The counter was tested by
determining if it could correctly count noisy low frequency that a human would also be able to count.
The count value that was obtained by the human counter was then compared to the value calculated by
the Counter VI, and it was determined that this VI was able to accurately count noisy low frequency
The final software test was to see if the LabVIEW program could count pulses and
simultaneously keep time. This was done by applying low frequency sine waves that were not properly
grounded to the DAQ. The sine wave was purposely grounded improperly to simulate the type of noisy
ECG data that the LabVIEW program would encounter. Furthermore, once patients were hooked up to
the ECG circuit, their heart rate in BPM was determined manually and compared to the results from
LabVIEW. The LabVIEW results compared very well with those determined manually. Due to
space restrictions for this report, the LabVIEW code could not be included here. It has been uploaded to
the project web site, so the LabVIEW programs can be viewed from there.
COST ANALYSIS
The prototype cost analysis takes into account the price of the product we intend to market. Since it is
the prototype, the costs will be decrease due to mass production efficiencies. Some parts, such as the
19
disposable electrodes ( 3M Red dot) and software (LabVIEW) were donated, but the costs were still
figured in the prototype cost. The cost of the case of electrodes is estimated to be about $45 based on
market value price.
Labor
Parts
CONCLUSION
20
The ECG Calorie Counter device was successfully developed. The ECG amplifier circuit was
able to amplify and filter a biopotential signal to make it suitable for display on LabVIEW while
preventing loading and protecting the patient from macroshock. Interface between the ECG hardware
and the LabVIEW software was successfully achieved by an AT-MIO-16 data acquisition card. The
LabVIEW program is able to sucessfully determine the frequency of a signal and convert that number
into beats per minute. This ability was successfully demonstrated when the LabVIEW program was able
to convert the frequency of input sine waves to cycles per minute by using the counting and timing
algorithm. Because LabVIEW was able to correctly count and time input data of a known frequency, it
can be assumed that it is also able to determine the beats per minute of a heart. Furthermore, BPM data
obtained with LabVIEW supported heart rate values obtained manually. Finally, the calorie counter was
able to sucessfully determine calories burned per hour and total calories burned through a simple
algorithm that calculated caloric expenditure as a function of age, weight, and heart rate.
The best way to test our project’s accuracy would have been to buy a cheap heart rate monitor
(such as one that comes on a watch) and to have compared the BPM data from this heart rate monitor to
the one that was constructed for this Senior Design project. Furthermore, although the output signal
from the ECG had very little noise due to the extra care taken to minimize noise, an even cleaner signal
could have been obtained in the ECG circuit was implemented on a PC board and enclosed in a Faraday
box.
If there had been more time avaliable to work on this project, a hardware version of the
LabVIEW program would have been a nice addition. Using a 555 timer circuit and modulo-6 and
modulo-10 counters would have allowed for heart rate display (in BPM) on an LED display. It would
have been interesting to see if the hardware output would have agreed with the software output, and this
addition would have given the authors some extra experinece in digital design.
21
APPENDIX A. TOLERANCE ANALYSIS
22
The bandpass filter of the ECG amplifier in the final circuit had values as follows: R11 = 159.9 k, R10 =
Figure 7.1 above shows the schematic of the bandpass filter (not labeled accordingly). The
resistor R11 was found that this gives a cutoff at 121.3 Hz. The PSPICE simulations were done to prove
experimental work. The acceptable values for the upper frequency are 100 Hz – 150 Hz. Solving these
boundary conditions we see that the acceptable range for R11 are from 137.89 k to 206.8 k. The
acceptable range for our high pass cutoff will be met as long as R11 = 159.9 k 1.16%.
Making the potentiometer R5 to 47 k solved the common-mode voltage problem discussed in the
design details. The SPICE simulations on the next page (figure 7.2) show that the acceptable range
before poor noise occurs is 47 k 5 %. The 5% variation will be in the acceptable range of CMRR
23
24
Figure 7.2 PSPICE Simulations of Common-mode voltages
References
25
[1] Health Resource Center at the McKinley Health Center, University of Illinois at Urbana-
Champaign, “Determining Your Target Heart Rate Range,” 1995,
http://www.uiuc.edu/departments/mckinley/health-info/fitness/exercise/targ-hea.html.
[2] National Instruments, LabVIEW User Manual, National Instruments Corporation, 1996.
[3] Webster, John G., Medical Instrumentation: Application and Design. 3rd Ed. Philadelphia: W.B.
Saunders Company, 1998.
26