How can i calculate the PI controller gains from my plant transfer function

168 views (last 30 days)
I am doing a project where I am using a synchronous bidirectional buck-boost converter too handle to powerflow between a battery and a dc bus. I have spend some time figuring out and understanding how to find the transfer function of my converter with state space modelling and have think I finally understand the whole process. My next step is to use that transfer function to calculate some gain values for the PI controller which i want to control converter with.
I have found my transfer function with state space modelling by following the example in a guide from texas instruments Guide (at the bottom of the guide they have attached a matlab script to copy in order to get the transfer function yourself). I have some other values for the components than texas, but taking initiative in the result from the guide is a good start, I think.
I think my biggest problem is that i don't know where to start. I know these definitions for PI controller, but I just can't see how it is connected.
omegaK = 1/ti
Gs = Kp *(1+1/ti) (PI controller)
Sorry for maybe not being too specific, I am not the strongest in control theory and really hope someone have time to give me an answer or show how to do it.
Best regards Mads
clear all;
clc;
s = tf('s');
% Values below is from an example made by texas instruments
% Input Voltage
Vp= 200;
% Input resistance
Rp=2.75*10^-3*200;
% Input capacitance
ci=1*10^-3;
% Input capacitance ESR
Rci=74*10^-3;
% DCR of the inductor
Rl=9.6*10^-3;
% Inductance
l=130*10^-6;
% Output Capacitance
co=15*10^-3;
% Output Capacitance ESR
Rco=5*10^-3;
% Output Load
Io=80;
% Duty cycle
D=0.5;
% The matrice for solving of inductor current transfer function
C = [0 0 1];
Dm = 0;
% state vector expressions
iL=Io/(1-D);
vci=Vp-Io*Rp/(1-D);
vco=(Vp/(1-D))-((Io*(Rp+Rl+D*(1-D)*Rco))/(1-D)^2);
% determining the state and input matrices for the converter in ON and OFF
A1 = [0 0 0; 0 -1/(ci*(Rp+Rci)) -Rp/(ci*(Rp+Rci)); 0 Rp/(l*(Rp+Rci)) (-(Rl*Rp+Rl*Rci+Rci*Rp))/(l*(Rp+Rci))];
B1 = [-1/co 0; 0 1/(ci*(Rp+Rci)); 0 Rci/(l*(Rp+Rci))];
A2 = [0 0 1/co; 0 -1/(ci*(Rp+Rci)) -Rp/(ci*(Rp+Rci)); -1/l Rp/(l*(Rp+Rci)) (-(Rl*Rp+Rl*Rci+Rci*Rp+Rp*Rco+Rco*Rci))/(l*(Rp+Rci))];
B2 = [-1/co 0; 0 1/(ci*(Rp+Rci)); Rco/l Rci/(l*(Rp+Rci))];
% Determining the state and input vectors
X = [vco; vci; iL];
U = [Io; Vp];
A_avg = A1*D+A2*(1-D);
B_avg = B1*D+B2*(1-D);
% Finding the transfer function
% (sI-A)
SIminusA = s*eye(3)-A_avg;
% (sI-A)^-1
inv_SIminusA = inv(SIminusA);
% (A1-A2)X+(B1-B2)U
A1minusA2XPlusB1minusB2U = (A1-A2)*X+(B1-B2)*U;
% Inductor current to duty cycle Trasnfer Function
% C*((sI-A)^-1*((A1-A2)X+(B1-B2)U))
y_IL = C*(inv_SIminusA*A1minusA2XPlusB1minusB2U)% Bodeplot af TF
% minreal cancelling poles and zeros
y_IL1 = minreal(y_IL)
% pole-zero-gain model
zpk(y_IL1)
% Display poles
pole(y_IL1)
% Display zeros
zero(y_IL1)
% Bodeplot af TF
figure;
hold on;
%bode(y_ILtexas);
bode(y_IL1)
grid on;
title('Bidirectional Buck-Boost converter transfer functions');
legend('TF');onal Buck-Boost converter transfer functions');
legend('TF');

Accepted Answer

