You are on page 1of 102

MATLAB

level 2
By
Ahmad A.Elhakeem Moustafa
Alexandria University
Faculty of Engineering
Electrical Engineering Department
Pow er Section

SIMULINK
1. Introduction
i.
ii.

Why SIMULINK?
Opening SIMULINK

2. The commonly used blocks


3. Additional blocks
4. SimPowerSystems toolbox
i.
ii.
iii.
iv.
v.

5.

Building and Simulating a Simple Circuit


Basic Principles of Connecting Capacitors and Inductors
Separately excited DC machines modeling
Machines simulation
Power electronics simulation

Control
i.
ii.

PID controller
DC motor speed modeling in SIMULINK

SIMULINK

Introduction:
Why SIMULINK?
o We will answer with this example.
o Example (consider the following circuit):

o With zero initial inductor current & 0.5 V initial capacitor voltage.

SIMULINK

Introduction:
Why SIMULINK?

o So the SIMULINK will help you to analyze it easily.


o But how?
i.
ii.
iii.

Using SimPowerSystems toolbox.


Modeling its differential equations.

SIMULINK

Introduction:
Why SIMULINK?
o Using SimPowerSystems toolbox.
o Build your model.

o See the results.

SIMULINK

Introduction:
Why SIMULINK?
o Modeling its differential equations.
o Build your model.

o See the results.

SIMULINK

Introduction:
Why SIMULINK?

Is it important ?!!

SIMULINK

Introduction:
Opening SIMULINK
o Open MATLAB
o On the MATLAB screen select SIMULINK or write
simulink in the command window.

o You will see the Simulink Library Browser.

SIMULINK

Introduction:
Opening SIMULINK
o Press new to open a new page to start your
simulation.

o Select your blocks from the Simulink Library


Browser.

SIMULINK

The commonly used blocks


The library contains the shown:

SIMULINK

The commonly used blocks


1) The Inport, Outport, and Subsystem Blocks

Example:

See the previous example:

SIMULINK

The commonly used blocks


1) The Inport, Outport, and Subsystem Blocks

Example:

Group all blocks without Step & Scope blocks and right
click on them then select Create Subsystem.

SIMULINK

The commonly used blocks


1) The Inport, Outport, and Subsystem Blocks

Example:

Double click on the Subsystem block.

SIMULINK

The commonly used blocks


2) The Ground Block

used to connect blocks whose input ports are not connected


to other blocks.

3) The Terminator Block

used to cap blocks whose output ports are not connected to


other blocks.

SIMULINK

The commonly used blocks


4) The Constant and Product Blocks

The Constant block is used to define a real or complex


constant value.
The Product block performs multiplication (*) or division (/) of
its inputs.
Example

SIMULINK

The commonly used blocks


5) The Scope ,Bus Creator and Bus Selector Blocks

The Scope block displays waveforms as functions of


simulation time.
Bus Creator blocks to create signal buses and Bus Selector
blocks to access the components of a bus.

SIMULINK

The commonly used blocks


5) The Scope ,Bus Creator and Bus Selector Blocks
Example

SIMULINK
The commonly used blocks
5) The Scope ,Bus Creator and Bus Selector Blocks
Sin wave 1*sin(2t)

The integral of the sine wave appears with a DC component


of value 0.5 being added to it.

SIMULINK

The commonly used blocks


5) The Scope ,Bus Creator and Bus Selector Blocks
Note for the Scope
Output is limited to the last 5000 point by default

Data could be sent to workspace (put it in a variable).

SIMULINK

The commonly used blocks


6) The Mux and Demux Blocks

Mux block combines its inputs into a single output.


Demux block extracts the components of an input signal and
outputs the components as separate signals.

SIMULINK

The commonly used blocks


6) The Mux and Demux Blocks
Example

SIMULINK

The commonly used blocks


7) The Switch Block

The Switch block will output the first input or the third input
depending on the value of the second input .

SIMULINK

The commonly used blocks


8) The Sum Block

This block performs addition or subtraction on its inputs.

9) The Gain Block

The Gain block multiplies the input by a constant value


(gain).

SIMULINK

The commonly used blocks


10) The Relational Operator Block

The Relational Operator block performs the specified


comparison of its two inputs.

11) The Logical Operator Block

The Logical Operator block performs the specified logical


operation on its inputs.

SIMULINK

The commonly used blocks


12) The Saturation Block

The Saturation block establishes upper and lower bounds for


an input signal.
Example

SIMULINK

The commonly used blocks


13) The Integrator Block

The Integrator block integrates its input and it is used with


continuoustime signals.
Configuration parameters

SIMULINK

The commonly used blocks


13) The Integrator Block
Configuration parameters

Reset condition
Enable external source
for initial condition
Initial condition value
Output saturation
configuration

SIMULINK

The commonly used blocks


14) The Unit Delay Block

The Unit Delay block delays its input by the specified sample
period.
Example

SIMULINK

The commonly used blocks


14) The DiscreteTime Integrator Block

The DiscreteTime Integrator block allows us to:


Define initial conditions (internal or input).
Define an input gain (K) value.
Output the block state.
Define saturation values.
Reset input.

SIMULINK

The commonly used blocks


15) Data Types and The Data Type Conversion Block

Builtin data types supported by SIMULINK

SIMULINK

The commonly used blocks


15) Data Types and The Data Type Conversion Block

The Data Type Conversion block converts an input signal of


any SIMULINK data type to the data type
Example

SIMULINK

Additional blocks
The StateSpace Block (Continuous library)

The StateSpace block implements a system defined by the


statespace equations.

SIMULINK

Additional blocks
The Transfer Fcn Block (Continuous library)

The Transfer Fcn block implements a transfer function.

SIMULINK

Additional blocks
The ZeroPole Block (Continuous library)

The ZeroPole block implements a system with the specified


zeros, poles, and gain in the sdomain.

SIMULINK

Additional blocks
The Saturation Dynamic Block (Discontinuous library)

The Saturation Dynamic block bounds the range of the input


signal to upper and lower saturation values.

SIMULINK

Additional blocks
The Dead Zone Block (Discontinuous library)

The Dead Zone block generates zero output within a


specified region, called its dead zone.
Example (dead zone 0.5 , -0.5)

SIMULINK

Additional blocks
The Dead Zone Dynamic Block (Discontinuous
library)

The Dead Zone Dynamic block dynamically bounds the


range of the input signal, providing a region of zero output.

SIMULINK

Additional blocks
The Rate Limiter Block (Discontinuous library)

The Rate Limiter block limits the first derivative of the signal
passing through it.
Example

SIMULINK

Additional blocks
The Quantizer Block (Discontinuous library)

The Quantizer block passes its input signal through a


stairstep function.
Example

SIMULINK

Additional blocks
The Hit Crossing Block (Discontinuous library)

The Hit Crossing block detects when the input reaches the
Hit crossing offset
Example

SIMULINK

Additional blocks
The Integer Delay Block (Discrete library)

The Integer Delay block delays its input by N sample periods.


Example

SIMULINK

Additional blocks
The Discrete Transfer Fcn Block (Discrete library)

The Discrete Transfer Fcn block implements the Ztransform


transfer function.

SIMULINK

SimPowerSystems toolbox
Building and Simulating a Simple Circuit:
Simulate the following circuit:

SIMULINK

SimPowerSystems toolbox
Building and Simulating a Simple Circuit:
Simulate the following circuit:

SIMULINK

SimPowerSystems toolbox
Building and Simulating a Simple Circuit:
Simulate the following circuit:

SIMULINK

SimPowerSystems toolbox
Building and Simulating a Simple Circuit:
Simulate the following circuit:

SIMULINK

SimPowerSystems toolbox
Building and Simulating a Simple Circuit:
Simulate the following circuit:

SIMULINK

SimPowerSystems toolbox
Building and Simulating a Simple Circuit:
Simulate the following circuit:

SIMULINK

SimPowerSystems toolbox
Building and Simulating a Simple Circuit:
Simulate the following circuit:

SIMULINK

SimPowerSystems toolbox
Building and Simulating a Simple Circuit:
Simulate the following circuit:

SIMULINK

SimPowerSystems toolbox
Building and Simulating a Simple Circuit:
Simulate the following circuit:

SIMULINK

SimPowerSystems toolbox
Building and Simulating a Simple Circuit:
Simulate the following circuit:

SIMULINK

SimPowerSystems toolbox
Building and Simulating a Simple Circuit:
Simulate the following circuit:

SIMULINK

SimPowerSystems toolbox
Building and Simulating a Simple Circuit:
Simulate the following circuit:

SIMULINK

SimPowerSystems toolbox
Basic Principles of Connecting Capacitors and
Inductors:
A voltage source to be connected in parallel with a capacitor.

SIMULINK

SimPowerSystems toolbox
Basic Principles of Connecting Capacitors and
Inductors:
A voltage source to be connected in parallel with a capacitor.
Add a small resistance in series between the voltage
source and the capacitors.

SIMULINK

SimPowerSystems toolbox
Basic Principles of Connecting Capacitors and
Inductors:
A current source to be connected in series with an inductor.

SIMULINK

SimPowerSystems toolbox
Basic Principles of Connecting Capacitors and
Inductors:
A current source to be connected in series with an inductor.
Add a large resistance in parallel with the inductor.

SIMULINK

SimPowerSystems toolbox
Separately excited DC machines modeling
Method(1) (open loop)

SIMULINK

SimPowerSystems toolbox
Separately excited DC machines modeling
Method(2) (open loop)

SIMULINK

SimPowerSystems toolbox
Separately excited DC machines modeling
Closed loop

SIMULINK

SimPowerSystems toolbox
Machines simulation

SIMULINK

SimPowerSystems toolbox
Machines simulation
DC machines

SIMULINK

SimPowerSystems toolbox
Machines simulation
DC machines

SIMULINK

SimPowerSystems toolbox
Machines simulation
DC machines

SIMULINK

SimPowerSystems toolbox
Machines simulation
DC machines

