Super Simple Electrocardiogram (ECG) Circuit

105K27137


Intro: Super Simple Electrocardiogram (ECG) Circuit

Electrocardiography is the study of the electrical signals produced by the heart during the cardiac cycle. Doctors monitor a person's electrocardiogram (ECG) in order to assess how the heart is functioning and can be used to diagnose a variety of cardiac diseases. The ECG is thought to have first been discovered by Alexander Muirhead[1] and has become a hallmark in patient care. It turns out that an ECG is very easily obtained with a few common circuit components. I'll show you how to build a "Super Simply Electrocardiogram (ECG) Circuit."

This Instructable assumes that you know a few basic concepts of circuit design and analysis such as:
Nodal Analysis
Operational Amplifiers
Filters
If you are a bit shaky on these topics, please consult the links provided for additional information.

[1] "Electrocardiography." Accessed: November 5, 2016. <https://en.wikipedia.org/wiki/Electrocardiography>

Warning: Please do not connect your ECG circuit to a wall outlet or any instrument powered through the wall outlet for safety reasons.
Warning: This is not a medical device.

STEP 1: Gather Your Tools

Instrumentation Amplifier
1 x AD623

Resistor
1 x 1k

Power Supplies
+5V
-5V
(2 lithium polymer batteries are suggested. That would give you +/- 3.7V.)
Warning: Please do not connect your ECG circuit to a wall outlet or any instrument powered through the wall outlet for safety reasons.

Accessories
3 x ECG electrodes
3 x Test leads

STEP 2: Instrumentation Amplifier

The Instrumentation Amplifier is probably the hallmark amplifier for bioelectrical measurements for a number of reasons, most notably: (1) high input impedance and (2) very good common mode rejection. High input impedance ensures that we do not draw current from the system that we are measuring. Since we are connected to a biological system, drawing current from that system can actually be dangerous in some instances. Additionally, electrodes are often used to interface the biological system with the circuit. We usually use metals as electrodes, which are very good conductors of electricity. Unfortunately, the impedance of an electrode can vary unpredictably when placed into a biological system for a number of reasons. Using a high input impedance amplifier helps us nullify the effects of changing electrode impedance and maintain signal integrity.

Common mode rejection allows us to diminish the effects of background signals that distort our measurement, often called common mode noise. Instrumentation amplifiers are specifically designed to ensure we reject as much common-mode noise as we can. This parameter is reported in the amplifier's "datasheet" which is essentially the amplifier's spec sheet produced by the manufacturer of the device. You will typically find CMRR (Common Mode Rejection Ratio) or CMR (Common Mode Rejection) reported as a function of frequency and is given in units of "dB." dB stands for "decibels" and is a logarithmic relationship of voltage gain.

CMRR and decibels are a bit out of the scope of this Instructable. Please see the links for more information.

STEP 3: Electrode Connections and Powering the Amplifier

There are many places on the body to put your electrodes to record the ECG. For this demo, I placed electrodes on my right wrist, my left wrist, and my right ankle. The right wrist electrode is "Electrode 1." The left wrist electrode is "Electrode 2." The right ankle electrode is attached to ground.

Additionally, power the op amp by placing +5V at "+Vs" (pin 6) and -5V at "-Vs" (pin 4).

STEP 4: That's It!


For the most part, that's all you need. The rest of this tutorial adds a few components based upon how you decide to configure your instrumentation amplifier.

STEP 5: Gather Your Tools

For the rest of this Instructable, I will use a modified circuit to use a "single supply" with my amplifiers. We need a few more components.

Instrumentation Amplifier
1 x AD623

Op Amps
1 x MCP6002

Resistors
1 x 1k
1 x 10k
1 x 820k
1 x 1.47M

Capacitors
3 x 470nF

