Module 5.scilab
Module 5.scilab
Module 5.scilab
1 7
Scilab Ninja
Control Engineering with Scilab
Like
Share
Share
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.
* 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
(1)
To simplify the notation, the time dependent is omitted. Define the system states as the joint position and
velocity
http://scilab.ninja/study-modules/scilab-control-engineering-basics/mod... 11/11/2016
2 7
(2)
By using these state variables, (1) can be rewritten as a system of first order differential equations
(3)
or in matrix form as
(4)
(5)
(6)
(7)
where
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
(8)
To convert between state space and transfer function in Scilab, use commands ss2tf and tf2ss. For example,
for a plant transfer function
-->s=poly(0,'s');
-->P = 1/(s^2+s)
P =
1
----2
s + s
http://scilab.ninja/study-modules/scilab-control-engineering-basics/mod... 11/11/2016
3 7
-->Pss.A
ans =
0.
1.
0. - 1.
-->Pss.B
ans =
0.
1.
-->Pss.C
ans =
1.
0.
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
matrix.
to the plant input. So, for a set of specifed closed-loop poles, the design goal is to compute
. To see this more clearly, assume the command input is zero. We have at the plant input
(9)
and the closed-loop state equation
(10)
The closed-loop poles can be computed from
(11)
Meanwhile, specifying the closed-loop poles
http://scilab.ninja/study-modules/scilab-control-engineering-basics/mod... 11/11/2016
4 7
(12)
Hence, we can compare (11) and (12) to solve for
, given the
matrices and a
(13)
with poles at
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
http://scilab.ninja/study-modules/scilab-control-engineering-basics/mod... 11/11/2016
5 7
,and at
the result is
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.
http://scilab.ninja/study-modules/scilab-control-engineering-basics/mod... 11/11/2016
6 7
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
http://scilab.ninja/study-modules/scilab-control-engineering-basics/mod... 11/11/2016
equals
. So a gain of
7 7
, 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.
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
1. V.Toochinda. Robot Analysis and Control with Scilab and RTSX. Mushin Dynamics, 2014.
http://scilab.ninja/study-modules/scilab-control-engineering-basics/mod... 11/11/2016