Tuning PI, PD, PID controller

4 views (last 30 days)
Dragana Krstevska
Dragana Krstevska on 15 May 2020
Answered: Sam Chak on 7 Sep 2022
Hi guys,
I'm using pidtune and pidtool for tuning the controllers, but even if I put all three constants (Kd, Ki, Kp) it tunes the controller as if it's a p controller. Will post the code bellow, also the return message as a pic. Please help <3.
Kp=290;
Ki=500;
Kd=46;
num1=[Kd Kp Ki];
den1=[1 0];
W=tf(num1,den1);
num2=[1];
den2=[1 10 20];
G=tf(num2,den2);
A=series(W,G);
sys=feedback(A,1);
t=0:0.01:2;
y=step(sys,t);
plot(t,y);
grid on;
pidtune(G,'pi')
pidtool(G,'pid');

Answers (1)

Sam Chak
Sam Chak on 7 Sep 2022
Not sure what happened. But it works for both auto and manual tuning.
% Plant
Gp = tf(1, [1 10 20])
Gp = 1 --------------- s^2 + 10 s + 20 Continuous-time transfer function.
% PID (Auto)
Gc1 = pidtune(Gp, 'PID')
Gc1 = 1 Kp + Ki * --- + Kd * s s with Kp = 39.3, Ki = 116, Kd = 3.33 Continuous-time PID controller in parallel form.
Gcl1 = feedback(Gc1*Gp, 1);
% PIDF (Manual)
kp = 32.94;
ki = 86.88;
kd = 0.3632;
Tf = 0.1208;
Gc = pid(kp, ki, kd, Tf)
Gc = 1 s Kp + Ki * --- + Kd * -------- s Tf*s+1 with Kp = 32.9, Ki = 86.9, Kd = 0.363, Tf = 0.121 Continuous-time PIDF controller in parallel form.
Gcl2= feedback(Gc*Gp, 1);
% Step responses
step(Gcl1, 2), hold on
step(Gcl2, 2), grid on
legend('PID', 'PIDF')

Tags

Community Treasure Hunt

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

Start Hunting!