Docsity

Getting Started with Simulink: A Lab Guide for Engineering Systems Students, Study notes of Design

Toggle sidebar
bg1
ES205 Getting started with Simulink Page 1 of 16
ES205 Analysis and Design of Engineering Systems: Lab 1:
An Introductory Tutorial: Getting Started with SIMULINK
What is SIMULINK? SIMULINK is a software package for modeling, simulating, and
analyzing dynamic systems. It supports linear and non-linear system modeling in
continuous time, sampled time, or a combination of the two. It provides a
graphical interface for building models as block diagrams using the mouse by
click-and-drag operations. It also provides a variety of simulated output devices
that can be attached to the system to monitor the output or state variables of the
system.
By defining the system graphically, the mathematical calculations required to
simulate the differential equations that represent the models are hidden from
your view. You only need to be able to supply the model structure and
parameters, the simulation parameters, and the output variables and forms. You
don't have to get bogged down in the math to determine the behavior of the
system of interest.
This tutorial will consist of 4 parts:
A) Launching and becoming familiar with the SIMULINK environment
B) Creating a simple 1st order model
C) Creating a 2nd order model of a mass, spring, damper system
D) Creating a model on your own of an electrical system.
Part A: Launching Simulink:
1) SIMULINK is run from the MATLAB prompt, >>, so the first step is to get MATLAB
running.
-- Connect to the Network
-- Launch MATLAB. ( if you have not already installed MATLAB you will need to
do so at this time. Refer to the instructions handed out in Le 01.)
2) At the prompt, >>, in the MATLAB Command Window, type simulink and
press ! Enter.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download Getting Started with Simulink: A Lab Guide for Engineering Systems Students and more Study notes Design in PDF only on Docsity!

ES205 Analysis and Design of Engineering Systems: Lab 1: An Introductory Tutorial: Getting Started with SIMULINK

What is S IMULINK? S IMULINK is a software package for modeling, simulating, and analyzing dynamic systems. It supports linear and non-linear system modeling in continuous time, sampled time, or a combination of the two. It provides a graphical interface for building models as block diagrams using the mouse by click-and-drag operations. It also provides a variety of simulated output devices that can be attached to the system to monitor the output or state variables of the system.

By defining the system graphically, the mathematical calculations required to simulate the differential equations that represent the models are hidden from your view. You only need to be able to supply the model structure and parameters, the simulation parameters, and the output variables and forms. You don't have to get bogged down in the math to determine the behavior of the system of interest.

This tutorial will consist of 4 parts: A) Launching and becoming familiar with the SIMULINK environment B) Creating a simple 1st order model C) Creating a 2nd order model of a mass, spring, damper system D) Creating a model on your own of an electrical system.

Part A: Launching Simulink:

  1. S IMULINK is run from the MATLAB prompt, >> , so the first step is to get MATLAB running. -- Connect to the Network -- Launch MATLAB. ( if you have not already installed M ATLAB you will need to do so at this time. Refer to the instructions handed out in Le 01.)

  2. At the prompt, >> , in the MATLAB Command Window, type simulink and

press! Enter.

  1. When S IMULINK opens you will see the box called the S IMULINK Library Browser. The Library consist of a number of different S IMULINK blocks with which a system model may be built.

To build a model, you first need to create a space to make the model.

Click the new model icon in the upper left corner to open a new S IMULINK file workspace.

Next, select the SIMULINK icon to expand the list of the available elements that are used to create a system model.

  1. After making the selections in Step 3, the S IMULINK Library Browser will show folders that contain the most commonly used elements you will be using for model creation.

Click on each of the following folders and quickly note the elements that are contained in each. -- Continuous -- Discrete -- Functions & Tables -- Math -- Nonlinear -- Signals & Systems -- Sinks -- Sources

When needed, these elements may simply be clicked, dragged, and dropped into the model workspace.

Part B) Example 1: A Simple Model

  1. The first model you are going to build will solve a simple 1st order differential equation given by

3 sin( 2 t )

dt

dx

with an initial condition x (0) = -1.

  1. To create a model of this equation, we first sketch a simulation diagram of the mathematical model.

The simulation diagram will consist of: an input --> the forcing function, 3 sin(2t) an output --> the solution, dx/dt a parameter --> the initial condition, x(0) = - an operator --> integration block

  1. To construct this model in Simulink, will require three elements: -- a Sine Wave Block --an Integrator Block -- a Scope Block

Locate the Sine Wave under the Sources folder and Click, Drag, and Drop it in the model workspace window to create the Input Block

output: x(t)

x

dx input: dt 3sin( 2t )

I.C.: x (0) = -

1 s

  1. Locate the Integrator under the Continuous folder and Click, Drag, and Drop it in the model workspace window to create the Operator Block.

  2. Locate the Scope under the Sinks folder and Click, Drag, and Drop it in the model workspace window to create the Output Block

Double click on the Integrator Block and set the parameter for the initial condition.

x(0) = -

Double Click on the Scope Block.

This does not have any parameters which need setting, but instead displays the scope display screen.

  1. Now that the model has been defined and created, the model simulation is ready to run.

To Start a simulation, pull down the Simulation menu, and select Start.

View the output of the simulation on the Scope window.

  1. Simulation Results

Your results should look like the figure.

Measure the magnitude of peaks and valleys and the period of the signal.

Peak = ____________

Valley = ____________

Period = ____________

  1. Simulation Verification:

