The following design example illustrates the state-space design concepts discussed in the textbook.
You can change some of the design parameters in this example. The example will then update the calculations and results. Update the design values using the controls in the example or the duplicates here
Consider the inverted pendulum on a cart driven by a position servo as shown in Figure 1.
The equation of motion of the pendulum is
$$\ddot{x}+l\ddot{\theta}-g\theta = 0$$and the cart is
$$\ddot{x} + 2\zeta\omega_n\dot{x} + \omega_n^2x = \omega_n^2u$$where $u$ is the input to the position servo.
Eliminate $\ddot{x}$ using both equations of motion, and one gets
$$\ddot{\theta}=\frac{g}{l}\theta+ \frac{\omega_n^2}{l}x+\frac{2\zeta\omega_n^2}{l}\dot{x}-\frac{\omega_n^2}{l}u$$Pick the state vector
$$\bold{x}= \begin{bmatrix} x_1\\x_2\\x_3\\x_4 \end{bmatrix} = \begin{bmatrix} \theta\\ \dot{\theta} \\ x \\ \dot{x} \end{bmatrix}$$then the following system and input matrices obtain:
$$ \bold{A} = \begin{bmatrix} 0 & 1 & 0 & 0 \\ g/l & 0& \omega_n^2/l & 2\zeta\omega_n/l \\ 0 & 0 & 0 & 1 \\ 0 & 0 & -\omega_n^2 & -\zeta\omega_n \end{bmatrix}, \optbreak{} \bold{B}= \begin{bmatrix} 0\\ -\omega_n^2/l \\ 0 \\ \omega_n^2 \end{bmatrix} $$
To go any farther we need some numerical values. For the pendulum
$$\begin{aligned} \zeta &= 0.707 \\ \omega_n &= 20 \text{rad/sec} \end{aligned}$$and we get plant matrices
$$\bold{A}= \begin{bmatrix} 0 & 1 & 0 & 0\\ 32.7 & 0 & 1333 & 94.3 \\ 0 & 0 & 0 & 1\\ 0 & 0 & -400 & -28.3 \end{bmatrix}, \optbreak{} \bold{B} = \begin{bmatrix} 0 \\ -1333 \\ 0 \\ 400 \end{bmatrix}$$Since the position servo natural frequency is about 3 Hz, we won’t require any higher frequency response from the controlled system. Thus a sampling frequency of 25 Hz ($T$ = 0.04) should be adequate. Discretizing the plant with this $T$ yields
$$ \bold{\Phi} = \begin{bmatrix} 1.0262 &0.0403 & 0.7240 & 0.0619\\ 1.3181 & 1.0262 & 29.0507 & 2.7782 \\ 0 & 0 & 0.7839 & 0.0215\\ 0 & 0 & −8.6106 & 0.1751 \end{bmatrix} , \optbreak{} \bold{\Gamma} = \begin{bmatrix} −0.7240 \\ −29.0507 \\ 0.2161 \\ 8.6106 \end{bmatrix}$$
Phi = [1.0262 1.3181 0 0;
0.0403 1.0262 0 0;
0.7240 29.0507 0.7839 −8.6106;
0.0619 2.7782 0.0215 0.1751];
Gamma = [−0.7240; −29.0507; 0.2161; 8.6106];
Ctr = ctrb(Phi,Gamma);
rank(Ctr)
MATLAB will display:
ans = 4
As expected, the plant is controllable.
For $\omega_K$ = rad/s (A logical choice is $\omega = \omega_n$ = 20rad/s)
The four poles in the s-plane are: .
In the z plane these four poles are: .
Using Matlab place
, the state feedback gain is
and a check of the observability matrix shows
C = [1 0 0 0];
rank(ctrb(Phi',C'));
MATLAB will display:
ans = 4
Since the observability matrix has full rank, the system is observable, and we can proceed with a prediction estimator design.
For $\omega_L$ = rad/s
The four poles in the s plane are: .
In the z plane these four poles are: .
It doesn’t really make sense to provide a reference input for pendulum angle $\theta$, except for trimming, since $\theta = 0$ is the only pendulum angle that can exist in steady-state. So the number of plant inputs $u$ and desired outputs $x$ are the same ($m = p$), hence the coefficient matrix in equation (7.70) is square, and terms $\bold{N}_x$ and $N_u$ are given by equation equation (7.71) $$\tag{7.71} \begin{bmatrix}\bold{N}_x \\ \bold{N}_u \end{bmatrix} = \begin{bmatrix}\bold{\Phi}-\bold{I} & \bold{\Gamma} \\ \bold{C}_r & \bold{0} \end{bmatrix}^{-1} \begin{bmatrix} \bold{0} \\ \bold{I} \end{bmatrix}$$ (See Section 7.8.1 in the textbook))
Cr = [0 0 1 0];
inv([Phi-eye(4) Gamma ; Cr 0])*([0;0;0;0;1])
MATLAB will display:
ans = -0.0000
0.0000
1.0000
0.0000
1.0000
Thus
$$\bold{N}_x = \begin{bmatrix} 0\\0\\1\\0 \end{bmatrix}, N_u=1$$
The response of the cart position and pendulum angle as the system returns to equilibrium is shown in Figure 3. Note that the initial motion of the cart is to the right, away from the desired center position! However, this is intuitive, since the stick was initially balanced, and to move the cart back to the left one must first move to the right to get the stick leaning to the left, then the cart can move left.
The previous example uses an estimator to predict the states and then uses those estimates, $\bold{\hat{x}}$, to calculate the feedback control, $u=\bold{K\hat{x}}$. In the example, it was assumed that we knew the plant exactly. This means the estimator can predict the state values perfectly. It also means that the feedback control gain, $\bold{K}$, will place the closed-loop poles exactly as designed. However, we are rarely able to model systems perfectly. A good control system must be "robust" and work even if the actual plant varies slightly from the model used in the design.
Use control below to change the value of the pendulum length. The example above will use the nominal length, 0.3m, for the design calculations, but the simulation will use the longer pendulum length.
Update the design values using the controls in the example or the duplicates here