Lab - 2 - Transfer Function Block in Simulink
Lab - 2 - Transfer Function Block in Simulink
1.1 Introduction:
The MATLAB Control System Toolbox offers functions for finding the transfer
functions from a given block diagram. However, as we shall shortly see, the
simulation environment provided by MATLAB’s Simulink Toolkit obviates the need
for block diagram reduction. The Simulink model mimics the block diagram of a
feedback control system and is used to evaluate the response of controlled
variable to any test input. It also provides the response of any internal variable of
the control system (output variable of a subsystem block) without the need for
block diagram reduction.
Let us reiterate the fact we have emphasized earlier: a good plant/process model
is the backbone of any realistic control design. A Simulink model based on the
structure and parameters of the system model is constructed. The responses of
the actual system and its Simulink model are obtained using a set of test inputs. If
the actual responses to the test inputs were significantly different from the
Simulink responses, certain model parameters would have to be revised, and/or
the model structure would have to be refined to better reflect the actual system
behavior. Once satisfactory model performance has been achieved, various
control schemes can be designed and implemented.
Simulation block diagrams are nothing but the same block diagrams we are using
to describe control system structures and signal flow graphs. SIMULINK offers a
large variety of ready-touse building blocks to build the mathematical models and
system structures in terms of block diagrams. Block parameters should be
supplied by the user. Once the system structure is defined, some additional
simulation parameters must also be set to govern how the numerical
computation will be carried out and how the output data will be displayed.
Expand the node labeled Simulink. Sub nodes of this node (Commonly Used
Blocks, Continuous, Discontinuities, Discrete, Logic and Bit Operations, etc) are
displayed. Now for example, expanding the Sources sub node displays a long list
of Sources library blocks. Simply click on any block to learn about its functionality
in the description box (see Fig .3a).
You may now collapse the Sources sub node, and expand the Sinks sub node. A
list of Sinks library block appears (Fig.6.3b). Learn the purpose of various blocks in
Sinks sub node by clicking on the blocks.
We have described some of the subsystem libraries available that contain the
basic building blocks of simulation diagrams. The reader is encouraged to explore
the other libraries as well. You can also customize and create your own blocks. For
information on creating your own blocks, see the MATLAB documentation on
‘Writing S- Functions’.
We are now ready to proceed to the next step, which is the construction of a
simulation diagram. In the SIMULINK library browser, follow File New Model
or press Ctrl+N to open an ‘untitled' workspace (Fig. 4) to build up an
interconnection of SIMULINK blocks from the subsystem libraries.
where
We will implement the model shown in Fig. 5 in the untitled work space (Fig. 4).
Let us first identify the SIMULINK blocks required to implement the block diagram
of Fig. 5. This is given in Fig. 6.
Expand the Sources sub node, move the pointer and click the block labeled
Constant, and while keeping the mouse button pressed down, drag the block and
drop it inside the Simulation Window; then release the mouse button (Fig. 6.7).
Right clicking on the block will provide various options to users from which one
can cut, copy, delete, format (submenu provides facilities for rotation of the
block, flipping, changing the font of block name,...), etc...
It is visible that all the block parameters are in their default settings. For example,
the default transfer function of Transfer Fcn block is ⁄ and default signs
of Sum block are + +. We need to configure these block parameters to meet our
modeling requirements. It is straightforward. Double click the block to set up its
parameters. For example, double clicking the Transfer Fcn block opens the
window titled Block Parameters: Transfer Fcn, shown in Fig. 8.
Note that the Decimation parameter value by default is 1. Increasing this value
reduces the number of data samples taken over the simulation time. We have
used the default value of 1.
Figure 9 Transfer function block parameters window
Lines are drawn to interconnect these blocks as per the desired structure. A line
can connect output port of one block to the input port of another block. A line can
also connect the output port of one block with input ports of many blocks by
using branch lines. We suggest readers to perform the following line/block
operations on blocks dragged in workspace to get hands on practice. To connect
the output port of one block to the input port of another block:
1. Position the pointer on the first block's output port; note that the cursor
shape changes to cross hair.
2. Press and hold down the left mouse button.
3. Drag the pointer to second block's input port.
4. Position the pointer on or near the port; the pointer changes to a double
cross hair.
5. Release the mouse button. SIMULINK replaces the port symbol by a
connecting line with an arrow showing the direction of signal flow.
Another simple methodology doesn't require dragging the line. Block1 output
port is required to be connected to Block2 input port.
To connect the output port of one block with the input ports of several blocks,
we can use branch lines. Both the existing line and the branch line carry the
same signal. To add a branch line, do the following:
1. Position the pointer on the line where you want the branch line to start.
2. While holding down the Ctrl key, left click on the line segment; note that
the cursor shape changes to cross hair.
3. Release the control key, while pressing down the left mouse button; drag
the pointer to the input port of the target block.
4. Release the mouse button; target block will be connected to the line
segment.
Some of the important line-segment and block operations are as follows:
1. To move a line segment, position the pointer on the segment you want to
move. Press and hold down the left mouse button. Drag the pointer to the
desired location and release. Note that this operation is valid with line
segments only, not with the dedicated connecting lines between two
blocks.
2. To disconnect a block from its connecting lines, hold down the shift key,
then drag the block to a new location. Incoming and outgoing lines will be
converted to red colored dotted lines. One can insert a different block
between these lines.
Now let us give a name to the untitled workspace. Hit Ctrl + S to save the
developed simulation diagram to the disk with an appropriate name. The file will
be saved with the extension .mdl , an abbreviation for the ‘model'.
Finally, we need to set the parameters for the simulation run. Press Ctrl + E to
open the simulation parameter configuration window. Left panel of the window
displays a tree structured view of parameter submenu. In the Solver submenu,
enter the start and stop time of the simulation (Fig. 11).
Set y-axis limits by right-clicking the axis and choosing Axes Properties. In Y-min,
enter the minimum value for the y-axis. In Y-max, enter the maximum value for
the y-axis. In Title, enter the title of the plot. See Fig. 12b.
Click the icon shown on the icon bar to open scope parameter editor (Fig. 13).
General parameters include Number of axes, Time range, Tick labels, and
Sampling.
Click on the Data history button. If you want input-output data from this scope to
be available to MATLAB workspace for further analysis, check the button Save
data to workspace. In the box Variable name, enter the variable name for saving
the data. By default it will save the data with variable name ScopeData. With the
pop-down menu Format, select the format in which you want to save the data.
Three specific formats for saving the data are as follows:
1. Structure with time: Data will be saved in structured format with time steps.
Type the following commands in your MATLAB prompt and observe the outputs.
Structures are used in MATLAB to store mixed mode data types, and individual
fields of the structure can be accessed by dot ' (.) operator. To see the
information stored in the field signals, type:
>> ScopeData.signals
ans =
values: [4663x1 double]
dimensions: 1
label: ''
title: ''
plotStyle: 0
It indicates that the field signals contains subfield values, which is of 4663 x 1 size
vector containing the values of angular velocity. Try accessing the field time of
ScopeData.
2. Structure: This is the same as Structure with time; the only difference is that
the time steps will not be saved.
3. Array: Array format is simply a two column matrix with number of data points
being equal to number of rows. The maximum number of data points limits to the
number entered in the box Limit data points to last.
We have used an example to show how to build the Simulink diagram, how to
enter data and carry out a simulation in the SIMULINK environment. The reader
will agree that this is a very simple process. Solving the following exercises will
make the readers more confident in solving the control system design and
analysis problems through SIMULINK.
series(G,D) for a cascade connection of G(s) and D(s); parallel(G1,G2) for a parallel
connection of G1(s) and G2(s); feedback(G,H, sign) for a closed-loop connection
with G(s) in the forward path and H(s) in the feedback path; and sign is -1 for
negative feedback or +1 for positive feedback (the sign is optional for negative
feedback); and cloop(G,sign) for a unity feedback system with G(s) in the forward
path, and sign is -1 for negative feedback or +1 for positive feedback (the sign is
optional for negative feedback).
The transfer function Gc(s)G(s) is computed using the series function as shown In
Figure 14 .The resulting transfer function is
where sys is the transfer function name
Figure 14: Application of the series function via (a) Simulink (b) series command
Let the process, G(s), and the controller, Gc(s), be as shown in Figure 15. To apply
the feedback function, we first use the series function to compute Gc(s)G(s),
followed by the feedback function to close the loop. The command sequence is
shown in Figure 15(b). The closed-loop transfer function is
Figure 15: Application of the feedback function via (a) Simulink (b) feedback
command
As an example, we will use Simulink to solve the first order differential equation
(ODE)
We can solve Equation (1) by integrating to formally obtain
∫( )
(a)
(b)
Lab Task 02: A multiloop feedback system is shown in Figure 17. Simulate the
control system using SIMULINK
Figure 17: Multiloop feedback system
(i)
(ii)
(iii)
Name:___________________________
Regd. No._________________________
Date of Lab:________________________
Example
Lab Section
Lab Task
Working
Lab Performance
Viva
Instructor’s Verification