Skip to content

Impulse and Frequency Response Analyzer

Copy this iframe to your website:

1
<iframe src="https://dmccreary.github.io/signal-processing/sims/impulse-and-frequency-response-analyzer/main.html" width="100%" height="627px" scrolling="no"></iframe>

Run MicroSim in Fullscreen

Edit in the p5.js Editor

Description

An LTI system can be described in several equivalent ways. This MicroSim shows four of them at once for the same system. The two plots on the left are in the time domain and the two on the right are in the frequency domain:

  • Impulse response \(h(t)\) (top left) is the output for the input \(\delta(t)\).
  • Step response \(s(t) = \int_{-\infty}^{t} h(\tau)\,d\tau\) (bottom left) is the output for the input \(u(t)\). When you select a pulse or a square wave, this plot shows the output \(y(t) = x(t) * h(t)\) and draws the input in grey.
  • Magnitude \(|H(f)|\) in decibels (top right) and phase \(\angle H(f)\) in degrees (bottom right), where \(H(f) = \int_{-\infty}^{\infty} h(t)e^{-j2\pi ft}\,dt\). The frequency axis is logarithmic from 0.1 Hz to 100 Hz.

Use the System menu to choose a Butterworth low-pass filter, a Butterworth high-pass filter, a differentiator, an integrator or a second-order resonant system. The Cutoff slider sets the cutoff frequency \(f_c\) of a filter, the unity-gain frequency \(f_0\) of the differentiator and integrator, or the natural frequency \(f_n\) of the resonant system. The Filter order slider (\(N = 1\) to \(4\)) applies to the filters and the Damping ratio slider (\(\zeta = 0.05\) to \(2\)) applies to the resonant system. Controls the selected system does not use are greyed out. Hover over any plot to move the red cursor and read the values at that time or frequency.

The four views always agree because every curve is computed from the same closed-form expression for the selected system. This simulation supports the section on impulse, step and frequency response in Chapter 3: System Properties and Analysis.

Mathematical Concepts

Every curve is drawn from a closed-form expression for the selected system, with \(\omega_c = 2\pi f_c\):