Power Supplies
+5V
(1 lithium polymer battery is suggested. That would give you +3.7V. I powered mine through 5V on the Arduino, however, with my Arduino disconnected from mains.)
Warning: Please do not connect your ECG circuit to a wall outlet or any instrument powered through the wall outlet for safety reasons.

Accessories
3 x ECG electrodes
3 x Test leads

STEP 6: Modifying Our Instrumentation Amplifier With a Vref Generator

I often use "single supply" amplifiers for convenience. Many amplifiers are powered with a "bi-polar supply" meaning that you have to give the amplifier a positive and a negative voltage for it to operate correctly. Some amplifiers are specified for "single supply" operation meaning you only need a positive voltage and ground to operate the amplifier. This is really convenient because it allows us to operate amplifiers with very small batteries such as lithium polymer battery (3.7 V) or even a few AAA batteries (1.5 V). Single supply operation is even more convenient when using a microcontroller with our amplifiers. Microcontrollers most often work with a single voltage supply (for example, the Arduino UNO runs off 5 V).

Single supply operation poses a bit of a problem, however, for using our instrumentation amplifier for measuring ECG. Our ECG waveform is AC (alternating current) and will alternate between positive and negative voltages. As a result, we will use a Vref (voltage reference) generator, that will provide an offset voltage for the output of our instrumentation amplifier. This ensures that the output voltage of the instrumentation amplifier will never be negative. We will set our Vref generator to 1/2 of the positive supply voltage. In my case, I powered by circuit with 5V. My Vref generator is then 2.5V.

STEP 7: Electrode Connections and Powering the Amplifier

Electrode connections are the same as Step 3 except for the right ankle electrode which is now attached to Vref instead of Ground (0 V). Otherwise, the right wrist electrode is "Electrode 1" and the left wrist electrode is "Electrode 2."

However, the power connections for our amplifier change slightly. Power the op amp by placing +5V at "+Vs" (pin 6) and Ground at "-Vs" (pin 4). Also, place the output of the Vref generator at "REF" (pin 5).

STEP 8: Additional Gain Stage: Active Highpass Filter

You may find that your signal is not big enough, even after putting a bit of gain on the instrumentation amplifier. If you do, an additional amplifier circuit will do the trick. Any number of amplifier configurations will work, but for reference sake I used an inverting amplifier. Notice from the diagram, we are also doing a bit of filtering in this stage as well, making this stage an "active highpass filter."

You may notice a few deviations from the typical inverting amplifier configuration that you may be familiar with. First, instead of placing a ground at the non-inverting pin, we actually place our generated reference voltage from step 6. Secondly, we include a high pass filter at the input of our inverting amplifier. This filter has a pretty specific purpose. Even though we used a Vref generator for our instrumentation amplifier to ensure that our output is maintained at a specific voltage level, small deviations from this level can occur. (Reasons for the deviations will be explained in Step 10). As such we use a high pass filter to block the unstable voltage level and re-center the signal at our generated reference voltage. Recall from op amp rules that the voltage at the inputs of our op amp are equal. Therefore, if the voltage at the non-inverting pin is Vref, then the voltage at the inverting pin is also Vref. Furthermore, because we use a high pass filter at the input of the amplifier, there will be no DC gain by our inverting amplifier and our output voltage will also be centered around Vref.

STEP 9: That's It! (Again)


You're done! No matter how many times I do this project (and it's a lot), I still get a kick out of it. It think it's pretty cool. Anyways, until next time. Enjoy!

STEP 10: A Few Pitfalls


The above video demonstrates what my ECG signal looked like when a number of the following guidelines were not followed.

