Simulink Lab
Simulink Lab
Simulink Lab
Final Project
Background:
SIMULINK
is
a
model
based
difference
or
differential
equation
solver
using
simulation
time/time
steps
as
a
fundamental
basis
for
the
simulation's
construction
and
evaluation.
A
model
consists
of
sources
and
sinks
and
intermediate
blocks
that
represent
basic
dynamical
system
elements.
These
elements
can
be
as
basic
as
passive
elements
such
as
power
supplies,
sine
waves,
resistors,
capacitors
etc.
to
complex
enigmatic
entities
like
neural
networks
and
image
processing
engines.
Each
entity
within
the
model
contains
properties
that
control
the
function
and
the
characteristics
of
each
block.
These
properties
need
to
be
configured
to
represent
the
system
being
modeled.
In
addition
to
the
model
elements
the
equation
solver
that
governs
the
simulation
needs
to
be
configured
as
well.
SIMULINK
enables
quick
evaluation
of
simple
to
complex
systems
and
can
shed
insight
into
system
behavior
in
a
fraction
of
the
time
of
physical
prototypes.
While
the
suggested
reading
and
activity
will
only
scratch
the
surface
of
SIMULINK
it
is
intended
to
bring
the
reader
up
to
a
basic
understanding
of
SIMULINK
and
its
interaction
within
MATLAB.
A
typical
SIMULINK
work
flow
session
will
consist
of
the
following
steps
1. Type
">>simulink"
at
MATLAB
prompt
2. Create
new
model
from
the
SIMULINK
library
browser
menu
pull
downs:
FILE->New
Model
3. Add
blocks
that
correspond
to
model
dynamics/functions:
Sine
waveforms,
constants,
filters,
ramps,
scopes,
user
functions
etc.
4. Define
the
blocks;
add
details
about
sources,
sinks,
operators.
There
are
many
resources
to
construct
model
topologies
As
previously
mentioned
each
block
needs
to
be
defined
with
appropriate
model
parameters.
If
it's
a
spring
model,
an
appropriate
"K"
value
needs
to
be
defined.
If
it's
a
sine
waveform:
Amplitude,
frequency,
phase
need
to
be
defined.
5. Save
the
Model.
6. Set
simulation
Options/
Solver
options:
The
type
of
solver
to
use
ODE45,
ODE3,
etc.
These
are
provided
with
MATLAB
The
time
step
and
various
differential
equation
boundary
conditions
should
be
defined.
7. Run
the
model
8. Configure
the
output
either
with
outputs
within
SIMULINK
or
export
data
to
the
MATLAB
workspace
for
more
control
over
the
plotting,
or
additional
post
processing.
Ver.1
ES442
Final Project
Read
the
provided
handout
in
PIAZZA
for
details
on
how
to
work
with
SIMULINK
and
create
models.
The
following
link
provide
valuable
resources
for
how
to
create
basic
models
using
SIMULINK:
https://www.mathworks.com/academia/student_center/tutorials/sltutorial_launchpad.html?confirmation_page#
Lab
Activity
It
is
important
to
go
through
the
handout.
This
project
is
based
on
the
examples
in
the
handout.
AM
Modulation
1. Create
a
DSB-SC
AM
modulator
model.
See
Pg
128
of
the
handout.
The
model
should
look
similar
to
the
figure
below:
M(t)
and
Carrier
are
sine
waveforms.
The
product,
gain,
and
SCOPE
blocks
can
be
found
by
searching
"product",
"gain"
and
"SCOPE",
respectively
within
the
library
browser:
Note
that
the
frequency
for
the
carrier
is
set
to
10
Hz.
The
frequency
for
the
modulating
frequency
is
set
to
1
Hz.
Tips
to
construct
the
model
using
SIMULINK:
Ver.1
ES442
Final Project
Any
variable
defined
in
the
MATLAB
workspace
can
be
used
within
SIMULINK.
Try
typing
>>fc
=
10
>>fm
=
1
In
the
Main
MATLAB
window
use
fc
and
fm
instead
of
1
and
10
within
the
sine
waveform
properties.
This
will
come
in
handy
to
experiment
with
different
model
parameters
in
more
complex
models.
2. We
now
need
to
configure
the
solver.
See
the
following
configurations:
Ver.1
ES442
Final Project
Form
the
SIMULINK
window
run
the
simulation.
The
SCOPE
should
be
able
to
be
configured
to
show
something
similar
to
what
is
shown
below.
Double
click
on
the
SCOPE
block
after
running
the
simulation
to
view
the
SCOPE
traces.
Ver.1
ES442
Final Project
If
the
output
is
only
a
portion
of
the
recorded
waveform
the
"history"
of
samples
recorded
may
need
to
be
modified,
or
the
waveform
needs
to
be
set
to
AUTO
scale
(shown
below).
3. Condense
the
two
blocks
in
the
AM
modulation
model
(the
gain
block
and
the
multiplier
block)
into
a
subsystem
as
shown
below.
This
can
be
done
by
selecting
the
two
blocks
and
then
right
clicking
and
selecting
"create
subsystem".
Run
the
simulation
again
confirm
that
the
system
still
works.
Take
a
snapshot
of
the
output
of
the
SCOPE.
Answer
the
following
questions:
a. What
happens
if
you
change
the
GAIN
value
to
unity?
b. Why
do
we
call
this
type
of
modulation
SC
(suppressed
carrier)?
Ver.1
ES442
Final Project
FM
Modulation
Use
a
new
file
and
create
the
FM
modulation
model
shown
below.
Read
page
130
of
the
handout
for
more
details.
The
mathematical
expression
of
the
FM
modulated
signal
will
be
In
our
model
we
assume:
kf
=
5Hz/V,
fc
=
10Hz
and
modulating
waveform
is
s(t)
=
cos(2*pi*t).
The
VCO
block
is
actually
a
user
defined
function,
search
"Fcn."
Double
click
on
the
"Fcn"
block
and
add
desired
function
with
"U"
representing
the
input
to
the
function.
Ver.1
ES442
Final Project
Configure
the
blocks
to
suit
the
system.
The
Discrete-Time
Integrator
should
have
a
sample
time
of
0.01
(the
same
as
the
simulation
sample
time,
previously
set
in
the
AM
Modulation
portion).
Configure
the
solver.
Refer
to
the
AM
modulation
solver
configuration.
Run
the
simulation.
The
SCOPE
should
be
able
to
be
configured
to
show
something
similar
to
what
is
shown
below:
If
the
output
is
only
a
portion
of
the
recorded
waveform
the
"history"
of
samples
record
may
need
to
be
modified,
or
the
waveform
needs
to
be
set
to
auto
scale.
Ver.1
ES442
Final Project
Condense the two FM modulation blocks into one FM modulation subsystem as shown below.
Run
the
simulation
again
confirm
that
the
system
still
works.
Take
a
snapshot
of
the
output
of
the
SCOPE.
Search
for
"MATLAB
Function"
and
add
it
to
your
model
subsystem.
Double
click
on
the
MATLAB
Function
Block
and
enter
in
the
code
below
in
the
MATLAB
block.
Save
the
function.
Ver.1
ES442
Final Project
Add
the
block
into
the
location
where
the
ADD
block
used
to
be:
Run
the
simulation,
confirm
that
the
simulation
provides
the
same
output.
Change
the
GAIN
to
15.
Take
a
snapshot
of
the
SCOPE
results.
NOTE:
If
there
is
any
problem
with
this
section
please
report
it!
Ver.1
ES442
Final Project
Note
that
the
FM
modulator
is
similar
to
the
modulator
you
created
in
the
previous
section.
1. Take
snapshots
of
the
spectrum
of
the
message
signal
and
FM
signal.
Elaborate
on
the
results.
What
is
the
carrier
frequency?
What
is
the
bandwidth?
2. Pay
attention
to
how
the
Spectrum
Analyzers
are
setup;
click
on
and
check
the
setting.
3. Click
on
different
tabs
and
observe
the
setting
for
SCOPE
Properties,
Display
Properties,
Axis
Properties,
and
Line
Properties.
4. Modify
the
model
(circuit)
as
shown
below
and
rename
the
mdl file.
Note
that
the
represents
a
LPF.
The
characteristics
of
the
filter
is
defined
as
follow:
block
10
ES442
Final Project
5. Run
the
simulator
and
observe
the
output.
Take
a
snapshot
of
the
FOUR
signals
captured
by
the
SCOPE.
6. Explain
briefly
how
the
demodulator
operates.
Ver.1
11