None Notebook

This notebook contains material from CBE30338; content is available on Github.

< 5.2 Closed-Loop Transfer Functions for Car Cruise Control | Contents | Tag Index | 5.4 Controller Tuning Rules in Frequency Domain >

Open in Colab

Download

5.3 Creating Bode Plots

This notebook demonstrate uss of the Python Control Systems Library to create and annotate Bode plots. Documentation of the control systems library is available here.

5.3.1 Initializations

These are the standard initializations with the Python Control Systems Library.

The control library is imported with full prefix control. This is good practice to avoid name conflicts with other libraries.

The control library has a bug where it continues to make use of the deprecated hold command from matplotlib. This results in warnings being issued. Use the warnings library to turn off these distracting warnings.

5.3.2 Creating Bode Plots

5.3.2.1 Specify a Transfer Function

Given a transfer function with time delay

$$G(s) = 0.2 \frac{0.5s + 1}{1.5s^2 + 0.5 s + 1}$$

the first task to create an object representing the transfer function.

5.3.2.2 Adding Time Delay

Time delay is a common feature of process control applications. The current version of the Python Control Systems Library does not provide a specific representation for time delay. However, the library does provide a function pade to create high-order Pade approximations to time delay.

$$G_p(s) = e^{-0.25s} G(s)$$

Here we add a third order pade approximation for a time delay of 0.25 time units.

5.3.2.3 Bode Plot using Default Options

Function control.bode() returns values of the magnitude ratio, phase lag, and frequency (in rad/time) for a given transfer function. It also creates a bode plot as a side effect.

5.3.2.4 Specify Frequency Range

The default frequency range created by bode is often too wide. Use numpy.logspace() to Fortunately, it is possible to specify a desired set of frequencies at which to evaluate the Bode plot. The frequencies are always specified in radians per unit time.

5.3.2.5 Setting Other Plotting Options

Bode plots can be customized with several key options as demonstrated in this cell. Note that setting Hz = True only changes the x-axis of the resulting bode plot, both input and output frequencies are still specified in radians per unit time.

5.3.3 Adding Features to the Bode Plot

In addition to creating plots, the bode function returns numpy arrays containing the magnitude, phase, and frequency.

5.3.3.1 Crossover Frequency and Gain at Crossover

This data can be used to annotate or add features to a Bode plot. The following cell interpolates the phase data to find the crossover frequency, then interpolates the magnitude data to find the gain at crossover.

< 5.2 Closed-Loop Transfer Functions for Car Cruise Control | Contents | Tag Index | 5.4 Controller Tuning Rules in Frequency Domain >

Open in Colab

Download