0% found this document useful (0 votes)
12 views6 pages

Lab Session 7

This lab session teaches students to model a mass-spring damper system using transfer functions in the command window and Simulink. It shows how to represent the system using tf() in the command window and the Transfer Fcn block in Simulink. Students then build the model using basic components like Integrator and Gain blocks. Finally, it demonstrates how to create a masked subsystem that allows setting parameter values to simulate the system response for different scenarios.

Uploaded by

Muhammad Arslan
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)
12 views6 pages

Lab Session 7

This lab session teaches students to model a mass-spring damper system using transfer functions in the command window and Simulink. It shows how to represent the system using tf() in the command window and the Transfer Fcn block in Simulink. Students then build the model using basic components like Integrator and Gain blocks. Finally, it demonstrates how to create a masked subsystem that allows setting parameter values to simulate the system response for different scenarios.

Uploaded by

Muhammad Arslan
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/ 6

MCT-331: Modeling & Simulation

Plant Modeling in Command Window and Simulink and Masking a Model


Lab Session 7:
Objective
This exercise will teach students to represent system model in command window using tf(‘s’) and in simulink
using Transfer Fcn and using basic components and at the end, student will apply masking to subsystem.
7.1 Modeling a Mass-spring damper:

Here, m = 1 kg fv = 0.7 Nsec/m k = 1 N-s/m f =1N

7.2.1 Model representation and step response in Command Window:


The command “tf ( )” is used to represent any physical model.

t = 0:0.1:50;
m = 2; % value of mass (Kg)
fv = 0.7; % value of viscous damping (N-sec/m)
k = 1; % value of spring constant (N-sec/m)
s = tf('s'); % sets up transfer function input mode
sys = (1/(m*s^2+fv*s+k));
y = step(sys,t);
plot(t,y);
grid on;

Modeling & Simulation Lab Fall 2017 Instructor: M Usman Sheikh


7.2.2 Building the Model in Simulink using Transfer Fcn Block:

Use following three blocks


Simulink Continuous  Transfer Fcn;
Double click on block and change: numerator coefficients [1]; denominator coefficients [2 0.7 1].
Simulink Sources  Step; Block properties; Step time  0; Initial Value 0, Final Value 1, Sample
Time 0.1
Simulink Sink  Scope
Run the simulation for 50 sec and observe the step response on scope plot

7.2.3 Building the Model in Simulink using discrete Components:


Rearranging equation 1

This complete system can also be converted into a subsystem. To build a subsystem, 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.

Modeling & Simulation Lab Fall 2017 Instructor: M Usman Sheikh


7.1.3.1 Masking A subsystem:
Masking a subsystem is a procedure of finalizing your model so the input parameters can be entered on prompt window
when we double click on a model. Also, we can add an icon image to subsystem for easier identification. One such
example is shown below.

Steps:
1.Create a subsystem and change its name Subsystem to MSD Model.
2. Write click on Model and go to
Mask  Create Mask;
Mask editor window will appear where all the parameter are added. Make following changes and preview them;
(i) In Icon & Ports Tab, type image(‘imagename.jpg’);
The path of icon image should be the same as for simulink model.

Modeling & Simulation Lab Fall 2017 Instructor: M Usman Sheikh


(ii) In Parameter and dialog tab, press Edit button three time because we have three input parameters
m, fv, and k. The values in Propmt column will appear as it is in Block prompt window for entering
values and the values entered in Name would be used by MSD block equation.

Modeling & Simulation Lab Fall 2017 Instructor: M Usman Sheikh


(iii) In Initialization Tab, we can set the defaults values of inputs or put few conditions on
acceptable values of m, fv, and k. In this example, all three variables should be positive.

(iv) In documentation tab, we can type the model type, and little introduction about the model.

Modeling & Simulation Lab Fall 2017 Instructor: M Usman Sheikh


After Making above changes, Our MSD model will look like the one below.

Last Thing to do:


Double click on MSD Model Block and change the parameters and see the effect of different parameters
combination on step response.

Watch the Video Demo: How to create mask of a subsystem in Simulink Matlab
https://youtu.be/6V-HdFza2JM
Or follow the tutorial here,
http://tutorialhunk.com/how-to-create-mask-of-subsystem-in-simulink/

Modeling & Simulation Lab Fall 2017 Instructor: M Usman Sheikh

You might also like