Sunteți pe pagina 1din 54

CONTROL SYSTEMS (MT-322)

Submitted as a part of partial requirement for


Bachelors of Science in Mechatronics Engineering

Submitted by:
Umar Farooq
15-MCT-25

Submitted to:
Engr. Naeem Zafar

Department of Mechatronics Engineering


University of Engineering and Technology, Taxila
SUB-CAMPUS CHAKWAL

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Table of Contents
Sr. Contents Page Date of
No. No. performance
1 Blocks used and their description throughout the 3 ---
manual
2 Experiment No. # 1 6 08 March, 2018
An introduction to MATLAB environment
3 Experiment No. # 2 13 15 March, 2018
To get a review of loops, conditional, and iterative or
logical operations in MATLAB.
4 Experiment No. # 3 18 20 March, 2018
To solve transfer functions of different electrical
networks in MATLAB (Simulink).
5 Experiment No. # 4 25 29 March, 2018
To solve transfer functions of different mechanical
systems in MATLAB (Simulink).
6 Experiment No. # 5 32 03 April, 2018
To solve transfer functions of different rotational
mechanical systems in MATLAB (Simulink).
7 Experiment No. # 6 39 12 April, 2018
To solve transfer functions for electromechanical
systems or mechatronic systems in MATLAB
(Simulink).
8 Experiment No. # 7 44 19 April, 2018
An introduction to state space models in MATLAB
9 Experiment No. # 8 48 26 April, 2018
Dynamic system’s response analysis

10 Experiment No. # 9 53 15 May, 2018


An introduction to modular servo system MS150.
11 Experiment No. # 10 57 24 May, 2018
To use operational amplifier unit of modular servo
system
12 Experiment No. # 11 63 29 May, 2018
DC motor control and characteristics
Control Systems 6th Semester (Spring 2018) 15-MCT-25
13 Experiment No. # 12 69 21 June, 2018
To use modular servo system as a closed-Loop position
control system.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Blocks used and their description throughout the manual

Sr. Component Symbol Description


No
1 Resistor The voltage-current (V-I) relationship for a linear resistor is V=I*R,
where R is the constant resistance in ohms. The positive and negative
terminals of the resistor are denoted by the + and - signs respectively.
By convention, the voltage across the resistor is given by V(+)-V(-),
and the sign of the current is positive when flowing through the device
from the positive to the negative terminal. This convention ensures that
the power absorbed by a resistor is always positive.
2 Inductor Models a linear inductor. The relationship between voltage V and
current I is V=L*dI/dt where L is the inductance in henries (H). The
Series resistance and Parallel conductance represent small parasitic
effects. The series resistance can be used to represent the DC winding
resistance and/or the resistance due to the skin effect. A small parallel
conductance may be required for the simulation of some circuit
topologies. Consult the documentation for further details.
3 Voltage sensor The block represents an ideal voltage source that is powerful enough to
maintain the specified voltage at its output regardless of the current
passing through it. The output voltage is V = Vs, where Vs is the
numerical value presented at the physical signal port.

4 Operational Models an ideal Operational Amplifier (Op-Amp). If the voltage at the


amplifier positive pin is denoted by Vp, and the voltage at the negative pin by
Vm, then an ideal op-amp behavior is defined by Vp = Vm. In other
words, the op-amp gain is assumed to be infinite. By implication, the
current from the Vp to the Vm terminal is zero
5 Capacitor Models a linear capacitor. The relationship between voltage V and and
current I is I=C*dV/dt where C is the capacitance in farads.

The Series resistance and Parallel conductance represent small parasitic


effects. The parallel conductance can be used to model dielectric losses
and the series resistance used to represent the effective series resistance
(ESR) of the capacitor. Simulation of some circuits may require the
presence of the small series resistance. Consult the documentation for
further details.
6 Electrical Electrical reference port. A model must contain at least one electrical
Reference reference port (electrical ground).
7 Controlled The block represents an ideal voltage source that is powerful enough to
voltage-source maintain the specified voltage at its output regardless of the current
passing through it. The output voltage is V = Vs, where Vs is the
numerical value presented at the physical signal port.

8 Ideal Force The block represents an ideal force sensor, that is, a device that converts
Sensor a variable passing through the sensor into a control signal proportional
to the force with a specified coefficient of proportionality. The sensor
is ideal since it does not account for inertia, friction, delays, energy
consumption, and so on.

Connections R and C are mechanical translational conserving ports that


connect the sensor to the line whose force is being monitored.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Connection F is a physical signal port that outputs the measurement
result. The sensor positive direction is from port R to port C.
9 Ideal The block represents an ideal mechanical rotational motion sensor, that
Rotational is, a device that converts an across variable measured between two
Motion Sensor mechanical rotational nodes into a control signal proportional to
angular velocity or angle. The sensor is ideal since it does not account
for inertia, friction, delays, energy consumption, and so on.

Connections R and C are mechanical rotational conserving ports and


connections W and A are physical signal output ports for velocity and
angular displacement, respectively.
10 Ideal The block represents an ideal mechanical translational motion sensor,
Translational that is, a device that converts an across variable measured between two
Motion Sensor mechanical translational nodes into a control signal proportional to
velocity and position. The sensor is ideal since it does not account for
inertia, friction, delays, energy consumption, and so on. Connections R
and C are mechanical translational conserving ports and connections V
and P are physical signal output ports for velocity and position,
respectively. The block positive direction is from port R to port C.
11 Rotational The block represents an ideal mechanical rotational linear spring.
spring
Connections R and C are mechanical rotational conserving ports. The
block positive direction is from port R to port C. This means that the
torque is positive if it acts in the direction from R to C.
12 Inertia The block represents an ideal mechanical rotational inertia.

