Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
182 views

Lab - 2 - Transfer Function Block in Simulink

The document discusses using Simulink to model and simulate control systems. It explains that Simulink allows modeling control systems using block diagrams and evaluating system performance without reducing the block diagram. It then provides steps to build a Simulink model of a DC motor control system as an example, including identifying required blocks, configuring block parameters, and connecting blocks to represent the system diagram.

Uploaded by

Waqas Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
182 views

Lab - 2 - Transfer Function Block in Simulink

The document discusses using Simulink to model and simulate control systems. It explains that Simulink allows modeling control systems using block diagrams and evaluating system performance without reducing the block diagram. It then provides steps to build a Simulink model of a DC motor control system as an example, including identifying required blocks, configuring block parameters, and connecting blocks to represent the system diagram.

Uploaded by

Waqas Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Lab – 02: 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.

In practice, it is best to test a control scheme off-line by evaluating the system


performance in the “safety” of the Simulink environment. The key components of
a control system include actuators, sensors, and the plant/process itself. A
decision to include all aspects such as amplifier saturation, friction in the motor,
backlash in gears, dynamics of all the devices, etc., may improve the model, but
the complexity of the model may result in a more complicated controller design,
which will ultimately increase the cost and sophistication of the system. The
design is usually carried out using an approximated model; the evaluation of the
design is done on the “true” model, which includes nonlinearities, and other
aspects neglected in the approximate model. Simulink is an excellent tool for this
evaluation.

SIMULINK (SIMUlation LINK) is an extension of MATLAB for modeling, simulating,


and analyzing dynamic, linear/nonlinear, complex control systems. Graphical User
Interface (GUI) and visual representation of simulation process by simulation
block diagrams are two key features which make SIMULINK one of the most
successful software packages, particularly suitable for control system design and
analysis.

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.

Because SIMULINK is graphical and interactive, we encourage you to jump right in


and try it. To help you start using SIMULINK quickly, we describe here the
simulation process through a demonstration example with MATLAB version 7.0,
SIMULINK version 6.0.

To start SIMULINK, enter Simulink command at the MATLAB prompt. Alternatively


one can also click on SIMULINK icon shown in Fig. 6.1.
Figure 1 MATLAB Desktop main menu and SIMULINK icon

A SIMULINK Library Browser (Figure 2) appears which displays tree-structured


view of the SIMULINK block libraries. It contains several nodes; each of these
nodes represents a library of subsystem blocks that is used to construct
simulation block diagrams. You can expand/collapse the tree by clicking on the +/-
boxes beside each node and block in the block set pan.
Figure 2 SIMULINK Library Browser

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

(a)Blocks in Sources sub node (b)Blocks in Sinks sub node


Figure 3: Simulink Library Blocks

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.

Figure 4 Untitled workspace


Example 1 Let us take a simple example. The block diagram of a dc motor
(armature-controlled) system is shown in Fig. 5

Figure 5 Block diagram of a dc motor (armature-controlled) system

where

is the resistance of the motor armature (ohms) = 1.75


is the inductance of the motor armature (H) =
is the torque constant (Nm/A) = 0.0924
is the back emf constant (V sec/rad) = 0.0924
is the inertia seen by the motor (includes inertia of the load) (kg-m2 )
=
is the mechanical damping coefficient associated with rotation
(Nm/(rad/sec))= 5.0
is the applied voltage (volts) = 5 volts

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.

Figure 6 SIMULINK blocks required for implementation


Identifying the block(s) required for simulation purpose is in fact the first step of
the construction of simulation diagram in SIMULINK. The next step is to ‘drag and
drop ‘the required blocks from SIMULINK block libraries to untitled workspace.
Let us put the very first block for applied voltage (Ea) to workspace.

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

Figure 7 Drag and drop blocks to Workspace from Library Browser


Figure 8 Unconnected blocks in Workspace

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.

For armature circuit transfer function, no need to change the numerator


parameter. For denominator parameters, enter [ ] for [ ],
which will be interpreted by SIMULINK as . To enhance the interpretability of
simulation diagram, we can also change the block identification name. Simply
click on the text Transfer Fcn to activate the small window around the text to
change the block name. For our simulation block diagram, the suitable text for
Transfer Fcn block may be Armature circuit.

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.

Figure 10: Finished block diagram

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

Figure 11 Enter simulation time


Now we are ready to simulate our block diagram of armature-controlled dc
motor. Press icon to start the simulation. Note that the icon changes to ;
pressing this icon, one can stop the simulation before stop time. After simulation
is done, double click the Scope block to display the angular velocity variation with
time. Click the auto scale icon in the display window to scale the axes as per
the variable ranges. Auto scaled scope display is shown in Fig. 12a. With zoom
facility, try to zoom the portion of graph between 0.5 to 1 sec, and 20 to 25
unit angular velocity to identify the numerical value of angular velocity at 0.8
seconds.

(a)Scope display of angular velocity (b)Scope axis properties editor


Figure 12: Scope Display and property editor

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.

Figure 13 Scope parameter setting window

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.

5.1 Transfer Function Manipulation


Suppose we have developed mathematical models in the form of transfer
functions for the plant, represented by G(s), and the controller, represented by
D(s), and possibly many other system components such as sensors and actuators.
Our objective is to interconnect these components to form block diagram
representation of a feedback control system. MATLAB offers several functions to
carry out block diagram manipulations.

Three methods are available:


5.1.1. Solution via series, parallel, and feedback commands:

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

5.1.2. Solution via algebraic operations:


G*D for a cascade connection of G(s) and D(s); G1+G2 for a parallel connection of
G1(s) and G2(s); G/(1+G*H) for a closed-loop negative feedback connection with
G(s) in the forward path and H(s) in the feedback path; and G/(1-G*H) for positive
feedback systems.

5.1.3. Solution via Simulink:


A simple open-loop control system can be obtained by interconnecting a
process and a controller in series, parallel and feedback using Simulink library.

Example 2: Series connection

Let the process represented by the transfer function G(s) be

and let the controller represented by the transfer function Gc(s) be

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

Example 3 The feedback function with unity feedback

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

5.2 Solving differential equations using Simulink

There are several computer packages for finding solutions of differential


equations, such as Maple, Mathematica, Maxima, MATLAB, etc. These systems
provide both symbolic and numeric approaches to finding solutions. They often
require a bit of coding. However, there are graphical environments for solving
problems, including differential equations. One such environment is Simulink,
which is closely connected to MATLAB.

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

∫( )

We will view this as a system in which the input, is fed into


an integrator and the output will be This is shown schematically in Figure 16.

Figure 16. Schematic for solving . The terms and


are fed into the integrator and x is output.

Figure 17 . System for solving first order ODE as a Simulink


simulation

For this example, we implement the following steps:


• Drag needed blocks into the model region [Figure 17]:
– Integrator block from the Continuous group;
– Sum block from the Math Operations group,
– Gain block from the Math Operations group,
– Sine Wave block from the Math Operations group; and,
– Scope block from the Sink group.
Lab Task 01. Simulate the control system shown in Figure 16 (a) and (b) using
SIMULINK

(a)

(b)

Figure 16: Feedback system

Lab Task 02: A multiloop feedback system is shown in Figure 17. Simulate the
control system using SIMULINK
Figure 17: Multiloop feedback system

Lab Task 03:

This problem is to study the effects of Proportional (P), Proportional + Integral


(PI), and Proportional + Derivative (PD) control schemes on the temperature
control system. A temperature control system has the block diagram given in
Figure 18. The input signal is a voltage and represents the desired temperature.
Simulate the control system using SIMULINK and find the steady-state error of the
system when is a unit-step function and

(i)

(ii)

(iii)

Figure 18: Block diagram for Lab Task 3


Hint: Use PID Controller block from Simulink Extras Additional Linear to implement the PID controller.
Assessment Sheet

Name:___________________________

Regd. No._________________________

Date of Lab:________________________

Performance Parameter Marks

Example
Lab Section
Lab Task

Working
Lab Performance
Viva

Total Score in Lab

Instructor’s Verification

You might also like