Electronic – Approximating the dirac delta function on LTspice to find the impulse response of a high pass filter

frequency responsehigh pass filterltspice

enter image description here

I have an assignment which requires me to find the impulse response of a high pass filter on LTspice. In order to do this the question suggest feeding a Dirac delta function as an input to a simple high pass filter circuit consisting of 100R resistor and 1uF Capacitor. Now I've tried a triangular pulse and square pulse with a high voltage and minimal rise and fall times but I don't quite get the expectedthe frequency response (the general frequency response of a high pass filter) when I take an FFT of the output voltage.

It would be brilliant if someone could show me the best way to approximate a Dirac delta function on LTspice. Any and all help is appreciated, thanks in advance.

High pass filter with simulation parameters for a square wave input:

enter image description here

enter image description here

Best Answer

The amplitude spectrum of a square pulse input is a sinc-function, and these are the high-frequency lobes that you see in your FFT. Whatever you do, these lobes will always be there. If you make your input pulse too long, these lobes will get in the way of your signal. This basically means that your input signal should be short enough compared to the highest frequency that you wish to capture in your FFT.

The time you simulate will also play an important role on the frequency range of your spectrum. In order to capture down to \$1Hz\$ for example, you will need to simulate at least \$1s\$ of your impulse response.

An lastly, the number of points in your FFT are also important to avoid seeing those artifacts in your FFT. You mainly need to ensure that at least one sampled point is part of your input pulse, and if you make it higher than that you will start to see those lobes at higher frequencies.

The ideal combination would be: $$T_{stop} = 1/f_{min}$$ $$T_{width,input} = 0.5/f_{max}$$ $$N_{fft} = f_{max} / f_{min}$$

Here, \$T_{stop}\$ is the transient simulation time. \$T_{width,input}\$ is the pulse width of the input voltage source. \$N_{fft}\$ is the number of points to use for the FFT.

And finally, there's numerical errors that can also affect your impulse response. Go as strict as you're comfortable with.

For example:

  1. Use an input pulse of \$10\mu s\$ wide and specify \$1ps\$ rise and fall times to ensure that the simulator also truncates the timestep (\$f_{max} = 50kHz\$).
  2. Simulate with a transient simulation from \$0\$ to \$100ms\$ to get an FFT down to \$10Hz\$ (\$f_{min} = 10Hz\$).
  3. Plot the FFT, but only use \$10\ 000\$ points instead of the default \$262\ 000+\$ points to avoid the high-frequency lobes. You can go higher, but keep in mind that these lobes are because of the non-0 pulse width of the input.

If you are unhappy with the results, make the tolerances stricter by going to the configuration under the tab "SPICE". For example:

  • Reltol = 1e-6 (this is the relative tolerance, default is 1e-3)
  • Trtol = 1e-4 (this is the truncation error tolerance factor, default is 1)

[EDIT] There are a few other things you might need to change.

  • LTSpice will smoothen out points by default, but this also messes with your FFT. If you take the FFT, make sure the binomial smoothing is set to 1 (3 is the default).
  • LTSpice uses a modified version of the trapezoidal method, leading to artifacts in the FFT. The regular trapezoidal method may give better results.
  • If you make the total integration time too big, then numerical errors may dominate.

Here's a screenshot of my results (I didn't normalize the input pulse area though, but that's just a scaling factor):

Impulse Response to FFT

Related Topic