The block has one mechanical rotational conserving port. The block
positive direction is from its port to the reference point. This means that
the inertia torque is positive if the inertia is accelerated in the positive
direction.
13 Ideal torque The block represents an ideal source of torque that generates torque at
source its terminals proportional to the input physical signal. The source is
ideal in a sense that it is assumed to be powerful enough to maintain
specified torque regardless of the angular velocity at source terminals.

Block connections R and C are mechanical rotational conserving ports.


Port S is a physical signal port, through which control signal that drives
the source is applied. Positive signal at port S generates torque acting
from C to R.
14 Ideal force The block represents an ideal source of force that generates force
Source proportional to the input physical signal. The source is ideal in a sense
that it is assumed to be powerful enough to maintain specified force
regardless of the velocity at source terminals.

Block connections R and C are mechanical translational conserving


ports. Port S is the physical signal port, through which control signal
that drives the source is applied. Positive signal at port S generates force
acting from C to R.
15 Rotational The block represents an ideal mechanical rotational viscous damper.
Damper Connections R and C are mechanical rotational conserving ports, with
R representing the damper rod, while C is associated with the damper
case. The block positive direction is from port R to port C.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


16 Gear-box The block represents an ideal, non-planetary, fixed gear ratio gear box.
The gear box is characterized by its only parameter, Gear ratio, which
can be positive or negative. Connections S and O are mechanical
rotational conserving ports associated with the box input and output
shaft, respectively. The gear ratio is determined as the ratio of the input
shaft angular velocity to that of the output shaft.

The block generates torque in positive direction if a positive torque is


applied to the input shaft and the ratio is assigned a positive value.
17 Mechanical This block represents a mechanical rotational reference point, that is, a
Rotational frame or a ground. Use it to connect mechanical rotational ports that
Reference are rigidly affixed to the frame (ground).
18 Rotational This block represents a mechanical rotational free end. Use it to allow
Free End a node to rotate freely without torque. This block can be used to
optionally specify initial rotational velocity.
19 Mass The block represents an ideal mechanical translational mass.

The block has one mechanical translational conserving port. The block
positive direction is from its port to the reference point. This means that
the inertia force is positive if mass is accelerated in positive direction.
20 Translational The block represents an ideal mechanical linear spring.
Spring
Connections R and C are mechanical translational conserving ports.
The block positive direction is from port R to port C. This means that
the force is positive if it acts in the direction from R to C.
21 Mechanical This block represents a mechanical translational reference point, that is,
Tranlational a frame or a ground. Use it to connect mechanical translational ports
Reference that are rigidly affixed to the frame (ground).
22 Tranlational This block represents a mechanical translational free end. Use it to
Free End allow a node to translate freely without force. This block can be used
to optionally specify initial velocity.
23 Tranlational The block represents an ideal mechanical translational viscous damper.
Damper
Connections R and C are mechanical translational conserving ports,
with R representing the damper rod, while C is associated with the
damper case. The block positive direction is from port R to port C.
24 DC Motor This block represents the electrical and torque characteristics of a DC
motor.
The block assumes that no electromagnetic energy is lost, and hence the
back-emf and torque constants have the same numerical value when in
SI units. Motor parameters can either be specified directly, or derived
from no-load speed and stall torque. If no information is available on
armature inductance, this parameter can be set to some small non-zero
value. When a positive current flows from the electrical + to - ports, a
positive torque acts from the mechanical C to R ports. Motor torque
direction can be changed by altering the sign of the back-emf or torque
constants.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Experiment No. # 1
An introduction to MATLAB environment
Objective:
The objective of this lab is to understand the use of
• How to get familiarize with MATLAB
• How to use MATLAB editor to create M-Files
• How to use vectors in MATLAB
• How to use matrix in MATLAB
• How to use loop, cases of conditions in MATLAB
• How to write a code for assigned task

MATLAB (matrix laboratory):


MATLAB is a commercial "MATrix LABoratory" package which operates as an interactive
programming environment. MATLAB program and script files always have filenames ending with
".m"; the programming language is exceptionally straightforward since almost every data object is
assumed to be an array. Graphical output is available to supplement numerical results.

Online help is available from the MATLAB prompt (a double arrow), both generally (listing all
available commands):

>> “Prompt”

The MATLAB Working Environment

The MATLAB Desktop

The MATLAB desktop is the main MATLAB application window. As Fig 1 shows the desktop
contains five sub windows:

1. The Command Window


2. The Workspace Browser
3. The Current Directory Window
4. The Command history Window
5. And one or more Figure Windows

The Command Window is where the user types MATLAB Commands and expressions at the
prompt >> and where the output of those commands are displayed

MATLAB defines the workspace as the set of variables that the user creates in a work session. The
Workspace Browser shows these variables and some information about them. Double Clicking on
a variable in the workspace browser launches the Array Editor, which can be used to obtain
information and in some instances edit certain properties of the variable

Control Systems 6th Semester (Spring 2018) 15-MCT-25


The Current Directory tab above the workspace tab shows the contents of the current directory,
whose path is shown in the Current Directory Window
For example in the windows operating system the path might be as follows:
C:\MATLAB\Work, indicating that directory “Work” is a subdirectory of the main directory
“MATLAB”, which is installed in drive C. Clicking on the arrow in the Current Directory Window
shows a list of recently used paths. Clicking on the button to the right of the window allows the
user to change the current directory.

The Command history Window contains a record of the commands a user has entered in the
command window, including both current and previous MATLAB sessions. Previously entered
MATLAB commands can be selected and re-executed from the command history window by right
clicking on a command or sequence of commands. This action launches a menu from which to
select various options in addition to executing the commands.
Getting Help

The Principle way to get help is to use the MATLAB Help Browser, opened as a separate window
either by clicking on the question mark symbol (?) on the desktop toolbar, or by typing help
browser at the prompt in the Command Window

>> help browser


[MATLAB help browser will be opened where you can get information about various topics]

The Help Browser consist of two panes, the help navigator pane, used to find information, and the
display pane, used to view the information

