Example: A StateSpace Controller for DC
Motor Position Control
Designing the fullstate feedback controller
Disturbance Response
Adding Integral Action
From the main problem, the dynamic equations in statespace form are the
following:
For the original problem setup and the derivation of the above
equations, please refer to the
Modeling DC Motor Position page.
With a 1 rad reference added to the system, the design criteria are:
 Settling time less than 0.04 seconds
 Overshoot less than 16%
 Zero steadystate error to a step input
 Zero steadystate error to a step disturbance
Create a new mfile and type in the
following commands (refer to the main problem for the details of getting
those commands).
J=3.2284E6;
b=3.5077E6;
K=0.0274;
R=4;
L=2.75E6;
A=[0 1 0
0 b/J K/J
0 K/L R/L];
B=[0 ; 0 ; 1/L];
C=[1 0 0];
D=[0];
Designing the fullstate feedback controller
Since all of the state variables in our problem are very easy to
measure (simply add an ammeter for current, a tachometer for speed,
and a potentiometer for position), we can design a fullstate feedback
controller for the system without worrying about having to add an
observer. The schematic for a fullstate feedback system is:
Recall that the characteristic polynomial for this closedloop system
is the determinant of (sI(ABKc)) where s is the Laplace
variable. Since the matrices A and B*Kc are both 3x3
matrices, there should be 3 poles for the system. By designing a
fullstate feedback controller, we can move these three poles anywhere
we want them. We shall first try to place them at 100 + 100i and 100100i
(note that this corresponds to a zeta = 0.5 which gives 0.16%
overshoot and a sigma = 100 which leads to a .04 sec settling time). Once
we come up with the poles we want, Matlab will find the controller
matrix,Kc, for us. Simply add the following code to the end of
your mfile :
p1=100+100i;
p2=100100i;
p3=200;
Kc=place(A,B,[p1,p2,p3]);
Now look at the schematic above again. We see that after adding the K
matrix into the system, the statespace equations become:
We can see the closedloop response by simply adding the following line to
the end of your mfile:
t=0:0.001:.05;
step(AB*Kc,B,C,D,1,t)
Run your mfile in the command window, You should see the following
plot:
Disturbance Response
In order to get the disturbance response, we must provide the proper
input to the system. Physically, a disturbance is a torque which acts
on the inertia of the motor. A torque acts as an additive term in the
second state equation (which gets divided by J, as do all the other
terms in this equation). We can simulate this simply by modifying our
closed loop input matrix, B, to have a 1/J in the second row. Add
the following line to your mfile and rerun.
step(AB*Kc,[0;1/J;0],C,D,1,t)
This is not a zero steadystate error to a disturbance, and we will
have to compensate for this.
Adding Integral Action
We know that if we put an extra integrator in series with the plant it
can remove steadystate error to an input. If the integrator comes
before the injection of the disturbance, it will cancel the
disturbance in steady state. This changes our control structure so it
now resembles the following:
We can model the integrator by augmenting our state equations with an
extra state which is the integral of the output. This adds an extra
equation which states that the derivative of the integral of theta is
theta. This equation will be placed at the top of our matrices. The
input, r, now enters the system before the integrator, so it appears
in the newly added top equation. The output of the system remains the
same.
These equations represent the dynamics of the system before the loop
is closed. We will refer to the matrices in this equation as
A_{a}, B_{a}, C_{a}, and D_{a}. We
will refer to the state vector of the augmented system as
x_{a}. Note that the reference, r, does not affect the states
(except the integrator state) or the output of the plant  this is
expected, since there is no path from the reference to the plant
input, u, without implementing the feedback matrix, Kc.
In order to find the closed loop equations, we have to look at how the
input, u, affects the plant. In this case, it is exactly the same as
in the unaugmented equations. Therefore, there is a vector, call it
B_{au}, which replaces B_{a} when we are treating u as
the input. This is just our old B vector with an extra zero added as a
first row. Since u=Kc*x_{a} is the input to the plant for the
closed loop, but r is the input to the closed loop system, the closed
loop equations will depend on both B_{au} and B_{a}.
The closed loop equations will become:
Now, the integral of the output will be fed back, and will be used by
the controller to remove steady state error to a disturbance. We can
now redesign our controller. Since we need to place one closedloop
pole for each pole in the plant, we will place another pole at 300,
which will be faster than the rest of the poles. Since the
closedloop system matrix depends on B_{au}, we will use
B_{au} in the place command rather that B_{a}. Add the
following to your mfile:
Aa=[0 1 0 0
0 0 1 0
0 0 b/J K/J
0 0 K/L R/L];
Ba=[ 1 ; 0 ; 0 ; 0];
Bau=[0 ; 0 ; 0 ; 1/L ];
Ca=[0 1 0 0];
Da=[0];
p4=300;
Kc=place(Aa,Bau,[p1,p2,p3,p4]);
t=0:0.001:.05;
step(AaBau*Kc,Ba,Ca,Da,1,t)
Run your mfile (or just these new lines) and you will get the
following output.
To look at the disturbance response, we apply a similar B matrix as we
did previously when simulating the disturbance response.
step(AaBau*Kc,[0 ; 0 ; 1/J ; 0] ,Ca,Da,1,t)
We can see that all of the design specifications have been met by this
controller.
User Feedback

State Space Examples

Cruise Control 
Motor Speed 
Motor Position 
Bus Suspension 
Inverted Pendulum 
Pitch Controller 
Ball and Beam

Motor Position Examples

Modeling 
PID 
Root Locus 
Frequency Response 
State Space 
Digital Control:RL

Tutorials

Basics 
Modeling 
PID 
Root Locus 
Frequency Response 
State Space 
Digital Control 
Examples
8/22/1997 JL
8/24/1997 WM