0% found this document useful (0 votes)
660 views18 pages

Control System Engineering: Lab Manual

Here are the key steps to mathematically model electrical and mechanical systems in MATLAB/Simulink: 1. Define the system components and parameters. This includes things like masses, springs, dampers, motors, gears, etc. Specify values for parameters like mass, stiffness, damping coefficient, etc. 2. Draw the free body diagram of the system and apply Newton's laws/Kirchhoff's laws to derive the governing differential equations of motion. This will result in a system of first or second order differential equations. 3. Transform the differential equations into transfer function form using Laplace transform. This gives the frequency response model of the system. 4. Implement the transfer function model in MATLAB using commands like tf,
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
660 views18 pages

Control System Engineering: Lab Manual

Here are the key steps to mathematically model electrical and mechanical systems in MATLAB/Simulink: 1. Define the system components and parameters. This includes things like masses, springs, dampers, motors, gears, etc. Specify values for parameters like mass, stiffness, damping coefficient, etc. 2. Draw the free body diagram of the system and apply Newton's laws/Kirchhoff's laws to derive the governing differential equations of motion. This will result in a system of first or second order differential equations. 3. Transform the differential equations into transfer function form using Laplace transform. This gives the frequency response model of the system. 4. Implement the transfer function model in MATLAB using commands like tf,
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Control System Engineering

Lab Manual

Prepared by: Narayan Longani


Supervised by: Dr. Uzair Khan

Department of Electrical Engineering


COMSATS Institute of Information Technology
Abbottabad
Student Detail
Name: ______________________________________

Registration Number __________________________

Class________________________________________

Section ______________________________________

Teacher’s Name ______________________________

Lab Engineer’s Name _________________________


Tasks
Lab:01 Introduction to MATLAB with control system aspect.................................................. 2
Lab:02 Mathematical modeling of electrical and mechanical systems using
MATLAB/Simulink .................................................................................................................. 7
Lab:03 Frequency domain modeling of electrical and mechanical systems ........................... 10
Lab:04 Frequency domain modeling of electromechanical system ....................................... 12
Lab:05 State space modeling of systems using MATLAB/Simulink..... Error! Bookmark not
defined.
Lab:06 Transient analysis of first order systems ...................... Error! Bookmark not defined.
Lab:07 Transient analysis for the second order systems .......... Error! Bookmark not defined.
Lab 08: System reduction with block diagrams and non-linearity analysis .. Error! Bookmark
not defined.
Lab:09 Stability analysis for the systems under different performance conditions .......... Error!
Bookmark not defined.
Lab:10 Observing the system steady state error for different configurations and parameters
.................................................................................................. Error! Bookmark not defined.
Lab:11 Root locus analysis for the system and introduction to SISO tool .... Error! Bookmark
not defined.
.................................................................................................. Error! Bookmark not defined.
Lab:12 To observe the performance of the PI controller and Lag compensator for different
systems ..................................................................................... Error! Bookmark not defined.
Lab:13 Design of the PD controller and & lead compensator for different systems ........ Error!
Bookmark not defined.
Lab:14 Bode Plot analysis for systems having different order and combination of poles and
zeros.......................................................................................... Error! Bookmark not defined.
Lab:15 Design of the PID controller and Lead-Lag compensator for the systems including
DC motor. ................................................................................. Error! Bookmark not defined.
Lab:01 Introduction to MATLAB with control
system aspect
Objective:
After completing this lab student will get familiar with basics of MATLAB, like basics of coding, how to
plot response of system and properly label it. How transfer function is representing in MATLAB. How to
deal with plot function and SIMULINK.

Introduction:
MATLAB, an abbreviation of MATrix LABoratory, is an interactive program for numerical computation
and data visualization; it is used extensively by control engineers for analysis and design. There are many
different toolboxes available which extend the basic functions of MATLAB into different application
areas; in these tutorials, we will make extensive use of the Control Systems Toolbox. MATLAB is
supported on Unix, Macintosh, and Windows environments.

