Introduction: ECG Collection Circuit
NOTICE: This is not a medical device. This is for educational purposes only using simulated signals. If using this circuit for real ECG measurements, please ensure the circuit and the circuit-to-instrument connections are utilizing proper isolation techniques.
Perhaps the most widespread physiological measurement in today’s healthcare industry is the Electrocardiogram (ECG/EKG). It is hard to walk through a hospital or emergency room without hearing the traditional “beep” of a heart rate monitor or seeing the ECG waveform rolling across the screen in a patient’s room. But, what is this measurement that has become so associated with modern healthcare?
The electrocardiogram is often mistaken for recording the physical activity of the heart, however, as the name suggests it is actually a recording of the electrical activity, the depolarization and repolarization, of the heart’s muscles. By analyzing the recorded waveform, physicians are able to gain insight into the behavior of the heart’s electrical system. Some common diagnoses made from ECG data include: myocardial infarction, pulmonary embolism, arrhythmias, and AV blocks.
The following Instructable will outline the process and principles used to construct a basic electric circuit that is capable of collecting an ECG with the use of simple surface electrodes as is done in hospitals.
Step 1: Design an Instrumentation Amplifier
The first circuit element required to record the ECG signal is an instrumentation amplifier. This amplifier has two effects.
1. It creates an electronic buffer between the recording electrodes and the rest of the circuit. This reduces the required current draw from the electrodes to practically zero. Allowing signal collection with very little distortion caused by input impedance.
2. It differentially amplifies the signal recorded. That means that any signal common in both recording electrodes will not be amplified, while the differences (the important parts) will be.
Typically surface electrode recordings for an ECG will be in the milliVolt range. Therefore, to get this signal into a range we can work with an amplification (K) of 1000 V/V will be appropriate.
The governing equations for the amplifier illustrated above are:
K1 = 1 + 2*R2 / R1, this is the stage 1 gain
K2 = - R4/R3, this is the stage 2 gain
Note that ideally, K1 and K2 should be approximately equal and to achieve the desired amplification K1 * K2 = 1000
The final values used in our circuit were....
R1 = 6.5 kOhm
R2 = 100 kOhm
R3 = 3.17 kOhm
R4 = 100 kOhm
Step 2: Designing a Notch Filter
It is likely in the modern world that the collection of the ECG will be done near some other electronic devices, or even just in a building which is supplied with electricity from local power lines. Unfortunately, the high-voltage and oscillating nature of the power provided means it will produce a great amount of electrical "noise" in practically any conductive material that is near it; this includes the wires and circuit elements used to construct our ECG collection circuit.
To combat this, any signal with a frequency equal to that of the noise generated by local power supply (called mains hum) can simply be filtered out and essentially removed. In the United States, the power grid supplies 110-120V with a frequency of 60 Hz. Therefore, we need to filter out any signal component with a frequency of 60 Hz. Luckily, this has been done many times before and just requires the design of a notch filter (pictured above).
The equations governing this filter are....
R1 = 1 / (2 * Q * w * C)
R2 = (2 * Q) / (w * C)
R3 = (R1 * R2) / (R1 + R2)
Q = w / B
where wc2 is the high cutoff frequency, w2 the low cutoff frequency, w the cutoff frequency in rad/sec, and Q a quality factor
Note that C is a value that can be freely chosen. The following values used in our circuit were:
R1 = 1.65 kOhm
R2 =424.5 kOhm
Q = 8
w = 120 * pi rad/sec
Step 3: Low-Pass Filter
ECG signals have a frequency of around 0 - 150Hz. In order to prevent more noise from coupling onto the signal from things with a higher frequency than this range, a second order low pass ButterWorth filter with a cutoff of 150Hz was implemented in order to only allow the ECG signal to pass through the circuit. Instead of immediately choosing a readily available capacitor value, like the previous components, the first capacitor value, C2, was chosen based on the formula found below. From that value, all other component values could be calculated and then added to the circuit while keeping the gain again to 1V/V.
C2 ≈ 10/fc uf, where fc is the cutoff frequency (150 Hz for this case).
Then, the remaining values can be calculated as shown in the table included as the second image in this step.
Final values used to be placed in the schematic above are:
C2 = 66 nF
C1 = 33 nF
R1 = 22.47 kOhm
R2 = 22.56 kOhm
Step 4: LabVIEW Preparation
The only materials required for this section of the ECG collection is a Windows computer equipped with a 64-bit copy of LabVIEW and a National Instruments Signal Conditioning Board ( ) with a single input module. The functional block diagram within LabVIEW should then be constructed in the following manner. Begin by opening a blank Functional Block Diagram.
Insert a DAQ Assistant block and adjust the settings to the following:
Measurement: Analog→ Voltage
Sampling: Continuous Sampling
Samples Collected: 2500
Sampling Rate: 1000 / sec
Output the collected waveform to a waveform graph. Additionally, calculate the maximum value of the current waveform data. Multiply the maximum value of the wave by a value such as .8 to create a threshold for peak detection, this value can be adjusted based on the noise level within the signal. Feed in the product of the previous step as the threshold and the raw voltage array as the data for the “Peak Detection” function. Next, take the “Location” output of the peak detection array and subtract the first and second values. This represents the difference in index values of the two peaks in the initial array. This can then be converted into a time difference by dividing the value by the sample rate, for the example case this is 1000 /sec. Finally, take the inverse of this value (giving Hz) and multiply by 60 to obtain the heart rate in beats per minute BPM. The final block diagram for this should resemble the header picture for this step.
Step 5: Full-System Integration
Now that all components have been constructed individually, it is time to put the mall together. This can be done by simply wiring the output of one section to the input of the following segment. The stages should be wired in the same order that they appear in this Instructable. For the last stage, the ButterWorth filter, its input should be attached to one of the two leads on the input module of the signal conditioning board. The other lead from this module should be attached to the circuits common ground.
For the instrumentation amplifier, its two leads should each be attached to an ECG/EKG electrode. This is easily done with the use of two alligator clips. Then, place one electrode on each wrist. Ensure all segments of the circuit are connected and that the LabVIEW VI is running and the system should be outputting a waveform graph in the LabVIEW window.
The output should look similar to the second image provided in this step. If it is not similar, the values of your circuit may need to be adjusted. One common issues is that the notch filter will not be centered directly at 60 Hz and may be slightly to high/low. This can be tested by creating a bode plot for the filter. Ideally, the notch filter will have at least 20 dB attenuation at 60 Hz. It also might be useful to check that your local power is supplied at 60 Hz. It is not uncommon for some areas to have 50 Hz AC supplies, this would necessitate centering the notch filter around this value.
We have a be nice policy.
Please be positive and constructive.