Introduction: Simulated ECG Circuit

An electrocardiogram is a common test used in both standard examinations and diagnoses of serious diseases. This device, known as an ECG, measures the electrical signals within the body responsible for regulating the heartbeat. The test is administered by applying electrodes to the subject's skin and observing the output, which takes the form of the known ECG waveform shown. This waveform contains a P wave, QRS complex, and T wave that each represent a physiological response. This guide will go through the steps of simulating an ECG in a circuit simulation software.


  • LTSpice or similar circuit simulator

Step 1: Build an Instrumentation Amplifier

The purpose of an instrumentation amplifier is to amplify a very small signal that is often surrounded by high levels of noise. The voltage of the input signal into an EMG is typically between 1 mV to 5 mV and the purpose of this stage is to amplify that signal with a gain of approximately 1000. Shown in the schematic, the gain can be controlled by the following equation where R1 = R2, R4 = R5, and R6 = R7:

Gain = K1*K2, where K1 = K2

K1 = 1 + (2R1/R3)

K2 = -R6/R4

The gain therefore was set equal to 1000, so K1 and K2 are approximately 31.6. Some resistors may be chosen arbitrarily and others calculated, as long as the gain equation is satisfied to equal 1000. In a physical circuit, the electrodes would go into the operational amplifiers, but for simulation purposes one is grounded and the other is used to signify the potential difference. The Vin node will be used to later simulate input waves. The Vout node leads to the next stage of the ECG. A LTC1151 operational amplifier was chosen as it is located in the LTSpice library, has a high CMRR, and has been used in medical instrumentation. Any basic operational amplifier with supply voltage of +15V and -15V would work in this system.

Step 2: Build a Notch Filter

The next stage in the ECG is a notch filter to filter out power line interference that occurs at a frequency of 60 Hz. A notch filter works by removing a small range of signals that occur at very close to a singular frequency. Therefore, by using a cutoff frequency of 60 Hz and the cutoff frequency equation, appropriate resistors and capacitors can be chosen. Using the schematic above and noting that C = C1 = C2, C3 = 2*C1, R = R10, and R8 = R9 = 2*R10, capacitor values can be arbitrarily chosen (The example shows a 1uF capacitor chosen). Using the following equation, appropriate resistor values can be calculated and used in this stage:

fc = 1/(4*pi*R*C)

The Vin node is the output from the instrumentation amplifier and the Vout node leads to the next stage.

Step 3: Build a Bandpass Filter

The last stage of the system consists of an active bandpass filter to remove noise above and below a certain range of frequencies. Baseline wander, caused by the baseline of the signal varying with time, occurs below 0.6 Hz and EMG noise, caused by the presence of muscle noise, occurs at frequencies above 100 Hz. Therefore, these numbers are set as the cutoff frequencies. The bandpass filter consists of a low pass filter followed by a high pass filter. However, both filters have the same cutoff frequency:

Fc = 1/(2*pi*R*C)

Using 1uF as an arbitrary capacitor value, and 0.6 and 100 as the cutoff frequencies, the resistor values were calculated for the appropriate portions of the filter. The Vin node comes from the output of the notch filter and the Vout node is where the simulated output of the full system will be measured. In a physical system, this output would connect to an oscilloscope or similar display device to view the ECG waves in real time.

Step 4: Test the Instrumentation Amplifier

Next, the instrumentation amplifier will be tested to ensure that it does provide a gain of 1000. To do this, input a sinusoidal wave at an arbitrary frequency and amplitude. This example used a 2mV peak to peak amplitude to represent an EMG wave and a frequency of 1000 Hz. Simulate the instrumentation amplifier in the circuit simulation software and plot the input and output waveforms. Using a cursor function, record the input and output magnitudes, and calculate the gain by Gain = Vout/Vin. If this gain is approximately 1000, this stage is working properly. Additional statistical analysis can be performed on this stage by taking into consideration resistor tolerances and modifying resistor values by +5% and -5% to see how it affects the output wave and subsequent gain.

Step 5: Test the Notch Filter

Test the notch filter by performing an AC sweep from a range that contains 60 Hz. In this example, the sweep was ran from 1 Hz to 200 Hz. The resulting plot, when measured at the Vout node, will output a graph of amplification in dB vs. frequency in Hz. The graph should begin and end at a 0 dB amplification at frequencies far from 60 Hz in both directions and a large drop in amplification should appear at or very close to 60 Hz. This shows that signals that occur at this frequency are being properly removed from the desired signal. Additional statistical analysis can be performed on this stage by taking into consideration resistor tolerances and modifying resistor and capacitor values by +5% and -5% to see how it affects the experimental cutoff frequency (the frequency that experiences the most attenuation graphically).

Step 6: Test the Bandpass Filter

Lastly, test the bandpass filter by performing another AC sweep analysis. This time, the sweep should be from a frequency less than 0.6 and greater than 100 to ensure the bandpass can be seen graphically. Once again, run the analysis by measuring at the Vout node shown in the schematic. The output should look like the figure above where the amplification is negative the farther from the 0.6-100Hz range. The points at which the amplification is -3dB should be 0.6 and 100 Hz, or values very close to those for the first and second points, respectively. The -3dB points signify when a signal is attenuated to the point where the output at these frequencies will be half of the original power. Therefore, the -3dB points are used to analyze attenuation of signals for filters. If the -3dB points on the outputted graph match the bandpass range, the stage is working properly.

Additional statistical analysis can be performed on this stage by taking into consideration resistor tolerances and modifying resistor and capacitor values by +5% and -5% to see how it affects both experimental cutoff frequencies.

Step 7: Put Together the Full ECG System

Finally, when all three stages are confirmed to be working properly, place all three stages of the ECG together and the final result is done. A simulated ECG wave can be inputted into the instrumentation amplifier stage and the outputted wave should be an amplified ECG wave.