Control Systems & Transfer Functions

13 views (last 30 days)
Richard
Richard on 2 Oct 2023
Answered: Gideon on 11 May 2024
I am trying to do multiple things:
  • Examine the stability of the Closed Loop Transfer Function (CLTF)
  • Using Simulink & MATLAB, simulate the system via plotting individual transfer function blocks and the overall CLTF
  • Plot the difference between the output of the simulations against time
My simulink configuration is ODE4 Runge-Katta and my start times are 0.
In essence, my graphs & plots appear as completely unusual to me and I have no reference to see if my simulations are correct. Any help would be greatly appreciated!
Figure of System:
Transfer Function Definitions:
I have attached 'model.slx' which is my Simulink model which should appear as:
MATLAB Editor Code:
% Defining Transfer Functions
Gn = [3 2.4];
Gd = [1 2 3];
Gsys = tf(Gn, Gd); % G(s)
C = [5];
Csys = tf(C, 1); % C(s)
Hn = 0.25;
Hd = [1 25];
Hsys = tf(Hn, Hd); % H(s)
sysCGtf = series(Csys, Gsys);
sysCLTF = feedback(sysCGtf, Hsys);
% Closed Loop Transfer Function (CLTF) Should Look like this:
% C(s)*G(S) + G(S)
% ---------------------------------
% 1 + [C(s)*G(S) + G(s)]*H(s)
B = isstable(sysCLTF); % Stability Check
% Plotting CLTF as a whole:
figure(1)
hold on
plot(step(sysCLTF))
grid on
ylabel('Amplitude')
xlabel('Time')
hold off
% Plotting G(s)
figure(2)
subplot(2, 1, 1)
step(Gsys)
grid on
subplot(2, 1, 2)
step(Hsys)
grid on
% Plotting H(s)
figure(3)
a = sim('model.slx');
b = a.y.data;
c = a.t.data;
plot(c, b);

Accepted Answer

Sam Chak
Sam Chak on 2 Oct 2023
Edited: Sam Chak on 2 Oct 2023
Update: A diagram illustrating the successive reductions of the multi-loop system has been added for clarity.
Below are the results from both MATLAB and Simulink simulations.
% Defining Transfer Functions
G = tf([3 2.4], [1 2 3]) % G(s)
G = 3 s + 2.4 ------------- s^2 + 2 s + 3 Continuous-time transfer function.
C = pid(5) % C(s), proportional control
C = Kp = 5 P-only controller.
H = tf(0.25, [1 25]) % H(s)
H = 0.25 ------ s + 25 Continuous-time transfer function.
Please refer to the diagram depicting the successive reductions of the multi-loop system.
F1 = minreal(feedback(G, H)) % group G and H
F1 = 3 s^2 + 77.4 s + 60 ----------------------------- s^3 + 27 s^2 + 53.75 s + 75.6 Continuous-time transfer function.
F2 = minreal(series(C, F1)) % group C and F1 (after moving the summing point)
F2 = 15 s^2 + 387 s + 300 ----------------------------- s^3 + 27 s^2 + 53.75 s + 75.6 Continuous-time transfer function.
F3 = minreal(feedback(F2, H)) % also equivalent to feedback(C*F1, H)
F3 = 15 s^2 + 387 s + 300 ---------------------------- s^3 + 27 s^2 + 57.5 s + 78.6 Continuous-time transfer function.
F4 = minreal(parallel(1/C, 1)) % becomes parallel after summing point is moved to the left of C(s)
F4 = 1.2 Static gain.
F5 = minreal(series(F4, F3)) % simplified corresponding Closed-loop transfer function
F5 = 18 s^2 + 464.4 s + 360 ---------------------------- s^3 + 27 s^2 + 57.5 s + 78.6 Continuous-time transfer function.
B = isstable(F5) % Stability Check
B = logical
1
MATLAB result
% Plotting CLTF as a whole:
figure(1)
step(F5, 10)
grid on
% Plotting
figure(2)
subplot(2, 1, 1), step(G, 6), grid on, title('Open loop response of Plant, G(s)')
subplot(2, 1, 2), step(H, 6), grid on, title('Open loop response of Sensor, H(s)')
Simulink result
  4 Comments
Sam Chak
Sam Chak on 2 Oct 2023
Hi @Paul,
Originally, F4 and F5 were coded as follows:
F4 = minreal(series (C, F1)); % Y2 = R*F1 (feedforward)
F5 = minreal(parallel(F1, F3)) % combined closed-loop and feedforward
Thank you for pointing out the mistakes. Having an illustration is helpful in reducing the multi-loop block diagram, as it aids in visualizing the reduction process rather than "mentally moving the summing points".
Sam Chak
Sam Chak on 2 Oct 2023
MATLAB's minreal() command can be used to cancel pole-zero pairs in transfer functions. However, the minreal() command should not be used for canceling zeros and poles with positive real parts. Generally, you should check the zeros and poles before using minreal().
% Defining Transfer Functions
G = tf([3 2.4], [1 2 3]); % G(s)
C = pid(5); % C(s), proportional control
H = tf(0.25, [1 25]); % H(s)
F1 = feedback(G, H) % group G and H
F1 = 3 s^2 + 77.4 s + 60 ----------------------------- s^3 + 27 s^2 + 53.75 s + 75.6 Continuous-time transfer function.
F3 = feedback(C*F1, H)
F3 = 15 s^3 + 762 s^2 + 9975 s + 7500 ---------------------------------------- s^4 + 52 s^3 + 732.5 s^2 + 1516 s + 1965 Continuous-time transfer function.
F5 = series(1.2, F3) % corresponding CLTF
F5 = 18 s^3 + 914.4 s^2 + 11970 s + 9000 ---------------------------------------- s^4 + 52 s^3 + 732.5 s^2 + 1516 s + 1965 Continuous-time transfer function.
% checking zeros and poles of the corresponding CLTF
zero(F5)
ans =
-25.0000 + 0.0000i -25.0000 - 0.0000i -0.8000 + 0.0000i
pole(F5)
ans =
-25.0000 + 0.0000i -24.8101 + 0.0000i -1.0950 + 1.4033i -1.0950 - 1.4033i
F6 = minreal(F5)
F6 = 18 s^2 + 464.4 s + 360 ---------------------------- s^3 + 27 s^2 + 57.5 s + 78.6 Continuous-time transfer function.

Sign in to comment.

More Answers (1)

Gideon
Gideon on 11 May 2024
% Defining Transfer Functions
G = tf([3 2.4], [1 2 3]); % G(s)
C = pid(5); % C(s), proportional control
H = tf(0.25, [1 25]); % H(s)
F1 = feedback(G, H) % group G and H
F3 = feedback(C*F1, H)
F5 = series(1.2, F3) % corresponding CLTF
% checking zeros and poles of the corresponding CLTF
zero(F5)
pole(F5)
F6 = minreal(F5)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!