This article is contained in *Scilab Control Engineering Basics* study module, which is used as course material for International Undergraduate Program in Electrical-Mechanical Manufacturing Engineering, Department of Mechanical Engineering, Kasetsart University.

### Module Key Study Points

- Understand state-space representation of a system

- How to convert data between state-space and transfer function form
- Design state feedback using simple pole-placement procedure
- Append an integrator to state feedback to eliminate steady-state error

State feedback control, the topic of this study module, can be thought of as a foundation for the so-called *“modern control*”* originated since ’60. In contrast to the frequency domain analysis of the classical control theory, modern control theory formulates the time-domain data as a system of first-order differential equations in matrix form called state-space representation, which is a mathematical model of the given system as a set of input, output, and state variable.

* This terminology is commonly used in the control literature, regardless of calling a 50-year-old approach modern could sometimes create confusion to a beginner. Indeed, the modern control approach is so eternal that later developments have to be called post-modern.

First, we give some review on state-space representation, which is essential for the state feedback design discussed later on. Let us take our simple DC motor joint model as an example. A dynamic equation that governs the motion can be written as

To simplify the notation, the time dependent is omitted. Define the system states as the joint position and velocity

(2)

By using these state variables, (1) can be rewritten as a system of first order differential equations

(3)

or in matrix form as

and the output equation, with y = θ

In general, a linear time-invariant (LTI) system can be described as

where x,u,y represent the state, input, and output vectors, respectively. (6) is called a *state equation*, and (7) an *output equation*. Note that this representation is not unique, but depends on how the states are defined. Moreover, though in our robot joint example the states are conveniently joint position and velocity, for the general case the states might not have any physical meaning, and hence could not be measured.

For a system represented by (6) and (7), it is easy to show that the corresponding transfer function equals

To convert between state space and transfer function in Scilab, use commands ss2tf and tf2ss. For example, for a plant transfer function P(s) = 1/(s^2 + s)

-->s=poly(0,'s'); -->P = 1/(s^2+s) P = 1 ----- 2 s + s

This can be converted to state-space form by

-->Pss = tf2ss(P);

Verify that the matrices conform to (4) with

-->Pss.A ans = 0. 1. 0. - 1. -->Pss.B ans = 0. 1. -->Pss.C ans = 1. 0.

Convert back to transfer function by ss2tf

-->P1=ss2tf(Pss) P1 = 1 ----- 2 s + s

Note that a transfer function for a physical system must be strictly proper; i.e., its frequency response must go to zero as the frequency approaches infinity. (No system could have unlimited bandwidth in reality.) This implies its state-space representation must have zero D matrix.

### State Feedback Control

Obviously, a state feedback control is feasible in practice when all states are measurable, such as the robot joint dynamics in (4) with joint position and velocity as state variables. State feedback design can be performed with a scheme known as *pole placement*, or more systematic way using *Ackerman’s formula*.

The idea of pole placement is simple. Specify pole locations of the closed-loop system that yields desired stability and performance criteria. Then choose the state feedback control gains to move the closed-loop poles to such locations. A necessary condition is that the plant must be stabilizable. The details can be studied from most undergraduate control textbooks.

The state feedback controller is simply a vector of gains K = [k_{1}, k_{2} … k_{n}]^{T} connecting the states to the plant input. So, for a set of specified closed-loop poles, the design goal is to compute k_{i}, i = 1, … ,n . To see this more clearly, assume the command input is zero. We have at the plant input

and the closed-loop state equation

The closed-loop poles can be computed from

Meanwhile, specifying the closed-loop poles p_{i}, i = 1, … , n yields the characteristic polynomial

Hence, we can compare (11) and (12) to solve for K manually, which could be tedious for higher order equations. Scilab provides a convenient command ppol to solve for K, given the A, B matrices and a vector of desired poles as arguments.

Ex. 1: Let us design a state feedback control for the simple robot joint described by (4), (5) with J = 1, B = 1. Specify the desired properties of closed-loop system as follows:

- overshoot less than 5%
- rise time less than 0.1 sec

By standard analysis of 2nd order system, we have that the specification (1) translates to damping ratio ζ ≥ 0.7, and using the relation t_{r} = 1.8/ω_{n} , we have for (2) that ω_{n} ≥ 18 rad/s. Substituting these two values to the closed-loop characteristic polynomials yields