Search field also exists on the navigator pane where you can type either specific words, function
names or any phrase to get information which you are looking for:

Another way to get help for a specific function is by typing doc followed by the function name at
the command prompt
[E.g. typing doc format followed displays documentation for the function called format in the
display pane of the Help Browser]

M- Functions have two types of information that can be displayed by the user.

The first is called the H1 line, which contains the function name and the one line
description

The second is a block of explanation called the Help text block


.
.
.
.
.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Using the MATLAB editor to create M-Files

The MATLAB editor is both a text editor specialized for creating M-files and a graphical
MATLAB debugger

The editor can appear in the window by itself, or it can be a sub window in the desktop. M-files
are denoted by the extension .m as in introlab.m.

The MATLAB editor window has numerous pull down menus for tasks such as saving, viewing
and debugging files. Because it performs some simple checks and also uses colors to differentiate
between various elements of code, this text editor is recommended as the tool of choice for writing
and editing M-Functions

To open the editor type edit at the prompt in the command window.

Introduction to Vectors in MATLAB

This is the basic introduction to MATLAB. Creation of vectors is included with a few basic
operations. Topics include the following:

1. Defining a vector
2. Accessing elements within a vector

Defining a Vector
MATLAB is a software package that makes it easier for you to enter matrices and vectors, and
manipulate them. The interface follows a language that is designed to look a lot like the notation
use in linear algebra.

Almost all of MATLAB's basic commands revolve around the use of vectors. A vector is defined
by placing a sequence of numbers within square braces:

>> v = [3 1 7 -21 5 6 4]

v=

3 1 7 -21 5 6 4

This creates a row vector which has the label "v". The first entry in the vector is a 3 and the second
entry is a 1. Note that MATLAB printed out a copy of the vector after you hit the enter key. If you
do not want to print out the result put a semi-colon at the end of the line:

Control Systems 6th Semester (Spring 2018) 15-MCT-25


>> v = [3 1 7 -21 5 6 4];

If you want to view the vector just type its label:

>> v

v=

3 1 7 -21 5 6 4
Notice, though, that this always creates a row vector. If you want to create a column vector you
need to take the transpose of a row vector. The transpose is defined using an apostrophe ("'"):

>> v = [3 1 7 -21 5 6 4]'


.
.
.
.
.
.

Introduction to Matrices in MATLAB

A basic introduction to defining and manipulating matrices is given here. It is assumed that
you know the basics on how to define and manipulate vectors using MATLAB.

A=

1 2 3
3 4 5
6 7 8

You can also treat it like a row of column vectors:

