Introduction to Simulink - Otto-von-Guericke

advertisement
Otto-von-Guericke-Univ. Magdeburg
Vorlesung « Messtechnik »
What is Simulink? (1/2)
¾Simulink : is an extension (toolbox) of Matlab, and must
therefore be started from the Matlab prompt >>
Introduction to Simulink
¾Allows to access all the instructions of Matlab, but adds on
top of it a wealth of specific tools to simulate and control in a
realistic manner dynamic systems
Dominique Thévenin, Gábor Janiga
¾Simulink is found at many universities but also in industrial
companies (real-time control, determination of working
parameters for Engines or Gas Turbines...)
Lehrstuhl für Strömungsmechanik und
Strömungstechnik (LSS)
¾This is only the shortest possible introduction, please consult
the documentation for more details!
thevenin@ovgu.de, janiga@ovgu.de
1
What is Simulink? (2/2)
¾Simulink can be used to carry out virtual experiments, for
example to prepare later experiments; or to acquire real
experimental data, like LabView (Real-Time Toolbox needed). 2
Working with Simulink (1/3)
¾Simulink uses a (graphical) representation based on blockdiagrams to describe dynamic (i.e. time-dependent) systems
¾To launch Simulink, just enter under the prompt Matlab >>
Î simulink
¾Any group of components can be associated and become a
single element, that can be used in further assemblies
Î in File menu, click New/Model to obtain a new work
window
¾For this purpose, inputs and outputs must be clearly defined
Î in the window Simulink you will find a quantity of
predefined working blocks
¾To get a first impression of Simulink, enter under the Matlab
prompt >> f14 (script f14.m is predefined):
Î click on individual blocks to open and explore sub-blocks
Î double-click e.g. on Sources: this opens a separate
window containing many standard « source » blocks, for
example signal generators
Î observe the connection between stick, incidence angle (in
radian) and acceleration on the pilot
Î choose e.g. the block Signal Gen by selecting it and
drawing it to your work window (Untitled)
Î to run: open the oscilloscopes, and click Simulation/Start3
Î in this way, you obtain an active copy of Signal Gen
Î this is a quite extensive model of a US-fighter F14
Working with Simulink (2/3)
Working with Simulink(3/3)
Î open the block Sinks (reception/acquisition of signals) :
opens a window containing many standard blocks useful to
get/acquire a signal and possibly represent the data
graphically in real-time
¾All block parameters can be controlled or modified by opening
the block (double-click or command bar)
¾ test Signal Gen and Scope
¾The axis extension of the Scopes can be modified by rightclicking on it
Î choose e.g. Scope (a standard oscilloscope) by selecting
it, and draw it to your work window
¾The parameters of the dynamic simulation can be modified
under the menu Simulation/Configuration Parameters
Î by clicking in the work window (Untitled) using the left
mouse button, you can connect the output of Signal Gen
to the input of Scope
¾You can save your work using the menu File/Save, using a
name terminated by .mdl (e.g. simplesimk.mdl)
Î open the oscilloscope by double-click
¾This "script" can now directly be executed under Matlab (no
need to start Simulink), or can be re-opened and modified under
Simulink using the menu File/Open
Î launch Simulation (default parameters) by clicking on
Simulation/Start
Î Start becomes Stop (for breaking the Simulation)
4
5
6
1
Hands-on simk1
Hands-on simk2
¾Amplify the signal coming out of a generator and visualize the
original and the amplified signal (look under Math
Operations) simultaneously using two scopes. Test different
gains and check result.
right mouse button to split
Signal
scope 1
generator
¾Same purpose, but using this time a single scope and a
multiplexer (Mux, predefined in the Signal Routing library).
signal
generator
multiplexer
scope
scope 2
amplificator
with variable gain
amplificator
with variable gain
7
Hands-on simk3
Matlab function
¾Same as previous but saving all the acquired data in a file for
later analysis (use predefined block To File in Sinks). Check
content of multi-column file. Check and modify simulation
parameters (accuracy, discretization step)!
signal
generator
8
multiplexer
¾Similarly to the Matlab scripts, it is also possible to define
Matlab functions, involving a certain number of inputs and
outputs
¾These inputs and outputs are usually gathered in a single
vector
¾ Example for a basic function delivering output=2*first
argument-second argument
scope
function [result]=linear(arg1, arg2)
to file
result=2.*arg1-arg2;
end
amplificator
with variable gain
9
Matlab function in Simulink
Virtual experiment
¾Any Matlab function can be directly integrated into a Simulink
script (use predefined block Matlab function). To input or
output vectors, use multiplexer/demultiplexer
signal
generator
multiplexer
multiplexer
Constant
=3
¾The script name must be the same as the function name, also
here linear.m
10
¾In this final hands-on, you will develop by yourselves a
complete, virtual experiment
¾First, study with attention the distributed document: it is vital for
the success of your project!
¾Ask for support if needed, but AT LEAST when you have
obtained the coefficients of the matrix system to solve...
scope
Enjoy!
to data file
function
Matlab function
linear
11
12
2
Download