Homemade Electrocardiograph
All the content you see here was taken from the web site of Jason NguyenTable of contents
Here you will find information how how to build a simple ECG with less than $10 in parts. But before we get started, let's take a moment to talk about shop safety. Be sure to read, understand, and follow all of the safety rules that come with your power tools. Knowing how ....ummmmm, sorry. I guess I got into a little New Yankee Workshop
Now that I've started with this positive note, I can begin. Happy reading!
Introduction
What is an ECG?
An ECG is a three letter acronym for ElectroCardioGraph. It is also known as an EKG which stands for ElektroKardioGraph (the German translation of the word). Basically, this device detects and displays small voltages generated by the human heart. If you would like to know more about the details (ie, how are the voltages generated, why they exist, etc), please refer to the fine books I have in the Notes section.
Voltages? What voltages? You said voltages are dangerous.
As many people know, voltages are not the killer in electricity. It is the current that people have to worry about. The current can cause a person's heart to stop beating or to beat irregularly. The amount of current needed to kill a person varies. Of course by age/weight/size/etc, but it also varies by where the current is applied and how much goes through the heart. Basically, if more than 1mA is applied to the skin, a person can feel it. Anything higher than about 5mA causes pain. About 20mA is what's necessary to paralyze someone because of involuntary muscle spasm. And around 80mA causes the heart to lose it's timing. If electricity is applied directly to the surface of the heart, only 80uA is needed to kill someone.
History - no one likes history
This web page
Been there, done that, why you?
So now you may be asking yourself, "Okay, it's been invented, why would you want to build one?" Good question! Having being recently laid off from my employer. (Oops, the politically correct term should be "Workforce managed"). I found a little bit more time on my hands. So while looking for a job, I began to think, "Why not biomedical engineering?" Even though I'm an Electrical Engineer with no background in biomedical engineering, I figured, "Why can't I be in that field?" I've always wanted to save people's lives and help make society better (doesn't everyone?). So I bought the books, and studied the information. Suddenly, while reading about the history of the ECG, it hit me. If there's a guy that could make an ECG in 1887, I should be able to do it too. Not only that, but if these things have been in use for 200 years, I should be able to make one cheaply. After all, it's just an amplifier (I snicker here because after designing it, I now know it's not that easy).
Money doesn't grow on trees
So now I needed to make up some constraints. The first one - cost. After all, I'm unemployed. I can't go out spending thousands of dollars building this thing. I wanted to build this thing as cheaply as possible. In fact, one of my biggest plan was to make it cost less than $10. This is a far cry from the ECG's you can buy
My second constraint was simplicity. I wanted to make sure anyone could go out and build this device. I didn't want to make people go out and buy thousand dollar oscilloscopes
Trusty power supply
Various electronic parts - that's not all of it, but you get the idea
El-Cheapo multimeter. Purchased from Harbor Freight
Some Stuff Sought Out
Electrodes - Yeah, I could look like that...if I wanted to
One man's trash....it's still trash
So now I have some constraints on what I want and what I'm willing to spend on it. Luckily, I had a pretty good stash of old electronic parts. Some resistors, some capacitors, a few op-amps, etc. What I didn't have lying around the house were electrodes to attach to my chest, some shielded wire for connecting the electrodes, nor any means to view the waveform.
No waveform viewer? Okay, you're screwed!
One item I forgot to mention I had available was my good old computer. This faithful device adds, subtracts, and even divides! It is even more accurate than a slide rule. (I may be 23 years old, but I'm proud to say that I know how to use a slide rule!) I won't go into the details about using the computer as the waveform viewer now. This will have to wait for the digital section.
Electrode wires....where oh where?
This one was easy. I just stopped off at the good old Home Depot and purchased 5 feet of two-conductor shielded wire. At $0.11 a foot, I was spending too much.
Electrodes for a penny!
You may call me cheap at this point, but I like this idea. Pennies contain copper. Copper conducts electricity. In addition, the copper in the pennies make it easier to solder to. Thus, it's a win-win situation. Of course, I could go out and buy
After I got some feedback from users, I found out that 1) shampoo is even better than lotion. 2) KY Jelly is actually the same stuff they use in electrode gel. I still like my lotion idea because it leaves a nice smooth circle on an otherwise dry skinned chest. But feel free to use any of these other fine products.
Adventures in Analog Land
The weird thing about me is, I like analog circuits. I used to design them (old job) and just find them very fun. So at first glance, I thought this circuit would be a piece of cake. I quickly drew up a design and built the circuit. Little did I know how difficult it would be. I won't bore you with the details, but here are only a few of the complications I encountered.
Offsets are evil, and noise...that just sucks
Each op-amp has its own characteristic input offset. For the particular op-amps I had, they were in the range of 3-5mV. That doesn't sound like much, but when you consider that I'm trying to detect voltages in the range of 1mV, you see my predicament. The input offsets of the op-amp were eating the range of my output. Thus, the output would always rail.
The other problem I had was the evil noise that came through the wire. The electrode wires were several feet long, so it gave plenty of opportunity to pick up noise. The shielding helped a lot, but there was still a lot of noise from my body picking up energy. I tell you, it's all a conspiracy!
My guess is that you don't want to know the details on how and why I chose certain parts of the circuit. A lot of it was chosen to defeat the problems I encountered above. Therefore, the final analog portion of the circuit is:
schematic
Graphic is courtesy of EAGLE
Some details
- The input of the amplifier is IN+ and IN-. These are the nodes you connect to your chest.
- The 200k resistor can be built by using two 100k resistors in series (one next to another)
- VDD/2 is just a node name that a lot of nodes connect to. In other words, if it's called VDD/2, connect it to the same place.
- BODY is a node that you connect to your body (arm, leg, or somewhere) Basically, it's a feedback so that the body gets biased around the right common mode.
- VDD is the positive (+) end of the power supply (or 9V battery) and also connects to the V+ of the op-amps
- GND is the negative (-) end of the power supply (or battery) and also connects to the V- of the op-amps
- VOUT is the connection to the next stage (display stuff)
Hey! Some things changed!
After some really good comments from other people, I decided to add a few components for extra safety. It didn't cost much more and makes things quite a bit safer. The changes from my last design are:
Diodes across every input to decrease the risk of shock. By doing this, the maximum voltage across any two electrodes will be .7V. This is much higher than the heart signal, so it won't effect any other performance.
Resistors on the input of the amplifier. This is to reduce shock hazard. If the op-amp fails and creates a direct short from the input to the supply, the extra resistor will offer the second layer of defense. (Redundant backup is gooooooood).
I really want to know why you did __
A few of my design choices may seem odd. Here's some of my reasoning. I wanted my ECG to be relatively safe and easy to construct. I could have used a +12V supply and a -12V supply, but that would require two power supplies, or two 12V batteries. I decided that a 9V battery is pretty safe considering how many people have licked them. Therefore, I chose to power this thing by a single 9V battery! Thus, you see a reference to a VDD/2 node. This is basically an op-amp configured as a buffer to provide a constant 4.5V voltage. Therefore, removing the need for two batteries. (Admit it, I'm brilliant - okay, this type of thing is done all the time).
Next, I chose 100k resistors as the standard because I wanted this to be low power. 100k was also the largest resistor I had which was plentiful. I also had a lot of 1k, 10k, and 4.7k Ohm resistors. So I had to design everything around that. Back to safety. I needed to bias the body to some constant DC voltage, but I wanted that to be as safe as possible. Therefore, I put a 10k resistor before the connection to the body so that if I happened to touch some bad node, the currents would be small. I didn't put the same resistance on the electrode inputs because the inputs to the op-amp have around 10 12 Ohms of resistance. I think 10 12 resistance is big enough. Someone emailed me on the problem with my thinking. Extra resistance on the inputs would be good because a JFET is only high resistance going one way. A good power surge coming back won't see the 10 12 ohm resistance. So people - you may want to add some to that input.
If you would like more explanations on why I did something some way, I'd be happy to tell you. However, I could spend days on this topic and like I said above, not everyone wants to hear it. The basic point is, I wanted someone who had little knowledge in electronics to be able to build this. It should be fairly safe and require no fine tuning. It may not be perfectly accurate, but you don't need to buy .01% tolerance parts.
No isolation?!
Quite a few people are concerned about safety with this circuit. I am too. I was 99.9999% sure that my configuration would not hurt ME. I don't have any possible other ground node around me, and so the only real way I could get involved in a ground loop is by going out an intentionally try to make one.
If you do not understand the need for isolation, you shouldn't be building this project. I will refresh the memories of the people who may not know what I mean. The computer is connected to a 120V power source. Say something goes wrong and that 120V gets injected back into the analog circuit above. Although the op-amp should prevent anything from coming back, there is a possibility it will fail and send 120V to your chest.
Another example is: say the ground of the computer isn't quite ground (say it's 50V). (House is wired up wrong or some other bad reason). Since there is a direct connection to the battery (-) terminal, the whole system goes up to 50V, including your body. If at the same time you touch something that is truely at ground, the current will flow through the electrodes and into the true ground. Potentially killing you.
Therefore, the suggestion for optical isolation (optocoupling) is very warranted! The reason I cannot put it on my web page is a) I don't know how to make a linear optoisolator, b) I have not tested any method to isolate the analog portion from the computer. As soon as I come up with a good isolation technique, I will post it. But this won't change my stance: Don't attempt this unless you know what is going on!
Now I'm depressed. Aren't there some workarounds?
Yes. Someone else suggested that I use a portable tape recorder to record the signal out of the analog circuit. This would benefit with a completely isolated system, and I could play it back later.
Plenty of Programming
I am not being completely truthful here. I didn't just build the analog circuit and magically it worked. I had to program a little Visual Basic so I could debug what's wrong with all of my previous analog designs. However, let's just pretend that I built the analog portion and now I need to do the Visual Basic (digital) part.
You've got analog - the computer's digital....how?
I needed a way to interface the amplified analog signal, and display it on my computer. However, I didn't want to go out and spend $3 on a nifty Analog-to-Digital
It had been years since I programmed in Visual Basic, but I knew that would be the easiest and fastest way for me to program a nice graphical user interface. So I pulled out my dusty textbooks and started programming again. Unfortunately, I had no experience getting data from a computer's sound card. Luckily, someone had already developed a similar program
Private Sub Form_Load()
MsgBox "Hello World!"
End SubSimple, huh? No, the real code is in this secret zip file ecg. As well as a precompiled .exe
Results
For those of you just joining us, I've already promised to pay everyone a million dollars. See what you miss when you skip out on the whole story?
Drumroll please - and here are the results
Here are the electrodes, all soldered up and ready to go. The extra wire on the leads are just to improve shielding as close to the electrodes as I could make them. In case you can't see the extra wire, it's held close by the big blob of tape below the two right pennies.
The electrodes prepped with lotion and tape. Scotch tape
Electrodes on my chest and arm. A little extra lotion here. A little extra there. Smoooooth.
All of the electrodes connected to the analog circuitry. It may look like a bundle of wires to some. That's just because I added more to make it look more complicated than it is. (Just kidding) Green wire is the bias node (you can't see). The shielding goes to VDD/2. The electrodes connect to the IN+ and IN- (in whatever direction gives me a positive pulse). The orange wires connect to the sound card CD input. A new thing that you can't see are the resistors on the input and diodes across the leads. (Added after the picture was taken).
Finally the ECG output. Neat, huh? The only problem is I don't think there is supposed to be that negative spike. Most people are telling me that the negative peak is just fine. :) Everything seems to work and it even has the right heart rate. Ahhh, the wonders of science
Future thoughts
My ECG
Another ECG I've seen - mine has a negative spike that's just too big.
Everything seems to work properly. The peaks come when I can feel my pulse. The heart rate seems to be calculating correctly. It even auto triggers in case the amplitude of the signal is not very high. As far as I can tell, there isn't a major problem. Some people may be concerned that my graph has a negative peak. At first, I was too, but after many much smarter people told me that the negative peaks are normal, I just wrote myself off as stupid. However, there are a few problems with my ECG. The T-wave (peak #3) is a little distorted. This is due to the minimum bandwidth of my sound card. My Soundblaster is spec'ed to be around 10Hz min. When I toggle an input low/high, you can see the effects of the minimum bandwidth.
Black line is the output with a square wave input (about 4.5Hz) Red line is after signal processing the output.
The black line is the output of my ECG with a square wave input (switched by an intricate device called "the hand"
Long story short, after running with the new filtered output, the ECG looked a little better. There were a few places that got more squared up, but overall, the effects weren't worth mentioning. When I thought more about it, I figured that everyone's sound card is different, so I removed my little signal processing routine and decided to leave it as is.
So now you may be asking me: what in the world would anyone do with this? For one, someone could monitor themselves so they don't die from over gaming
Here's a few of my favorites given to me by some good people: Go to the local hospital and see if the ECG matches a 'real' ECG. Use it with other stuff to make a lie detector. See if the heartbeats of two people sleeping close together really do synchronize. Use it to pick up women!
That's cool. Why don't you manufacture these and sell them?
I would never dream of selling these as is. For one, this circuit has absolutely no isolation to the digital interface (the computer). With the risk of electrocuting a patient, I would guess hospitals don't want to buy something that's not UL listed or gone through the FDA. Another reason is the accuracy. Somehow I think my ECG isn't accurate enough for hospital use. And consumers? If the consumer got a hold of an ECG, what would they do with it? Would you know how to read an ECG and tell if there was a problem with your heart? I personally don't see a lot of use except for the hobbyist who knows what they are doing.
Now what?
I'm still kind of tempted to improve upon my design or my program. Especially the isolation with the digital portion. I might put in that analog-to-digital converter, then read the data (rather than remove the effect of the sound card via mathematical formulas). I may even be able to adapt this project so it works with a PDA. Oooo, better yet, I could put in a defibrillator circuit! Well, maybe not that one. I may feel safe probing my body for electrical signals, but I'm not comfortable applying large voltages to it. But, if someone wants to be my guinea pig, I'll be happy to zap them. (I'll of course make you sign a release form).
Unfortunately, due to financial constraints, I need to put this project on the back burner. (Hey, I need to start earning money again!) I am happy that I succeeded in fulfilling my constraints. Considering how I had most of the parts on hand, the total cost to me was about $0.58. (That's $0.55 for the 5 foot wire and $0.03 for the three pennies I had to solder to). Of course, for people starting from scratch, it will cost them around $4. My second constraint on ease of building was also accomplished. The project uses a simple 9V battery, a bunch of resistors, some caps, and some LF353 op-amps. Considering how everything was just a 5% tolerance component, I don't think there is any fine tuning that needs to be done. The circuit should automagically set all of the right bias points and work.
I hope everyone enjoyed my little project, and thanks for visiting!
Notes/References
Just because I know that some people are skeptics and they don't believe things without proof, I've put together the references I used in my project.
Microsoft Visual Basic Professional 6.0 Step by Step by Michael Halvorson
Biomedical Instrumentation and Measurements by Leslie Cromwell
Principles of Biomedical Instrumentation and Measurement by Richard Aston
And of course, the nice sample code
And special thanks to National Semiconductor
Special Thanks
Everyone who visited my web page.
Everyone who emailed me.
Everyone who thought this project is cool.
Everyone who sent me suggestions on how to improve my circuit.
Everyone who explained why my ECG is normal.
Basically everyone, but some more that come to mind:
Jelani John for making a Linux version
Mouser
The University of Utah
Geocities, Tripod, Fortunecity, CoolFreePage, and 1asphost - for letting me mirror my site while it was being slashdotted
And Slashdot - for posting my web page.
Oh, and I guess I should thank my parents, my friends, my dogs, my .......
Debugging
Okay, I guess it's not as robust as I had hoped
These are my suggestions on some of the critical nodes to probe when debugging this circuit. The list is arranged in order of what depends on something higher in the list. In other words, step 1 requires nothing other than the circuit and power to work. If step 1 gives a bad result, then step 2, 3, 4, 5, etc will probably fail. This list of potential problems are endless. However, if a certain step fails, it probably means there is a bad connection or bad part. The components near the node you are checking should be checked. (Ie. swap out the ICs with other ones and see if the numbers change).
- Verify that VDD/2 is right. It should equal about 4.5V and should not vary. (Non-dependent on other items).
- Short IN+, IN-, and BODY together. Verify the voltage of the shorted nodes is the same or close to VDD/2 (4.5V)
- Keep config of step 2. Check pin 1 of IC1A. It should be somewhere around VDD/2, but not exact (close to 4.5V)
- Check pin 7 of IC1A just like step #3 above.
- Check pin 1 of IC2A. It can be anywhere between 1 and 8 V (we're just checking to make sure this amplifier has not railed).
- Check pin 3 and pin 2 of IC2A. These should be nearly the same and equal to VDD/2 (4.5V).
- Check pin 7 of IC2B. It should be around VDD/2 (4.5V). Give or take a little.
- Check pin 6 of IC3B. This should equal pin 5 or VDD/2 (4.5V).
- Finally, look at VOUT. It should be VDD/2 (4.5V) or somewhere close.
After all this, the circuit should output a good signal. One way to check is to apply a signal with a function generator or some other device. It will saturate the audio input, but you will see a signal.
Good luck, and I hope you all have fun!
Created by: admin.
Last Modification: Sunday 30 of November, 2008 20:24:27 CET by admin.
Sidebar
Wiki Contents
Recent activity
Forum
- Software: LabVIEW and Matlab question
- Software: MIT-BIH Database
- Software: MIT-BIH Database
- Software: MIT-BIH Database
- Software: European ST-T and MIT-BIH database
- Hardware: Complete ECG front end
- Hardware: how to get signal from the body
- Hardware: Complete ECG front end
- Hardware: how to get signal from the body
- Hardware: Complete ECG front end
Blog
-
openECGproject: 34th Annual Conference of the International Society for Computerized Electrocardiology
Sat 28 of Feb., 2009 18:52 CET -
openECGproject: Two ECG iPhone apps
Sun 15 of Feb., 2009 12:56 CET -
openECGproject: openECGproject featured on TikiWiki
Fri 09 of Jan., 2009 11:14 CET -
openECGproject: Medgadget supports the openECGproject
Wed 10 of Dec., 2008 10:49 CET -
openECGproject: First reactions
Mon 08 of Dec., 2008 09:41 CET -
openECGproject: openECGproject is alive
Wed 03 of Dec., 2008 07:37 CET

