EE 340: Control Systems Lab 4 Manual Introduction To Simulink
EE 340: Control Systems Lab 4 Manual Introduction To Simulink
Lab 4 Manual
Introduction to Simulink
Student Name
Roll No.
Marks obtained
Date Performed
Instructor Signature
Introduction
Simulink is a software package included in MATLAB for modeling, simulating, and analyzing dynamical
systems. It supports linear and nonlinear systems, modeled in continuous time, sampled time, or a hybrid
of the two. For modeling, Simulink provides a graphical user interface (GUI) for building models as block
diagrams, using click-and-drag mouse operations. Simulink includes a comprehensive block library of
sinks, sources, linear and nonlinear components, and connectors. You can also customize and create your
own blocks.
In this lab session an introduction to Simulink is given to the students, in which they learn how to use
Simulink, how to program in Simulink, and how to simulate dynamical systems using the blocks included
in the library.
The following window will appear as shown in Figure 1. To create a new model, go to:
Search for the desired block in the library browser, and then drag that block and place it in the model
file. Any block can be resized easily by dragging its corners. To place the model of any physical system,
drag the Transfer Function Block from the following path.
Following are some examples to understand how to use the Transfer Function block:
Exercise 1
s2 + 3s + 1
G(s) =
s2 + 8s + 10
Numerator Coefficient = [1 3 1]
Denominator Coefficient = [1 8 10].
Exercise 2
s + 10
G(s) =
s3 + 3s + 1
Numerator Coefficient = [1 10]
Denominator Coefficient = [1 0 3 1].
Exercise 3
s2 + 10s + 10
G(s) =
s
Numerator Coefficient = [1 10 10]
Denominator Coefficient = [1 0].
On entering this, an error box will appear. Why does this error occur?
Task 2: Building a block diagram in Simulink
It is very easy to build a block diagram in the Simulink. First open a new model file. Place the required
blocks in the blank model file and connect them as required. Build the block diagram as shown in Figure
3 and run it.
Note: To set up the step function, double click on its block and set the values according to those found
in Figure 4. Also double click on the scope function block and check the ”save to workspace” option as
illustrated in Figure 5. Once the simulation runs, the scope data is saved in the MATLAB workspace.
You may view the data by using the plot command. The start and stop buttons for Simulink are shown
in Figure 3. The simulation time can be changed through the text box shown in Figure 3.
The list of the Simulink blocks used most often is given at the end of this lab manual. This list will help
you in future labs as well, so make sure to go through it.
Exercise 4
Plot the step response of the above system and comment on the nature of the response.
Figure 4: Step function window
Set the properties of the block, “To Workspace” as shown in Figure 7. After setting the properties, rerun
the simulation. This will generate the “Data” and “tout” variables in the workspace as shown in Figure
8. The “Data” object will contain information for the input and output signals. To plot these variables,
we have to separate the information from this object into two different variables.
Exercise 5
Plot the input and response on a single figure in the MATLAB editor.
Exercise 6
Does the response exibit any steady-state error? How much is it?
Figure 7: Properties of “To Workspace Block”
dv
m =u
dt
Since we are incorporating the frictional force, which is proportional to the velocity v of the mass, the
above equation becomes:
dv
m = u − bv
dt
dv u b
= − v
dt m m
where u is the force from the engine and b is the constant of proportionality. For this example, let us
assume the following parameters for the system
m = 1000 kg
b = 50 N sec/m
Exercise 7
What should the value of uf be in order for the vehicle to attain a final speed of 10 m/s?
Run the simulation for your selected value of u for 120 sec.
Exercise 8
Obtain a plot of the open loop step response of the system.
Exercise 9
Is this system stable in the open loop configuration?
Exercise 10
What is the final value achieved by this system?
Exercise 11
Is the control objective specified previously met by this open-loop control scheme? Please elaborate.
Important Blocks
Constant
Simulink → Sources (or Commonly Used Blocks) → Constant
Integrator
Simulink → Continuous (or Commonly Used Blocks) → Integrator
Transfer Function
Simulink → Continuous → Transfer Fcn
State Space
Simulink → Continuous → State-Space
Saturation
Simulink → Discontinuities → Saturation
Zero-order hold
Simulink → Discrete → Zero-order Hold
Subtract
Simulink → Math Operations → Subtract
Sum
Simulink → Math Operations → Sum
Subsystem
Simulink → Ports and Subsystems → Subsystem
Mux
Simulink → Signal Routing → Mux
Scope
Simulink → Sinks → Scope
To File
Simulink → Sinks → To File
To Workspace
Simulink → Sinks → To Workspace
Pulse Generator
Simulink → Sources→ Pulse Generator
Ramp
Simulink → Sources→ Ramp
Signal Generator
Simulink → Sources→ Signal Generator
Step
Simulink → Sources→ Step
MATLAB Function
Simulink → User-defined Functions → MATLAB Functions
PID
Simulink → Continuous → PID Controller
Outcomes Assessed:
CLO1: Ability to analyze and extract meaningful information from observed data (P).
CLO3: Ability to follow instructions and convey experiment results in an effective manner (A).
CLO5: Ability to use the techniques, skills, and modern engineering tools necessary to practice
control engineering (P).
Report filled in
Lab report has been Parts of the report illegible writing with
Lab Report filled in neatly with not filled in neatly or improper
(CLO3) proper grammar and with improper pucntuations or a
scientific terminology grammar casual, non-scientific
tone
Provides meaningful
interpretation of Provides some Interpretation of
results. Provides interpretation of results is not clearly
Discussion scientific reasoning explained. No
(CLO1) results. Includes some
and draws sort of conclusions. conclusions are made
appropriate based on the results.
conclusions based on
data.
Total