Make your own electrocardiogram machine to measure heartbeats.
|3||100R resistor (R2, R3, R4)|
|1||2.2K resistor (R5)|
|1||10K resistor (R7)|
|1||100K resistor (R1)|
|2||10K potentiometer (RV3, RV1)|
|1||100K potentiometer (RV2)|
|5||100nF capacitor (C2, C4, C6, C7, C8)|
|3||100uF capacitor (C1, C3, C5)|
|6||Diode 1N4148 (D1, D2, D3, D4, D5, D7)|
|1||Diode 1N5817 (D6)|
|1||AD620 instrumentation amplifier (U1)|
|2||LM358 (U2, U4)|
|1||7805 5V regulator (U3)|
The field of medicine has been radically changed thanks to the efforts of scientists and engineers. Scientists help to make new discoveries and develop new cures while engineers turn those discoveries into action. In this DIY Hacking project, we will build an ECG machine that detects heartbeats which can be helpful in medical diagnosis.
WARNING! – THIS DEVICE IS CONNECTED ACROSS THE CHEST THAT CAN POTENTIALLY CAUSE HARM AND/OR DEATH UNDER FAULT CONDITIONS. This circuit should only be operated and built by those who are confident in the functionality of circuits and know what they are doing.
DIY ECG Schematic
How Does the ECG Work?The human heart is a muscle like most others in the human body. Upon receiving an electrical impulse, it will tense up and then relax once that electrical signal is removed. However, unlike most muscles in the human body which rely on nerves from the brain for control signals, the heart contains its own electrical system for controlling the pumping action. When the heart beats, it generates a potential difference which is large enough to be detected by electronics and this is what our circuit detects.
Simply connecting a pair of electrodes across the chest and measuring the difference is not an ideal way for measuring this potential difference. While the signal can be detected, it is commonly superimposed on 60Hz noise thanks to the electrical grid distribution so this needs to be reduced as much as possible. One method for doing this is to use three electrodes instead of two with the third electrode being connected to the left leg and then being connected to the ground plane on our circuit. The second electrode, CHEST1, is then connected to the right side of the chest, and the last electrode, CHEST2, is connected to the left side of the chest. By doing this, we ground most of the body and make the 60Hz signal common to everywhere.
So, with a lot of the noise removed, it's time to detect our heartbeat! The first stage in our circuit is a series resistor and two reversed biased diodes. These parts are there for safety with the resistor acting as a current limiter while the diodes conduct during high voltage spikes and mitigate electric shock against the user. The next stage is the instrumentation amplifier (U1) which takes these two tiny voltages and amplifies them. The amount of amplification depends on the value of RV3 but is it advised that RV3 is configured as to provide a resistance of 2.2KΩ across pins 1 and 8. The amplified signal is then added to an offset voltage of 100mV (potential divider formed by R1 and R5), to provide a small DC offset which improves the LM358 signal detection. This signal is then amplified by U2A which is an adjustable gain amplifier whose gain is controlled by RV1.
This signal will still contain some 60Hz noise and this is further removed by R3 and C1 which form a low pass filter. This filter will pass the heart beat signals very well but not the hum from the mains and so this filter produces a very clean signal. This heartbeat signal is then passed into a comparator (U4A) and a buffer (U4B). The comparator is set to trigger upon a heartbeat which blinks the LED while U4B is used to view the signal on a computer or other circuit (such as an oscilloscope).
ConstructionThis circuit can be built using most (if not all) construction techniques such as PCBs, stripboard, matrix board, and even solderless breadboards. The project here was mounted on a wooden base with some connectors to demonstrate the final circuit board. However, if this was to be used on a regular basis then this circuit would be better mounted in a proper enclosure with exterior connectors. All files needed to produce this project are included as a project zip and include CNC G-Code with auto leveling.
Using an ECGFirst, and most important, POWER THIS CIRCUIT WITH A BATTERY. There are two reasons for this, one being safety, and the other being noise. A battery (such as a 9V) is very unlikely to cause harm due to the small voltage produced which if placed across the chest would not be able to cause issues (however please do not try this). The second reason is to prevent noise from mains power supplies entering the circuit. In this circuit, we are trying to get rid of as much noise as possible, so the last thing we want to do is inject more noise than we already have!
As stated before, you will need to take the three electrodes and place one onto your left leg (thigh if possible), left of the chest, and right of the chest all horizontal to your heart. The left chest electrode connects to CHEST2, and the right electrode connects to CHEST1. Using an oscilloscope, you should probe the output of the instrumentation amplifier to confirm the small heartbeat signal which should be anywhere between 10mV and 5V (yes, the output really can be that much depending on the value of RV3). Adjust RV3 until you get an obvious signal and make sure not to saturate the next amplifier (U2A). At this point, adjust U2A so that a clean signal appears on C1 (the low pass filter). Finally, you can adjust RV2 until you see the LED blink with your heart and if you are lucky, it will pulse on both beats (remember, your heart beats twice per beat). If you have issues getting a signal you may need to swap your chest electrodes around as a negative voltage could be generated instead of a positive one.