Electrode connections

  • Electrode placement and contact is essential for obtaining a stable ECG signal. Please ensure that your electrodes have very good contact with the skin and are not drying out. Please use electrode gel to ensure your electrodes remain moist.
  • We usually pick up small DC voltages with our electrodes that will subsequently be amplified by our Instrumentation amplifier. If you notice that the output of your instrumentation amplifier goes to the maximum or minimum voltage, please decrease the gain of the amplifier. You can also check the DC offset voltage on your electrodes by measuring the DC voltage at each of inputs of the instrumentation amplifier. If the difference in the DC voltage of each of your inputs multiplied by the gain of your amplifier is very large, then your signal is will be distorted by causing a strong deviation from our bias point that we set in Step 3. Try adjusting the electrodes to ensure firm contact with your skin and/or apply electrode gel to ensure a good connection.

Amplifier Considerations

  • I have noticed that any resistance smaller than 1k for Rg causes unstable behavior in the amplifier.

Power-on Sequence

  • I suggest connecting all your electrodes to your circuit, including ground, before turning your circuit on. If the inputs of your instrumentation amplifier are not connected to a reference point before the amplifier is turned on, they could "float" unpredictably causing the output of your amplifier to be unstable. Immediately connecting your electrodes may not solve this problem as the amplifier has to re-adjust quickly and may not have a proper path to discharge the its output.

General Guidelines

  • Stay still. Moving around will distort your signal.
  • Stay relaxed. Tensing your muscles will causes distortion by picking up electrical signals from skeletal muscles instead of the heart.

A Few More Suggestions

Gain and more Filtering

  • I made this circuit for general biopotential measurements, but once you figure out the specific signal you want to measure, you'll probably need to make more changes. For ECG, the amount of gain used is probably sufficient, but for EEG or a more sensitive signal, you'll probably need some more gain. I would recommend adding a few bandpass filters. I usually use two bandpass filters with gains of 26.6dB and cutoff frequencies of 0.7Hz and 34Hz for EEG.
  • A 60Hz notch filter would be nice as well.

STEP 11: Going on Further

There is MUCH, MUCH more we can do to this circuit to make it robust. The purpose of this Instructable was to provide the minimal circuitry necessary to obtain a reasonable ECG signal. I have presented the circuit I used to do just that. I attached screenshots of a mock-up of a more involved circuit design. Please note that this design was simulated and not built. I have also included the magnitude vs. frequency response of the circuit.You can modify the simulation on Circuitlab.com. Please feel free to search the web for more sophisticated implementations of the ECG circuit, but what I have presented should get you going. Have fun!

34 Comments

Yes. Just be sure you power the UA741 appropriately. The UA741 has different powering requirements than the MCP6002. If you have an LM258, LM358, oor LM2904 (or something like that) that might be better since those chips can be powered with a single supply like the MCP6002.
I am very curious that you get a reasonable signal from your body without shielding cables and right-leg-drive... Have you really used ceramic capacitors for the notch filter? I read many times that they are not suitable for this filter...
What is ic2p is for? How to connect it to main circuit? Plz reply asap.

There's an inconsistency here. If you build yourself an ECG, heart-monitoring machine, ie a kit of parts with wires to wrists and ankles, you all worry you might get electrocuted by your 5v mains PSU. But if you instead built say a radio or anything else powered by that same PSU, you would not be in the slightest concerned if you touched live wires during the construction process because its only 5v. But thats the same 5v, connected to your hands. Its either dangerous in both circuits or safe in both circuits - completely irrelevant that one happens to be measuring your heart.

I suggest to you that this circuit is perfectly safe, unless your mains adaptor is faulty - then it is dangerous whatever the circuit you construct!

The body has a high resistance and is immune to low voltages like this. I am not in the slightest concerned to grab the terminals of a 12v car battery one in each hand.

It's not the same thing - here you are deliberately connecting the terminals to the skin in such a way that the heart is on the path between them, and likely leaving the connection in place for some time. So the consequences of your mains adaptor developing a fault, unlikely as that may be, can be far worse.

I pull the cord out of my lawnmower before clearing the blade, even though there's very low likelihood the power switch will fail closed while I'm doing it.

There is no failure mode of a battery, as far as I know, which can cause it to generate 110V AC or similar by itself.