with poles at -12.6 ± 12.8546i. The above procedure can be carried out by the following Scilab commands

-->z=0.7; wn=18; -->lamda = s^2+2*z*wn*s+wn^2; -->clpoles = roots(lamda) clpoles = - 12.6 + 12.854571i - 12.6 - 12.854571i

and with the plant data from Pss calculated earlier, the state feedback gains can be computed by this command

-->K=ppol(Pss.A,Pss.B,clpoles) K = 324. 24.2

Construct Xcos model in Figure 1, or download ppol.zcos, to simulate the system. Notice in the diagram that the plant is conveniently represented in transfer function form since the joint velocity and angle can be accessed. Also, in computing the state feedback gains, we do not take into consideration the command input. Hence the step response will have nonzero steady-state error that needs to be compensated with a feedforward gain. An easy way to compute this gain is by checking the DC gain of feedback system

Figure 1 ppol.zcos Xcos diagram for state feedback control

-->cltf=ss2tf(syslin('c',Pss.A-Pss.B*K,Pss.B,Pss.C)) cltf = 1 --------------- 2 324 + 25.2s + s

which can be found by letting s = jω ,and at ω = 0 the result is 1/324. So, to compensate this DC offset, we apply a feedforward gain of 324 to both the step and disturbance inputs. With the disturbance of magnitude 0.1 enters the system at time t = 1 sec, the simulation yields the step response in Figure 2. We see that the transient period conforms to the desired spec; i.e., (1) overshoot less than 5% (2) rise time less than 0.1 sec. However, the closed-loop system cannot get rid of the constant disturbance of 0.1 after t = 1 sec. This result is predictable, because the state feedback is just a pair of static gains with no dynamics to compensate the disturbance entering at the plant input. In the next example, we suggest a way to circumvent this drawback.

Figure 2 step response from Xcos model in Figure 1

Ex. 2: From the PID example discussed earlier, we show the advantage of integral term in eliminating the steady-state error. This principle can be applied to the state feedback scheme by augmenting an integrator as shown in Figure 3. There exist some systematic procedure to augment an integrator and design all gains simultaneously, but that means the second-order relationship in the previous example is no longer applicable. So in this example we still use the pole-placement for second-order system as before, and then adjust the integral gain afterwards to achieve the desired response.

Figure 3 ppol_int.zcos Xcos model of state feedback with integrator

Notice that the integrator replaces the DC gain compensation in Figure 1 to correct the response to the target steady-state value. Using the same state feedback gains results in slower transient response than Figure 2, so we redesign the pole-placement step by increasing &omega_{n} to 40 rad/s.

-->z=0.7; wn = 40; -->lamda = s^2+2*z*wn*s+wn^2; -->clpoles = roots(lamda) clpoles = - 28. + 28.565714i - 28. – 28.565714i

This yields a new pair of state feedback gains.

-->K = ppol(Pss.A,Pss.B,clpoles) K = 1600. 55.

The DC gain of closed-loop system

-->cltf=clean(ss2tf(syslin(‘c’,Pss.A-Pss.B*K,Pss.B,Pss.C))) cltf = 1 ------------- 2 1600 + 56s + s

equals 1/1600. So a gain of 1600 is applied as compensation to the disturbance input to yield the same level as in previous example; i.e., d = 0.1. By experimenting with the integral gain, we select K_{i} = 20000 , which gives the response as in Figure 4. The rise time and overshoot satisfy the specification given in Ex. 2, while the system recovers to the desired value after the disturbance is applied at t = 1 sec.

Figure 4 step response from the Xcos model in Figure 3

### Summary

In this module, we discuss state-space representation, using the robot joint driven by DC motor model as an example. The two state variables are the joint position and velocity, which are measurable in a real application. Hence the state feedback design scheme is suitable for this system. Joint position is normally obtained from an encoder using hardware or software readouts. Joint velocity may be measured via a tachometer, or obtained indirectly by counting encoder pulses per known time period. Finally, we show how to append an integrator to a state feedback design to eliminate steady-state error.

### References

- V.Toochinda. Robot Analysis and Control with Scilab and RTSX. Mushin Dynamics, 2014.