关键词: simple ECG
I haven’t been writing for some time and I am sorry for it. During the summer I got a three week scholarship in Germany! I had a great time there, btw. I would like to greet those people now! Finally the exams are over and I wanted to share one of my projects with you. Lately Biomedical engineering is getting more and more popular, the emerging technologies made this field change rapidly. So I gave it a try, why not?
This article should teach you how to build a simple heart monitoring device, ECG/EKG (electrocardiograph). In the United States and Worldwide million’s of people are losing their life because of heart failure. It is a disease that comes with diabetes, stress and etc. Before I continue to explain what I did, I would like to WARN you! 500mA (miliAmps) on 220V will completely destroy your nervous system (so run it from battery supply), check everything twice and you are responsible for it on you own. OK! I think I can continue. There was a student job which I wanted in the Biomedical field, so to make my CV look even better I wanted to have something from this field so I built an ECG. First what I did was I went to google.com and looked for similar projects and I found a great number of similar projects. Some were for logging data of heart disease patients, some were for some futuristic health monitoring devices and some were just for fun, as mine.
Let’s start with the definition what ECG is all about (taken from Introduction to Medical Electronics Application by D. Jennings, A. Flint, BCH Turton, LDM Nokes):
“The human heart can be considered as a large muscle whose beating is simply muscular contraction. Therefore contractions of the heart cause a potential to be developed. The measurement of the potential produced by cardiac muscle is called electrocardiology.
The depolarising field in the heart is a vector which alters its direction and magnitude through the cardiac cycle. The placement of the electrodes on the surface of a patient determines the view which will be obtained of that vector as a function of time. The most commonly used electrode placement scheme is shown in Figure 1. Here the differential potential is measured between the right and left arm, between the right arm and the left leg and between left arm and left leg. These three measurements are referred to as leads I, II, III respectively. This measurement lead placement was developed by Einthoven who stated that through measurement of lead I and lead II the signal seen at lead III could be calculated. This is the most basic form of ECG lead placement: from this the various features of the heart’s depolarisation can be calculated. Clinically there is a range of lead placement schemes which incorporate limb leads and chest leads.
Therefore the ECG waveform shows the clinician the electrical waveforms associated with the contraction of the atria and ventricles. From an ECG a clinician may determine the relative timing of the contractions of the atria and the ventricles and assess the relative amplitude of the atrial and ventricular depolarisation and repolarisation. This information may allow the identification of mild heart block. Following a heart attack a patient’s ECG shows changes as the timing and shape of the waveform are dependent on the transmission of the waveform through the muscle tissue. This changes with ischaemic muscle damage associated with heart attacks.”
Figure 2., connection diagram
After a little introduction into ECG we will move on to the electronic description. The simplest way to explain how it works is to make a block diagram! The signal from the body is being amplified(the signals from the body are small and weak, ranging from 0.5 mV to 5.0 mV), filtered (to remove the noise), sampled (by sampling I mean it goes to an Analog to Digital converter aka ADC) and then sent to your computer through RS232 (wireless or any other way but RS232 was chosen because it is the simplest and fastest to make). The first two steps are shown in Figure 3.
Figure 3., ECG Chain
The amplifiers we use in biomedical engineering, data acquisition or where the signal of interest is represented by a small voltage fluctuation superimposed on a voltage offset are called Instrumentation amplifiers. Instrumentation amplifiers have a high CMRR(Common Mode Rejection Ratio) which means they have the ability of a differential amplifier to not pass (reject) the portion of the signal common to both the + and – inputs. The famous producers of Instrumentation amplifiers are Texas Instruments and Analog Devices. I used the amplifiers from the second company, Analog Devices. The AD620, instrumentation amplifier, and OP97, a high precision operational amplifier. As they require negative voltage supply I generated it with the Linear LTC1044, switched capacitor voltage converter, Figure 4. The supplied voltage was 5V. The schematic is shown on Figure 5, and it was taken from this datasheet where it is explained in more details.
Figure 4., LTC1044, negative voltage generator
Figure 5., ECG Schematic (click on it for a larger version)
The noise comes from muscle contractions, power line interference 50-60 Hz, electrode contact noise, noise from other electronic devices and etc. The filter for the ECG application should be a notch filter(high-pass and low-pass filter). It should filter in the range from 0.5 Hz to 50 Hz. I created a simple RC highpass and lowpass filter, in series connected (just two capacitors and resistors).
Figure 6., ECG Signal
The ADC I used was an internal ADC from an Atmel MCU, ATMega8. The code is here:
.def temp = r16
.equ CLOCK = 4000000 ; define frequency speed
.equ BAUD = 9600 ; define baud rate of sending data
.equ UBRRVAL = CLOCK/(BAUD*16)-1
ldi r16, 0b00100000 ; configure the ADC
out ADMUX, r16
ldi r17, 0b10000111
out ADCSRA, r17
; Stackpointer initialisation
ldi temp, LOW(RAMEND)
out SPL, temp
ldi temp, HIGH(RAMEND)
out SPH, temp
; Baudrate configuration
ldi temp, LOW(UBRRVAL)
out UBRRL, temp
ldi temp, HIGH(UBRRVAL)
out UBRRH, temp
; Frame-Format: 8 Bit
ldi temp, (1<<
out UCSRC, temp
sbi UCSRB,TXEN ; TX activate
ldi r18, 0b00100000
out ADMUX, r18
ldi r19, 0b11000111
out ADCSRA, r19
in r24, ADCSRA ; check if ADC done
sbrc r24, 6
in temp, ADCH ; fill the converted ADC value to temp
rcall serout ; send ADC value to RS232(to computer)
out UDR, temp
The results can be seen on the following pictures. I used LABView to see the ECG of my heart. I would like to mention the blog from my friend, Rich Hoeg, eContent. I hope you like it.
Figure 7., ECG Results in LABView (click on the picture for a larger version)
Figure 8., ECG Results in LABView (click on the picture for a larger version)
Figure 9., that’s me with the electrodes (the image on the t-shirt is the logo of the Bosnian Basketball Association)
Figure 10., the ECG board that I created myself, front (click for a larger version)
Figure 11., the ECG board that I created myself, back (click for a larger version)