Great point. Thanks for posting this. For a small battery, 9V, I would say the risk is relatively minimal. Plus mains is AC which crosses the body a lot easier due to the capacitance associated with the body model and electrode-electrolyte interface. Oh and the obvious fact that 110V AC is MUCH higher than 9V from a battery. Lol.

Hola amigo me gustaria saber como realizo ese proyecto. Gracias

You're welcome dude. Thanks for the compliment.

De nada. Aprecio su cumplido!

Hello

Nicely done and something close to my heart (no pun).

As an ICD (Implanted Cardiac Device) patient , I owe a lot to ECG's not only for the diagnosis of my condition (complete heart block, so no natural pacemaker function) and to the wonderful device that keeps me ticking over.

The ICD is a wonder of micro-electronics and presumably has all the circuitry you describe plus a lot more to store events, be interrogated contact-free and decipher what remains of my natural pacemaker before administering the correct electrical pulses. I am on ICD number two, the old one failing after 11-years use.

I often wonder what patients did before basic electronics were invented.

Much as I like the project, I don't think I will be trying it out, too risky.

I measured a cheap PSU output and although it showed 12-V dc across the LV side, it was 120-V relative to ground, safer to stick with batteries.

how about the V1 to V5 derivates? is that possible to monitoring these derivates ?

If i do remember well, V1-V5 are measured against a fake ground composed of left hand, right hand and left foot connected through 1Mohm resistors in a star configuration. The center point is the fake ground. Hope this helps. (A bit of googling will help too... ;) (Image stolen from Electrocardiografia.es)

It's V1 to V6 actually - the electrodes placed across the left front of the chest wall.

This circuit is in effect displaying Electrode 2 (left arm) (ie the heart as viewed from left shoulder - where the left arm joins the body!), using Electrode 1 as reference and Electrode 3 as a ground.

So to view V1 to V6, simply move the Electrode 2 from left wrist to the desired place on chest wall and that will do the trick. Maybe not medically perfect, but close enough.

Yep. V1-V6. My bad. The circuit that you describe is called aVL, the "a" stands for"augmented". They are unipolars, like Vx, and they fake ground against the other arm/foot (Same thing for aVR, aVF.). Moving the electrode to the six points on the chest can give you readings, but they will be better with the "fake ground" circuit. Making medical diagnosis is a tricky thing, and it depends heavily on the quality of the signals. A little up or down of the baseline and you can do the wrong diagnosis. Other than this, i do agree with you.
Best regards

I described a chest lead, not aVL.

Your 'fake ground' is properly called 'Goldberger's Central Terminal'. It's all described nicely in the Wikipedia linked from the original article - ie https://en.wikipedia.org/wiki/Electrocardiography

For measuring the the chest leads V1-V6 the exact ground does not really matter, and using the two wires connected to right arm and a leg will be quite OK.

The main quality issue with this circuit is that the author has not implemented a low-pass filter to get rid of the 50 Hz mains hum (60 Hz if you are unlucky enough to be ruled by Mr Trump!).

Well. I must agree with you... mainly. Calling it 'fake ground' was just a simplistic way to kickstart the original question. But, I must quote Wikipedia:"Leads aVR, aVL, and aVF are the augmented limb leads. They are derived from the same three electrodes as leads I, II, and III, but they use Goldberger's central terminal as their negative pole which is a combination of inputs from other two limb electrodes".

Being picky, you said "Electrode 2 (left arm) (ie the heart as viewed from left shoulder - where the left arm joins the body!), using Electrode 1 as reference and Electrode 3 as a ground".


