# How to write a system to PID

1 view (last 30 days)
Kevin Tran on 17 May 2020
Answered: Nikhil Sonavane on 20 May 2020
Hi guys,
I'm currently in a course in control engineering and still pretty new on the whole subject. I got this system: y''+25y'+25y=u
The problem is I want to make a PID where I can change the parameters Kp, TI and TD. I know how to write the system into matlab with ode45:
[T2,Y2]=ode45(@diffeq2,[0 10],[0;0]);
plot(T2,Y2)
function dy = diffeq2(t,y)
if t < 0
u = 0;
else
u = 1;
end
dy = zeros(2,1);
dy(1) = y(2);
dy(2) = u - 10*y(2) - 25*y(1);
end
but I have no idea how to change the script so I can change the parameters Kp, TI and TD for example to Kp=1 TI=0.1 and TD=0.2 to get a better step response like my professor did. He didn't show how to do it just that with those parameters you will get a better step response and then he showed the graph but no script on how to do it. I have searched everywhere and watched several videos for hours without understanding anything. So my last resort is asking the matlab community for help.
Thanks in advance if you can help me!

Nikhil Sonavane on 20 May 2020
I would suggest you go through the Design and implement PID controllers which has several videos and documents which may help you solve your query.