>> B = [ [1 2 3]' [2 4 7]' [3 5 8]']


B=
1 2 3
2 4 5
3 7 8

Control Systems 6th Semester (Spring 2018) 15-MCT-25


If you have been putting in variables through this and the tutorial on vectors, then you probably
have a lot of variables defined. If you lose track of what variables you have defined, the WHOS
command will let you know all of the variables you have in your work space.

>> whos
Name Size Bytes Class
double
A 3x3 72 array double
B 3x3 72 array double
V 1x5 40 array

Grand total is 23 elements using 184 bytes

.
.
.
.
.

Conditional Control (If, Switch)

This group of control statements enables you to select at run-time which block of code is executed.
To make this selection based on whether a condition is true or false, use if statement (which may
include else or elseif). To select from a number of possible options depending on the value of an
expression, use the switch and case statements.

if, else, and elseif

if evaluates a logical expression and executes a group of statements based on the value of the
expression. In its simplest form, its syntax is

if logical_expression

statement
s end
Control Systems 6th Semester (Spring 2018) 15-MCT-25
If the logical expression is true (1), MATLAB executes all the statements between if and end lines.
It resumes execution at the line following the end statement. If the condition is false (0), MATLAB
skips all the statements between if and end lines, and resumes execution at the line following the
end statement. For example,

if rem(a, 2) == 0 disp('a is
even')
b = a/2;
end

You can nest any number of if statements.

Switch, case, and otherwise

Switch executes certain statements based on the value of a variable or expression. Its basic form is
switch expression (scalar or string)

.
.
.
.
.

Loops

With loop control statements, you can repeatedly execute a block of code, looping back through
the block while keeping track of each iteration with an incrementing index variable. Use the ” for
statement” to loop a specific number of times.

For Loop

The for loop executes a statement or group of statements a predetermined number of times.

Its syntax is
for index = start: increment: end statements
end

The default increment is 1. You can specify any increment, including a negative one. For positive
indices, execution terminates when the value of the index exceeds the end value; for negative
increments, it terminates when the index is less than the end value.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


For example, this loop executes five times. for n = 2:6 x(n)
= 2 * x(n - 1);
end

You can nest multiple for loops.

for m = 1:5 for n


= 1:100
A(m, n) = 1/(m + n - 1);
end
end

while Loop

The while loop executes a statement or group of statements repeatedly as long as the controlling
expression is true (1).
Its syntax is

while expression statements


end

If the expression evaluates to a matrix, all its elements must be 1 for execution to continue. To
reduce a matrix to a scalar value, use the all and any functions.

Exercises:
Write a MATLAB code of Factorial Program with the help of loop Constructs (Use For or
While).

MATLAB Code:

N = 5; factorial = 1; for
i=1:1:n factorial = factorial*i;
end

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Experiment No. # 2
To get a review of loops, conditional, and iterative or logical operations in
MATLAB.
Objective:
The objective of this lab is to understand the use of
• User-defined functions in MATLAB.
• If/else statements in MATLAB.
• Nested for/ while loops in MATLAB.

User-defined Functions in MATLAB:


MATLAB includes several build in functions for complex problem analysis. In this lab, we started
by creating a simple M-file. M-file is a function file. Unlike a script file, all the variables in a
function file are local variables, which means their values are available only within the function.
Function files are useful when you need to repeat a set of commands several times. They are the
building blocks of larger programs. To create a function file, open the Editor window. The first
line in a function file must begin with a function definition line that has a list of inputs and outputs.
This line distinguishes a function M-file from a script M-file.
Its syntax is as follows,
function [output variables] = function_name (input variables)
The output variables are those variables whose values are computed by the function, using the
given values of the input variables. Note that the output variables are enclosed in square brackets,
while the input variables must be enclosed with parentheses. The function_name should be the
same as the file name in which it is saved (with the .m extension). That is, if we name a function
title, it should be saved in the file title.m. The function is “called” by typing its name (for example,
title) at the command line.
For example the following function named area.m calculate the area of circle for the given radius,
function [A] = area(r) r=input('please
enter the value of radius:')
A=pi*r
end

Loops in MATLAB:
A loop is a structure for repeating a calculation a number of times. Each repetition of the loop is a
pass. MATLAB uses two types of explicit loops. the for loop and a while loop. They are
explained below.
• The for loop
The for loop is used when the number of passes is known ahead of time. The following example
demonstrate the use of for loop.
Control Systems 6th Semester (Spring 2018) 15-MCT-25
The typical structure of a for loop is for
loop variable m:s:n
statements end
We write a script file to compute the sum of the first 15 terms in the series 5𝑘2 − 2𝑘, k =
1, 2, 3, . . . , 15.
Because we know how many times we must evaluate the expression 5𝑘2 − 2𝑘, we can use for loop.
The script file is the following,

total = 0; for k = 1:15


total = 5*k^2 - 2*k +
total; end
disp ('The sum for 15 terms is:') disp
(total)

• The while loop


The while loop is used when the looping process terminates when a specified condition is satisfied,
and thus the number of passes is not known in advance.
The typical structure of a while loop follows.
while logical expression statements
end
A simple example of a while loop is
We write a script file to determine the number of terms required for the sum of the series 5k2 − 2k,
k=1, 2, 3,…… to exceed 10,000. What is the sum for this many terms?
Because we do not know how many times we must evaluate the expression 5k2 − 2k, we use
a while loop. The script file is the following:

total = 0;
k = 0;
while total < 1e+4
k = k + 1;
total = 5*k^2 - 2*k + total;
end
disp('The number of terms is:')
disp(k)
disp('The sum is:')
disp(total)

The if/elseif/else Statements:


In everyday language we describe our decision making by using conditional phrases such as “If I
get a raise, I will buy a new car.” If the statement “I get a raise” is true, the action indicated will
be executed.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


The if statement’s basic form is
if logical expression statements
end

The basic structure for the use of the else statement is


if logical expression statement group 1 else
statement group 2
end

The general form of the elseif statement is


if logical expression 1 statement group 1
elseif logical expression 2 statement
group 2 else
statement group 3
end
The conditional statements are explained through an example as follows given by the instructor
as a home task. Exercises:
Write a user-defined function in MATLAB to calculate the grade awarded to the student
according to percentage entered by the user.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


while(1)
x=input('Please enter the value of
percentage:') if x>=90&&x<=100
disp('You have passed the exams with grade A+')
elseif x>=80&&x<=89 disp('You have passed the
exams with grade A') elseif x>=70&&x<=79
disp('You have passed the exams with grade B')
elseif x>=60&&x<=69 disp('You have passed the
exams with grade C') elseif x>=50&&x<=59
disp('You have passed the exams with grade D')
elseif x>=0&&x<=49 disp('Sorry, You are Fail!')
else
disp('Please enter a correct percentage between 0-
100') end end

Command window asked for an input and execute the instruction to decide the grade of the student
as follows

Results/ Conclusion:
In this lab, we made a short review of conditional and iterative opartions in MATLAB. A revision
for mostly used MATLAB commands were made. We create simple MATLAB’s user
Control Systems 6th Semester (Spring 2018) 15-MCT-25
defined functions and call them in MATLAB command window to check the results. At the end
of the lab, a simple program by using if statement was created. Different MATLAB features were
explored in the lab.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Experiment No. # 3
To solve transfer functions of different electrical networks in MATLAB
(Simulink).
Objective:
The objective of this lab is to understand the use of simulink.
• To model and analyze any system like electrical, mechanical, hydraulic and pneumatic
etc.
• To solve transfer function for electrical networks including passive elements
• To solve transfer function for electrical networks including other electronic components
like amplifiers etc.

What is a Simulink?
Simulink is a program that runs as a companion to MATLAB. Simulink provides a graphical user
interface (GUI) that is used in building block diagrams, performing simulations, as well as
analyzing results of dynamic systems. In Simulink, models are hierarchical so that you can view a
system at a high level, then double click on blocks by using the mouse to go down through the
design levels.

How to open simulink?


To open Simulink open the MATLAB command window first. Click on the icon which is present
in the toolbar in the command window of MATLAB. Alternatively you can also enter the
command Simulink to open the graphics library of Simulink.

Procedure to use simulink for modeling of any system:


Steps:
• Open MATLAB workspace.
• Type simulink and return---simulink library browser window is open.
• Click file and choose new then choose model---a blank window is open.
• Open one of the commonly used blocks and drag and drop whatever you need to the
blank window.
• Connect the components by arrows.
• Click each component to setup the parameters properly
• When ready, click simulation and choose configuration parameters to setup simulation
time. Finally, click simulation and choose start.

Transfer function:

Control Systems 6th Semester (Spring 2018) 15-MCT-25


A function that algebraically relates a system's output to its input. This function will allow
separation of the input, system, and output into three separate and distinct parts, unlike the
differential equation. The function will also allow us to algebraically combine mathematical
representations of subsystems to yield a total system representation.
In general, a physical system that can be represented by a linear, time-invariant differential
equation can be modeled as a transfer function. In this and next couple of experiments, we will
learn how to represent electrical networks, translational mechanical systems, rotational mechanical
systems, and electromechanical systems as transfer functions.

Transfer functions of electrical networks:


In this experiment, we formally apply the transfer function to the mathematical modeling of
electric circuits including passive networks and operational amplifier circuits. In next experiments,
we will cover mechanical and electromechanical systems. Equivalent circuits for the electric
networks that we work with first consist of three passive linear components: resistors, capacitors,
and inductors. We now combine electrical components into circuits, decide on the input and
output, and find the transfer function.
Let us apply the concept of a transfer function to an example and then use the result to find the
response of the system.

Exercises:

1. To open a block library, double click on the associated library icon in the Simulink block
library window. After opening the Sources library, the Sources library window opens.
2. To add the first block to the diagram, point the mouse at the block in the Sources library
window and press the left button. Create a new model window by clicking on to the new
icon at the toolbar. Without releasing the left mouse button, drag the mouse to the new
model window and release the mouse button.
3. In general the inputs to a block are on the left a > symbol points into the block. In addition,
outputs are generally on to the right, a > symbol out of the block.
4. To add a connection, use the mouse to position the pointer over the output port of the block.
During this time the pointer changes to cross hairs.
5. Labels can be added to lines to further annotate your model. To create a signal label, double
click on a line segment and type the label at the insertion point.
6. Add a scope at the output of the function’s modeling to analyze the results.
7. To view the results of the simulation, double click on the scope block.
8. Double click on any of the added block and examine the data fields.
Go to >>Simscape>>Electrical>>Create Model>> >> Search for select any
component block. Left click on component and click on add to untitled or named file.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


1) Find the transfer function, G(s) = VL(s)/V(s), for the
circuit given in Figure.

Modeling:

Scope:

MATLAB command window:

Control Systems 6th Semester (Spring 2018) 15-MCT-25


2) Find the transfer function relating the capacitor
voltage, Vc(s), to the input voltage, V(s) in Figure.

Modeling:

Scope:

MATLAB command window:

Control Systems 6th Semester (Spring 2018) 15-MCT-25


3) Find the transfer function, V0(s)/Vi(s), for the
circuit given in Figure.

Modeling:

Scope:

Control Systems 6th Semester (Spring 2018) 15-MCT-25


MATLAB command window:

4) Given the network of Figure, find the transfer


function, Vc(t)/V(t).

Modeling:

Scope:

Control Systems 6th Semester (Spring 2018) 15-MCT-25


MATLAB command window:

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Experiment No. # 4
To solve transfer functions of different mechanical systems in MATLAB
(Simulink).
Objective:
The objective of this lab is to understand the use of Simulink.
• To understand the layout or graphical user interface of MATLAB.
• To model and analyze any system like electrical, mechanical, hydraulic and pneumatic etc.
• To solve transfer function for translational mechanical systems including common
mechanical components like mass, spring, damper etc.
• To solve transfer function for other systems like rotational mechanical systems etc.

Transfer Function in MATLAB:


We have modeled different electrical networks in the last lab. Now we are familiarized with our
objective to solve for transfer function in s domain. To do so we have followed the following steps
to achieve our objective.
• First of all open the modeled network in the Simulink.
• Now go to Analysis>>Control Design>>Linear Analysis.
• Linear analysis tool window will open. Before going to next step, make sure that you have
modeled a successful build model with no errors.
• On linear analysis tool window click on step and copy file form linear analysis workspace
to MATLAB workspace.
• Finally enter tf(linsys1) to find the find the transfer in s domain where linsys1 is the name
of the variable in MATLAB workspace.

Transfer functions of mechanical systems:


Mechanical systems parallel electrical networks to such an extent that there are analogies between
electrical and mechanical components and variables. Mechanical systems, like electrical networks,
have three passive, linear components. Two of them, the spring and the mass, are energy-storage
elements; one of them, the viscous damper, dissipates energy. The two energy-storage elements
are analogous to the two electrical energy-storage elements, the inductor and capacitor. The energy
dissipater is analogous to electrical resistance.

Translational Mechanical Systems:


Translational mechanical systems move along a straight line. These systems mainly consist of
three basic elements. Those are mass, spring and dashpot or damper. If a force is applied to a
translational mechanical system, then it is opposed by opposing forces due to mass, elasticity and
friction of the system. Since the applied force and the opposing forces are in opposite directions,
the algebraic sum of the forces acting on the system is zero. Let us now see the force opposed by
these three elements individually.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Rotational mechanical systems:
Rotational mechanical systems move about a fixed axis. These systems mainly consist of three
basic elements. Those are moment of inertia, torsional spring and dashpot. If a torque is applied
to a rotational mechanical system, then it is opposed by opposing torques due to moment of inertia,
elasticity and friction of the system. Since the applied torque and the opposing torques are in
opposite directions, the algebraic sum of torques acting on the system is zero. Let us now see the
torque opposed by these three elements individually.

Procedure:
The procedure for mechanical system modeling consists of same steps as for previous experiment
expect we will use mechanical components instead of electrical components.
• First of all, open MATLAB and enter Simulink or click on the Simulink icon on the top of
the MATLAB window to open Simulink.

• Go to >>Simscape>>Electrical>>Create Model>> >> Search for select any


component block. Left click on component and click on add to untitled or named file.
• Incase if you are not getting any component then check individually each components by
going to Simscape>>Foundation Library>>Mechanical and select required component
block from library.

Exercises:
We are now ready to find transfer functions for translational mechanical systems. Our first example
is similar to the simple RLC network. The mechanical system requires just one differential
equation, called the equation of motion, to describe it. We will begin by assuming a positive
direction of motion, for example, to the right. This assumed positive direction of motion is similar
to assuming a current direction in an electrical loop. Using our assumed direction of positive
motion, we first draw a free-body diagram, placing on the body all forces that act on the body
either in the direction of motion or opposite to it. Next we use Newton’s law to form a differential
equation of motion by summing the forces and setting the sum equal to zero. Finally, assuming
zero initial conditions, we take the Laplace transform of the differential equation, separate the
variables, and arrive at the transfer function.

1) Find the transfer function,(𝒔)/𝑭(𝒔), for the system of Figure.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Modeling:

Scope:

MATLAB command window:

Control Systems 6th Semester (Spring 2018) 15-MCT-25


2) Find the transfer function, G(s) = X2(s)/F{s), for the translational mechanical
network shown in Figure.

Modeling:

Scope:

Control Systems 6th Semester (Spring 2018) 15-MCT-25


MATLAB command window:

3) For the system of Figure P2.12 find the transfer 29. Write, but do not solve,
the equations of motion for function, G(s) = Xi{s)/F(s).