MATLAB, its Toolboxes and SIMULINK have become, over a number of years, the industry standard
software package for control system design. The purpose of this LAB is to introduce the students to some
of the more useful aspects of MATLAB, and to illustrate how the software may be used to solve problem
in control system design.

Plot
It is also easy to create plots in MATLAB. Suppose you wanted to plot a sine and cosine wave as a
function of time. First make a time vector (the semicolon after each statement tells MATLAB we don't
want to see all the values) and then compute the sine and cosine value at each time.

t = 0:0.25:10;
y = sin(t);
W=cos(t)
plot(t,y,'.ko','LineWidth',2,'MarkerEdgeColor','k','MarkerFaceColor','k','Mar
kerSize',3)
hold on
plot(t,W,'b*','LineWidth',1.5,'MarkerEdgeColor','k','MarkerFaceColor','k','Ma
rkerSize',3);
plot(t,W)
grid on
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Sine and Cosine Waves','fontweight','bold','fontsize',10)
legend('Sine wave','Cosine Wave',1)

For using more functions type in command window


>> help plot
>> help (any function)
While using Simulink, results are observed in scope, Scope block of previous version of MATLAB don’t
give you freedom to edit the graph like today, so first you have to import the data to workspace with help
of block “to workspace” and plot the result using figure. Figure give you ease to edit the graphs

Transfer Function
This part introduces the reader to time domain analysis using MATLAB. It uses commands from the
Control System Toolbox. A list of the commands can be found using
>> help control
>> help step
Following are some examples how to represent transfer function in MATLAB.
Example 1: Consider a first-order transfer function G(s) = 1/(s+1). The impulse response and step
response function can be created by using following commands in script file.

Method 1: use command “tf”


num = [1];
den = [1 1];
sys=tf(num,den)
impulse (sys)
figure
step(sys)
grid on;
Method 2: use command “zpk”
sys=zpk([],[-1],1)
impulse (sys)% Impulse response
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Impulse Response for system
G(s)=1/(s+1)','fontweight','bold','fontsize',10)
legend('Impulse Response',1)
grid on
figure
step(sys) % step response
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Step Response for system
G(s)=1/(s+1)','fontweight','bold','fontsize',10)
legend('Step Response',1)
grid on;

figure
t = 0:0.01:10;
u = sin(t);
y=lsim(sys,u,t)% Sinusoidal response
plot(t,y)
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Sine Response for system
G(s)=1/(s+1)','fontweight','bold','fontsize',10)
legend('Step Response',1)
grid on;
Method 3: use “s=tf('s')”
s=tf('s')
sys=1/(s+1)
subplot(2,1,1) %% for description type help subplot
impulse(sys)
grid on
subplot(2,1,2)
step(sys)
grid on

SIMULINK
The Simulink give us easy Model analysis and construction. SIMULINK allows a block diagram
representation of a control system to be constructed and real-time simulation performed.

Data import/Export in between Simulink and MATLAB


Workspace.
Normally we like to have our results in the Matlab workspace to present them in a more
elaborative way. For this purpose, we intend to transfer the data fromSimulink environment to
the Matlab workspace. Following is the procedure:
1. Go to Simulink Library.
2. Check in to the “Sources” sub-library, and then select and drag the “Clock” into Simulink
editor.
3. Go to “Sink” sub-library, and then select “To-Workspace” block.
4. You can change the label in the “To-Workspace” block for your own convenience in
accordance with the data you are trying to send to MATLAB workspace.
5. You can connect the “To-Workspace” block to any data line (for example: In Figure 3, it
can be connected to the data that is provided to scope).
6. For data synchronization also export the clock data from Simulink to MATLAB
workspace. Copy the “To-Workspace” block and connect it to the “Clock” output.
7. Once it is done, now you need to run the Simulink design. Now you can observe the
results in the MATLAB workspace.
8. You can select different storage options in the “To-Workspace” block. Like in structures
or arrays.
Figure 1: Use Zero-Pole Function Block

Command to plot in MATLAB


plot(TimeOut,Output)
grid on
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Step Response for system
G(s)=1/(s+1)','fontweight','bold','fontsize',10)
legend('Step Response',1)

For data synchronization also export Output as structure from Simulink to MATLAB workspace.

Figure 2: Use Transfer Function Block


Command to plot in MATLAB
plot(Output.time,Output.signals.values)
xlabel('Time','fontweight','bold','fontsize',9)
ylabel('Amplitude','fontweight','bold','fontsize',9)
title('Step Response for system
G(s)=1/(s+1)','fontweight','bold','fontsize',10)
legend('Step Response',1)
grid on

Task: Following are the two transfer functions. Plot the step and impulse response and label properly in
script as well as in Simulink.
1. (s+1)/(s2+2s+1) 2. 10/(s+1)(s+3)(s+5)

In your report label each graph properly as in examples. Also insert caption with each figure. Most
importantly write your observations after each sub-task.

Important Note:
1. If student will copy the lab report, all the identical copy holders will get zero marks.
2. In all subsequent lab reports same lab report style should be used.
Lab:02 Mathematical modeling of electrical and
mechanical systems using MATLAB/Simulink
Objective:
Every day we deal with different physical systems. Interesting fact is that motion or working of these
systems can be modeled mathematically and their behavior can be observed using software’s like Matlab.
This feature helps us in the design of a system. Once the system dynamic mathematical model is
developed, we can transform it into frequency or time domain representation to further analyze the system
performance. In this lab students should be able to mathematically model and simulate the system using
Matlab/Simulnk environment.

Introduction:
A basic RLC circuit is shown is the Figure.1. The system has a voltage source and voltage drops across
each element in the network as shown.

Figure 1: RLC circuit

Its dynamic time domain model on terms of differential equations after following the KVL is

𝑑𝑖(𝑡) 1
𝐿 + ∫ 𝑖(𝑡)𝑑𝑡 + 𝑖(𝑡)𝑅 = 𝑣(𝑡) (1)
𝑑𝑡 𝐶

This is the cause of conversation of energy. As the sum of all voltage drops across each component is
equal to the total applied voltage. There is one resistive and two reactive components in the network. The
circuit is a simple series circuit where it has the same current in the network.

Simulink model for RLC circuit


A simulink model is developed in the Figure 2. In this figure the dynamic mathematical model (1) is
developed in the Simulink environment. The system output is upto the choice of designer for the given
input.
Figure 2: RLC circuit modeled in the Simulink environment

In an identical manner a translational mechanical system is given in Figure 3 can be model as (2).

Figure 3: Translational Mechanical System

The governing differential equation for the system is


d2 x dx
M dt2 + fv dt + Kx = f(t) (2)

This system could also be modeled in the identical manner using Matlab/Simulink. The choice of the
output is upto the student for the given input.
Student Task: Use the Matlab/Simulink environment to model and simulate the 3DOF system shown in
Figure 4. Take the step response and discuss the results. Provide the complete and solid analysis on the
system response. Lab report should be presented under the instructions provided in the earlier lab.

Figure 3. 3DOF RLC network for the task

The set of differential equations representing the 3 degree of freedom system is


d
v(t )  2i1 (t )  (i1  i3 )  (i1  i2 )  2  i1  i2  (3)
dt
d d
0  2(i2  i3 )  (i2  i1 )  2  i2  i1   3  i2  i3   4i2 (4)
dt dt
d
0  (i1  i3 )  2(i3  i2 )  3  i3  i2  
dt
 1
1
 i3dt (5)
5
Lab:03 Frequency domain modeling of electrical
and mechanical systems
Objective:
In this lab students will learn how to generate the frequency domain mathematical model of the system
when ODE’s of a system are available. This lab emphasizes on the use of frequency domain modeling
technique to model the system in frequency domain. System transfer function are used for system model
and its response generation.

Introduction:
In this lab Electrical and mechanical system will be modeled in the frequency
domain. First a simple rectilinear plant will be modeled. The system has three
masses m1 , m2 and m3 . These masses are connected to each other and to the rigid
body by the help of springs ( k1 , k2 , k3 , k4 ) and dampers ( c1 , c2 , c3 , c4 ). The applied
external force is F(t). The output can be observed at any point in the network which
is undergoing a change.

Figure 1: 3DOF rectilinear plant

The time domain equations of motion for the three DOF rectilinear plant are

m1x1 + c1x 1 + (k1 +k2)x 1-k 2x2 = F(t) (1)


m2x2 + c2x2 + (k2 +k3)x2-k2x1-k3x3 = 0 (2)
m3x 3 + c3x3 + (k 3 +k4)x3-k3x 2 = 0 (3)
Laplace transforms of equations 1- 3 are
x 1 (s) N (s)
= 1
F(s) D(s)
x 2 (s) N (s)
= 2
F(s) D(s)
x 3 (s) N (s)
= 3
F(s) D(s)

Where 𝑁𝑖 (𝑠) and 𝐷(𝑠) are the numerator and denominator for the system.

Student should be able to apply the Laplace transform on the equation 1-3 and solve the equations for the
unknown variables 𝑥1 (𝑠), 𝑥2 (𝑠) and 𝑥3 (𝑠) for the given input F(s). Student should use the Matlab
commands to find the system transfer function. The command ‘tf(numerator, denominator)’ will help to
find the system transfer function.

Electrical System
A three degree of freedom system is shown in Figure 2. The system is identical to the one provided in the
earlier lab. Student has to convert the given set of equation (3-5) in the frequency domain using Laplace
transformation. Student is free to decide the system output for the given input. Use the Matlab command
to find the system transfer function.

Figure 2. 3DOF RLC network for the task

The set of differential equations representing the 3 degree of freedom system is


d
v(t )  2i1 (t )  (i1  i3 )  (i1  i2 )  2  i1  i2  (3)
dt
d d
0  2(i2  i3 )  (i2  i1 )  2  i2  i1   3  i2  i3   4i2 (4)
dt dt
d
0  (i1  i3 )  2(i3  i2 )  3  i3  i2  
dt
 1
1 3 i dt (5)
5
Student Task: In this lab student needs to take the step response of the above two systems. The choice of
output is with the student. Student should be able to analyze the system performance by the change of
component values in both networks. Discussion on the results should be comprehensive.
Lab:04 Frequency domain modeling of
electromechanical system
Objective:
A DC motor is one the basic electro-mechanical system and is used in almost 95% of the systems for
control in one or another form. The DC motor can be used to control the process speed or in some way
position as parameter. The property that it takes electrical input and produces a mechanical output makes
it an electro-mechanical system.

Introduction:
The DC motor have two set of equations. One represents the electrical network and the other assumes the
mechanical side of the DC motor.

DC Motor Speed Mathematical Model

The mathematical equation representing the electrical side of DC motor is

Ra I a (s)  La sI a (s)  Vb (s)  Ea (s) (1)

and the mechanical side mathematical equation for the same system is

 
Tm ( s)  J m s 2  Dm s  m ( s) (2)

The final transfer function between motor speed and applied input after substitution of different available
equations becomes (Section 2.8 in textbook)
Kt
 m ( s) Ra J m
 (3)
Ea ( s)   Kt Kb  
 s  1 J  Dm  
m Ra  

Sr. No System Variables Variable Value

01 Mechanical Inertia J m 01 Kg𝑚2

02 Mechanical Damping Dm 5 N-m-s/rad

03 Electrical Resistance Ra 1 ohm

04 Electrical Inductance La 0.3 H

04 Motor Torque Constant K t 0.01 N.M/Amp

05 Back emf constant K b 0.01 V/rad/sec


Table 1: System variables

Student Task: Find the system transfer function using the Matlab commands. Student should perform
the analysis by changing the values of system variables. Student should be able to discuss the system
response after changing the variable and the results should be presented in a detailed way.

You might also like