Sam Chak
Sam Chak on 1 Dec 2022
Perhaps you can directly insert the PI controller and obtain the closed-loop response. Tune the gains if not good enough.
s = tf('s');
% Values below is from an example made by texas instruments
% Input Voltage
Vp = 200;
% Input resistance
Rp = 2.75*10^-3*200;
% Input capacitance
ci = 1*10^-3;
% Input capacitance ESR
Rci = 74*10^-3;
% DCR of the inductor
Rl = 9.6*10^-3;
% Inductance
l = 130*10^-6;
% Output Capacitance
co = 15*10^-3;
% Output Capacitance ESR
Rco = 5*10^-3;
% Output Load
Io = 80;
% Duty cycle
D = 0.5;
% The matrice for solving of inductor current transfer function
C = [0 0 1];
Dm = 0;
% state vector expressions
iL = Io/(1 - D);
vci = Vp - Io*Rp/(1 - D);
vco = (Vp/(1-D)) - ((Io*(Rp + Rl + D*(1 - D)*Rco))/(1 - D)^2);
% determining the state and input matrices for the converter in ON and OFF
A1 = [0 0 0; 0 -1/(ci*(Rp+Rci)) -Rp/(ci*(Rp+Rci)); 0 Rp/(l*(Rp+Rci)) (-(Rl*Rp+Rl*Rci+Rci*Rp))/(l*(Rp+Rci))];
B1 = [-1/co 0; 0 1/(ci*(Rp+Rci)); 0 Rci/(l*(Rp+Rci))];
A2 = [0 0 1/co; 0 -1/(ci*(Rp+Rci)) -Rp/(ci*(Rp+Rci)); -1/l Rp/(l*(Rp+Rci)) (-(Rl*Rp+Rl*Rci+Rci*Rp+Rp*Rco+Rco*Rci))/(l*(Rp+Rci))];
B2 = [-1/co 0; 0 1/(ci*(Rp+Rci)); Rco/l Rci/(l*(Rp+Rci))];
% Determining the state and input vectors
X = [vco; vci; iL];
U = [Io; Vp];
A_avg = A1*D+A2*(1-D);
B_avg = B1*D+B2*(1-D);
% Finding the transfer function
% (sI-A)
SIminusA = s*eye(3) - A_avg;
% (sI-A)^-1
inv_SIminusA = inv(SIminusA);
% (A1-A2)X+(B1-B2)U
A1minusA2XPlusB1minusB2U = (A1 - A2)*X + (B1 - B2)*U;
% Inductor current to duty cycle Trasnfer Function
% C*((sI-A)^-1*((A1-A2)X+(B1-B2)U))
y_IL = C*(inv_SIminusA*A1minusA2XPlusB1minusB2U) % Bodeplot af TF
y_IL = 1.699e06 s^5 + 6.499e09 s^4 + 1.813e13 s^3 + 2e16 s^2 + 1.032e18 s + 1.351e19 --------------------------------------------------------------------------------- s^6 + 4395 s^5 + 1.894e07 s^4 + 3.143e10 s^3 + 5.071e13 s^2 + 2.9e15 s + 4.221e16 Continuous-time transfer function.
% minreal cancelling poles and zeros
y_IL1 = minreal(y_IL)
y_IL1 = 1.699e06 s^5 + 6.499e09 s^4 + 1.813e13 s^3 + 2e16 s^2 + 1.032e18 s + 1.351e19 --------------------------------------------------------------------------------- s^6 + 4395 s^5 + 1.894e07 s^4 + 3.143e10 s^3 + 5.071e13 s^2 + 2.9e15 s + 4.221e16 Continuous-time transfer function.
% Step response of the Buck-Boost Converter (Uncontrolled, Open loop)
step(y_IL1)
% pole-zero-gain model
zpk(y_IL1)
ans = 1.6994e06 (s+1603) (s+29.38) (s+24.14) (s^2 + 2168s + 6.994e06) --------------------------------------------------------------- (s+29.38)^2 (s^2 + 2168s + 6.994e06)^2 Continuous-time zero/pole/gain model.
% PI Controller
Kp = 1;
Ki = 2;
Gc = pid(Kp, Ki)
Gc = 1 Kp + Ki * --- s with Kp = 1, Ki = 2 Continuous-time PI controller in parallel form.
Gcl = minreal(feedback(Gc*y_IL1, 1))
Gcl = 1.699e06 s^3 + 2.768e09 s^2 + 7.128e10 s + 1.315e11 --------------------------------------------------------- s^4 + 1.702e06 s^3 + 2.775e09 s^2 + 7.148e10 s + 1.315e11 Continuous-time transfer function.
% Step response of the Feedback Control System (Closed-loop)
step(Gcl)
  6 Comments