Modeling:

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Scope:

MATLAB command window:

4) Find the transfer function, G(s) = X2(s)/F(s). for the translational mechanical
system shown in Figure.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Modeling:

Scope:

MATLAB command widow:

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Experiment No. # 5
To solve transfer functions of different rotational mechanical systems in
MATLAB (Simulink).
Objective:
The objective of this lab is to understand the use of Simulink.

• To understand the layout or graphical user interface of MATLAB.


• To model and analyze any system like electrical, mechanical, hydraulic and pneumatic etc.
• To solve transfer function for rotational mechanical systems including common mechanical
components like mass, spring, damper etc.
• To solve transfer function for other systems that includes mechanisms like gears etc.

Rotational mechanical systems:


Having covered electrical and translational mechanical systems, we now move on to consider rotational
mechanical systems. Rotational mechanical systems are handled the same way as translational mechanical
systems, except that torque replaces force and angular displacement replaces translational displacement.
The mechanical components for rotational systems are the same as those for translational systems, except
that the components undergo rotation instead of translation.
The concept of degrees of freedom carries over to rotational systems, except that we test a point of motion
by rotating it while holding still all other points of motion. The number of points of motion that can be
rotated while all others are held still equals the number of equations of motion required to describe the
system.

Transfer Functions for Systems with Gears:


