LQR and Integral Feedback

You are not logged in.

Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.

Adding An Integral Term to State-Space Control

Recall that in classical control, adding an integral in the compensator eliminates steady-state errors, usually at the cost of worsening the stability. To minimize the distabilizing effects of adding the integral term, we often adjust the other terms (such as the proportional and derivative terms in the PID controller). We can also add an integral to the state-space controller to eliminate steady-state errors, and in the case of state-space control, we have more feedback gains to modify, so we can usually avoid a stability penalty.

State-space control without an integral term

The generic state-space equations are

\textbf{E}\frac{d}{dt}\textbf{x} = \textbf{Ax} + \textbf{B}u

y = \textbf{Cx}

u = -\textbf{Kx} + K_r y_d

where x is the state, u is the "plant" input, y_d is the primary input and is usually the desired output of the system, and y is the actual output of the system. Once one has determined \textbf{E}, \textbf{A}, \textbf{B}, and \textbf{C}, and has determined a good set of LQR weights for the state and the input, we can use the lqr to determine values for \textbf{K} that result in good closed-loop performance.

A key point to note is that the state-feedback gains do not depend on the scaling of the primary input, that is, the K's do not depend on K_r. One can determine K to optimize dynamic performance, and then scale the primary input by K_r so as to achieve a desired steady-state without changing the dynamics! Changing K_r does not change the system poles, just the steady-state.

Once K and the K_r have been determined, the closed-loop system is given by

\textbf{E}\frac{d}{dt}\textbf{x} = \left(\textbf{A-BK}\right)\textbf{x} + \textbf{B}K_r y_d

y = \textbf{Cx}

We can compute K_r from the formula

K_r = -\left(\textbf{C} \left(\textbf{A-BK}\right)^{-1}\textbf{B}\right)^{-1},
which follows from insisting that if y_d is a constant with respect to time, then y \rightarrow y_d as t \rightarrow \infty. Since K_r is dependent on the state-space matrices and the state-feedback gains, any modeling errors can easily lead to an incorrect K_r, and can lead to an irreparable error in the steady-state. It is possible to correct that error by adding a tracking-error-integral state to the state-space model.

Adding the tracking-error-integral state

Consider adding an extra state to the system, denoted by w, and defined by the differential equation,

\frac{d}{dt} w(t) = y(t) - y_d(t) = \textbf{Cx}(t) - y_d(t).
Based on the above differential equation, w(t) will be the integral of the tracking error.

We can add this extra state to a state-space model by appending w to \textbf{x}, as in

\textbf{x}_+=\begin{bmatrix} \textbf{x}\\ w \end{bmatrix}.

The extra state means that there is a row added to \textbf{B}, a column added to \textbf{C}, and a row and column added to both \textbf{E} and \textbf{A}. The expanded matrices, denoted with a subscript + are:

\textbf{A}_+ = \begin{bmatrix}\textbf{A} & 0\\ \textbf{C} & 0\end{bmatrix}
\textbf{B}_+ = \begin{bmatrix}\textbf{B} \\ 0 \end{bmatrix}
\textbf{C}_+ = \begin{bmatrix}\textbf{C} & 0\end{bmatrix}
and
\textbf{E}_+ = \begin{bmatrix}\textbf{E} & 0 \\ 0 & 1\end{bmatrix}

To include the integral term, we alter the representation of the state-space control problem to include the reference input in a different way. That is,

\textbf{E}_+\frac{d}{dt}\textbf{x}_+ = \textbf{A}_+ \textbf{x}_+ + \textbf{B}_+ u + \begin{bmatrix} \textbf{0}\\ -1 \end{bmatrix} y_d,

y = \textbf{C}_+ \textbf{x}_+

u = -\textbf{K}_+ \textbf{x}_+

Note that for the extra row in B_+, we used the value of zero, which means that the extra state has the equation

\frac{d}{dt} w = y - y_d = \textbf{C} x - y_d,
and ensures a steady-state match without requiring a scaling of the reference input.

Substituting for u gives us a closed-loop state-space system,

\textbf{E}_+\frac{d}{dt}\textbf{x}_+ = \left( \textbf{A}_+ - \textbf{B}_+ \textbf{K}_+ \right) \textbf{x}_+ + \begin{bmatrix} \textbf{0}\\ -1 \end{bmatrix} r = \textbf{A}_{clp} \textbf{x}_+ + \textbf{B}_{clp} y_d,
where we can used the subscript clp to denote closed-loop for the augmented system. Recall that the output remain the same weighted combination of states,
y = \textbf{C}_+ \textbf{x}_+ = \textbf{C}_{clp} \textbf{x}_+.

For the case of the three-state model of the propeller, adding the tracking-error-integral state generates a four-state model. The new state vector is then

\textbf{x}_+ =\begin{bmatrix} \theta \\ \omega \\ v_{bemf} \\ w \end{bmatrix},
and \textbf{E}_+ and \textbf{A}_+ are 4 \times 4, \textbf{B}_+ is 4 \times 1, and \textbf{C}_+ is 1 \times 4.

Determining the gains with the extra state

When we add the extra state w, we also need an extra state-feedback gain, K_w, so that

\textbf{K}_+ = \begin{bmatrix}\textbf{K}_{+_x} & K_{+_w}\end{bmatrix}
where we have used the notation \textbf{K}_{+_x} and K_{+_w} to remind us that ALL the state-feedback gains determined from analyzing the system with the integrator will be different from the gains determined from analyzing the system without the integrator.

We can determine \textbf{K}_+ using either the place or lqr function with the expanded matrices, \textbf{E}_+, \textbf{A}_+ and \textbf{B}_+. For example, in matlab we could use

Kp = place(Ep\Ap,Ep\Bp,[-1,-2,-3,-4]).
where we can used the subscript p because matlab will not let us use + in a variable label.

To prepare for the lab, please re-derive the \textbf{A}_+, \textbf{B}_+, \textbf{C}_+, and \textbf{E}_+ matrices for the open-loop propellor state space model including the integrator state. You will modify the MATLAB script for lab to include the integrator state. You'll need to:

  • Create the \textbf{A}_+, \textbf{B}_+, \textbf{C}_+, and \textbf{E}_+ matrices.
  • Update the Q and R weights in the LQR optimization.
  • Edit the formula that computes the closed-loop matrices for the augmented system.

Notice that in the lab Matlab script, we have done some of the modifications for adding the integral term, but not all of them.

Check Yourself 1:

When you get in to lab, you'll see that we have set up a Matlab script and Teensy sketch so that you can modify the matlab script and run it, an intermediate file will be generated. That file will be read when you compile and download the Teensy sketch onto the Teensy.