Scilab Ninja: Module 6: Discrete-Time Control Systems
Scilab Ninja: Module 6: Discrete-Time Control Systems
1 8
Scilab Ninja
Control Engineering with Scilab
Like
Share
Share
http://scilab.ninja/study-modules/scilab-control-engineering-basics/mod... 11/11/2016
2 8
, where integer
, called the
sampling period. (In some areas of engineering such as communication systems, multi-rate sampling may
exist, but for digital control applications there is no use for such complicated schemes.)
http://scilab.ninja/study-modules/scilab-control-engineering-basics/mod... 11/11/2016
3 8
very well. That is valid. But, well, we tend to forget one thing. The more frequent the
sampling, the more data we have to keep. In a modern desktop PC this does not sound like a problem. But for
embedded control applications, resources are expensive. The memory allocated for data process may be
limited.
Let us investigate what happens if the sampling rate is too low. Figure 3 shows such a scenario. The original
signal we want to sample is
the original. This problem is called aliasing. Another good example of aliasing is when we watch a movie,
sometimes we notice a moving car with its wheels turn in the opposite direction. The film is an image
sampling system. That happens when the frame rate is too slow relative to the angular velocity of the wheel.
http://scilab.ninja/study-modules/scilab-control-engineering-basics/mod... 11/11/2016
4 8
a rational function of a complex variable . Without going into the theory, the point to remember is the unit
delay D transforms to
in the Z-domain.
http://scilab.ninja/study-modules/scilab-control-engineering-basics/mod... 11/11/2016
5 8
(1)
(2)
http://scilab.ninja/study-modules/scilab-control-engineering-basics/mod... 11/11/2016
6 8
Since dscr accepts data in state-space format, the transfer functions must be converted to state-space
descriptions first
-->Pss = tf2ss(P);
-->Css = tf2ss(C);
Note to MATLAB user: Obviously, the dscr command in Scilab is not quite convenient to use compared to
c2d in MATLAB. First, it does not accept data directly in transfer function form. Second, c2d allows you to
select discretization method such as ZOH, FOH, TUSTIN, etc. dscr, on the other hand, simply uses ZOH
method. In case you want the TUSTIN method, there is another Scilab command cls2dls, which uses the same
syntax as dscr. See Scilab help for more detail.
Closed-loop Stability
It is explained in a standard textbook in digital control systems that, generally speaking, the stability region of
a discrete transfer function is inside a unit circle. So we can use this fact to determine whether closed-loop
transfer function in Z-domain is stable or not. From the above plant and controller data already in Scilab
workspace, we form the discrete-time complementary sensitivity transfer function
-->Ld = Cd*Pd;
-->Td = Ld/(1+Ld)
Td =
0.0999933 + 0.0999967z
-----------------------2
0.4678592 - 1.267846z + z
that yields the plot in Figure 6. The poles and zeros are indicated by x and o, respectively.
http://scilab.ninja/study-modules/scilab-control-engineering-basics/mod... 11/11/2016
7 8
I still cannot find a specific command to compute poles from a transfer function. Anyway, with data already
in transfer function form, all we need to do is to compute the roots of denominator polynomial of Td
-->roots(Td.den)
ans =
0.633923 + 0.2569064i
0.633923 - 0.2569064i
http://scilab.ninja/study-modules/scilab-control-engineering-basics/mod... 11/11/2016
8 8
match the sampling time used for descritizing the controller, in this case, 0.01 second. Simply put the
numerator and denominator data of Cd as block parameter.
Supplement
hybridsim.zcos Xcos model example for hybrid simulation (Figure 7)
http://scilab.ninja/study-modules/scilab-control-engineering-basics/mod... 11/11/2016