You are on page 1of 5

CONTROL SYSTEM ANALYSIS WITH MATREMATICA

H A Backer, P W Grant and M Zhuang

1. Introdudion

Although symbolic computation software has been available for many yea#, its application to control
engineering has been rather limited,possibly because the early softwarewas not particularly user-friendly. It
was possible to solve particular problems of considerable complexity using fmt-generation software such as
MACSYMA3, but for the development of general tools the facilities of second-generation software such as
~athematica~ were quired. These facilities now include linkages to software more familiar to the control
engineer, such as M A W 6 , which opens up interesting possibilities of combined symbolic and numeric
softwarefor control.

In this presentation, it is shown that the linkage between Mathematica and MATLAB also allows the graphical
user interface of the associated simulation software SIMULINK to be used as a graphid user interface for
Murhematicu. This facility for defining the dynamic system madels to be analysed by Mahematica has several
s. In particular, the models are constNcted by means of a prehensive and well-
developed graphical interface familiar to the control engineer, and the results of analysis obtained with
Ma?kmatica can be compared directly &th the results of simulation obtained with SIMULDK.

A Mathematics-based toolbox for the analysis and design of linear control systems is then described. It is
shown that both continuous and digital systems may be analysed by Laplace- and z- transforms and that familiar
tools such as root locus-and frequency response-diagrams are also available. Fiially, an application of
Mathematicu to the analysis of nonlinear systems by means of multidimensional transforms is described, and
results presented which by manual methods would take an inordinateamount of timeto obtain.

2.Linking SIMULXNK and Muthemaiicu

