Frequency Response
When analyzing linear time-invariant systems (LTI systems) it is often easier to analyze it on the frequency domain. What does this mean? Suppose we apply a sine wave signal into an LTI system, we would get as output another sine wave with the same frequency but with a different amplitude and a different phase angle. Why is this important? In 1807 Joseph Fourier introduced the Fourier series showing that you could write any periodic function as a sum of sine waves with different frequencies, this idea was later extended to non-periodic signals too by the fourier transform so understanding how a system alters the frequency components of a signal can help us understand how the output of a system will relate to it's input.
Definitions
Suppose we have a system that for a sinusoidal input of angular frequency \(\omega = 2\pi f\) that has an amplitude of \(M_i(\omega)\) and a phase angle of \(\phi_i(\omega)\), the output of our signal will be a sinusoidal wave with frequency \(\omega\), an amplitude of \(M_o(\omega)\) and a phase angle of \(\phi_o(\omega)\) as seen on the picture.We define the magnitude of the frequency response as:
\[M(\omega) = \frac{M_o(\omega)}{M_i(\omega)}\]
And we define the phase angle of the frequency response as:
\[\phi(\omega) = \phi_o(\omega) - \phi_i(\omega)\]
With that we can define the frequency response to be the phasor:
\[G(j\omega) = M(\omega) \angle{\phi(\omega)}\]
Where \(j = \sqrt{-1}\).
Those definitions are very helpful for us because it helps us interpret the system as a multiplication by a complex number.
Suppose we have a system with a transfer function of \(G(S)\), to calculate the frequency response to this system one may simply evaluate: \[G(j\omega) = \lim_{s \rightarrow j\omega} G(S)\]
Consider a system with transfer function \(G(S)\) and a signal \(x(t) = A cos(\omega t) + B sin(\omega t)\) and let \(Y(S) = X(S)G(S)\). By calculating \(\mathscr{L}\{x(t)\}\) we get that:\[Y(S) = \frac{As + B\omega}{s^2 + \omega^2} \cdot G(S) = \frac{As + B\omega}{(s + j\omega)(s - j\omega)} \cdot G(S)\]
\[Y(S) = \left(\frac{K_1}{s + j\omega} + \frac{K_2}{s - j\omega}\right) \cdot G(S)\]
We can now work out the partial fractions decomposition by the limit method where:
\[K_1 = \lim_{s \rightarrow -j\omega} \frac{As + B\omega}{s - j\omega} = {1 \over 2}(A + jB)G(-j\omega) = {1 \over 2}M_x e^{-j\phi_x} M_g e^{-j\phi_g}\] \[K_1 = \frac{M_x M_g}{2} e^{-j(\phi_x + \phi_g)}\]
\[K_2 = \lim_{s \rightarrow j\omega} \frac{As + B\omega}{s + j\omega} = {1 \over 2}(A - jB)G(j\omega) = {1 \over 2}M_x e^{j\phi_x} M_g e^{j\phi_g}\] \[K_2 = \frac{M_x M_g}{2} e^{j(\phi_x + \phi_g)} = K_1^*\]
Where \(M_g = |G(j\omega)|\) and \(\phi_g = \angle{G(j\omega)}\).
\[Y(S) = \frac{\frac{M_x M_g}{2} e^{-j(\phi_x + \phi_g)}}{s + j\omega} + \frac{\frac{M_x M_g}{2} e^{j(\phi_x + \phi_g)}}{s - j\omega}\]
By applying the inverse Laplace transform we have that:
\[y(t) = M_x M_g \left( \frac{e^{j(\omega t + \phi_x + \phi_g)} + e^{-j(\omega t + \phi_x + \phi_g)}}{2} \right) = M_x M_g cos(\omega t + \phi_x + \phi_g)\]
Which could as well be written as the phasor multiplication:
\[M_y\angle{\phi_y} = (M_g\angle{\phi_g})(M_x\angle{\phi_x})\]
Since \(M_g\angle{\phi_g}\) is the phasor representation of \(G(j\omega)\) it follows that a system with transfer function \(G(s)\) has a frequency response \(G(j\omega)\).
What is the frequency response of the following RC circuit?
We start by applying Kirchhoff's voltage law, which follows that: \[Ri(t) + {1 \over C}\int i(t) dt = V_{in}(t)\]By applying the Laplace transform: \[I(S)(R + {1 \over {Cs}}) = V_{in}(S)\] \[\frac{I(s)}{V_{in}(s)} = \frac{Cs}{RCs + 1}\]
The current on the capacitor can also be described as: \[i(t) = C{{dv_{out}(t)} \over {dt}}\] \[I(s) = Cs V_{out}(s)\]
So, the transfer function of this system is: \[\frac{Cs V_{out}(s)}{V_{in}(s)} = \frac{Cs}{RCs + 1} \Rightarrow \frac{V_{out}(s)}{V_{in}(s)} = \frac{1}{RCs + 1} = \frac{\frac{1}{RC}}{s + \frac{1}{RC}}\]
So the frequency response is given by: \[G(j\omega) = \frac{\frac{1}{RC}}{j\omega + \frac{1}{RC}}\]
We can also write it as the phasor: \[G(j\omega) = |G(j\omega)| \angle{tg^{-1}\left(\frac{\mathfrak{Im}\{G(j\omega)\}}{\mathfrak{Re}\{G(j\omega)\}}\right)}\]
Bode plot
The Bode plot is a tool that helps us visualize how the system will behave in various frequencies, as well as check for the stability. It is particularly nice because, if it's not possible to model the system, one can still find if a system is stable simply by applying various frequencies at it, measuring the gain and plotting the Bode plot.
The Bode plot is actually composed of two plots, the first being the gain and the second being the phase angle for the frequencies. For the gain, we plot on the y-axis the gain in decibels and on the x-axis, the \(log_{10} ( \omega )\), with \(\omega\) being the angular frequency in \(\frac{rad}{s}\). On the phase plot, we plot the phase angle \(\phi\) in degrees by the angular frequency \(\omega\).
We define the gain \(A\) in decibels to be:
\[A = 20 \cdot log( M(j\omega) )\]
with \(M(j\omega)\) being the magnitude of the frequency response at the frequency \(\omega\).
Let's plot the Bode plot for the system with the transfer function:
\[G(S) = \frac{10S}{S^2 + 2S + 1}\]
Details about how to plot it manually will be shown further ahead, this example will only illustrate the bode plot of the system. We can trace it using python with the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29from scipy import signal import matplotlib.pyplot as plt import numpy as np # Frequencies to calculate response w = np.linspace(1e-2, 1e2, 1000) # Transfer function of the system sys = signal.TransferFunction([10, 0], [1, 2, 1]) # Calculate the bode plot of the system with the frequncies w, mag, phase = signal.bode(sys, w=w) # Plot the gain plt.subplot(2, 1, 1) plt.grid() plt.title("Bode plot") plt.ylabel("Gain [db]") plt.xlabel("Frequncy [rad/s]") plt.semilogx(w, mag) # Plot the angle plt.subplot(2, 1, 2) plt.grid() plt.ylabel("Phase [deg]") plt.xlabel("Frequncy [rad/s]") plt.semilogx(w, phase) # Ajust graph and show it plt.tight_layout() plt.show()
Asymptotic Bode Plot
References
- Krishnavedala, O. Butterworth response. Retrieved from https://en.wikipedia.org/wiki/Frequency_response