System Frequency response Impulse response Step response
Low-pass, order 1 \(\dfrac{1}{1 + jf/f_c}\) \(\omega_c e^{-\omega_c t}u(t)\) \((1 - e^{-\omega_c t})u(t)\)
High-pass, order 1 \(\dfrac{jf/f_c}{1 + jf/f_c}\) \(\delta(t) - \omega_c e^{-\omega_c t}u(t)\) \(e^{-\omega_c t}u(t)\)
Differentiator \(jf/f_0\) \(\delta'(t)/(2\pi f_0)\) \(\delta(t)/(2\pi f_0)\)
Integrator \(f_0/(jf)\) \(2\pi f_0\,u(t)\) \(2\pi f_0\,t\,u(t)\)
Resonant \(\dfrac{1}{1 - (f/f_n)^2 + j2\zeta f/f_n}\) decaying sinusoid for \(\zeta < 1\) rises to 1, overshoots for \(\zeta < 1\)

The low-pass and high-pass filters are Butterworth filters of order \(N = 1\) to \(4\). Their magnitude responses are \(1/\sqrt{1 + (f/f_c)^{2N}}\) and \((f/f_c)^N/\sqrt{1 + (f/f_c)^{2N}}\), so the gain is always \(-3\) dB at \(f_c\) and the roll-off is \(20N\) dB per decade. Their impulse and step responses are computed from the filter poles by partial fractions.

Impulses cannot be plotted as ordinary curves, so they are drawn as arrows: a single arrow for \(\delta(t)\) and an up-down pair for the doublet \(\delta'(t)\).

The Input menu replaces the unit step with a 0.5 s rectangular pulse or a 1 Hz square wave of height \(\pm 1\). Both are sums of steps, so by linearity and time-invariance the output is the same sum of shifted step responses. For the pulse, \(y(t) = s(t) - s(t - 0.5)\). This equals the convolution \(y(t) = x(t) * h(t)\).

How to Use

  1. Choose a System and read its four plots.
  2. Hover over either time plot to move the time cursor, and over either frequency plot to move the frequency cursor. The red read-outs above the plots give the values at the cursor.
  3. Move Cutoff, Filter order and Damping ratio. The orange dotted line on the frequency plots marks the cutoff, natural or unity-gain frequency.
  4. Change the Input to see how the same system responds to a pulse or a square wave.
  5. Export h(t) as CSV downloads the regular part of the impulse response and the step response, sampled every 0.01 s from 0 to 2.5 s. Impulses and doublets are described in comment lines at the top of the file.

Lesson Plan

Learning Objectives

After using this MicroSim, students will be able to:

  1. Explain why the impulse response completely characterizes an LTI system.
  2. Relate the step response to the impulse response through integration.
  3. Connect features of \(h(t)\) (decay rate, ringing) to features of \(H(f)\) (cutoff, resonant peak).
  4. Compare how low-pass, high-pass, differentiating, integrating and resonant systems change a signal in time and in frequency.
  5. Predict the response to a pulse or a square wave by superposing shifted step responses.

Target Audience

Undergraduate students in a signals and systems or introductory signal processing course. Plan 20-30 minutes for the activities below.

Prerequisites

  • The unit impulse and unit step functions
  • Convolution and the meaning of an impulse response
  • Complex numbers, magnitude and phase, and decibels

Activities

Activity 1: Exploration (5 min). Select the low-pass filter with order \(N = 1\), \(f_c = 1\) Hz and the unit step input.

  • Put the time cursor near \(t = 0.16\) s, which is the time constant \(\tau = 1/(2\pi f_c) = 0.159\) s. The read-out shows \(s(t) \approx 0.63\).
  • Put the frequency cursor on 1 Hz (the orange line, where it starts). The read-out shows a gain of \(0.707 = -3.0\) dB and a phase of \(-45°\).

Activity 2: Bandwidth and speed (5 min). Keep \(N = 1\) and raise the cutoff from 1 Hz to 4 Hz.

  • The peak of \(h(t)\) is \(2\pi f_c\), so it grows from 6.28 to 25.1, and the impulse response becomes four times narrower.
  • The time constant falls from 0.159 s to 0.040 s, and the 10% to 90% rise time of \(s(t)\) falls from about 0.35 s to about 0.09 s.
  • State the rule: the rise time is about \(0.35/f_c\), so a wider bandwidth means a faster response.

Activity 3: Cost of a sharper cutoff (10 min). Set \(f_c = 1\) Hz and step the filter order from 1 to 4.

  • Hover on the magnitude plot at 10 Hz each time. The gain is \(-20\), \(-40\), \(-60\) and \(-80\) dB.
  • Read the phase at \(f_c\): it is \(-45°\), \(-90°\), \(-135°\) and \(-180°\).
  • Watch \(s(t)\). The step response overshoots by about 4% at \(N = 2\), 8% at \(N = 3\) and 11% at \(N = 4\), and the time to reach 50% grows from 0.11 s to 0.45 s. Describe what a sharper cutoff costs in the time domain.

Activity 4: Ringing and resonance (10 min). Select the resonant system with \(f_n = 1\) Hz and \(\zeta = 0.2\).

  • The magnitude plot has a peak of 8.1 dB near 0.96 Hz, and the step response overshoots by 53%.
  • \(h(t)\) crosses zero at 0.51 s and 1.53 s, so it rings with a period of about 1.02 s, close to \(1/f_n\).
  • Raise \(\zeta\) to 0.7 and then to 1.0. The peak disappears and the overshoot falls to about 5% and then to zero.

Activity 5: Inputs other than a step (5 min). Select the high-pass filter (\(N = 1\), \(f_c = 1\) Hz) with the square-wave input. Explain the output from the gain at low frequencies: the filter blocks the constant part of each half-cycle, so at every edge the output jumps by the same amount as the input (2 units at each edge after the first) and then decays toward 0 with a time constant of 0.16 s.

Assessment

  1. A first-order low-pass filter has \(f_c = 2\) Hz. What is its time constant, and what is \(s(t)\) at that time? (Answer: \(\tau = 1/(2\pi \cdot 2) = 0.080\) s, and \(s(\tau) = 1 - e^{-1} = 0.63\).)
  2. A fourth-order Butterworth low-pass filter has \(f_c = 1\) Hz. What is its gain at 10 Hz? (Answer: \(-80\) dB, because the roll-off is \(20N = 80\) dB per decade above \(f_c\).)
  3. A resonant system has \(f_n = 1\) Hz and \(\zeta = 0.2\). Estimate the height of the resonant peak and the step overshoot. (Answer: about 8.1 dB, which is a gain of about 2.5, and about 53% overshoot. Both come from the same lightly damped poles.)
  4. For the low-pass filter with \(N = 1\) and \(f_c = 1\) Hz, use \(s(t)\) to find the output of the 0.5 s pulse at \(t = 0.5\) s. (Answer: \(y(0.5) = s(0.5) - s(0) = 0.957\), which is the value read from the output plot.)
  5. Why is the impulse response of the differentiator drawn as a pair of arrows? (Answer: \(h(t)\) is the doublet \(\delta'(t)/(2\pi f_0)\), the derivative of an impulse. It is zero everywhere except at \(t = 0\) and cannot be drawn as an ordinary curve.)

Common Misconceptions

  • "The impulse response and the frequency response describe different things." They are the same system seen in two domains. Move the cutoff slider and watch both \(h(t)\) and \(|H(f)|\) change together.
  • "A sharper cutoff is free." Raise the filter order and the step response overshoots and rings, and it reaches 50% later.
  • "A wide bandwidth makes a system respond slowly." The opposite is true. Raise the cutoff and \(h(t)\) narrows and \(s(t)\) rises faster.

References

  1. Impulse response - Wikipedia - definition of the impulse response and its role in characterizing LTI systems
  2. Step response - Wikipedia - the step response as the integral of the impulse response, with rise time and overshoot
  3. Frequency response - Wikipedia - magnitude and phase response and how they relate to the impulse response
  4. Butterworth filter - Wikipedia - the maximally flat filter used for the low-pass and high-pass systems
  5. The Scientist and Engineer's Guide to Digital Signal Processing - Steven W. Smith - free online textbook with chapters on linear systems and convolution
  6. Oppenheim, A. V., Willsky, A. S., & Nawab, S. H. (1997). Signals and Systems (2nd ed.). Prentice Hall. Chapters 2, 4 and 6 cover the impulse response, the Fourier transform, and time and frequency characterization of systems.