PID controller behaves strangely for larger Ts values
Show older comments
I am designing a PID controller for a rudimentary elevator system
The elevator has to take more than 5s to arrive at the next floor but no more than 6s
The transfer function is as follows:
syms Ki Kd Kp s
M = 1019;
B = 100;
K = 19875;
num=[1];
den=[M B K];
G = tf(num, den)
Zeta = 1;
Ts = 5;
Wn = 0.8;
Using the PID function
GC = (Kp*s + Ki + Kd*s^2)/s
The close loop function is found to be:
T = (Kp*s + Ki + Kd*s^2)/(M*s^3 + B*s^2 + K*s + Kp*s + Ki + Kd*s^2)
Comparing this with the ITAE ideal tranfer function for a third order system yields the following equations
ITAE_tf3 = vpa(Wn^3/(s^3 + (Wn)*s^2 + (Wn^2)*s + Wn^3))
Kp = (2.15)*(M)*(Wn^2)-(K)
Ki = M*(Wn^3)
Kd = (1.75)*(M)*(Wn)-B
However the large Kp value drives the system downwards when it should be going up and the large integrator value also causes some issues

Changing zeta and ts gives me a results that is almost what I need
overshoot = 10/100;
Zeta = (-log(overshoot))/sqrt(pi^2+(log(overshoot)^2));
% Zeta = 1
Ts = 2.4;;
Wn = 4/(Zeta*Ts);

But of course the Ts value is too high.
Any help would be greatly appreciated
Answers (1)
Hi @Wynand
There are a few things for which you can find detailed explanations in control theory books. In short, the ideal ITAE third-order transfer function is different from your actual PID-controlled third-order transfer function.
Blunder: Two coefficients are missing in your version of the ITAE third-order transfer function.

While your derived PID-controlled third-order transfer function is correct, to make an apples-to-apples comparison, we must divide both the numerator and the denominator by M.


%% Plant TF
M = 1019;
B = 100;
K = 19875;
num = [1];
den = [M B K];
Gp = tf(num, den)
%% Ideal TF
wn = 3; % Tune this parameter only, DO NOT individually tune P-I-D gains (Always use single parameter tuning!)
Gi = tf(wn^3, [1, 1.781*wn, 2.171*wn^2, wn^3])
figure(1)
step(Gi, 5), grid on
title('Step response of Ideal TF')
%% Pole placement
ki = M*wn^3;
kp = 2.171*M*wn^2 - K;
kd = 1.781*M*wn - B;
Gc = pid(kp, ki, kd)
%% Closed-loop TF
Gcl = minreal(feedback(Gc*Gp, 1))
zero(Gcl) % to be cancelled out later
figure(2)
step(Gcl, 5), grid on
title('Step response of Closed-loop TF')
%% Design of Prefilter, Gf
[num, den] = tfdata(Gcl, 'v');
Gf = tf(den(end), num)
%% Filtered Closed-loop TF
Fcl = minreal(series(Gf, Gcl))
figure(3)
step(Fcl, 5), grid on
title('Step response of Filtered Closed-loop TF')
My preferred control architecture: Simple yet accurate!
%% My PID controller
Ts = 5.5; % Desired Settling Time (single tuning parameter)
[Gc, Gh] = chakpid(Gp, Ts) % Gc in forward path, Gh in feedback path
%% Closed-loop System
Gcl = minreal(feedback(Gc*Gp, Gh))
S = stepinfo(Gcl) % Performances
figure(4)
step(Gcl, round(3*Ts, 0)), grid on, grid minor
%% Double compensation control scheme
function [C, H] = chakpid(P, Ts)
% Gp is a 2nd-order Plant
% Ts is the desired settling time
[numP, denP] = tfdata(minreal(P), 'v');
a1 = denP(2);
a2 = denP(3);
b = numP(3);
Tc = -log(0.02)/Ts; % Desired time constant
%% The formulas
k1 = (3*(b^2)*((Tc/b)^2) - a2)/b;
k2 = (b^2)*((Tc/b)^3);
k3 = (3*b*(Tc/b) - a1)/b;
k4 = 2*b*((Tc/b)^2); % P-gain of PID controller
k5 = k2; % I-gain of PID controller
k6 = Tc/b; % D-gain of PID controller
C = pid(k4, k5, k6); % Classical PID controller
H = minreal(tf([k3 k1 k2], [k6 k4 k5])); % Compensator at the Sensor path
end
Categories
Find more on PID Controller Tuning in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


