Professional Documents
Culture Documents
دورة المحاكاة بإستخدام السميولينك SIMULINK
دورة المحاكاة بإستخدام السميولينك SIMULINK
SIMULINK
SIMULINK
Subsystems
simulink Debugger
Simulink Accelerator
S-function
S-function M-files
S-function C++ codes
SIMULINK
: Simulink
Simulink
.
simulink
simulink
.
SIMULINK Model-Based Design
nonlinear
.
Demo
.
simulink graphical user interface
)(GUI
S-function .
simulation
simulation non-real time
real time
Xpc Target Real Time Workshop .
Simulation
Simulation
Toolboxs .
: Building a Model
signal generator
signals
square wave.
Transfer function
Scope
Simulation
Mux block
signal scope
:
::
simulink
:
>>simulink
Signal generator
simulink
sources
signal generator
: scope
1 simulink 2 sinks3 scope
: transfer function
simulink
continuous
transfer function
:: Mux block
simulink
Signal Routing
Mux
::
::
node
ctrl
.
:
+
+
.
Configuring the Model
Transfer function
Simulation
simulation 10
: start simulation :
start simulation double click Scope
Simulation square
wave 10
:
.
.
Block Diagram
(nonvirtual block and virtual blocks) .
.
States
states : Discrete continuous
.
intervals .
States
continuous states :
Integrator
State-Space
State-Space
Transfer Fcn
transfer function
Zero-Pole
transfer function
zero-pole-gain S .
Continuous States
.
.
Discrete States
update functions
.
Modeling Hybrid Systems
.
Block Parameters
Parameter
Parameters .
.
A tunable parameter
recompiling
parameters .
.
An implicit discrete sample time
.
Systems and Subsystems
subsystem
virtual and nonvirtual
Subsystems
.
Block Methods
:
Outputs
Update
Derivatives
::
BlockType.MethodType
Start Simulation
Model Compilation
executable form
:
1 block parameter expressions
2 3 attribute propagation
4 optimizations
5 hierarchy
6 block sorted order
7 Sample Time
: Link Phase
: Simulation Loop Phase
:
1- Loop Initialization phase
2- Loop Iteration phase
1 2-
3 zero-crossing detection
( (
4 .
successive states
solvers
1- Fixed-step solvers
step
size step size .
2- Variable-step solvers
.
Solvers
1- Continuous solvers
.
2- Discrete solvers
Zero-Crossing Detection
.
.
.
Algebraic Loops
direct feedthrough
:
The Math Function block
The Gain block
The Integrator block's initial condition ports
The Product block
z = u z z = u/2
Algebraic Constraint
algebraic loop
) (sampled data (multirate
)systems - ) (hybrid systems ::
step size
sample time hits
fundamental sample time
fundamental sample time sample time:
sample times 0.25 0.5
fundamental sample time 0.25
solver
variable-step discrete
fixed-step
fixed-step simulation step size fundamental sample time
variable-step solver step size sample time
hits.
:
::
gain
::
1 2
::
::
1 parameters nontunable2 ) (inf .
Tunable Parameters
Sample Time Propagation
::
.mdl
::
Model Editor
::
1- Menu Bar
2- Toolbar
3- Canvas
block diagram
4- Status Bar
Format
Port/Signal Displays
ode45
ode3
:: M-file
:
function new_model(arab_eng)
% NEW_MODEL Create a new, empty Simulink model
% NEW_MODEL('MODELNAME') creates a new model with
% the name 'MODELNAME'. Without the 'MODELNAME'
% argument, the new model is named 'my_untitled'.
% the model name is arab_eng
if nargin == 0
arab_eng = 'arab_eng';
end
% create and open the model
open_system(new_system(arab_eng));
% set default screen color
set_param(arab_eng, 'ScreenColor', 'blue');
% set default solver
set_param(arab_eng, 'Solver', 'ode3');
% set default toolbar visibility
set_param(arab_eng, 'Toolbar', 'off');
% save the model
save_system(arab_eng);
Format Foreground color
Background color Screen color
set_param
RGB
::
::
:
Sample Time
Annotating
Annotation
Properties ::
M function Annotation
1 annotation Enable
TeX Commands ::
TeX
::
\alphara\beta-\iteng
Creating Subsystems
simulink & ports
subsystems subsystem ::
::
::
input
outport
::
::
create subsystem
::
Go To Parent
::
Window Reuse
File Preferences Window reuse
type ::
::
::
Read/Write permissions
ReadOnly
NoReadOrWrite
ReadWrite
control signal
Enabled Subsystems
Triggered Subsystems.
Triggered and Enabled Subsystems
A control flow subsystem
::
::
Enable block ::
Triggered Subsystems
Trigger
trigger input
Trigger
Rising
Falling
Either
:
trigger .
trigger R F
3 trigger
ports & subsystems
trigger
:
trigger
:
triggered subsystems
enabled subsystems
Function-Call Subsystems
S-function
.
::
Trigger
) (-1
.
::
trigger
::
::
sine wave trigger step
input
.
pulse 10
50% duty cycle
enable
trigger
sine trigger
.
full-wave rectifier
:
::
simulation format
Block displays
sorted order ::
simulation
:
X:Y
X layer
X=0
Y :
Pulse generator
constant subsystem gain scope X
Y
1- Pulse generator
2- constant
3- subsystem
4- gain
5- scope
subsystem } 0:2{1
::
1:0
subsystem
Subsystem parameters
Propagate execution context across subsystem boundary
gain
:
constant gain
1- constant
2- subsystem
3- gain
Conditional Execution Behavior
CE behavior
execution context
.
execution context .
execution context
:
1 2
3 testpoint
4 execution context
5 multirate block6 sample time execution context
execution context
Switch
execution context
.
:: conditional
execution behavior
Configuration Parameters Optimization
Conditional input branch execution
::
Propagate execution context across subsystem boundary
triggered subsystem
subsystem's execution context
Propagate
execution context
format Block Displays
Execution Context Indicator
Referencing Models
.
model
simulink
.
3- Incremental loading
.
4- Incremental code generation
Real-Time Workshop
stand-alone applications binaries
binaries .
Subsystems Model Referencing
.
Model Reference
Creating a Model
Reference
set path
::
Inline parameters optimization
simulation
configuration parameters
optimization Inline parameters
model
ref1 :
model
::
ref1
solver
Fixed step
edit model reference parameters
step scope
::
global tunable parameters
global tunable parameters.
.
model workspace ::
workspace
workspace add MATLAB
variable
counter
1
::
Model Arguments
::
::
counter
!
Model Block Sample Times
simulation target
1 ) )2 3 4 fixed-step solver fixed step size5 sample time propagation triggered sample
time
6
Triggered subsystem
Function call
iterator subsystem
.
Blocks That Preclude Sample-Time Inheritance
simulation target
simulation target
default
Discrete-Time Integrator
)From Workspace (if it has input data that contains time
)Probe (if probing sample time
Rate Limiter
Sine Wave
::
model
Referenced Model I/O
model:
Bus I/O Limitations
bus
1 bus object2 bus object workspace
3 bus Bus Creator blockIndex I/O Limitations
:
0 - or 1- based indexing
for
:
0- or 1-based indexing
Matching I/O Rates
rate
Building Simulation Targets
Simulation Targets S-function
simulation targets
updating the model's diagram edit slbuild .
.
targets
.
slprj
Simulink Accelerator Real-Time Workshop
Function-Call Models
Function-Call Generator
function-call model.
trigger trigger function
call Model
function call controller
ports & subsystem
model
simulation configure parameters
solver fixed step
Periodic sample time constraint
Ensure sample time independent
scalar
:
view_mdlrefs