0% found this document useful (0 votes)
172 views13 pages

EE 340: Control Systems Lab 4 Manual Introduction To Simulink

This document provides instructions for a lab session on introduction to Simulink. The lab includes 4 tasks: 1) defining transfer functions in Simulink, 2) building a basic block diagram, 3) transferring data from Simulink to the MATLAB workspace, and 4) modeling and controlling a cruise control system. Exercise questions are provided to help students learn how to use Simulink blocks and simulate dynamical systems. An assessment rubric is also included to evaluate lab performance.

Uploaded by

Ansar Niazi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
172 views13 pages

EE 340: Control Systems Lab 4 Manual Introduction To Simulink

This document provides instructions for a lab session on introduction to Simulink. The lab includes 4 tasks: 1) defining transfer functions in Simulink, 2) building a basic block diagram, 3) transferring data from Simulink to the MATLAB workspace, and 4) modeling and controlling a cruise control system. Exercise questions are provided to help students learn how to use Simulink blocks and simulate dynamical systems. An assessment rubric is also included to evaluate lab performance.

Uploaded by

Ansar Niazi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

EE 340: Control Systems

Lab 4 Manual
Introduction to Simulink

Instructor: Talha Manzoor


Lab Engineer: Usman Qadir

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.

Task 1: Defining transfer functions in Simulink


To open Simulink, there are two options:

1. Click on the simulink button in the menu bar.


2. Type ”simulink” in the command window.

The following window will appear as shown in Figure 1. To create a new model, go to:

File → New → Model

Figure 1: Starting window of Simulink

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.

Simulink → Continuous → TransferFcn


To enter the coefficients of the Transfer Function, double click on the Transfer Function block. A window
will appear where you can enter these coefficients as shown in Figure 2.

Figure 2: Window to enter Transfer Function

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.

Figure 3: Basic Block Diagram

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

Figure 5: Scope function window


Figure 6: Transferring data from simulink to workspace

Task 3: Data Transfer from Simulink to workspace


We usually do not have much control over data processing. By transferring the data from Simulink
to workspace, however, we are able to do many desirable manipulations (processing) over it and its
formatting is very easy. To transfer the data from the Simulink scope to workspace, the Simulink library
browser provides a block named “To Workspace” as shown in Figure 6.
You can find the block, “To Workspace” from the following path:

Simulink → Sinks → ToWorkspace

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”

Figure 8: Display of variables in the workspace


Task 4: Modeling & Controlling a Cruise Control System in
Simulink
Modeling
The model of the cruise control system is relatively simple. If the inertia of the wheels is neglected and
friction is assumed to be the force opposing the motion of the car, then the problem is reduced to a
simple mass and damper system, as shown in Figure 9.

Figure 9: Cruise model.

Using Newton’s law

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

Building the model in Simulink


This system can be modeled by summing the forces acting on the mass and integrating the acceleration
to get velocity. Build the block diagram to implement this differential equation according to the one
shown in Figure 10.
This complete system can also be converted into a subsystem. To build a subsystem of the cruise control,
select all the components except the step input and the scope blocks. Now right-click on the selected
components and select “Create Subsystem” from the options. This will create a new subsystem of the
cruise control with input and output ports in it as shown in Figure 11.

Open-loop response of the system


Connect the step input and scope to the subsystem as shown in Figure 12. For our control objective, we
require that the vehicle accelerate from rest to 10 m/s in under 5 secs.
Figure 10: Block diagram of cruise system

Setup the parameters of the step input block as follows


Step time = 0
Initial Value = 0
Final Value = uf

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.

Figure 11: Subsystem of cruise control


Figure 12: Open loop control of cruise 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

Simulink Design Optimization


MATLAB Command line → srolib
Assesment Rubric for Lab 4
Method of Evaluation:
text
Lab report and instructor observation during Lab Session.

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).

Good Satisfactory Unsatisfactory


Performance Marks
(4-5) (2-3) (1)

Most tasks completed


Task All tasks completed Most tasks either
correctly with some
Completion correctly incomplete or
incomplete or
(CLO5) incorrect
incorrect

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy