# Analysis of Gain-Scheduled PI Controller

This example analyzes gain-scheduled PI control of a linear parameter-varying system. This example is based on  and .

The plant $\mathit{G}\left(\rho \right)$ is a first-order system with dynamics depending on the parameter $\rho$.

$\stackrel{˙}{\mathit{x}}=-\frac{1}{\tau \left(\rho \right)}\mathit{x}+\frac{1}{\tau \left(\rho \right)}\mathit{u}$

$\mathit{y}=\mathit{c}\left(\rho \right)\mathit{x}$

Here:

$\tau \left(\rho \right)=\sqrt{133.6-16.8\rho }$

$\mathit{c}\left(\rho \right)=\sqrt{4.8\rho -8.6}$

The parameter $\rho$ is restricted to the interval [2,7]. The closed-loop system consists of the plant $\mathit{G}\left(\rho \right)$, gain-scheduled PI controller $\mathit{K}\left(\rho \right)$, and time delay ${\mathit{T}}_{\mathit{d}}=0.5$ sec, as shown in this interconnection figure. ### LPV Plant

Use lpvss to construct a model of the LPV plant. The function plantFcnGSPI returns the state-space matrices and offsets as a function of time t and parameter rho. To see the code for this function, open the file plantFcnGSPI.m or enter type plantFcnGSPI at the command line.

G = lpvss('rho',@plantFcnGSPI);

### Gain-Scheduled PI Controller

The gain-scheduled Proportional-Integral (PI) controller $\mathit{K}\left(\rho \right)$ is designed to achieve a closed loop damping ratio ${\zeta }_{\mathit{d}}=0.7$ and natural frequency ${\omega }_{\mathit{d}}=0.25$ in the domain $\rho \in \left[2,7\right]$. You can construct this controller in two different forms.

• Controller ${\mathit{K}}_{1}$, with the integral gain at the integrator input.

${\stackrel{˙}{\mathit{x}}}_{\mathit{c}}={\mathit{K}}_{\mathit{i}}\left(\rho \right)\mathit{e}$

$\mathit{u}={\mathit{x}}_{\mathit{c}}+{\mathit{K}}_{\mathit{p}}\left(\rho \right)\mathit{e}$

• Controller ${\mathit{K}}_{2}$, with the integral gain at the integrator output.

${\stackrel{˙}{\mathit{x}}}_{\mathit{c}}=\mathit{e}$

$\mathit{u}={\mathit{K}}_{\mathit{i}}\left(\rho \right){\mathit{x}}_{\mathit{c}}+{\mathit{K}}_{\mathit{p}}\left(\rho \right)\mathit{e}$

These forms are equivalent when $\rho$ and ${\mathit{K}}_{\mathit{i}}$ are constant. However, the two forms have different input/output response when the parameter varies in time. This example compares these two options in terms of closed-loop performance.

This example provides the code for these two controllers in the files k1FcnGSPI.m and k2FcnGSPI.m. Use lpvss to construct the two controllers.

K1 = lpvss('rho',@k1FcnGSPI); K2 = lpvss('rho',@k2FcnGSPI);

### Closed-Loop Models

Construct the closed-loop LPV models as shown in the interconnection figure with controllers ${\mathit{K}}_{1}$ and ${\mathit{K}}_{2}$.

Use a second-order Pade approximation of the delay.

Td = 0.5; [n,d] = pade(Td,2); H = tf(n,d);

Construct the closed-loop models.

CL1 = feedback(G*H*K1,1); CL2 = feedback(G*H*K2,1);

### LTI Analysis

Evaluate this closed-loop response for several frozen values of $\rho$.

Sample the LPV system for three values of rho.

Nvals = 3; pvals = linspace(2,7,Nvals); CL1vals = sample(CL1,[],pvals); CL2vals = sample(CL2,[],pvals);

Plot the Bode response of complementary sensitivity at fixed values of $\rho$.

bode(CL1vals,'b',CL2vals,'r--',{1e-2,1}); As expected, the location of the integral gain does not affect the controller when $\rho$ is constant. Hence, the two closed-loop responses are identical in the LTI cases.

### LPV Analysis

Generate closed-loop step responses from $\mathit{r}$ to $\mathit{y}$ along one specific parameter trajectory.

Specify the parameter trajectory.

t = linspace(0,30,1e3); rho = interp1([0 10 30],[2 7 7],t); plot(t,rho,'b'); grid on xlabel('Time (seconds)'); ylabel('\rho'); title('Parameter Trajectory for Step Response'); Plot the step responses.

step(CL1,CL2,t,rho) grid on title('Step Responses for Parameter Trajectory'); legend('Ki at input (K1)','Ki at output (K2)','Location','Best'); The two closed-loop simulations are different. This indicates that the placement of the integrator in a gain-scheduled control makes a difference when the parameters vary.

### Plant and Controller Data Functions

type plantFcnGSPI.m
function [A,B,C,D,E,dx0,x0,u0,y0,Delays] = plantFcnGSPI(t,rho) % LPV data for plant rho = max(2,min(rho,7)); % keep rho in range [2,7] tau = sqrt(133.6-16.8*rho); A = -1/tau; B = 1/tau; C = sqrt(4.8*rho-8.6); D = 0; E = []; % No offsets or delays dx0 = []; x0 = []; u0 = []; y0 = []; Delays = []; end 
type k1FcnGSPI.m
function [A,B,C,D,E,dx0,x0,u0,y0,Delays] = k1FcnGSPI(t,rho) % LPV data for PI controller K1 tau = sqrt(133.6-16.8*rho); c = sqrt(4.8*rho-8.6); % PI Gains sigma = 0.7; wcl = 0.25; Kp = (2*sigma*wcl*tau-1)/c; Ki = wcl^2*tau/c; % State-space and offset data: Ki at the input A = 0; B = Ki; C = 1; D = Kp; E = []; % No offsets or delays dx0 = []; x0 = []; u0 = []; y0 = []; Delays = []; end 
type k2FcnGSPI.m
function [A,B,C,D,E,dx0,x0,u0,y0,Delays] = k2FcnGSPI(t,rho) % LPV data for PI controller K2 tau = sqrt(133.6-16.8*rho); c = sqrt(4.8*rho-8.6); % PI Gains sigma = 0.7; wcl = 0.25; Kp = (2*sigma*wcl*tau-1)/c; Ki = wcl^2*tau/c; % State-space and offset data: Ki at the output A = 0; B = 1; C = Ki; D = Kp; E = []; % No offsets or delays dx0 = []; x0 = []; u0 = []; y0 = []; % no offsets Delays = []; end 

### References

1. Tan, Shaohua, Chang-Chieh Hang, and Joo-Siong Chai. “Gain Scheduling: From Conventional to Neuro-Fuzzy.” Automatica 33, no. 3 (March 1997): 411–19. https://doi.org/10.1016/S0005-1098(96)00162-8.

2. Pfifer, Harald, and Peter Seiler. “Robustness Analysis of Linear Parameter Varying Systems Using Integral Quadratic Constraints.” International Journal of Robust and Nonlinear Control 25, no. 15 (October 2015): 2843–64. https://doi.org/10.1002/rnc.3240.