Sam Chak
Sam Chak on 2 Dec 2022
That's because the value of your chosen is relatively small compared to the coefficients and . Moreover, you can to mix and match the combinations of and values to observe some results. In your case, seems to have a greater influence over the response than does. See the following example...
...
Gp = minreal(y_IL, 1e-6)
Gp = 1.699e06 s^2 + 2.764e09 s + 6.575e10 -------------------------------------- s^3 + 2197 s^2 + 7.057e06 s + 2.055e08 Continuous-time transfer function.
% Brute force simulating the step responses of 25 PI Controllers
Kp = [1e-2 1e-1 1e-0 1e1 1e2];
Ki = [2e-2 2e-1 2e-0 2e1 2e2];
[ca, cb] = ndgrid(Kp, Ki);
combs = [ca(:), cb(:)];
for j = 1:length(combs)
K = combs(j, :);
Kp = K(1);
Ki = K(2);
Gc = pid(Kp, Ki);
Gcl = minreal(feedback(Gc*Gp, 1));
step(Gcl), hold on
end
hold off
Lastly, keep in mind that using a 2-parameter 1st-order controller (PI) on a 3rd-order system yields a 4th-order closed-loop system with 4 free terms to be solved in the Characteristic Polynomial (look up ). The free terms outnumber the design parameters {Kp, Ki} making the design problem overconstrained.
In other words, you cannot freely design the controller to achieve desired response (specified in terms of desired settling time). However, it is possible use the Brute Force method to find a combination of Kp and Ki that give a satisfactory stable response.
Mads Olesen
Mads Olesen on 5 Dec 2022
Thanks sharing, I will have that in mind.
Last question, in order to find the most satisfactory combination is there a way to legend the combinations so I can see what responses and combinations which match?

Sign in to comment.

More Answers (2)

Sam Chak
Sam Chak on 5 Dec 2022
You can try this. But use a small combination pool.
From the previous simulations, it seems that Kp has a more dominant influence on the transient behavior than Ki.
formatSpec = '%.2f';
s = tf('s');
Gp = (1.699e06*s^2 + 2.764e09*s + 6.575e10)/(s^3 + 2197*s^2 + 7.057e06*s + 2.055e08);
% Kp = [1e-1 45e-2 1e0];
% Ki = [2e-1 11e-1 2e0];
Kp = 0.2:0.2:1.0;
Ki = 2e0;
[ca, cb] = ndgrid(Kp, Ki);
combs = [ca(:), cb(:)]
combs = 5×2
0.2000 2.0000 0.4000 2.0000 0.6000 2.0000 0.8000 2.0000 1.0000 2.0000
for j = 1:length(combs)
K = combs(j, :);
Kp = K(1);
Ki = K(2);
Gc = pid(Kp, Ki);
Gcl = minreal(feedback(Gc*Gp, 1));
t = linspace(0, 3.5e-5, 351);
y = step(Gcl, t); hold on
plot(t, y, 'linewidth', 1.5, 'DisplayName', ['K_p = ' num2str(combs(j), formatSpec) ', K_i = ' num2str(combs(j+length(combs)), formatSpec)]);
end
hold off, grid on, ylim([-0.2 1.2])
legend('show', 'location', 'best');
  2 Comments
Mads Olesen
Mads Olesen on 19 Dec 2022
Hello @Sam Chak
I was wondering.
Since the DC gain of the system is so big that would make the steady state error very small and therefore almost negligible. Using a PI-controller the steady state error would be zero, but since the integral control have no effect, wouldn't it be fine to use P-controller if I dont care about the very small steady state error?
Another question. Forming the system with a P-controller instead of PI-controller changes nothing to the trasnfer function and the step response, however shouldn't it still be a type 0 system with a P-controller, because there is no integrator to place a pole in origin. The system with a P-controller does have a pole in origin, which i dont understand, because that makes it a type 1 system anyway.
Best regards
Mads

Sign in to comment.


Sam Chak
Sam Chak on 20 Dec 2022
It appears that your intuition is right. The P-only controller is sufficient because the steady-state error is insignificant, at least for this range of P-values. The larger the P-value is, the smaller the steady-state error is.
On your Question #2, there are some differences. The Loop transfer function with a P-only controller is a Type-0 system, while Loop transfer function with a PI controller is a Type-1 system.
The Closed-loop transfer function under a P-only controller is a 3rd-order system, while Closed-loop transfer function under a PI controller is a 4th-order system. See results below.
formatSpec = '%.2f';
s = tf('s');
Gp = (1.699e06*s^2 + 2.764e09*s + 6.575e10)/(s^3 + 2197*s^2 + 7.057e06*s + 2.055e08);
% P-only controller
Gca = pid(1);
% Loop transfer function (Type-0 system)
Gl1 = series(Gca, Gp)
Gl1 = 1.699e06 s^2 + 2.764e09 s + 6.575e10 -------------------------------------- s^3 + 2197 s^2 + 7.057e06 s + 2.055e08 Continuous-time transfer function.
% closed-loop system under P-only controller (3rd-order system)
Gcl = minreal(feedback(Gl1, 1))
Gcl = 1.699e06 s^2 + 2.764e09 s + 6.575e10 ------------------------------------------ s^3 + 1.701e06 s^2 + 2.771e09 s + 6.596e10 Continuous-time transfer function.
Kp = 0.2:0.2:1.0;
for j = 1:length(Kp)
K = Kp(j);
Gc = pid(K);
Gcl = minreal(feedback(Gc*Gp, 1));
yssP(j) = dcgain(Gcl);
t = linspace(0, 3.5e-5, 351);
y = step(Gcl, t); hold on
plot(t, y, 'linewidth', 1.5, 'DisplayName', ['K_p = ' num2str(Kp(j), formatSpec)]);
end
hold off, grid on, ylim([-0.2 1.2])
legend('show', 'location', 'best');
% output steady-state under P-only controller
yssP % if not exactly 1, then the steady-state error ess is non-zero
yssP = 1×5
0.9846 0.9922 0.9948 0.9961 0.9969
% PI controller
Gcb = pid(1, 2);
% Loop transfer function (Type-1 system)
Gl2 = series(Gcb, Gp)
Gl2 = 1.699e06 s^3 + 2.767e09 s^2 + 7.128e10 s + 1.315e11 --------------------------------------------------- s^4 + 2197 s^3 + 7.057e06 s^2 + 2.055e08 s Continuous-time transfer function.
% closed-loop system under PI controller (4th-order system)
Gcl = minreal(feedback(Gl2, 1))
Gcl = 1.699e06 s^3 + 2.767e09 s^2 + 7.128e10 s + 1.315e11 --------------------------------------------------------- s^4 + 1.701e06 s^3 + 2.774e09 s^2 + 7.148e10 s + 1.315e11 Continuous-time transfer function.
% steady-state under PI controller
yssPI = dcgain(Gcl) % if exactly 1, then the output is exactly equal to the unit step input.
yssPI = 1.0000
  1 Comment
Siddharth Jawahar
Siddharth Jawahar on 22 Nov 2024 at 21:21
Hello! Thanks for the detailed effort, Sam, to guide Mads here. I would also like to point out that once you have the pid object in MATLAB, you can use the pidtune command to tune the gains automatically based on the controller requirements you need. Please see an example below with the plant model you have:
% Define the PID controller type and set up a PID control object
pidController = pid(1,1,0.1); % Initialize PID controller
% Configure tuning options with 'balanced' design focus
opts = pidtuneOptions('DesignFocus', 'balanced');
% Tune the PID controller
[pidTuned, tuningInfo] = pidtune(y_IL1, controllerType, opts);
% Display the tuned PID controller and tuning information
disp('Tuned PID Controller with balanced focus:');
disp(pidTuned);
disp('Tuning Info:');
disp(tuningInfo);
% Create closed-loop system with the tuned PID controller
closedLoopSystem = feedback(pidTuned * y_IL1, 1);
% Plot step response of the closed-loop system
figure;
step(closedLoopSystem);
title('Step Response with Balanced PID Tuning');
grid on;
HTH,
Sid

Sign in to comment.

Categories

Find more on Get Started with Control System Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!