Engee documentation
Notebook

Analysing the response of the RLC circuit

This example shows how to analyse the time and frequency response of RLC circuits as a function of their physical parameters using ControlSystems.jl functions.

Before you start, connect the package ControlSystems.jl.

In [ ]:
import Pkg
Pkg.add("ControlSystems")
In [ ]:
using ControlSystems
s = tf('s')

RLC bandwidth network

The following figure shows the parallel form of a strip RLC circuit.

image.png

The transfer function from input to output voltage is equal to:

$$ G(s) = { s / (RC) \over s^2 + s/(RC) + 1/(LC) } $$

The $LC$ controls the bandwidth and $RC$ controls the degree of bandwidth narrowing. To create a bandpass filter tuned to 1 rad/s, set $L=C=1$ and use $R$ to adjust the filter bandwidth.

To analyse the frequency response of the system

The Bode plot is a convenient tool for investigating the bandwidth characteristics of an RLC network. Use tf, to specify the transfer function of the circuit for the values $R=L=C=1$.

In [ ]:
R = 1; L = 1; C = 1;
G = tf([1/(R*C), 0],[1, 1/(R*C), 1/(L*C)])
Out[0]:
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
       1.0s
-------------------
1.0s^2 + 1.0s + 1.0

Continuous-time transfer function model
In [ ]:
bodeplot(G)
Out[0]:

As expected, the RLC filter has maximum gain at 1 rad/s. However, the attenuation is only -10 dB half a decade below this frequency. To get a narrower bandwidth, try increasing the value of $R$ as follows.

In [ ]:
R1 = 5;
G1 = tf([1/(R1*C), 0],[1, 1/(R1*C), 1/(L*C)]);
R2 = 20;
G2 = tf([1/(R2*C), 0],[1, 1/(R2*C), 1/(L*C)]);

bodeplot([G, G1, G2], lab = ["R = 1" "R = 5" "R = 20"])
Out[0]:

A resistor value of R=20 provides a narrow filter tuning around the target frequency of 1 rad/s.

Analysing the time response of the circuit

We can confirm the attenuation properties of the G2 circuit ($R=20$) by modelling how this filter converts sine waves at 0.9, 1 and 1.1 rad/s.

In [ ]:
t = 0:0.05:250;

lp1 = lsim(G2,sin.(t)',t)
lp2 = lsim(G2,sin.(0.9*t)',t)
lp3 = lsim(G2,sin.(1.1*t)',t)
plot(
    plot(lp1, title = "w = 1"),
    plot(lp2, title = "w = 0.9"),
    plot(lp3, title = "w = 1.1"),
    layout = (3,1)
)
Out[0]:

The 0.9 and 1.1 rad/s waves are significantly attenuated. The 1 rad/s wave remains unchanged after transient attenuation. The long transient is due to poorly damped filter poles, which are unfortunately necessary for the narrow bandwidth.

In [ ]:
dampreport(G2)
|        Pole        |   Damping     |   Frequency   |   Frequency   | Time Constant |
|                    |    Ratio      |   (rad/sec)   |     (Hz)      |     (sec)     |
+--------------------+---------------+---------------+---------------+---------------+
| -0.025  ±      1im |  0.025        |  1            |  0.159        |  40           |

Conclusion

Thus, we have looked at which functions can be used to analyse the time and frequency characteristics of RLC circuits.