Академический Документы
Профессиональный Документы
Культура Документы
Submitted by:
Umar Farooq
15-MCT-25
Submitted to:
Engr. Naeem Zafar
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.
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.
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.
Online help is available from the MATLAB prompt (a double arrow), both generally (listing all
available commands):
>> “Prompt”
The MATLAB desktop is the main MATLAB application window. As Fig 1 shows the desktop
contains five sub 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
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
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 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.
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:
>> 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 ("'"):
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
>> whos
Name Size Bytes Class
double
A 3x3 72 array double
B 3x3 72 array double
V 1x5 40 array
.
.
.
.
.
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 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
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.
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
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
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;
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)
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.
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.
Transfer function:
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.
Modeling:
Scope:
Modeling:
Scope:
Modeling:
Scope:
Modeling:
Scope:
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.
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.
Scope:
Modeling:
Scope:
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:
4) Find the transfer function, G(s) = X2(s)/F(s). for the translational mechanical
system shown in Figure.
Scope:
• 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.
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.
Scope:
Modeling:
Scope:
Modeling:
4) Find the transfer function (𝒔) = (𝒔)/(𝒔) for the rotational mechanical
system shown in Figure.
Scope:
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.
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, (𝒔)/(𝒔).
Scope:
Modeling:
Scope:
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
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.
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.
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
>> 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
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
sys =
s+2
-----------------------------
s^4 + 2 s^3 + 3 s^2 + 4 s + 5
>> pzplot(sys)
>> rlocus(sys)