Frequency domain analysis of signals and control systems

Aleksei Tepljakov

Lecture outline

  • Fourier Series and Transform
  • Laplace Transform
  • Frequency Domain Analysis
  • Stability Margins and Robust Control
  • PID Control Case Studies (live demo)

Periodic functions

A function $f(x)$ is called a periodic function with a period $p$, if for all $x$ there holds

\begin{equation} f(x+p) = f(x). \end{equation}

If $f(x)$ has a period $p$, then it also has a period $2p$, $3p$, and so on. In general,

\begin{equation} f(x+np) = f(x), \end{equation}

where $n=1,2,3,\dots$.

In what follows, we will consider the representation of functions $f(x)$ of period $2\pi$.

Fundamental trigonometric functions

The phase difference between $\sin(x)$ and $\cos(x)$ is $\frac{\pi}{2}$ rad.

Fourier series

Suppose that $f(x)$ is a function of period $2\pi$ that can be represented by a convergent series of the form

\begin{multline} f(x) = a_0 + a_1 \cos x + b_1\sin x\\ + a_2 \cos 2x + b_2 \sin 2x + \cdots. \end{multline}

Then, the Fourier series of $f(x)$ is given by

\begin{equation} f(x) = a_0 + \sum_{n=1}^{\infty}(a_n \cos nx + b_n \sin nx), \end{equation}

where $a_0$, $a_n$, and $b_n$ are called the Fourier coefficients.

Fourier coefficients

Assuming $f(x)$ is known, the Fourier coefficients can be computed using the Euler formulas:

\begin{eqnarray} a_0 & = & \frac{1}{2\pi}\int_{-\pi}^{\pi} f(x){\rm d}x,\\ a_n & = & \frac{1}{\pi}\int_{-\pi}^{\pi} f(x) \cos(nx) {\rm d}x,\\ b_n & = & \frac{1}{\pi}\int_{-\pi}^{\pi} f(x) \sin(nx) {\rm d}x, \end{eqnarray}

for $n=1,2,3,\dots$. These coefficients comprise the spectrogram of the studied signal.

Spectrograms for common signals

Importance of Fourier Analysis

  • Every periodic function (or signal) has a corresponding Fourier series representation.
  • Constant signals can be seen as periodic functions with relatively long periods.
  • Therefore, every signal $u(t)$ has a Fourier series representation, that is, every signal can be seen as a combination of fundamental harmonic functions.

Interactive Fourier series demo

Start Square Triangle Sawtooth Pulse

Fourier Transform

  • The general Fourier transform is defined as
    \[ F(k) = \int_{-\infty}^{\infty} f(t) {\rm e}^{-2\pi j k t}{\rm d}t. \]
  • Notice that integration is from $-\infty$ to $\infty$, i.e., we are assumed to have knowledge of $f(t)$ for $t\in(-\infty, \infty)$.
  • In practice, we rarely have this knowledge for signals and operate on a limited time interval (window) of $t\in[t_a, t_b]$.
  • Therefore, we can use Fast Fourier Tranform (FFT) and Discrete Fourier Tranform (DFT) for practical purposes.

Fourier Transform for identification

When the FFT of the input signal $u(t)$ is known, measure the output signal $y(t)$, and process it with FFT. Then, use the difference in input/output signal spectrum to figure out the system model. Above: process identification for PID tuning.

Laplace Transform

  • A function $F(s)$ of the complex variable $s=\sigma + j\omega$ is called the Laplace transform of the original function $f(t)$ and defined as
    \[ F(s)=\int_0^{\infty} {\rm e}^{-s t}f(t){\rm d} t. \]
  • Notice that the definition is similar to Fourier transform, except the limits of integration are now $0\leqslant t < \infty$.
  • It is usual to use the Fourier transform to study signals, and the Laplace transform to study systems.

Differential equations and transfer functions

A linear, continuous-time, single input, single output dynamic system can be expressed by a differential equation