The block-oriented graphical representation of dynamic systems used by the simulation software S
provides a basis for a linkage to the symbolic computation software Mathematicu. Any dynamic system
represented in this way may be defined by means of linked lists. A unique number is allocated to eac m
the system and each block operation is then defined by the format {input signd(s), output signal(s), 1-
For example, as shown in Fig. 1, the three block types Sum, Transfer Fcn and Gain are sufficient to define a
simple hear system, with the information to be passed to Mathematica contained in the linked list { { 1,4,2,-},
{ 2,3,G), { 3,4,3/(s2 +lOs)}}. Each system input is provided by an Inport block, and each system output is taken
from an Outport block.

v
3
-
3
SSlOs
Y

I I

Fig.1 SIMULINK diagram of linear system

H.A.Barker, P.W.Grant and M. Zhuang are with the University of Wales Swansea

211
i
i
SIMULINK
Diagram
- - MATLAB
Program
i
:
Mathlink
Program
-** ..
i i
i i
* .
e
a .
.

: Simulation
Results
Analytical
Results - :
i
Mathematica
Program
* ..
*S

i* .
S
Ia
.

.
..

Fig. 2 Software environmeqt linkage

The linkage is controlled by a graphi aser interface developedwith MATLAB facilities. The interface has a
main menu with buttons and pull-down menus to allow SIh4ULm mocJels to be constructed and loaded, inputs
to be specified and outputs to be computed and displayed in symbblic or graphical form.
L

3. Control system toolbox

The Muthematica Control Engineerin&Toolbox was closely m4elled on the eqivalent MATLAB toolkbo~,
with the objective of making the MATLAB toolbox facilities available to Muthemaficu users. At the time of
development, Muthematicu offered b e t q graphical facilities thy MATLAB but in more recent versions the
balance has been restored. A comprehensive package of routines for z and Laplace transforms and inverse
transforms was implemented in the toolkbox, extending considerably the primitive Laplace transform package
supplied with Mathemtica Version 1.2.

Mafhmaticu manipulates its data as mathematical expressions, so transfer functions can be represented in
symbolic form, and there is no need for artificial repFsentations kuch as the use of a pair of coefficient lists to
represent a rational polynomial as in MATLAB. Muthemticu 's pattem matching and transformation rule based
programming facility is used to impletpent the z and Laplace F s f o r m package. For example, part of the
d e f ~ t i o nof the Laplace transform func

( * Laplace Transform for tnn E"ct * )


Laplace[t-"n- -[a- t-],t,,s,] :=
n! / ( (s - a)^n+l ) /; (FreeQ[Cn,a),tl && n > 0 )

Mathematica has many useful plottingkcapabilities and these have been used to provide procedms for
producing Polar plots, Nyquist diagrams, Root locus diagrams, Bode plots and Nichols charts. For example, a
Nichols chart is produced by the following function:

NicholsPlotIfunc-, {win-, yrnax-I, opts-]' :=


Module[ Cy, magnitude, PhaseAngle),
magnitude = Abs[func / . s-> I y1;
PhaseAngle = Arg[func / . s-> I y1;
ParametricPlot [ {PhaseAngle, 20 Log[lO, magnitude] I ,
{y, ymin, *ax) ,Ticks->{PiScal!e, Automatic}, opts,

212
AxesLabel->{"Phase\nangle", "Magnitude\n (db) 11 'I

1 /: NumberQ[NEyminll &6r NumberQ[N[ymaxIl

For the original version of the toolbox, an interface was constructed to a block diagram editor MACCODE
based on the editor in eXCeS8. In MACCODE,the block diagram file is converted into an internal state space
model of a dynamic system, where conversion routines are provided for changing between various
representations. This is somewhat merent from the interface to SIMULINK which is now being used.
Examples of conversion routines are:- ConnectSystem,a comprehensive facility for obtaining a state space
model from a block diagram, Trf2StateSpace a function for converting transfer function models to state
space models and FindTrf a function for obtaining a transfer function between a specified input and output.

Mathemarica has an impressive hypertext notebook interface which allows mixing of text, graphics and input
and output. The packages of the toolbox are stored as five notebooks. These are useful for teaching and
inccnpOrate standard examples for the user to execute, together with pre-processed graphical results.

4. Nonlinear system analysis

In the linkage described in Section 1, the SIMuLINK black types are not restricted to those with simple h
ear
operators. Any operator may be passed to Mathematica, but only those concemed with the subsequent analysis
are relevant. For nonlinear system analysis by multidimensional transforms, two block types with nonlinear
operators, Product and Fcn, may be used in the SIMULINK diagram and recognised by Mathmtica. Fig. 3
shows how a Fcn block may be introduced into the h ear system in Fig. 1 to simulate a nonlinear saturation
characteristic within the range le1 < 1.

El-"
1
U
m -3 -y.+l
lnport
Qrt Sum1 -j SSlOs 4 Outport
Transfer Fcn

Fig. 3 SIMULINK diagram of nonlinear system

For the purposes of analysis, every signal in a nonlinear system is taken to be the sum of a series of components,
each of which is related to a specific order of nonlinearity. A signal v is therefore dehed as

where v,(tl,z2 ,...,t l ) defines the component due to r-th order nonlinearities when z, = tz = ...E z, = t . Only the
component vg, a constant value upon which all other components are superimposed, is nonzero for t 0.

To obtain the transform V of the signal v, a multidimensional transform is applied to each compnemt in Eqn. 1,
to give

v = v, + v,(s)+V,(s1,sz)+ ~ ( S I , S Z , S 3 ) +... (2)

in which the r-th component transform is given by


The input-output relationships for each cif the block types in the SIMULINK diagram may be obtained though
the block diagram algebra of George'. These relationships are then implemented as Mathematicu procedures.

For a Sum block with inputs U and V &e!componentsof the outpbt Y are given by
I

y, (s, ,s, ,...,s, ) = U ,(s, ,s, :..,s, ) + v,(s, ,s, ,...,b, )


(4)

which is implemented as the procedure Add. For a Transfer Fcb block with transfer function W and input U,
the components of the output Y a r e given by
y,(s,,s, ,..., s,)= w(s, + s, + ...+ s,)u,(sI,s2 s,) ,..., (5)
which is implemented as the procedure Tirans, and this is also $he procedure for a Gain block. For a Product
block with inputs U and V the component's e output Yare given by
I 1

which is implemented as the procedure Mu1t . For a Fcn block which the function is the n-th power of the
input U,n - 1 repeated applications of Mu1 t with V = U are implemented as the procedure Power.

'
To obtain manually the relationship beGeen any system output Y and input U,Eqns. 4-6 are first applied to
every block in the system to obtain equations that relate components of the signal transforms. From this set of
equations, the components of Yare then calculated in ascending order until the required order of approximation
is achieved. Calculations of extreme complexity are often needed to obtain components of order greater than
three. In contrast, the components of Y &e obtained quite easily1 in Muthematicu by directly solving the set of
equations simultaneously in the procedure' Nonlinear.
1I
If the input U has only a first-order compdnent U(sI), then the r

Y, (s l , s, ,......,s, ) = w,(SI,s, ,
.
t
i .. ..
s, )U(s,>U(s,). * (7)

where W,(sl ,s, ,......,s,) is the r-th order multidimensional transfer function relating Y, (s, ,s2,__.
..~,
s, ) to U.
This may be made symmetrical in &e arguments by the procedurelsy"etrize.

For example, the multidimensional transfer functions obtained for the system in Fig. 3 are

To obtain manually the actual response to a particular input, the variables in each of the components of Y are
repeatedly associated9, until unidimensidhal t&msforms are obtaihed. In Muthematicu this is accomplished by
the procedure Assocvar. The time response is then obtained by the procedure Timeresp. The harmonic
response is obtained from the multidimensional transfer functions by the procedure Harmonic -
i
/ P

For example, the nonzero components of the response of the system in Fig. 3 to a unit step input are
9 + -e-
1 9r
y,= 1--
8 8
ys=-- 1041
e-' +-
729 e- 31 169 e- 91 + 729 e- 111 e- 191 ; -271
4160 2048 960 10240 10240 79872 e
etc.

Fig. 4 shows y~ and B,together with their sum and a comparison with the total simulated response.

4 ; i a 4 ' 6' 7 . o .l O'


. a OO 1 2 3 4 6 6 7 0 a lo
k.
Fig. 4 Step responses of nonlinear system

Acknowledgements

Part of the work described here is supported by the United Kingdom Engineeriug and Physical Sciences
Research Council

1 R. Pavelle, R. Michael and J. Fitch, Computer Algebra, ScientijicAmerican, 245,1981,136-152.

2 R.Pavelle and P.S. Wang, Macsyma from F to G, J. SymboZic Computation, 1, 1985,69-100.


3 H.A. Barker and Y.W. KO,The application of a computer algebra system to the analysis of a class of
nonlinear systems, Proceedings of the IFAC Symposium on Nonlinear Control Systems Design, Capri, 1989,
88-93.

4 S. Wolfram, Mathematica: a systemfor doing mathematics by computer, Addison-Wesley, Reading, 1988.

5 A.M.K. Shouaib, P.W. Grant and C.P. Jobling, A control engineering toolkit for Mathematica on the
Macintosh, Digest of the IEE Colloquium on ComputerAided Control Systems Design, Algorithms, Packages
and Environments, London, 1992.

6 MATLAB User's Guide, The Mathworks, Natick, 1992.

7 SIMULINK User's Guide, The Mathworks, Natick, 1992.

8 HA.Barker, M. Chen, P.W. Grant, I.T.Harvey, C.P. Jobling, A.P. Parkman and P. Townsend, eXCeS - an
environment for building and managing dynamic system models, Proceedings of the ZEE Colloquium on Model
Building Aidsfor Dynamic System Simulation, Warwick, 1991.

9 D.A.George, Continuous nonlinear systems,MlT Research Laboratory of Electronics Report 355,1959.


0 1996 The institution of Electrical Engineers.
Printed and publishedby the IEE, Savoy Place, London WCBR OBL. UK.

You might also like