Speaking strictly, we measure an electric potential against a reference, being this reference a simple one for bipolars (the other limb), or a compound reference for augmented (the other two limbs) or precordials (the three limbs of the Einthoven's triangle). Not a ground. Well. I do know. A ground lead most often does exist, but is connected to equipment's ground. On some (weakly designed) electrocardiograph, is used to improve mains hum rejection.

Quoting Wikipedia again: "The precordial leads lie in the transverse (horizontal) plane, perpendicular to the other six leads. The six precordial electrodes act as the positive poles for the six corresponding precordial leads: (V1, V2, V3, V4, V5 and V6). Wilson's central terminal is used as the negative pole" and "The common lead, Wilson's central terminal VW, is produced by averaging the measurements from the electrodes RA, LA, and LL to give an average potential across the body".
Wikipedia said things better than i can.

On a personal note, I am a electronic hobbyist, from more than 40 years now. Yes. You are right, I'm not an engineer (surely you are).
I developed this same thing for personal amusement more than 25 years ago, with opamps, and it was a pain, and a pleasure. The output was connected to an osciloscope with no persistence, so it was a pain to read. A trigger signal was also sent to a Commodore 64 to read heart's rate. Changing from bipolar to augmented to precordials was done with pushbutons. It was just fun and not for real use, even if it worked OK.

But also I am an ICU M.D, for more than 30 years now. I can tell you first hand the huge difference between a weak or good designed electrocardiograph when you are in a RCP, massaging a heart, with all this movement interfering the readings, and you do need to distinguish what is happening inside the chest. And close enough is not enough when it defines if someone will live or die. (Yes. It is embarrasing. Is V1-V6, not V1-V5.)

So, in my own opinion, for what is worth, for precordials you need what is properly called Wilson's central terminal.

Ok. This is Instructables and i am being too much picky. But someone was enthusiastic about expanding this to be used on the field, so i think is better to say thing right.
Anyway, you spotted a very weak design point: no low-pass filter. For any serious use is a must have.

I enjoyed your other post. Maybe the article you was unable to find was "DIY EEG (and ECG) Circuit" by cah6, here at Instructables?. The link you posted "DIY ECG with 1 op-amp" is amazingly simple!
Also, i do agree. 5v (or 12v) will do nothing to you (or me, or anybody). But discovering a just-starting PSU leakage when you connect your ECG machine to a patient can be... well... shocking. Because disaster strikes when no one expect this. So, for safety reasons, is better to stick to a battery source. Not because 5v will kill you. Because a PSU can fail after some time of use, and this kind of thing cant be prevented. (Safety First. A principle by which to live)

By the way: I'm lucky enough to be NOT ruled by Mr Trump :) (I hope you do not either). But we live in the same planet. This is unlucky. Whatever happens on USA, repercutes on the entire world.. :(
Be well.

Our chat is getting too long. My comment meant "good enough for experimentation use" not medical diagnostic use.

The article I was unable to find wasn't on Instructables after all. It's at https://blog.adafruit.com/2016/08/31/electrocardio...

I am a physician too, not an engineer, British but now live in Switzerland. I do Patient Safety in the pharma industry. My best claim to fame is that I nearly invented Windows, but unfortunately didn't realise how revolutionary it was - things could have worked out rather differently ...

Well, a colleague after all :-). More to agree than to diverge.
Sorry to hear about you lost Windows patent. What a shame. How would you name your company? (When i think of it, I do remember an old Mel Brooks movie. The evil was called "Bite and Devours" or something like that.) Just joking. Dont take me wrong. By the way, i am from Argentina. If somehow i do manage to go to Switzerland (very unlikely, i am afraid), let me buy you a beer.

You are right. Is getting too long. I am getting too old too... I must shut up.
Best regards.

You should take more care specifying the power supply, medical grade supplies have a very low leakage current. Cheap amateur bricks can have very considerable, and potentially hazardous leakage.

I really you emphasise this project is battery only

Cool. Thanks for the tips. You're right. I should be clear that using mains is a bad idea. I put a warning in the intro, but I'll go ahead and bold the text and also place it again in the "Power Supplies" section in the "Gather Your Tools" steps. Thanks for the comment.

More Comments