\begin{multline} \def\dif{\mathrm{d}} \def\dft#1{\frac{\dif#1}{\dif t}} \def\dftn#1#2{\frac{\dif^{#2}#1}{\dif t^{#2}}} a_{n}\dftn{y(t)}n+a_{n-1}\dftn{y(t)}{n-1}+\cdots+a_{1}\dftn{y(t)}{}+a_{0}y(t)=\\ b_{m}\dftn{u(t)}m+b_{m-1}\dftn{u(t)}{m-1}+\cdots+b_{1}\dftn{u(t)}{}+b_{0}u(t), \end{multline}

where $a_k,b_k\in\mathbb{R}$.

Applying the Laplace transform to the DE with zero initial conditions we obtain the transfer function representation of the dynamic system

\begin{equation} G(s)=\frac{Y(s)}{U(s)}=\frac{b_{m}s^{m}+b_{m-1}s^{m-1}+\cdots+b_{1}s+b_{0}}{a_{n}s^{n}+a_{n-1}s^{n-1}+\cdots+a_{1}s+a_{0}}.\label{eq:Gs} \end{equation}

Frequency domain analysis

    Recall that for a function $f(x)$ the Fourier series is given by

    \begin{equation} f(x) = a_0 + \sum_{n=1}^{\infty}(a_n \cos nx + b_n \sin nx), \end{equation}

    which means that any signal $u(t)$ can be represented by a Fourier series, i.e., as an infinite sum of weighted harmonic functions.

    Now, consider an input signal $u(t)=U\sin(\omega t)$ passed through an asymptotically stable transfer function $H(s)$ such that

    \[ \stackrel{u(t)}{\longrightarrow}\boxed{H(s)}\stackrel{y(t)}{\longrightarrow} \]

    Steady-state output will be $y(t)=U \left|H(j\omega)\right|\sin\left(\omega t+\angle H(j\omega)\right)$.

Frequency domain analysis (continued)

To construct the magnitude and phase responses of a system represented by a transfer function $G(s)$ with a transport delay $L$, substitute $s=j\omega$. Then, for

\begin{equation} G(j\omega)=\frac{b_{m}(j\omega)^{m}+b_{m-1}(j\omega)^{m-1}+\cdots+b_{1}(j\omega)+b_{0}}{a_{n}(j\omega)^{n}+a_{n-1}(j\omega)^{n-1}+\cdots+a_{1}(j\omega)+a_{0}}{\rm e}^{-L(j\omega)} \end{equation}

at a particular frequency $\omega_k$ we have

\begin{equation} A_{k}=\left|G(j\omega_{k})\right|,\quad\phi_{k}=\arg(G(j\omega_{k}))=\angle G(j\omega_{k}), \end{equation}

where $|\cdot|$ denotes the absolute value, and $\arg(\cdot)$—the argument (or angle, in radians) of the complex value $G(j\omega_k)$.

Recall: polar form of complex numbers

\[ \left|z\right|=r=\sqrt{a^{2}+b^{2}},\quad\arg(z)=\angle z=\theta=\arctan\left(\frac{b}{a}\right). \]

Frequency domain analysis (continued)

Frequency domain characteristics completely describe the behavior of a linear, time-invariant system. Frequency response is graphically represented in the following ways:

  • Bode plot—two separate graphs for magnitude and phase against frequency, usually on logarithmic scales;
  • Nyquist plot—a single graph depicting real vs. imaginary parts of the response covering the full frequency range;
  • Nichols plot—a single graph depicting magnitude vs. argument.

Since it is possible to assess qualitative properties of the linear system under study (e.g., relative stability margins), frequency domain analysis is essential in control design.

Bode plot

  • The Bode plot (named after Hendrik Wade Bode) is a graph of the absolute value $|G(j\omega)|$ and phase shift $\angle G(j\omega)$ of a transfer function $G(s)$ evaluated in $s=j\omega$.
  • The Bode plot shows the system frequency response as a function of frequency $\omega$, for all $\omega>0$.
  • The frequency axis $\omega$ is in logarithmic scale.
  • The absolute value is expressed as decibel (dB):
    \[ |G(j\omega)|_{dB}=20 \log_{10} |G(j\omega)|. \]
  • Unity gain: $|G(j\omega)|=1$ we have $|G(j\omega)|_{dB}=20\log_{10}1=0$ dB.

Bode plot (continued)

Bode frequency analysis

To study the frequency response of a system it is useful to rewrite the transfer function $G(s)$ in Bode form:

\[ G(s) = \frac{K}{s^h} \cdot \frac{\displaystyle \prod_{i=1}^{N}(1+s\tau_i)}{\displaystyle\prod_{j=1}^{M}(1+sT_j)}\cdot\frac{\displaystyle\prod_{i=1}^{P}(1+\frac{2\xi'_i}{\omega'_{ni}}s+\frac{1}{\omega'^2_{ni}}s^2)}{\displaystyle\prod_{j=1}^{Q}(1+\frac{2\xi_j}{\omega_{nj}}s+\frac{1}{\omega^2_{nj}}s^2)}, \]

where $K$ is the Bode gain; $h$ is the type of system, i.e., the number of poles in $s=0$; $T_j$ (for real $T_j>0$) is a time constant; $\xi_j$ is a damping ratio, with $-1<\xi_j<1$; and $\omega_{nj}$ is a natural frequency of the system.

Analysis using Bode form

Nyquist (polar) plot

  • The Nyquist plot (named after Harry Nyquist), also called polar plot, is the graph in polar coordinates of $G(j\omega)$ for $\omega\in[0,+\infty)$ in the complex plane.
  • The Nyquist plot combines the Bode magnitude and phase plot on a single plot and therefore provides a more compact representation.
  • Stability assessment: For an open-loop asymptotically stable system $G(s)$, the closed-loop system $W(s)$ is asymptotically stable if and only if the Nyquist plot $G(j\omega)$ does not encircle clockwise the critical point $-1+j0$.

Example: First-order system

  • The system is described by a transfer function
    \[ G(s)=\frac{1}{1+s}. \]
  • Generate the Bode and Nyquist plots, as well as sine wave and step responses of the system in the time domain.
  • In MATLAB, use bode(sys), nyquist(sys), y=lsim(sys,u,t), and step(sys) functions.

$G_1$: Bode plot

$G_1$: Nyquist plot

$G_1$: Sine wave response ($\omega=1.47$)

$G_1$: Step response

Example: Second-order system

  • The system is described by a transfer function
    \[ G(s)=\frac{1}{1+s+5s^2}. \]
  • Generate the Bode and Nyquist plots, as well as sine wave and step responses of the system in the time domain and compare the results to the first-order system.

$G_2$: Bode plot

$G_2$: Nyquist plot

$G_2$: Sine wave response ($\omega=0.446$)

$G_2$: Step response

Relative stability margins

  • Assume $N(s)=C(s)G(s)$ is open-loop asymptotically stable
    \[ \stackrel{r(t)}{\longrightarrow}\boxed{C(s)}\stackrel{u(t)}{\longrightarrow}\boxed{G(s)}\stackrel{y(t)}{\longrightarrow} \]
  • Let $\omega_c$ be the gain crossover frequency: $|N(j\omega_c)|=1$. The phase margin is the quantity
    \[ \varphi_m = \angle N(j\omega_c)-(-\pi). \]
  • Let $\omega_p$ be the phase crossover frequency: $\angle N(j\omega_p)=-\pi$. The gain margin is the quantity
    \[ G_m = 20 \log_{10} \frac{1}{|N(j\omega_p)|}. \]

Stability margins on Bode plot

Stability margins on Nyquist plot

Robust control

  • The characteristics of real-life systems may change during operation, and frequency characteristics may get shifted from the nominal case potentially causing instability.
  • For robustness of stability, the values of the gain and phase margins should be as large as possible.
  • The phase margin is linked to damping of the system.
  • Gain and phase margins should be chosen such that a balance is achieved between ensuring stability, fast reference tracking, and disturbance rejection.

Example: Negative stability margins

Suppose that the plant to be controlled is described by the transfer function

\[ G(s)=\frac{1}{1+s+5s^2}. \]

A PI controller is used with $K_p=K_i=1$:

\[ C(s)=1+s^{-1}. \]

Let us observe what happens in this case. In MATLAB, we can use the margin(sys) command.

Bode plot of open-loop control system

Closed-loop system: intended operation

When we close the loop, we expect to have

Negative unity feedback introduces a phase lag of $-180^{\circ}$ between the error input $e(t)$ and output $y(t)$. The error converges to zero as the output reaches the reference value $r(t)$.

Closed-loop system: positive feedback

However, the following situation is possible

when the phase lag between error input and output is $-360^{\circ}$. In this case, the output signal is in phase with the error input signal, and, if amplified with gain $K>1$, it grows uncontrollably.

Open-loop system analysis

Open-loop system analysis: magnitude

Certain frequency components of the input signal are amplified with a gain $K>1$. Any transient input signal has these components, even if they have infinitesimally small amplitudes at given frequencies.

Open-loop system analysis: phase

In a closed-loop system, these same frequency components are fed back with a phase shift $\varphi<-360^{\circ}$ which means they effectively contribute to positive feedback. A signal in phase with itself is quickly added up and grows uncontrollably. The system is unstable.

Open-loop system analysis: Nyquist plot

Closed-loop step response

BODEPID tool for MATLAB

  • Can be used to tune PID controllers of the form
    \[ C(s) = K_p + K_i\cdot s^{-1} + K_d\cdot s. \]
    for plants described by linear system models.
  • Shows the impact of frequency domain characteristics on control system behavior.
  • Allows to use Simulink in a semi-automatic way.
  • Source code is available at GitHub: https://github.com/AlekseiTepljakov/bodepid

BODEPID tool for MATLAB: UI

BODEPID tool for MATLAB: UI

BODEPID tool for MATLAB: UI

BODEPID tool for MATLAB: UI

BODEPID tool for MATLAB: UI

BODEPID tool for MATLAB: UI

Case study: Heating furnace

Image source: https://www.secowarwick.com/

Case study: Heating furnace

  • The heating furnace is described by a FOPDT model:
    \[ G(s) = \frac{0.5886}{4801.86s+1}{\rm e}^{-11.2571s},\tag{CS1} \]
    where the input $u(t)$ is power [W], and output $y(t)$ is combined temperature [$^{\circ}$C].
  • The task is to design a robust PI controller for this plant.
  • Solve this task using the BODEPID tool.

Case study: Coupled tanks

Laboratory model of the coupled tanks system

Case study: Coupled tanks

  • The first (left) tank can be modeled using
    \[ G(s) = \frac{2.39515}{1+21.4699s},\tag{CS2} \]
    where the input $u(t)\in[0,1]$ is a normalized voltage input to the pump, and output $y(t)\in [0, 0.28]$ is level of liquid in the tank [m].
  • The task is to design a robust PID controller for this plant.
  • Solve this task using the BODEPID tool.

Case study: Modular servo system

Servo system manufactured by INTECO

Case study: Modular servo system

  • The model of the position servo is given by
    \[ G(s) = \frac{192.1638}{s(1.001s+1)},\tag{CS3} \]
    where the input $u(t)\in[0,1]$ is a normalized voltage input to the DC motor, and output $y(t)$ is the servo position angle [rad].
  • The task is to design a PD controller for this plant.
  • Proposed initial gains $K_p=0.1, K_d=0.01$.
  • Solve this task using the BODEPID tool.

Further reading

  1. K. Ogata, Modern Control Engineering, 5th edition, Prentice Hall, 2009.
  2. E. Kreyszig, Advanced Engineering Mathematics, 10th edition, John Wiley & Sons, 2010.
  3. N. Nise, Control Systems Engineering, 6th edition, John Wiley & Sons, 2011.