Vous êtes sur la page 1sur 5

Simulink is a block-orientated program that allows the simulation of dynamic systems in a block diagram format whether
they are linear or nonlinear, in continuous or discrete forms.
Start the School of Engineerings version of Matlab [note that the Faculty version of Matlab does not support
In the MATLAB command window, type simulink <CR> [<CR> means press the enter key]
The following window should now appear

Select File-New-Model from the menu bar of this window. The following window should now appear.

## This window represents a blank worksheet where systems can be simulated.

There are two major classes of items in Simulink: blocks and lines. Blocks are used to generate, modify, combine, output,
and display signals. Lines are used to transfer signals from one block to another.
Blocks

## There are several general classes of blocks:

Sources: Used to generate various signals
Sinks: Used to output or display signals
Discrete: Linear, discrete-time system elements (transfer functions, state-space models, etc.)
Linear: Linear, continuous-time system elements and connections (summing junctions, gains, etc.)
Nonlinear: Nonlinear operators (arbitrary functions, saturation, delay, etc.)
Connections: Multiplex, Demultiplex, System Macros, etc.
Blocks have zero to several input terminals and zero to several output terminals. Unused input terminals are indicated by a
small open triangle. Unused output terminals are indicated by a small triangular point. The block shown below has an
unused input terminal on the left and an unused output terminal on the right.

Lines
Lines transmit signals in the direction indicated by the arrow. Lines must always transmit signals from the output terminal
of one block to the input terminal of another block.
Exercise 1
In this example we will demonstrate what Simulink is capable of by simulating the motion of a car. The forces acting on a
car are illustrated below:

bv
(friction)

f
(force)
m
(mass)

v
(velocity)

In this example we are interested in analysing the relationship between the force applied to the car, f, and the resultant
velocity, v, of the car. The relationship between force and velocity is given below:

dv
= f bv (1)
dt

## where m = 1000 kg and b = 50 Ns/m

Although it is possible to model the above system in Simulink directly, it is simpler if we convert the system into the
Laplace domain. Transforming equation (1) gives the following:

dv
+ bv = f
dt
msV ( s) + bV ( s) = F ( s )
1000sV ( s ) + 50V ( s ) = F ( s)
m

V ( s)
1
=
F ( s ) 1000 s + 50
To provide a simpler analysis we tend to write 1st order dynamic equations in the general form of:

OUTPUT
K
=
INPUT
Ts + 1
Therefore:

1
V (s)
= 50
F ( s ) 20 s + 1
We will now find out what happens when we increase the force applied to the car from 0 N to 500 N. To do this we will
1.

2.

3.

4.

5.
6.

From the SIMULINK window, click on the Sources folder and use the mouse to drag the Step block to the new workspace window.
The step will represent the force that is applied to the car. Double clicking on the Step block in the new workspace allows the initial
and final values of the step change and the time of the step change to be specified. Select a Select a step time of 10, an initial value of
0 and a final value of 500. Ignore the sample time. This will introduce a step change in the force at a time of 10 seconds.
Click on the Linear folder, in the SIMULINK window, and use the mouse to drag the Transfer Fcn block to the workspace
window. Double click on this block and enter the numerator and denominator coefficients which represent the system defined above,
i.e. the numerator should be equal to [1/50] and the denominator should be [20 1]. The coefficients are entered in descending powers
of s (make sure that you leave in the square brackets). Click on OK when the coefficients have been entered.
Click on the Sinks folder and drag a scope into the workspace. Your workspace should now look like this:

To represent the signal flow, the mouse is used to draw a line from the output of any block to the input of any other block. Simply
click the left mouse button on the output of any block (i.e. the > sign on the right-hand side of the block), keep the mouse button
pressed and move the cursor to the input of the required block (i.e. the > sign on the left-hand side of the block). An arrow will
appear to show the direction of the signal flow. Position the blocks in the workspace and connect up the required blocks so that the
following system is formed:

Note that if your arrows do not appear with the pointy end in bold, i.e. you get a
, rather than a
then they have not
connected to the block correctly. Click on the line to select it again and then press the delete key on the keyboard and try again.
Select Simulation-Simulation Parameters in the workspace menu bar. A new window should now appear. This window
allows you to change some of the mathematical options within Simulink (its best to ignore most of it). In the stop time, enter a value
of 100 and then click on OK.
In the workspace window double click on the scope block (a new graph window, the scope window, should appear). Now click on
) in the workspace window. You will notice that a line has been plotted on the scope window. Go to this
the play button (
window and click on the binocular icon. This graph shows how the velocity of the car will change with time as the force is applied
and should be the same as the graph below. Does it look reasonable, i.e. does the velocity change as you would expect?

7.

The simulink model can be saved by selecting file-save as from the workspace menu bar.

Optional Section
It was stated earlier that the simulink model could have been developed directly from the differential equation in the time domain. The
figure below illustrates the simulink model for such a system.

In this diagram, the inertia and damping are gain blocks (located in the math folder). The damping block has been flipped around. To flip
a block, right click on it and then select format-flip block from the pull down menu. The text for each of the blocks can be edited
by simply clicking on the text and entering whatever you like.

Exercise 1
In this exercise we will develop a simple control system that will regulate the velocity of the car. To do this construct the following
system:

This time labels have been placed on the worksheet you do not need to put these on yourself. The set-point is a step block which
represents the required velocity of the car. In this example the step block should be configured as follows: Step Time: 10, Initial Value: 0,
Final Value: 10. This implies that between time 0 and 10 seconds, we want the velocity of the car to be 0 m/s. After 10 seconds we want
the velocity of the car to be 10 m/s. The summation block can be found in the math folder. This block should be configured so that the list
of signs is |+-. The controller is simply a gain block this means that its output is equal to the input multiplied by the value of the gain.
The gain block is also available in the math folder. For this block, set the gain to be equal to 1. To draw the feedback loop, right click the
line that links the Dynamics of the car block to the velocity block and drag the mouse to link with the input to the summation block.
Double click the velocity block and start the simulation (click the play button). You should get the following graph:

The controller in this example is what is known as a proportional controller. This is because the output of the controller is proportional
to its input, i.e. output = K * input , where K is the gain of the controller. The controller clearly isnt very good since we want the
velocity to increase to 10m/s and the controller has caused the velocity to increase, but only to 0.2 m/s.

Problem 1
Increase the value of the gain and analyse the response of the system. What observations can you make?