Typical Open Loop Bode Diagram for Control Systems. C Code and Octave Script
1. Abbreviation
2. Introduction
Most linear control systems can be represented in the following form:
Figure 2-1: Analog Control System
Then the open-loop transfer function of the control system:
Transfer function for closed-loop control system:
Obviously the control error is for a closed control system:
A few important notes and formulas:
-
It is convenient to evaluate the quality of the linear system by applying the following test signals to the input:
-
To calculate the steady state values of the transient process, we will use the well-known formula:
-
The stability reserves will be estimated by the phase at the cross frequency:
or logarithmic scale (in dB):
Phase shift:
At this frequency there is a ballance of amplitudes in the feedback and if the phase reaches φ = -180 ° degrees, then this will lead to undamped oscillations in the control system with a frequency of ω_crosss.
To ensure an acceptable transition process, it is necessary to have a phase margin at least 58 ° degrees at the cross frequency. See the table:
Table 2-1: Step Response Overshoot for the Difference Phase Margin (from the [1]) -
Integrator:
Then from (18) get the adjustment error:
Now we will send a linear signal (16) to the input of the control system with an integrator
In this case there is a control error and it decreases if the Kv is increased.
Conclusion:
Thus the control error for the static signal (step response) is zero if there is an integrator. Similarly it can be proved that if two integrators 1/s^2 are used, then the static (step response) and speed (linear response) control error is zero. And if there are three integrators 1/s^3, then the static (step response), speed (linear response) and acceleration (parabola response) control error is zero. In the last two cases (using two or three integrators) it is difficult to design a stable control system. -
Then I will use the magnitude and phase on the Bode graph. These graphs are plotted on a logarithmic scale. For example, let’s take a transfer function with one pole:
Substituting s=jω in (26):Turning to the logarithmic scale:
Figure 2-2 shows an example of a Bode Diagram:Figure 2-2: Bode Diagram for One Pole Transform Function (40)
Conclusions:
-
Pole: Magnitude Response has the -20 dB/decade (or -6dB/octave) and -3dB in pole frequency.
Phase Response has the -45° for ω = ω_pole and -90° for ω >> ω_pole -
Zero: Magnitude Response has the +20 dB/decade (or +6dB/octave) and +3dB in pole frequency.
Phase Response has the +45° for ω = ω_zero and +90° for ω >> ω_zeroTransform function example with zero:
3. The First Type of the Bode Diagram for Control System
The first type of characteristic is used most often and has the form:
This transfer function has an integrator and a pole that is selected near the cross frequency:
The phase at the cross frequency (≈ pole) will be:
Phase Margin:
This leads to an outlier (overshoot), see the Table 2-1:
Take as an example:
Figure 3-1: Bode Diagram for the (48)
Figure 3-2: Step Response for the (48)
The speed error (linear response) is calculated by the formula (25) at v=10:
Figure 3-3: Linear (Speed) Response for the (48)
Figure 3-4: Parabola (Acceleration) Response for the (48)
To reduce overshoot: 1.23, it is necessary to increase the phase margin at the cross frequency => to decrease Kv. For example adjust the transfer function:
The cross frequency is 60Rad/s and the phase margin in this case is 58°(see Table 2-1), which corresponds to overshoot:
On the Figure 3-5 Step Response for (50):
Figure 3-5: StepResponse for the (50)
With a decrease in Kv, the error in speed (linear response) and acceleration (parabola response) increases. Speed error for (50) and for v=10:
4. The Second Type of the Bode Diagram for Control System
The second type of characteristic has the form:
The cross frequency is selected so that:
in this case the maximum phase correction from zero at the cross frequency is obtained.
[1] recommends choosing:
Substitute (58) in (59):
You need to choose Kv using the formula (60) varying ω1:
The phase at the cross frequency is calculated by the formula:
Then the margin by phase:
Note:
Thus we obtain a phase margin ≥ 53 °.
Consider an example:
To design a control system with a characteristic of the second type with the following parameters:
System Requirement
Gain:
Frequency band of the control system:
Design
Then from (59):
From (60):
Finally:
Phase margin:
Figure 4-1: Bode Diagram for the (62)
The phase margin is 59°, and the overshoot is 1.16 (see the Figure 4-2), which exceeds the data of Table 2-1. This is due to the fact that (62) has zero, and in this case large phase reserves are required at the cross frequency. To reduce the overshoot we need to increase ω1 and thereby to decrease the Kv.
Figure 4-2: Step Response for the (62)
The speed error (linear response) is calculated by the formula (25) at v=10:
The error is much smaller than for the Type 1 characteristic. Compare Figure 4-3, Figure 3-3, as well as Figure 4-4, Figure 3-4.
Figure 4-3: Linear (Speed) Response for the (62)
Figure 4-4: Parabola (Acceleration) Response for the (62)
5. Digital Realization of the Regulator
Let there be a control object (plant) described by a transfer function:
The task is to implement a control system that provides a characteristic (62) for controlling the object (64). To do this we need to implement a controller of the form:
An additional zero
is added to the regulator to compensate for the pole of the object.
Now let’s choose the sampling frequency based on the allowable uncertainty of the phase at the cross frequency.
Let’s choose the uncertainty in phase 2° at the cross frequency. Then:
The digital regulator is shown in Figure 5-1:
Figure 5-1: Digital Control System
The object (plant) is controlled by the signal of the controller u(nTs), which is fed to the Digital to Analog Converter (DAC). The DAC transfer function is approximated as Zero Order Hold. See the [2]. The signal y(t) – the measured value from the output of the object, passing through the Analog to Digital Converter (DAC) is converted back to digital form. The measured value of y(nTs) is compared with the required value of x(nTs) and then fed to the input of the digital controller.
Convert the regulator (66) to digital form using a bilinear transformation (6):
To simulate the operation of a digital controller, we will also convert the analog part of the control system into digital form:
The system’s response to the step signal is shown in Figure 5-2. The overshoot is 4% worse than that of the analog prototype (compare with the Figure 4-2). This is caused by the sampling of the signal, which in our case leads to 2° uncertainty in phase at the cross frequency.
Figure 5-2: Step Response for the (69), (70), (71)
6. Conclusions
-
The Type 1 of the characteristic is simple and is most often used in applications. There is no static error, but there is a speed and acceleration error. In such systems it is difficult to obtain large Kv values and therefore reduce the speed and acceleration control error.
-
The Type 2 of the characteristic is more difficult to ensure the stability of the system, but at the same time it is possible to obtain large Kv values, which reduces speed and acceleration control errors. Here it is possible to reduce the speed error to zero.
-
Both characteristics use an integrator, which means that it is necessary to use Antiwindup methods. In the examples this implementation is not given, but it should be implemented in real control systems.
7. Octave GNU file OpenLoopMagnitudePhaseRespTypes.m
The m script generates magnitude, phase and step responses of the Bode Diagrams for types 1 and 2, test signals and checks the analog/digital control systems. To do this, the following functions are defined in this file:
% Plotting the Step Response of the Analog Filter: (…+b1*s^2+b2*s+b3)/(…+a1*s^2+a2*s+a3)
% Input parameters:
% SB — numerator
% SA — denominator
% TimeVector – Time space
function plot_StepResponseAnalogFilter(sys, TimeVector, Text)
% Plotting the Step Response for the Digital Filter: (b1+b2*z^-1+b3*z^-2+…)/(a1+a2*z^-1+a3*z^-2+…)
% Input parameters:
% ZB — numerator
% ZA — denominator
% SampleNumber – Sample number of the step function
function plot_StepResponseDigitalFilter(ZB, ZA, SampleNumber, Text)
% Digital Close Loop: Regulator and Object
% Input parameters:
% ZB_Regulator — numerator
% ZA_Regulator — denominator
% ZB_Object — numerator
% ZA_Object — denominator
% x_input – input signal
function [y_output] = DigitalCloseLoopRegulatorObject(ZB_Regulator, ZA_Regulator, ZB_Object, ZA_Object, x_input)
% Float Table to File
% Support C-Code
% Input parameters:
% ParameterVector – data array
% FileNameString – output file name
function FloatParamVector2file(ParameterVector, FileNameString)
8. C Language BodeDiagramType2.c/h
The demo SW is realized the digital regulator of the Bode Diagram Type2. See the files BodeDiagramType2.c/h
Functions:
/*
Control System Initialization
Clear the working arrays
Input: void
Return: void
*/
void ControlSystemInit(void)
/*
IIR Filter with Transposed Form II
Input
float input – filter input
float const* all_coef_ptr – filter coefficients
float* all_history_ptr – filter history
uint8 sos_nmb – second order section number
Return
float – filter output
*/
float iir_filter(float input, float const* all_coef_ptr, float* all_history_ptr, uint8 sos_nmb)
/*
Regulator
Input
float delta – (require – measurement) value
Return
float – control value
*/
float Regulator(float delta)
9. Download the OpenLoopMagnitudePhaseRespTypes.m and BodeDiagramType2.c/h
You can download the files:
OpenLoopMagnitudePhaseRespTypes.m
BodeDiagramType2.c
BodeDiagramType2.h
with the button:
10. Literature / References
[1] E. Krogius “Radio Automation Course of Lectures“, LEIC, 1981
[2] R. Dorf, R. Bishop “Modern Control System”, Eddison-Wesley, ISBN: 0-201-30864-9, 1998