Gears provide mechanical advantage to rotational systems. For many applications, gears exhibit backlash,
which occurs because of the loose fit between two meshed gears. The drive gear rotates through a small
angle before making contact with the meshed gear. The result is that the angular rotation of the output gear
does not occur until a small angular rotation of the input gear has occurred. In this section, we idealize the
behavior of gears and assume that there is no backlash.
The quantities used in rotating systems are very similar to those in translating systems. They are

• In rotating mechanical systems, the inertia elements are masses that rotate and are characterized
by moment of inertia.
• Rotational spring is an element that is deformed (wound or unwound) in direct proportion to the
amount of torque applied. Ideal springs have no inertia.
• Three elements were introduced, springs, friction elements and inertial elements (masses). An
ideal linear spring has no mass and a linear relationship between force and elongation. For
viscous friction there is a linear relationship between force and velocity. Friction may either be
between
two surfaces (depicted as hash marks) or between two objects (depicted as a dashpot). An ideal
dashpot is also massless. Masses have a linear relationship between force and acceleration.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Linearization of control system:
Following steps shows how to obtain a linear model of a nonlinear system in SIMULINK

• Open the model.


• Open linear analysis tool for the model (Analysis >> Control Design>> Linear Analysis).
• Define Input and output operating points (Right click >> Linear Analysis points).
• Select the desired plot results (like Bode plot, step response).
• Click linearize the model.
• The linearized model is saved as a state space object (linsys1) in the workspace.
• The transfer function can be obtained by using tf command.

Procedure:
The procedure to perform this experiment is similar to last experiments except that we are using here
rotational mechanical components instead of translational mechanical or electrical system components.
• To get start, open Simulink from MATLAB and create a new rotational mechanical system
model. Then open Simulink components library by clicking on the icon.
• After this follow the following directory to get any rotational mechanical component from
Simulink library.
Simscape>>Foundation Library>>Mechanical>>Rotational Elements
• Then follow the same steps as for previous experiment to find out transfer function for the created
model.
• To get required mechanism follow
Simscape>>Foundation Library>>Mechanical>>Mechanism

Exercises:
Simscape enables you to rapidly create models of physical systems within the Simulink
environment. With Simscape you build physical component models based on physical connections
that directly integrate with block diagrams and other modeling paradigms. You model systems
such as electric motors, bridge rectifiers, hydraulic actuators, and refrigeration systems by
assembling fundamental components into a schematic. Simscape add-on products provide more
complex components and analysis capabilities.
Simscape helps you develop control systems and test system-level performance. You can create
custom component models using the MATLAB based Simscape language, which enables
textbased authoring of physical modeling components, domains, and libraries. You can
parameterize your models using MATLAB variables and expressions, and design control systems
for your physical system in Simulink.

1) Find the transfer function (𝒔) = (𝒔)/(𝒔) for the rotational mechanical
system shown in Figure.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Modeling:

Scope:

MATLAB command window:

Control Systems 6th Semester (Spring 2018) 15-MCT-25


2) Find the transfer function (𝒔) = (𝒔)/(𝒔) for the rotational mechanical
system shown in Figure.

Modeling:

Scope:

Control Systems 6th Semester (Spring 2018) 15-MCT-25


MATLAB command window:

3) Find the transfer function 𝑮(𝒔) = 𝜽𝟐(𝒔)/𝑻(𝒔) for the rotational


mechanical system shown in Figure,

Modeling:

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Scope:

MATLAB command window:

4) Find the transfer function (𝒔) = (𝒔)/(𝒔) for the rotational mechanical
system shown in Figure.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Modeling:

Scope:

MATLAB command window:

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Experiment No. # 6
To solve transfer functions for electromechanical systems or mechatronic
systems in MATLAB (Simulink).
Objective:
The objective of this lab is to understand the use of simulink.
• To model and analyze any system that includes electrical, mechanical, hydraulic
pneumatic, and electromechanical system components etc.
• To solve transfer function for systems that include magnetic components as different
electromechanical motors etc.
• To solve transfer function for electromechanical networks including other mechanical
and electronic components.

Electromechanical systems:
Now, we move to systems that are hybrids of electrical and mechanical variables, the
electromechanical systems. One application for systems with electromechanical components are
robot controls, sun and star trackers, and computer tape and disk-drive position controls. A motor
is an electromechanical component that yields a displacement output for a voltage input, that is, a
mechanical output generated by an electrical input. We will derive the transfer function for one
particular kind of electromechanical system, the armature-controlled dc servomotor.
As the name suggests, electromechanical systems or devices convert electrical energy into
mechanical movement – and sometimes vice versa. Most of the common electromechanical
components, such as electric motors and solenoids are used in combination with mechanical parts
to provide actuation or movement.

A mechatronic system, an electromechanical system:


A relatively new branch of engineering design called mechatronics involves integrating the three
areas of sensing, electronic control and mechanical actuation. A modern camera is a good example
of a mechatronic product. One of the goals of mechatronics is to reduce the number of mechanical
components to an absolute minimum; nevertheless in any system where movement is needed, there
remains a basic need for some kind of controlled mechanical output.

Linearization:
The electrical and mechanical systems covered thus far were assumed to be linear. However, if any
nonlinear components are present, we must linearize the system before we can find the transfer function. In
this section, we show how to obtain linear approximations to nonlinear systems in order to obtain transfer
functions. The first step is to recognize the nonlinear component and write the nonlinear differential
equation. When we linearize a nonlinear differential equation, we linearize it for small-signal inputs about
the steady-state solution when the small-signal input is equal to zero. This steady-state solution is called
equilibrium and is selected as the second step in the linearization process. For example, when a pendulum
Control Systems 6th Semester (Spring 2018) 15-MCT-25
is at rest, it is at equilibrium. The angular displacement is described by a nonlinear differential equation,
but it can be expressed with a linear differential equation for small excursions about this equilibrium point.
Next we linearize the nonlinear differential equation, and then we take the Laplace transform of the
linearized differential equation, assuming zero initial conditions. Finally, we separate input and output
variables and form the transfer function.

Procedure:
The procedure for this experiment is similar to last three experiments except that we will use all
system components including electrical, mechanical, and electromechanical components. The
procedure consists of the following steps.
• First of all, open MATLAB and enter command simulink to open the simulink window.
From there create a new generic model or follow the second point.
• Go to >>Simscape>>Generic model>>Create Model>> >> Search for select any
component block. Left click on component and click on add to untitled or named file.
• Incase if you are not getting any component then check individually each components by
going to Simscape>>Foundation Library>> and select required system component type.
Then from there we can select any block from library for network modeling.
• Model the system and linearize it for analyzes.
• After this perform the same steps as for previous experiments and find the transfer function
of the system.

Exercises:
The results for the following exercises are not concise or accurate due to less provided information
about inductance. However, best approach has been made to ensure as accurate answer as can be.
So let us start electromechanical system’s modeling.

1) Given the system and torque-speed curve of Figure 2.39(a) and (b), find
the transfer function, (𝒔)/(𝒔).

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Modeling:

Scope:

MATLAB command window:

Control Systems 6th Semester (Spring 2018) 15-MCT-25


2) Find the transfer function, (𝒔) = (𝒔)/𝑬(𝒔)., for the motor and load shown
in Figure 2.40. The torque-speed curve is given by Tm =8Wm+200 when
the input voltage is 100 volts.

Modeling:

Scope:

MATLAB command window:

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Control Systems 6th Semester (Spring 2018) 15-MCT-25
Experiment No. # 7
An introduction to state space models in MATLAB
Objective:
The objective of this lab is to understand the use of
• How to create a state-space model .
• How to plot root locus of a dynamic systems.
• How to plot pole-zero map on MATLAB.
• How to find state (stable, unstable, marginally stable etc.) of a system from root locus
plot.
• The use of basic commands for stability analysis of dynamic systems

State space approach:


Two approaches are available for the analysis and design of feedback control systems. The first,
which we have studied in first six experiments, is known as the classical, or frequency-domain,
technique. This approach is based on converting a system's differential equation to a transfer
function, thus generating a mathematical model of the system that algebraically relates a
representation of the output to a representation of the input.
The state-space approach is a unified method for modeling, analyzing, and designing a wide
range of systems. For example, the state-space approach can be used to represent nonlinear
systems that have backlash, saturation, and dead zone. Also, it can handle, conveniently, systems
with nonzero initial conditions. Time-varying systems, (for example, missiles with varying fuel
levels or lift in an aircraft flying through a wide range of altitudes) can be represented in state
space. Many systems do not have just a single input and a single
output. Multiple-input, multiple-output systems (such as a vehicle with input direction and input
velocity yielding an output direction and an output velocity) can be compactly represented in
state space with a model similar in form and complexity to that used for single-input, single-
output systems. The time-domain approach can be used to represent systems with a digital
computer in the loop or to model systems for digital simulation. With a simulated system, system
response can be obtained for changes in system parameters—an important design tool. The state
space approach is also attractive because of the availability of numerous state-space software
packages for the personal computer.

State space models:


A system is represented in state space by the following equations:
𝑥 ̇ = 𝐴𝑥 + 𝐵𝑢
𝑦 = 𝐶𝑥 + 𝐷𝑢
Where,
𝑥 = state vector
𝑥 ̇ = derivative of the state vector with respect to time
𝑦 = output vector
𝑢 = input or control vector
𝐴 = system matrix
𝐵 = input matrix

Control Systems 6th Semester (Spring 2018) 15-MCT-25