To verify that this plot represents the solution to the problem, let's solve the equation another way. Either manually, or using Maple, obtain the solution x(t) of the ODE with the initial condition

3 sin( 2 t )

dt

dx

= with x(0) = -

Show solution here:

The result should be:

This is the function that was plotted in the S IMULINK Scope window.

Save this S IMULINK model in the simulink_files folder as as Example1.mdl

x ( t ) = 21 āˆ’ 23 cos ( 2 t )

  1. Let's walk through the steps.

For comparison, start by solving the model equation for the highest order derivative term.

k x

dt

dx

f t c

dt

d x

m 2 = ( )āˆ’ āˆ’

2

The first block you create should be a Sum block, where the output of the Sum block is the left-hand term of the equation above.

Now using S IMULINK, Create a new workspace..... File ..... New.....Model

Locate the Sum Block in the ____________ library and Click, Drag and Drop it into your new workspace.

The Sum block is to have 3 inputs. Double click on the Block and set the parameters to rectangular and + - -.

sum block

m

d 2 x dt 2

  1. Gain Block.

Add a gain (multiplier) block to normalize the coefficient, m, to modify the signal so it is equal to the highest order derivative term alone.

Click, Drag, and Drop a Gain Block from the _____________ library into the S IMULINK workspace.

Double-click on the Gain block to change the block parameters.

Use a Gain of ___________________

Add a title to the Gain Block.

m d 2 x dt 2 1 m

d 2 x dt 2

sum block gain

  1. Return Branch Gain Blocks

In the Simulation Diagram, connect the integrated signals with gain blocks to create the terms on the right-hand side of the model equation.

In S IMULINK, Drag in two additional Gain blocks from the Math library to the workspace. --Flip these blocks by selecting each block and using ...... Format.......Flip Block --Double click on each of the blocks and set the appropriate parameters c = 0. k = 1. --Connect the signal lines: Either Click the gain block input and drag to each of the branch points. or Ctrl-Click to select the branch point first and drag to the gain inputs. --Add appropriate titles to the gain blocks

m d 2 x dt 2 1 m

d 2 x dt 2

sum block

s

1

s

1

k

c

dx dt

k x

c

dx dt x

k = 1.

c = 0.

  1. Connect all Input Signals.

In the Simulation Diagram, connect all the input signals to the appropriate inputs of the Sum Block.

In the S IMULINK workspace: -- Add a Step Block from the Source library and set its parameters. Step time = 0 Initial value = 0 Final value = 3 -- Connect the signal lines to the sum Block, paying attention to the signs of the inputs.

m d 2 x dt 2 1 m

d 2 x dt 2

s

1

s

1

k

c

dx dt

k x

c

dx dt

+ x

- -

Input: f(t) Output: x(t)

This concludes the S IMULINK Tutorial Module.

You are now to complete Part D: Lab 1 Worksheet. To complete the worksheet you are expected to understand and use the terms below.

Terms used on the worksheet:

Steady State Value is the final value of the system settles at after transient behavior has dissipated.

Overshoot is characterized as the maximum response swing past the steady state value.

Rise time is time required for the system to rise from ten to ninety percent of the steady state value.

Settling time is the amount of time the system takes to value settle close to the steady state condition (to within approximately 2% of the step size).

Rise Time

+/- 2% of step

Settling Time

Overshoot Steady State Value

ES205 Lab 1 Worksheet Page 1 of 6

Name __________________________Section _______ C M _____________

Lab Partners: ________________ __________________ _______________

Part D: Lab 1 Worksheet

ES205 Analysis and Design of Engineering Systems

1) Mass-Spring-Damper Model: Below you will explore how changing each of the three parameters, m, c, and k , affect the system response of the spring-mass-damper model created in Part C.

Varying the mass, m: In the space below, make a prediction. How do you think changing the mass, m, of the system will affect its dynamic behavior?

Now using your S IMULINK model, vary the value of the mass, m, using the multipliers given below, while keeping k and c constant. Then on the graph below sketch and label each response.

Use Mass values: m/5 m/2 1.0m 2.0m and 5*m

Summary: Give a short summary which qualitatively describes how changing the mass affected the system response. Include qualitative reference to the overshoot, settling time, and steady state value.

ES205 Lab 1 Worksheet Page 3 of 6

Varying the elastic coefficient, k: Make a prediction: How will changing the elastic coefficient, k, of the system affect its dynamic behavior?

Now using your S IMULINK model, vary the value of the elastic coefficient, k, using the multipliers given below, while keeping m and c constant. Then on the graph below sketch and label each response.

Use Elastic Coef values: k/5 k/2 1.0k 2.0k and 5*k

Summary: Give a short summary which qualitatively describes how changing the elastic coefficient affected the system response. Include qualitative reference to the overshoot, settling time, and steady state value.

0 1 2 3 4 5

0

2

4

6

8

10

12

14

16

ES205 Lab 1 Worksheet Page 4 of 6

2) Modeling a Simple Electrical RLC Circuit.

A simple electrical circuit consists of a Resistor, Coil, and Capacitor in series with a variable voltage source, E(t).

The circuit may be modeled using two 1st order DE's given as

1 1 ( )

di R i e E t dt L L L

    • = (^) and

1 0

de i dt C

āˆ’ =

with i (0) = 0 with e (0) = 0

where i is the current in the circuit and e is the electric potential at the node between the coil and capacitor.

Draw the Simulation Diagram that represents these DEs below.

i

R

L

C

E(t)

+

-

e