SIMULINK

SimPowerSystems toolbox
Machines simulation
DC machines
Starting using starting resistances

SIMULINK

SimPowerSystems toolbox
Machines simulation
DC machines
Starting using starting resistances

SIMULINK

SimPowerSystems toolbox
Machines simulation
DC machines
Starting using starting resistances

SIMULINK

SimPowerSystems toolbox
Machines simulation
AC machines
Induction machines

SIMULINK

SimPowerSystems toolbox
Machines simulation
AC machines
Synchronous machines

SIMULINK

SimPowerSystems toolbox
Power electronics simulation
Single phase half wave rectifier (uncontrolled)

SIMULINK

SimPowerSystems toolbox
Power electronics simulation
Single phase half wave rectifier (uncontrolled)
With a FWD

SIMULINK

SimPowerSystems toolbox
Power electronics simulation
Single phase half wave rectifier (uncontrolled)
Without a FWD

SIMULINK

SimPowerSystems toolbox
Power electronics simulation
Single phase half wave rectifier (controlled)

Firing control
Firing angle

SIMULINK

SimPowerSystems toolbox
Power electronics simulation
Single phase half wave rectifier (controlled)
For alpha=0

SIMULINK

SimPowerSystems toolbox
Power electronics simulation
Single phase half wave rectifier (controlled)
For alpha=45

SIMULINK

SimPowerSystems toolbox
Power electronics simulation
Single phase half wave rectifier (controlled)
For alpha=120

SIMULINK

SimPowerSystems toolbox
Power electronics simulation
Single phase full wave rectifier (uncontrolled)

SIMULINK

SimPowerSystems toolbox
Power electronics simulation
Single phase full wave rectifier (uncontrolled)

SIMULINK

SimPowerSystems toolbox
Power electronics simulation
Single phase full wave rectifier (fully controlled)

SIMULINK

SimPowerSystems toolbox
Power electronics simulation
Three phase half way rectifier (fully controlled)

SIMULINK

SimPowerSystems toolbox
Power electronics simulation
Three phase full way rectifier (half controlled)

SIMULINK

SimPowerSystems toolbox
Power electronics simulation
Three phase full way rectifier (fully controlled)

SIMULINK

SimPowerSystems toolbox
Power electronics simulation
AC voltage controller
Inverters

SIMULINK

Control
PID controller

SIMULINK

Control
PID controller
A proportional controller (Kp) will have the effect of reducing the rise
time and will reduce but never eliminate the steady-state error.
An integral control (Ki) will have the effect of eliminating the steadystate error, but it may make the transient response worse.
A derivative control (Kd) will have the effect of increasing the
stability of the system, reducing the overshoot, and improving the
transient response.

SIMULINK

Control
DC motor speed modeling in SIMULINK

SIMULINK

Control
DC motor speed modeling in SIMULINK

SIMULINK

Control
DC motor speed modeling in SIMULINK

SIMULINK

Control
DC motor speed modeling in SIMULINK

SIMULINK

Control
DC motor speed modeling in SIMULINK

SIMULINK

Control
DC motor speed modeling in SIMULINK

J=0.01;
b=0.1;
K=0.01;
R=1;
L=0.5;

SIMULINK

Control
DC motor speed modeling in SIMULINK

SIMULINK

Control
DC motor speed modeling in SIMULINK
Extracting a linear model into MATLAB

SIMULINK

Control
DC motor speed modeling in SIMULINK
Extracting a linear model into MATLAB
>> [A,B,C,D]=linmod('DCmotor_modeling')
A=
-10.0000 1.0000
-0.0200 -2.0000
B=
0
2
C=
1
D=
0

SIMULINK

Control
DC motor speed modeling in SIMULINK
Extracting a linear model into MATLAB

>> [num,den]=ss2tf(A,B,C,D)
num =
0

2.0000

den =
1.0000 12.0000 20.0200

SIMULINK

Control
DC motor speed modeling in SIMULINK
Extracting a linear model into MATLAB
>> step(num,den)

SIMULINK

Control
DC motor speed modeling in SIMULINK
Extracting a linear model into MATLAB

>> sys=tf(num,den)
Transfer function:
2
-----------------s^2 + 12 s + 20.02
>> rlocus(sys)
>> axis([-22 3 -15 15])

SIMULINK

Control
DC motor speed modeling in SIMULINK
Extracting a linear model into MATLAB

>> zeta=0.8;
>> Wn=2;
>> sgrid(zeta, Wn)

SIMULINK

Control
DC motor speed modeling in SIMULINK
Extracting a linear model into MATLAB
>> [k,poles] = rlocfind(sys)
Select a point in the graphics window
selected_point =
-5.9751 + 1.0714i
k=
8.5637
poles =
-6.0000 + 1.0712i
-6.0000 - 1.0712i

SIMULINK

Control
DC motor speed modeling in SIMULINK
Extracting a linear model into MATLAB

>> sys_cl= feedback(k*sys,1)


Transfer function:
17.13
-----------------s^2 + 12 s + 37.15
>> step(sys_cl)

You might also like