PID Controller Design by Pole Assignment
3 views (last 30 days)
Show older comments
Hello, im trying to design a PID controller by polynomial coefficient method by given code below but the code seems to find Ki and bres always zero. Can someone help me understand what the problem is?
clc
clear all
syms s x s h y z t K_d K_p K_i ares bres;
% symbolic variables are defined to see if function is working correctly
h=12;x=15;y=35;z=45;t=50;
pole = 1-1i;
p_ds = expand((s-pole) * (s-(conj(pole))))
coef2=coeffs(p_ds,s,'All');
p_es = (s^2+ares*s+bres);
coef = coeffs(p_es,s,'All');
Gs = h /(x*s^3+y*s^2+z*s+t);
[numGs,denGs] = numden(Gs)
denGs1 = coeffs(denGs)
denGs2 = double(denGs1)
p = (p_es * p_ds)
p1 =coeffs(p,s,'All')
Fs = (K_d*s^2+K_p*s+K_i )/ s
Tss = (Gs*Fs)/(1+Gs*Fs)
[numTss,pcs] = numden(Tss)
prob = coeffs(pcs/x,s,'all') == coeffs(p_ds*p_es,s,'all');
for i = 1:length(prob)
disp(vpa(prob(i),4));
end
sol = solve(prob)
disp(sol)
Kdval = double(sol.K_d)
Kpval = double(sol.K_p)
Kival = double(sol.K_i)
aresval = double(sol.ares)
bresval = double(sol.bres)
0 Comments
Accepted Answer
Paul
on 2 Dec 2024
Edited: Paul
on 2 Dec 2024
Hi Bahadir,
I'm not sure if the code is implementing what it should, but the reason the result is coming back with Ki = bres = 0 is due to the form of the equations.
syms s x s h y z t K_d K_p K_i ares bres;
% symbolic variables are defined to see if function is working correctly
h=12;x=15;y=35;z=45;t=50;
pole = 1-1i;
p_ds = expand((s-pole) * (s-(conj(pole))));
coef2=coeffs(p_ds,s,'All');
p_es = (s^2+ares*s+bres);
coef = coeffs(p_es,s,'All');
Gs = h /(x*s^3+y*s^2+z*s+t);
[numGs,denGs] = numden(Gs);
denGs1 = coeffs(denGs);
denGs2 = double(denGs1);
p = (p_es * p_ds);
p1 =coeffs(p,s,'All');
Fs = (K_d*s^2+K_p*s+K_i )/ s;
Tss = (Gs*Fs)/(1+Gs*Fs);
[numTss,pcs] = numden(Tss);
prob = coeffs(pcs/x,s,'all') == coeffs(p_ds*p_es,s,'all');
%{
for i = 1:length(prob)
disp(vpa(prob(i),4));
end
%}
Here are the equations to be solved.
prob(:),split(string(char(prob(:))),";")
The first equation is extraneous. The last equation is a simple relationship between Ki and bres. Apparently solve can find a soluution to all of the equations with Ki = bres = 0
sol = solve(prob)
If you want to get all solutions parametrically, then use the ReturnConditions flag.
sol = solve(prob,'ReturnConditions',true)
Apparently only ares is fixed and the rest of the unknowns are determined from a single parameter.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!