ENSC 383
Simulink Tutorial
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 1
ENSC 383
Introduction to Simulink
Simulink is a platform for multidomain simulation and Model-Based Design of dynamic systems. An interactive graphical environment and a customizable set of block libraries. Design, simulate, implement, and test control, signal processing, communications, and other time-varying systems.
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 2
ENSC 383
Introduction to Simulink
Add-ons, Matlab for algorithm development, data visualization, data analysis and access, and numerical computation. How to start Simulink ? Matlab Command Window >>simulink click on the Simulink icon specify an existing Simulink file
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 3
ENSC 383
Simulink - Example Differential block & Integral block
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 4
ENSC 383
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 5
ENSC 383
Simulink block library
Continuous Discontinous Discrete Math Operations Signal routing Sinks Sources Other blocksets
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 6
ENSC 383
Editting the Diagram - Demo
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 7
ENSC 383
Model Parameters
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 8
ENSC 383
Simulation Parameters
The default simulation time units are seconds. Set the simulation start time to `0' (zero) and the stop time to `10' Since the Square Wave block is set to produce a 1/2 Hertz signal, this setting will produce 5 complete square wave periods. For the Solver and Output options, leave the default settings shown in the figure below.
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 9
ENSC 383
Simulink example - 2
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 10
ENSC 383
Levels of Use
Simulation from the menu bar
interactive, simple to use, quick to learn, provide fast result simulink
Simulation from command line
Result into Matlab workspace, built-in graphics tools set_param('OBJ','PARAMETER1',VALUE1,'PARAMETER2',VA LUE2,...)
Access a models S-function directly
flexible, complex Model. Compiler to generate Simulink C MEX S-functions.
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 11
ENSC 383
And More
Model Parameters ODE Solvers
Ode23() Ode45()
Connect with
Labview, C/C++ C MEX files.
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 12
ENSC 383
MATLAB - Reference:
MATLAB/SIMULINK Resources
http://www.eng.fsu.edu/~cockburn/matlab/matlab_help.html
Mathworks Simulink
http://www.mathworks.comproducts/simulink/
Course Website
http://www.ensc.sfu.ca/research/idea/courses/ENSC383_05_outli ne.htm
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 13
ENSC 383
Some Functions
zpk - Create a zero/pole/gain model. tf - Create a transfer function model. pole, eig - System poles step - Step response. impulse - Impulse response. lsim - Response to arbitrary inputs. ltiview - Response analysis GUI. bode - Bode plot of the frequency response. nyquist - Nyquist plot. rlocus - Evans root locus
Guangqing JIA, William A. GRUVER Simon Fraser University P. 14
ENSC 383
The END!
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 15
ENSC 383
Problem Tutorial 2.30b
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 16
ENSC 383
Problem 2.30 The original system
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 17
ENSC 383
Problem 2.30
The original system
The Modified system
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 18
ENSC 383
Problem 2.30
Defining:
1 (s) 2 (s) 3 (s) 4 (s) 5 (s)
= rotation of = rotation of = rotation of
J1 K 1 and D1 J2
= rotation between
= rotation of right-hand side of
K2
J3
P. 19
Guangqing JIA, William A. GRUVER
Simon Fraser University
ENSC 383
Problem 2.30
( J1s + K1 )1 ( s ) K1 2 ( s ) = T ( s )
2
K11 ( s ) + ( D1s + K1 ) 2 ( s ) D1s 3 ( s ) = 0 D1s 2 ( s ) + ( J 2 s 2 + D1s + K 2 ) 3 ( s ) K 2 4 ( s ) = 0 K 2 3 ( s ) + ( D2 s + K 2 + K 3 ) 4 ( s ) ( D2 s + K 3 ) 5 ( s ) = 0 ( D2 s + K 3 ) 4 ( s ) + ( J 3 s 2 + D2 s + K 3 ) 5 ( s ) = 0
Guangqing JIA, William A. GRUVER P. 20
Simon Fraser University
ENSC 383
Problem 2.30
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 21
ENSC 383
The END!
Guangqing JIA, William A. GRUVER
Simon Fraser University
P. 22