First order PID controller

72 次查看(过去 30 天)
John Rogers
John Rogers 2021-4-6
Hi,
I am having a bit of bother with a PID controller I am creating on MATLAB. I have the below transfer function for my system, which i've to incorporate a PID controller into.
clc
clear all
% Implementing T.F G(s) = 85/(42s+1)
num = [85]; %Numerator of Transfer function (DC Gain k)
den = [42 1]; %Denominator of Transfer function (Time constant tau +1)
Gs = tf([num],[den],'InputDelay',10) %a transfer function with a lag tim); %transfer function
u = 1; %unit step input
% plotting the graph
figure(1)
[x,y]=step(u*Gs);
plot(y,x);
xlabel('time /s'); ylabel('Level');
I have tried using the below code for the PID controller, which doesn't seem to have the same times. Also on all controllers i've done the step response never got to 1 without tuning before.
% Implementing T.F G(s) = 85/(42s+1)
num = [85]; %Numerator of Transfer function (DC Gain k)
den = [42 1]; %Denominator of Transfer function (Time constant tau +1)
Gs= tf(num,den); %TF function
H=[1]; %feedback
M=feedback(Gs,H);
step(M)
grid on
When I add the PID controller script I no longer get anything I expect. I set Kp to 2, which does quicken the response, however I expect some overshoot. I have increased Kp bu different higher values and it only provides quicker respnses without overshoot. This is not how any of my other controllers have operated.
%%
Kp = 2;
Ki = 0;
Kd = 0;
Gc=pid(Kp,Ki,Kd)
Mc=feedback(Gc*Gs,H)
step(Mc)
grid on
I know I am doing something wrong, but can't see what. Is there anyone that can look this over and assist? I am using Matlab online as I do not have permission to download additional content on my laptop as IT won't allow it. You may have also noticed that there is no delay added to the scripts. This is due to it not working if I do.

回答(3 个)

Steven Caliari
Steven Caliari 2021-4-6
Hi,
your system is a first-order system. If you want see an overshoot use a second-order system.
First order system doesn't have overshoot.
Try with: den = [10 42 1];
num = [85]; %Numerator of Transfer function (DC Gain k)
den = [10 42 1]; %Denominator of Transfer function (Time constant tau +1)
Gs= tf(num,den); %TF function
H=[1]; %feedback
M=feedback(Gs,H);
step(M)
grid on
  3 个评论
Steven Caliari
Steven Caliari 2021-4-6
Hi John,
the oscillation appear into the system when the poles are immaginary.
If you change only Kp and Ki=Kd=0, you are moving the pole on real axis, so the oscilltion can never appear.
Plot with Kp = 2, Kd=Ki=0
When you change Ki (example with Ki = 3):
Now the system has damped oscillation.
System evolution:
John Rogers
John Rogers 2021-4-8
Thanks Steven, it has taken me a while to get my head around this, but you were a great help.

请先登录,再进行评论。


Sam Chak
Sam Chak 2022-8-20
Just some additional info. The plant is a 1st-order Type-0 system.
num = [85];
den = [42 1];
Gp = minreal(tf(num, den))
Gp = 2.024 ----------- s + 0.02381 Continuous-time transfer function.
Adding an Integral action raises the system to become a Type-1 system.
Kp = 43239/42500;
Ki = 2059/85000;
Gc = pid(Kp, Ki)
Gc = 1 Kp + Ki * --- s with Kp = 1.02, Ki = 0.0242 Continuous-time PI controller in parallel form.
The step response will achieve at steady-state.
Gcl = minreal(feedback(Gc*Gp, 1))
Gcl = 2.059 --------- s + 2.059 Continuous-time transfer function.
step(Gcl), grid on
Sc = stepinfo(Gcl)
Sc = struct with fields:
RiseTime: 1.0670 TransientTime: 1.9000 SettlingTime: 1.9000 SettlingMin: 0.9045 SettlingMax: 1.0000 Overshoot: 0 Undershoot: 0 Peak: 1.0000 PeakTime: 5.1218

venkatesan T
venkatesan T 2024-8-8
MATLAB code required for the given problem.
Consider a unity feedback system with open loop transfer function, G(s)=100/(s+1)(s+2)(s+3). Determine a PID controller, so that the phase margin of the system is 45 degree at a frequency of 4 rad/sec and the steady state error for unit ramp input is 0.1

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by