𝐶 = output matrix
𝐷 = feedforward matrix
Use ss to create state-space models (ss model objects) with real- or complex-valued matrices or
to convert dynamic system models to state-space model form. The following example illustrates
the use of MATLAB to model in state space.
>> A=[1 2;3 4];
>> B=[1;3];
>> C=[1 2];
>> D=0;
>> model=ss(A,B,C,D)

model =

A=
x1 x2
x1 1 2
x2 3 4

B=
u1
x1 1
x2 3

C=
x1 x2
y1 1 2

D=
u1
y1 0

Continuous-time state-space model.

Zeros, Poles, and Gain of a Discrete-Time System:


Poles and Zeros of a transfer function are the frequencies for which the value of the denominator
and numerator of transfer function becomes zero respectively. The values of the poles and the
zeros of a system determine whether the system is stable, and how well the system performs.
Control systems, in the simple sense, can be designed simply by assigning specific values to the
poles and zeros of the system.

Determining poles and zeros from transfer function:


Consider a discrete-time system defined by the transfer function

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Determine its zeros, poles, and gain directly from the transfer function. Pad the numerator
with zeros so it has the same length as the denominator.

>> num=[2 3 0];


>> den=[1 0.4 1];
>> [z p k]=tf2zp(num,den)
z=
0
-1.5000
p=
-0.2000 + 0.9798i
-0.2000 - 0.9798i
k=
2

Pole-zero map:
To create poles-zeros map in MATLAB, first create a transfer function and name the answer.
Finally use command pzplot(answer) to draw the required plot.
The process is illustrated by the following example.

>> sys = tf([2 5 1],[1 3 5]);


>> h = pzplot(sys);
>> grid on

Turning on the grid displays lines of constant damping ratio (zeta) and lines of constant natural
frequency (wn). This system has two real zeros, marked by o on the plot. The system also has a pair
of complex poles, marked by x.
Plot:
The plot for the system is shown below.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Converting from state space representation to transfer function representation
and vice versa.
To do so use the command tf2ss and ss2tf for converting to each other. The process is illustrated
below.

>> [A B C D]=tf2ss(num, den)


A=
-0.4000 -1.0000
1.0000 0
B=
1
0
C=
2.2000 -2.0000
D=
2
>> [b,a] = ss2tf(A,B,C,D)
b=
2 3 0
a=
1.0000 0.4000 1.0000

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Experiment No. # 8
Dynamic system’s response analysis
Objective:
The objective of this lab is to understand the use of
• How to plot step response of a dynamic system.
• How to plot root locus map of a dynamic systems.
• How to plot pole-zero map on MATLAB.
• How to find state (stable, unstable, marginally stable etc.) of a system from root locus
plot.
• The use of basic commands for stability analysis of dynamic systems.

Step Response:
step calculates the step response of a dynamic system. step(sys) plots the step response of an
arbitrary dynamic system model, sys. This model can be continuous- or discrete-time, and SISO or
MIMO. The step response of multi-input systems is the collection of step responses for each input
channel. The duration of simulation is determined automatically, based on the system poles and
zeros. The following example illustrate the use of step function for system’s dynamic analysis.

D=
u1 u2
y1 0 0

Continuous-time state-space model.

>> step(sys)
>> num=[ 1 2 3];
>> den=[4 5 6 7 8];
>> sys=tf(num, den)

sys =

s^2 + 2 s + 3
-------------------------------
4 s^4 + 5 s^3 + 6 s^2 + 7 s + 8

Continuous-time transfer function.


>> step(sys)

Control Systems 6th Semester (Spring 2018) 15-MCT-25


>> A=[1 2;3 4];
>> B=[5 6;7 8];
>> C=[9 10];
>> D=0;
>> sys=ss(A,B,C,D)

sys =

A=
x1 x2
x1 1 2
x2 3 4

B=
u1 u2
x1 5 6
x2 7 8

C=
x1 x2
y1 9 10

Control Systems 6th Semester (Spring 2018) 15-MCT-25


The left plot shows the step response of the first input channel, and the right plot shows the step
response of the second input channel.

System’s stability analysis:


Now, to check whether the system is stable, unstable or marginally stable. The response of a
system depends upon the number and position of poles. On the poles-zero map, for the position
of poles.
Three conditions exists,
 If all the poles lie on left side of imaginary axis, it implies that system is stable.
 If anyone pole is lying on right side of imaginary axis, it implies that system is unstable.
 If the poles lie on the imaginary axis the system will be marginally stable.

Step response characteristics:


To check rise time, peak time, and settling time of a step response then right click on plot and follow
characteristic>>rise time/settling time/peak time.
The following step response fig. shows peak time, settling time and rise time of the given
waveform.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Root locus plot:
rlocus computes the root locus of a SISO open-loop model. The root locus gives the closed-loop
pole trajectories as a function of the feedback gain k (assuming negative feedback). Root loci are
used to study the effects of varying feedback gains on closed-loop pole locations. In turn, these
locations provide indirect information on the time and frequency responses.
rlocus(sys) calculates and plots the root locus of the open-loop SISO model sys. This function can
be applied to any of the following negative feedback loops by setting sys appropriately.

>> num=[1 2];


>> den=[1 2 3 4 5];
>> sys=tf(num,den)

sys =

s+2
-----------------------------
s^4 + 2 s^3 + 3 s^2 + 4 s + 5

Continuous-time transfer function.

>> pzplot(sys)
>> rlocus(sys)

Control Systems 6th Semester (Spring 2018) 15-MCT-25


You can use the right-click menu for rlocus to add grid lines, zoom in or out, and invoke the Property
Editor to customize the plot. Also, click anywhere on the curve to activate a data marker that displays
the gain value, pole, damping, overshoot, and frequency at the selected point.

Control Systems 6th Semester (Spring 2018) 15-MCT-25


Control Systems 6th Semester (Spring 2018) 15-MCT-25

S-ar putea să vă placă și