Introduction: Simulated ECG Signal Acquisition Using LTSpice

The ability of the heart to pump is a function of electrical signals. Clinicians can read these signals on an ECG to diagnose various heart issues. Before the signal can be properly ready by a clinician, though, it must be properly filtered and amplified. In this guide, I will walk you through how to design a circuit to isolate ECG signals by breaking this circuit was broken down into three simple components: an instrumentation amplifier, a band-pass filter, and a notch filter, with desired cut-off frequencies and gains determined by published literature and current models.


This is guide meant for LTSpice simulations, so the only material you will need to model the circuits is an LTSpice application. If you wish to test your circuit with an ECG wav file, I found mine here.

Step 1: Designing a Band-pass Filter

Typical ECG signals have frequency ranges of 0.5-250 Hz. If you're curious about the theory behind this, feel read to read more on this here or here. For the purposes of this guide, what this means is that we want to filter out everything not in those regions. We can do this with a band-pass filter. Based on the posted variables in the posted schematic, band-pass filters filter between ranges of 1/(2*pi*R1*C1) and 1/(2*pi*R2*C2). They also amplify the signal by (R2/R1).

Values were chosen so that the frequency cut off values would match the desired ECG signal bounds and the gain would be equal to 100. A schematic with these values substituted in can be seen in the attached figures.

Step 2: Designing the Notch Filter

Now that we've filtered out everything not in the ECG's signal frequency range, its time to filter out noise distortions within its range. Power-line noise is one of the most common ECG distortions and has a frequency of ~50 Hz. Since this is within band-pass range, it can be taken out with a notch filter. A notch filter works by removing a center frequency with a value of 1/(4*pi*R*C) based on the attached schematic.

A resistor and capacitor value were chosen to filter out 50 Hz noise, and the their values were plugged into an attached schematic. Note that this is not the only combination of RC components that will work; it was just what I chose. Feel free to calculate and choose different ones!

Step 3: Designing the Instrumentation Amplifier

A raw ECG signal will also need to be amplified. Though when we build the circuit, we will put the amplifier first, it's easier conceptually to think about after the filters. This is because the circuit's overall gain is partially determined by the band-pass amplification (See Step 1 for a refresher).

Most ECGs have a gain of at least 100 dB. A circuit's dB gain is equal to 20*log|Vout / Vin|. An Vout/Vin can be solved for in terms of resistive components by nodal analysis. For our circuit, this leads to a new gain expression:

dB Gain = 20*log|(R2/R1)*(1+2*R/RG)|

R1 and R2 are from the band-pass filter (Step 1), and R and RG are components from this amplifier (see attached schematic). Solving for a dB gain of 100 yields R/RG = 500. Values of R = 50k ohms and RG = 100 ohms were selected.

Step 4: Testing the Components

All components were separately tested with LTSpice's AC Sweep octave analysis tool. Parameters of 100 points per octave, 0.01 Hz starting frequency, and 100k Hz ending frequency were selected. I used an input voltage amplitude of 1V, but you can a different amplitude. The important take aways from the AC sweep is the shape of the outputs corresponding to changes in frequencies.

These tests should yield graphs similar to the attached ones in Steps 1-3. If they do no, try recalculating your resistor or capacitor values. It is also possible that your circuit rails because you aren't providing enough voltage to power the op amps. If your R and C math is right, try increasing the amount of voltage you are giving to your op amp(s).

Step 5: Putting It All Together

Now, you're ready to put all the components together. Typically, amplification is performed before filtration, so the instrumentation amplifier was put first. The band-pass filter further amplifies the signal, so it was put second, before the notch filter, which purely filters. The total circuit was run through an AC Sweep simulation as well, which produced expected results with amplification between 0.5 - 250 Hz, except for the 50 Hz notch range.

Step 6: Inputting and Testing ECG Signals

You can change your voltage source to supply the circuit with an ECG signal instead of an AC Sweep. To do this, you will need to download your desired ECG signal. I found a noise-enhanced .wav file here and a clean.txt ECG signal here. but you may be able to find better ones. The raw input and output for .wav file can be seen attached. It is hard to say whether the or not a non-noise enhanced ECG signal would produce a better-looking output. Depending on the signal, you may need to slightly adjust your filter boundaries. The clean-pass signal output can also been seen.

To change the input, select your voltage source, choose the setting for PWL File, and select your desired file. The file I used was a .wav file, so I also needed to change the LTSpice directive text from "PWL File = " to "wavefile = ". For the .txt file input, you should keep the PWL text as is.

Comparing the output to an ideal ECG signal shows that there is still some room for improvement with component-tweaking. However, given the shape and noise-enhanced nature of the source file, the fact that we were able to extract a P-wave, QRS, and T-wave is a great first step. The clean ECG text file should be able to pass through the filter perfectly.

Note be careful how you interpret these ECG input signal results. If you only use the clean .txt file, that does not mean your system works to properly filter a signal -- it only means that the important ECG components are not filtered out. On the other hand, without knowing more about the .wav file, it is hard to way whether or not the wave inversions and odd shapes are due to the source file or if there's an issue in filtering out unwanted signals.

Step 7: