Loading...
Print Send a link

Refik's ECG

This content was taken from Refik's web site (external link).


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.

Figure 1.


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


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:

1. .include “m8def.inc”
2. 
3. .def temp = r16
4. .equ CLOCK = 4000000    ; define frequency speed
5. .equ BAUD = 9600    ; define baud rate of sending data
6. .equ UBRRVAL = CLOCK/(BAUD*16)-1
7. 
8. main:
9. 
10. ldi r16, 0b00100000    ; configure the ADC
11. out ADMUX, r16
12. 
13. ldi r17, 0b10000111
14. out ADCSRA, r17
15. 
16. ; Stackpointer initialisation
17. ldi temp, LOW(RAMEND)
18. out SPL, temp
19. ldi temp, HIGH(RAMEND)
20. out SPH, temp
21.  
22. ; Baudrate configuration
23. ldi temp, LOW(UBRRVAL)
24. out UBRRL, temp
25. ldi temp, HIGH(UBRRVAL)
26. out UBRRH, temp
27. 
28. ; Frame-Format: 8 Bit
29. ldi temp, (1<<
30. out UCSRC, temp
31.  
32. sbi UCSRB,TXEN    ; TX activate
33. 
34. ADC:
35. ldi r18, 0b00100000
36. out ADMUX, r18
37. 
38. ldi r19, 0b11000111
39. out ADCSRA, r19
40. 
41. loop:
42. in r24, ADCSRA    ; check if ADC done
43. sbrc r24, 6
44. rjmp loop
45. 
46. in temp, ADCH    ; fill the converted ADC value to temp
47. rcall serout    ; send ADC value to RS232(to computer)
48. 
49. rjmp ADC
50. 
51. serout:
52. sbis UCSRA,UDRE
53. 
54. rjmp serout
55. out UDR, temp
56. ret


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 (external link). I hope you like it. biggrin

Figure 7. ECG Results in LABView


Figure 8., ECG Results in LABView


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


Figure 11. the ECG board that I created myself, back





Created by: admin. Last Modification: Friday 28 of November, 2008 20:28:14 CET by admin.