Sei sulla pagina 1di 3

PID Controller:

MATLAB Code
1. 2.
>> %Example of PID controller >> %Example of PID controller
>> clear all; >> clear all;
>> num=[1]; >> num=[1];
>> den=[2 2 1]; >> den=[2 2 1];
>> sys=tf(num,den); >> sys=tf(num,den);
>> H=1; >> H=1;
>> Gs=feedback(sys,H); >> Gs=feedback(sys,H);
>> step(Gs) >> step(Gs)
>> hold on; >> hold on;
>> grid on; >> grid on;
>> Kp=1; >> Kp=12;
>> Kd=0; >> Kd=10;
>> Ki=0; >> Ki=5;
>> s=tf('s'); >> s=tf('s');
>> Gc=(Kp+(Ki/s)+(s*Kd)); >> Gc=(Kp+(Ki/s)+(s*Kd));
>> Go=feedback(Gc*sys,H); >> Go=feedback(Gc*sys,H);
>> step(Go) >> step(Go)
>> grid on; >> grid on;
On further changing the values of Kp=12, Kd=10 and Ki=5, obtained graph is shown below:

It is seen that peak overshoot as well as oscillation has decreased and system is in stable state.

Potrebbero piacerti anche