0% found this document useful (0 votes)
18 views

EXPERIMENT 1_merged (2)

Merged

Uploaded by

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

EXPERIMENT 1_merged (2)

Merged

Uploaded by

Satish Sahu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

Experiment No.

- 1
Aim: Introduction to MATLAB computing control Software.

Theory:

Control System Toolbox:

Control System Toolbox provides algorithms and apps for systematically analyzing, designing,
and tuning linear control systems. You can specify your system as a transfer function, state-
space, zero-pole-gain, or frequency-response model. Apps and functions, such as step response
plot and Bode plot, let you analyze and visualize system behavior in the time and frequency
domains. You can tune compensator parameters using interactive techniques such as Bode loop
shaping and the root locus method. The toolbox automatically tunes both SISO and MIMO
compensators, including PID controllers. Compensators can include multiple tunable blocks
spanning several feedback loops. You can tune gain-scheduled controllers and specify multiple
tuning objectives, such as reference tracking, disturbance rejection, and stability margins. You
can validate your design by verifying rise time, overshoot, settling time, gain and phase margins,
and other requirements.

>>help control

Control System Toolbox

Version 8.5 (R2010a) 25-Jan-2010

General.

ctrlpref - Set Control System Toolbox preferences.

ltimodels - Detailed help on the various types of LTI models.

ltiprops - Detailed help on available LTI model properties.

Graphical User Interfaces.

ltiview - LTI Viewer (time and frequency response analysis).

sisotool - SISO Design Tool (interactive compensator tuning).

sisoinit - Configure the SISO Design Tool at startup.

Creating linear models.

tf - Create transfer function (TF) models.

zpk - Create zero/pole/gain (ZPK) models.


ss - Create state-space (SS) models.

dss - Create descriptor state-space models.

delayss - Create state-space models with delayed terms.

frd - Create frequency response data (FRD) models.

lti/exp - Create pure continuous-time delays (TF and ZPK only)

filt - Specify digital filters.

lti/set - Set/modify properties of LTI models.

setDelayModel - Specify internal delay model (state space only).

Data extraction.

lti/tfdata - Extract numerators and denominators.

lti/zpkdata - Extract zero/pole/gain data.

lti/ssdata - Extract state-space matrices.

lti/dssdata - Descriptor version of SSDATA.

frd/frdata - Extract frequency response data.

lti/get - Access values of LTI model properties.

ss/getDelayModel - Access internal delay model (state space only).

Conversions.

tf - Conversion to transfer function.

zpk - Conversion to zero/pole/gain.

ss - Conversion to state space.

frd - Conversion to frequency data.

c2d - Continuous to discrete conversion.

d2c - Discrete to continuous conversion.

d2d- Resample discrete-time model.

upsample - Upsample discrete-time LTI system.


System interconnections.

append - Group LTI models by appending inputs and outputs.

parallel - Connect LTI models in parallel (see also overloaded +).

series - Connect LTI models in series (see also overloaded *).

feedback - connect lti models with a feedback loop.

lti/lft - Generalized feedback interconnection.

lti/connect - Arbitrary interconnection of lti models.

sumblk - Specify summing junction (for use with connect).

strseq - Builds sequence of indexed strings (for I/O naming).

System gain and dynamics.

dcgain - Steady-state (D.C.) gain.

lti/bandwidth - System bandwidth.

lti/norm - H2 and Hinfinity norms of LTI models.

lti/pole - System poles.

lti/zero - System (transmission) zeros.

lti/order - Model order (number of states).

pzmap - Pole-zero map.

lti/iopzmap - Input/output pole-zero map.

damp - Natural frequency and damping of system poles.

esort - Sort continuous poles by real part.

dsort - Sort discrete poles by magnitude.

lti/stabsep - Stable/unstable decomposition.

lti/modsep - Region-based modal decomposition.


Time-domain analysis.

step - Step response.

stepinfo - Step response characteristics (rise time, ...)

impulse - Impulse response.

initial - Free response with initial conditions.

lsim - Response to user-defined input signal.

lsiminfo - Linear response characteristics.

gensig - Generate input signal for LSIM.

covar - Covariance of response to white noise.

Frequency-domain analysis.

bode - Bode diagrams of the frequency response.

lti/bodemag - Bode magnitude diagram only.

sigma - Singular value frequency plot.

nyquist - Nyquist plot.

nichols - Nichols plot.

margin - Gain and phase margins.

lti/allmargin - All crossover frequencies and related gain/phase margins.

lti/freqresp - Frequency response over a frequency grid.

lti/evalfr - Evaluate frequency response at given frequency.

Model simplification.

minreal - Minimal realization and pole/zero cancellation.

ss/sminreal - Structurally minimal realization (state space).

lti/hsvd - Hankel singular values (state contributions)

lti/balred - Reduced-order approximations of LTI models.

ss/modred - Model order reduction.


Compensator design.

rlocus - Evans root locus.

place - Pole placement.

estim - Form estimator given estimator gain.

reg - Form regulator given state-feedback and estimator gains.

LQR/LQG design.

ss/lqg - Single-step LQG design.

lqr, dlqr - Linear-Quadratic (LQ) state-feedback regulator.

lqry - LQ regulator with output weighting.

lqrd - Discrete LQ regulator for continuous plant.

ss/lqi - Linear-Quadratic-Integral (LQI) controller.

ss/kalman - Kalman state estimator.

ss/kalmd - Discrete Kalman estimator for continuous plant.

ss/lqgreg - Build LQG regulator from LQ gain and Kalman estimator.

ss/lqgtrack - Build LQG servo-controller.

augstate - Augment output by appending states.

State-space (SS) models.

rss - Random stable continuous-time state-space models.

drss - Random stable discrete-time state-space models.

ss2ss - State coordinate transformation.

canon - Canonical forms of state-space models.

ctrb - Controllability matrix.

obsv - Observability matrix.

gram - Controllability and observability gramians.

ss/prescale - Optimal scaling of state-space models.


balreal - Gramian-based input/output balancing.

ss/xperm - Reorder states.

Frequency response data (FRD) models.

frd/chgunits - Change frequency vector units.

frd/fcat - Merge frequency responses.

frd/fselect - Select frequency range or subgrid.

frd/fnorm - Peak gain as a function of frequency.

frd/abs - Entrywise magnitude of the frequency response.

frd/real - Real part of the frequency response.

frd/imag - Imaginary part of the frequency response.

frd/interp - Interpolate frequency response data.

mag2db - Convert magnitude to decibels (dB).

db2mag - Convert decibels (dB) to magnitude.

Time delays.

lti/hasdelay - True for models with time delays.

lti/totaldelay - Total delay between each input/output pair.

lti/delay2z - Replace delays by poles at z=0 or FRD phase shift.

pade - Pade approximation of continuous-time delays.

thiran - Thiran approximation of fractional discrete-time delays.

Model dimensions and characteristics.

class - Model type ('tf', 'zpk', 'ss', or 'frd').

isa - Test if model is of given type.

tf/size - Model sizes.

lti/ndims - Number of dimensions.

lti/isempty - True for empty models.


lti/isct - True for continuous-time models.

lti/isdt - True for discrete-time models.

lti/isproper - True for proper models.

lti/issiso - True for single-input/single-output models.

lti/isstable - True for models with stable dynamics.

lti/reshape - Reshape array of linear models.

Overloaded arithmetic operations.

+ and - - Add and subtract systems (parallel connection).

* - Multiply systems (series connection).

/ - Left divide -- sys1\sys2 means inv(sys1)*sys2.

/ - Right divide -- sys1/sys2 means sys1*inv(sys2).

^ - Powers of a given system.

' - Pertransposition.

.' - Transposition of input/output map.

.* - Element-by-element multiplication.

[..] - Concatenate models along inputs or outputs.

lti/stack - Stack models/arrays along some array dimension.

lti/inv - Inverse of an LTI system.

lti/conj - Complex conjugation of model coefficients.

Matrix equation solvers and linear algebra.

lyap, dlyap - Solve Lyapunov equations.

lyapchol, dlyapchol - Square-root Lyapunov solvers.

care, dare - Solve algebraic Riccati equations.

gcare, gdare - Generalized Riccati solvers.

bdschur - Block diagonalization of a square matrix.


Experiment :-2

Aim: Define system in TF, ZPK form.

Theory:- Transfer Function:-

Transfer Function can be representing MATLAB as LTI(Linear Time Invariant) objects using

Numerator and polynomials consider the Transfer Function given by :-

G(s) = s2(s+3s1)+1

+
It can be represented in MATLAB as:-

>> num=[1 1] >> den=[ 1 3 1]


>> G=tf
(num,den)
Transfer function:
s + 1 -------------
s^2 + 3 s + 1 >>
zero(G) ans =
-1

>> pole(G)
ans = -
2.6180
-0.3820
>> zpk(G)
Zero/pole/gain:
(s+1)
-------------------
(s+2.618) (s+0.382)

Example :- The function conv has been used to multiply polynomials in the MATLAB
session for the file transfer function :

GH(s)=

It can be represented in MATLAB as:-


>> n1=[5 1];

>> n2=[15 1];


>> d1=[1 0];

>> d2=[3 1];


>> d3=[10 1];
>> num=100*conv(n1,n2);

>> den=conv(d1,conv(d2,d3);
>> GH=tf(num,den)

Transfer function:
7500 s^2 + 2000 s + 100

-----------------------
30 s^3 + 13 s^2 + s

>> zero(GH)
ans =

-0.2000
-0.0667
>> pole(GH) ans
=
0
-0.3333

-0.1000

>> zpk(GH)
Zero/pole/gain:

250 (s+0.2) (s+0.06667)

-----------------------
s (s+0.3333) (s+0.1)

Example :-2
Transfer Function Can also be directly in polynomial form as we enter them in the
notebook using LTI object. Observe the following MATLAB session.
G1=150*(s^2+2*s+7)/(s*(s^2+5*s+4)
It can be represented in MATLAB as:-

>> n1=[1 2 7];


>> d1=[1 0];

>> d2=[1 5 4];


>> num=150*n1;

>> den=conv(d1,d2);
>> G1=tf(num,den)

Transfer function:

150 s^2 + 300 s + 1050


----------------------
s^3 + 5 s^2 + 4 s
>> zero(G1) ans =
-1.0000 + 2.4495i
-1.0000 -
2.4495i >>
pole(G1) ans =
0
-4

-1

>> zpk(G1)
Zero/pole/gain:

150 (s^2 + 2s + 7)
------------------
s (s+4) (s+1)
EXPERIMENT NO.- 4
OBJECT: Analysis of the Response of RLC circuit

Problem:

The following figure shows the parallel form of a band pass RLC circuit.

Fig: 4.1 Bandpass RLC Network.

s
G (s ) = RC
s 2
+ s + 1
RC LC

Analyzing the Frequency Response of the Circuit

The Bode plot is a convenient tool for investigating the bandpass characteristics of the RLC
network. Use tf to specify the circuit's transfer function for the values

Input:
<<%|R=L=C=1|:
<<R = 1; L = 1; C = 1;
<<G = tf([1/(R*C) 0],[1 1/(R*C) 1/(L*C)])
>> bode(G), grid
Output:
Continuous-time transfer function
s
-----------
s^2 + s + 1

Fig: 4.2 Frequency Response of the RLC circuit


As expected, the RLC filter has maximum gain at the frequency 1 rad/s. However, the
attenuation is only -10dB half a decade away from this frequency. To get a narrower passing
band, try increasing values of R as follows:

Input:
<<R1 = 5; G1 = tf([1/(R1*C) 0],[1 1/(R1*C) 1/(L*C)]);
<<R2 = 20; G2 = tf([1/(R2*C) 0],[1 1/(R2*C) 1/(L*C)]);
<<bode(G,'b',G1,'r',G2,'g'), grid
<<legend('R = 1','R = 5','R = 20')

Output:
The resistor value R=20 gives a filter narrowly tuned around the target frequency of 1 rad/s.

Fig: 4.3 Frequency Response of the RLC circuit at different values of R


Analyzing the Time Response of the Circuit

We can confirm the attenuation properties of the circuit G2 (R=20) by simulating how this filter
transforms sine waves with frequency 0.9, 1, and 1.1 rad/s:

Input:

<<t = 0:0.05:250;

<<opt = timeoptions;

<<opt.Title.FontWeight = 'Bold';
<<subplot(311), lsim(G2,sin(t),t,opt), title('w = 1')
<<subplot(312), lsim(G2,sin(0.9*t),t,opt), title('w = 0.9')
<<subplot(313), lsim(G2,sin(1.1*t),t,opt), title('w = 1.1')
Output:
The waves at 0.9 and 1.1 rad/s are considerably attenuated. The wave at 1 rad/s comes out
unchanged once the transients have died off. The long transient results from the poorly damped
poles of the filters, which unfortunately are required for a narrow passing band:

Fig: 4.4 Time Response of the RLC circuit


Input:
<<damp(pole(G2))

Output:

Pole Damping Frequency Time Constant


(rad/TimeUnit) (TimeUnit)

-2.50e-02 + 1.00e+00i 2.50e-02 1.00e+00 4.00e+01


-2.50e-02 - 1.00e+00i 2.50e-02 1.00e+00 4.00e+01

Interactive GUI

To analyze other standard circuit configurations such as low-pass and high-pass RLC networks,
click on the link below to launch an interactive GUI. In this GUI, you can change the R,L,C
parameters and see the effect on the time and frequency responses in real time.

Input:
<<rlc_gui
Output:

Fig:4.5
EXPERIMENT NO.- 5
OBJECT: Assessing gain and phase margins to examine the effect of stability margins on
closed-loop response characteristics of a control system.

Problem:

Stability of a Feedback Loop


Stability generally means that all internal signals remain bounded. For linear feedback systems,
stability can be assessed by looking at the poles of the closed-loop transfer function.
SISO System

Fig: 5.1 SISO feed back loop


Input:
>>G = tf([.5 1.3],[1 1.2 1.6 0]);
>>T = feedback(G,1);
>>pole(T)
>>rlocus(G)
>>bode(G), grid
>>step(T), title('Closed-loop response for k=1')
>>[Gm,Pm] = margin(2*G);
>>GmdB = 20*log10(Gm) % gain margin in dB
>>Pm % phase margin in degrees
>>step(feedback(2*G,1)), title('Closed-loop response for k=2')

Output:
-0.2305 + 1.3062i
-0.2305 - 1.3062i
-0.7389 + 0.0000i
Root Locus
15

10

5
Imaginary Axis

-5

-10

-15
-3 -2.5 -2 -1.5 -1 -0.5 0 0.5 1
Real Axis

Fig: 5.2 Root Locus Graph

Bode Diagram
20

0
Magnitude (dB)

-20

-40

-60

-80

-100
-90
Phase (deg)

-135

-180

-225
-1 0 1 2
10 10 10 10
Frequency (rad/sec)

Fig: 3.3 Bode diagram of Transfer Function


Closed-loop response for k=1
1.4

1.2

0.8
Amplitude

0.6

0.4

0.2

0
0 5 10 15 20 25
Time (sec)

Fig: 3.4 Closed loop Response for K=1

GmdB =
2.7471
Pm =
8.6328
Closed-loop response for k=2
1.6

1.4

1.2

1
Amplitude

0.8

0.6

0.4

0.2

0
0 10 20 30 40 50 60 70 80
Time (sec)

Fig: 3.5 Closed loop Response for K=2

Systems with Multiple Gain or Phase Crossings

Fig: 3.6 SISO feed back loop with Multiple Phase Crossovers
Input:

>>G = tf(20,[1 7]) * tf([1 3.2 7.2],[1 -1.2 0.8]) * tf([1 -8 400],[1 33 700]);
T = feedback(G,1);
step(T), title('Closed-loop response for k=1')
>>bode(G), grid
>>k1 = 2; T1 = feedback(G*k1,1);
k2 = 1/2; T2 = feedback(G*k2,1);
step(T,'b',T1,'r',T2,'g',12),
legend('k = 1','k = 2','k = 0.5')
>>m = allmargin(G)
GainMargins_dB = mag2db(m.GainMargin)
margin_gui

Output:

Closed-loop response for k=1


1.4

1.2

0.8
Amplitude

0.6

0.4

0.2

0
0 1 2 3 4 5 6 7
Time (sec)

Fig: 3.7 Closed loop Response for K=1


Bode Diagram
40

Magnitude (dB) 20

-20

-40
270

180
Phase (deg)

90

-90
-2 -1 0 1 2 3
10 10 10 10 10 10
Frequency (rad/sec)

Fig: 3.8 Bode diagram of Transfer function

Step Response
1.5
k=1
k=2
k = 0.5

1
Amplitude

0.5

0
0 2 4 6 8 10 12
Time (sec)

Fig: 3.9 Step Response of Transfer Function


m=
struct with fields:
GainMargin: [0.3408 3.3920]
GMFrequency: [1.9421 16.4807]
PhaseMargin: 68.1178
PMFrequency: 7.0762
DelayMargin: 0.1680
DMFrequency: 7.0762
Stable: 1
GainMargins_dB =
-9.3510 10.6091

Fig: 3.10 Interactive GUI


Experiment No. 6

Designing and implementing a closed-loop control system for a DC motor involves several key steps,
including modeling the motor, designing the control algorithm, and implementing the system in
MATLAB/Simulink. Here's a step-by-step guide to help you through the process:

Step 1: Modeling the DC Motor

1. Motor Equations:
The DC motor can be modeled using the following differential equations:
o Electrical equation: V(t)=Ldi(t)dt+Ri(t)+Keω(t)
o Mechanical equation: Jdω(t)dt+Bω(t)=Kmi(t)
o Where:
o V(t) is the input voltage.
o i(t) is the armature current.
o ω(t) is the angular velocity.
o L is the armature inductance.
o R is the armature resistance.
o Ke is the back EMF constant.
o Km is the torque constant.
o J is the moment of inertia.
o B is the friction coefficient.
2. Transfer Function:
Convert the motor equations into a transfer function or state-space representation. For
example:

3.Simulink Model:
Implement the transfer function in Simulink using blocks like Transfer Function, Gain,
Sum, etc.

Step 2: Design the Controller

 Control Objective:
Define the control objective, such as speed or position control.

 Controller Type:
Choose a suitable controller type, such as Proportional-Integral-Derivative (PID), based on the
system requirements.

 PID Tuning:
 Use methods like Ziegler-Nichols, trial and error, or MATLAB’s PID Tuner to tune the
PID controller.
 Ensure that the controller meets the desired transient and steady-state performance
criteria (e.g., settling time, overshoot, steady-state error).

 Simulink Implementation:
Implement the PID controller in Simulink using the PID Controller block.

Step 3: Closed-Loop System Simulation

1. Simulate the System:


Connect the DC motor model with the PID controller in Simulink to form a closed-loop
system. Simulate the system's response to a step input or any desired input profile.
2. Analyze the Response:
o Examine the system’s response in terms of speed, position, or any other relevant
parameter.
o Verify that the system meets the design specifications (e.g., no overshoot, quick
settling time).

Step 4: Implement on Hardware

1. Choose Hardware:
Select a suitable hardware platform like Arduino, Raspberry Pi, or a DSP board with
PWM output and ADC input capabilities for real-time implementation.
2. Motor Driver:
Use an H-bridge motor driver compatible with the chosen hardware platform to control
the motor.

3.Real-Time Control:

 Use MATLAB’s Simulink Coder to generate code from the Simulink model and deploy
it to the hardware platform.
 Implement sensor feedback (e.g., encoder for position feedback) to close the loop in real-
time.

4.Test and Debug:


Test the closed-loop control system on the hardware. Adjust the controller parameters if
necessary to ensure stability and performance.

Step 5: Validation and Refinement

1. Performance Verification:
Compare the simulation results with the real-time hardware implementation. Ensure that
the hardware system behaves as expected.
2. Refinement:
Fine-tune the controller parameters on the hardware to account for non-idealities such as
sensor noise, motor friction, etc.

MATLAB/Simulink Tools to Use:

 Simulink for system modeling and simulation.


 PID Tuner for automatic tuning of the PID controller.
 Simulink Coder for generating C/C++ code for the hardware platform.
 MATLAB for scripting and data analysis.

Example Code Snippet for PID Tuning in MATLAB:

% Define transfer function parameters

J = 0.01; % Moment of inertia

B = 0.1; % Friction coefficient

K_m = 0.01; % Motor constant

R = 1; % Resistance

L = 0.5; % Inductance

% Transfer function

s = tf('s');

P_motor = K_m / ((J*s + B)*(L*s + R) + K_m*K_e);

% PID Tuning

C = pidtune(P_motor, 'PID');

% Simulate the closed-loop system

T = feedback(C*P_motor, 1);

step(T);

This approach will help you design, simulate, and implement a closed-loop control system for a DC
motor using MATLAB/Simulink and suitable hardware platforms.
Here all the required time domain specifications are described in this image. The transient response is
called as the response to the settling time and the response after the settling time is known as steady state
response.
A) Delay Time: Delay time is known as the time requirement for the response to reach half of its final
value from the zero instant, represented by:

Now see the step response of the second order system for t ≥ 0, when ‘δ’ lies between zero and one.
Here the final value of the step response is one.
Therefore, at t=td, the value of the step response will be 0.5. Substitute,

If you use the linear approximation, you will get the delay time td as,
B) Rise time: Rise time is the time required for the response to rise from 0% to 100% of its final
value. Usually this is applicable for the under-damped systems. You can consider the duration from
10% to 90% of the final value for the over-damped systems. Rise time is denoted by tr.

At t =t1= 0, c(t) = 0.

Here we that the final value of the step response is one.


Therefore, at t=t2, the value of step response is one.
Substitute, these values in the following equation.
Now substitute t1and t2values in the following equation of rise time

A) Peak time: Peak time is the time required for the response to reach the peak value for the first
time. It is represented by tp. At t=tp, the first derivate of the response is zero.
B) We have an idea that the step response of second order system for under-damped case is,
Differentiate c(t)with respect to ‘t’.
We can finalize the peak time tp and from the above equation that the damped frequency ωd are inversely
proportional to each other.
C) Peak Overshoot: Peak overshoot Mp is also called as the deviation of the response at peak time
from the final value of response. This is also *called as the maximum overshoot.
We can write it mathematically as

Where,

c(tp) is the peak value of the response.


c(∞) is the final (steady state) value of the response.
At t=tpt=tp, the response c(t) is
will decrease if the damping ratio δ increases.
D) Settling time: The settling time ts is the time interval required by an output signal of a dynamical
system to get trapped inside a band around a new steady-state value after a perturbation is applied
to the system. It is the time required for the response to reach the steady state and stay within the
specified tolerance bands among the final value. In usually the tolerance bands are 2% and 5%.
Here the settling time is presented by ts.

The settling time for 5% tolerance band is


Both the settling time and the time constant T are inversely proportional to the damping ratio δ.

Both the settling time and the time constant are independent of the system gain. That means even the

system gain changes, the settling time and time constant will never change.

Problem:
In this lab, the time responses of control systems will be studied using MATLAB. The time response of a
control system is usually divided into two parts: the transient response and the steady-state response. We
will study these responses for the second order systems. For simplicity, the "step input" will be used, though
other inputs can also be applied.

Exercise 1: Open loop control system example


Let us look at the following second order (open-loop) system whose transfer function is:
1 G(s)
R(s)= --- _______________
s | b | C(s) -------
------| ------------ |--------->
|s^2 + a.s + b |
---------------
Four typical cases are as follows:
(1) Overdamped
4
G(s) = ------------ (1)
s^2 + 5 s +4
The step response of system (1) is

(2) Underdamped
4
G(s) = ------------ (2)
s^2 + s +4
The step response of system (2) is
(3) Undamped
4
G(s) = ------------ (3)
s^2 + 4
The step response of system (3) is

(4) Critically damped


4
G(s) = ------------ (4)
s^2 +4 s + 4
The step response of system (4) is
For determining above plots in MATLAB, you can use the following code:
% Overdamped system
s = tf('s'); G =
4/(s^2+5*s+4)
step(G)
% Underdamped system
G = 4/(s^2+s+4)
step(G)
% % Undamped system G
= 4/(s^2+4) step(G)
% % Critically damped system
G = 4/(s^2+4*s+4)
step(G)

Exercise 2: Closed loop control system example


Now let us try another system Case 1:
4
G(s) = ------------- (5)
s^2 + s - 4
The system's step response is

The system's response diverges and blows up finally, which means the system is "unstable." An unstable
system is not desirable. What we want is that the system could behave smoothly and have its output follow
(track) our desired (reference) input. For this purpose, we use "feedback control". Let us feed the output of the
system G(s) back to the input position and compare it with our desired (reference) input to construct the
following closed-loop system
__ _______ ______
+ / \ | | | | output
ref input -->( )------>| K |----->| G(s) |---------> (6)
r(t)\__/ e(t) | | x(t) | | |y(t)
----- ------ |
- /|\ |
| |
|__________________________________|
The closed-loop transfer function of system (6) is calculated as
4 K
Gc(s) = ------------------ (7)
s^2 + s + 4 (K-1)
From which we can plot the step response as follows:
• If K>1, the closed-loop system (7) is Asymptotically Stable.
• If K<1, the closed-loop system (7) is Unstable.
• If K=1, the closed-loop system (7) is Marginally Stable (Stable but not Asymptotically Stable).
Justify why it happens.

Case 2: Let K be 0.5, 1.0, 1.5 and 15 respectively, observe and plot the different step responses. Calculate
(theoretically) the steady error for the two cases of K=1.5 and K=15, check them against your figure and
compare them to see what conclusion you can draw.

Exercise 3: Closed loop control system example


Consider the following second order (open-loop) system whose transfer function is:
5
G(s) = ------------ (8)
s (s + 2)
The step response of system (8) is

This system is not asymptotically stable (can you tell why?). Therefore you could not observe a convergent
response. This means that we have a system which does not behave as we expected. Now let us use a
"feedback control" to regulate its behavior to our desired one. What is our expectation to its behavior or, more
precisely, its output? Yes, we wish its output to follow (track) our reference input, say, the step function.
Alright, let us use the following unit feedback strategy:
__ ______
+ / \ | | output
ref input -->( )----------->| G(s) |---------> (9)
r(t)\__/ e(t) | | |y(t)
------ |
- /|\ |
| |
|__________________________|
Now, perform the following
(a) Derive the closed-loop transfer function of system (9).
(b) Do simulation for step response. Calculate (theoretically) the damped natural frequency, peak time, percent
overshoot, rise time and settling time and, mark them on your resultant simulation figure.

Determining the rise time, settling time and response time (‘stepinfo’ command):
S = stepinfo(sys)computes the step-response characteristics for a dynamic system model sys. The function
returns the characteristics in a structure containing the fields:

RiseTime — Time it takes for the response to rise from 10% to 90% of the steady-state response.
SettlingTime — Time it takes for the error |y(t) - yfinal| between the response y(t) and the steady-state
response yfinal to fall to within 2% of yfinal.
SettlingMin — Minimum value of y(t) once the response has risen.
SettlingMax — Maximum value of y(t) once the response has risen.
Overshoot — Percentage overshoot, relative to yfinal.
Undershoot — Percentage undershoot.
Peak — Peak absolute value of y(t)
PeakTime — Time at which the peak value occurs.

The following figure illustrates some of these quantities on a typical second-order response.

Observations:
Various analyses for studying the responses of second order systems are performed.
EXPERIMENT NO.- 8

OBJECT: Design lead-lag compensator for the given system


There are three types of compensators — lag, lead and lag-lead compensators. These are most
commonly used.

Lag Compensator

The Lag Compensator is an electrical network which produces a sinusoidal output having the
phase lag when a sinusoidal input is applied. The lag compensator circuit in the ‘s’ domain is
shown in the following figure.

Here, the capacitor is in series with the resistor R2 and the output is measured across this
combination.

The transfer function of this lag compensator is 𝑉 𝑜𝑖(( 𝑠 ) = 1 ( 𝑠+ 1𝛼𝜏𝜏 )


𝑉 𝑠 ) 𝛼 𝑠+ 1

Where, 𝜏 = 𝑅2𝐶 𝛼 = 𝑅1𝑅+2𝑅2

From the above equation, α is always greater than one.


From the transfer function, we can conclude that the lag compensator has one pole at s=−1/ατ and
one zero at s=−1/τ. This means, the pole will be nearer to origin in the pole-zero configuration of
the lag compensator.

Substitute, s=jω in the transfer function, 𝑉𝑉𝑜𝑖((𝑗𝜔𝑗𝜔)) = 𝛼1 (𝑗𝜔+𝑗𝜔+11𝛼𝜏𝜏 )

Phase angle 𝜙 = 𝑡𝑎𝑛−1 𝜔𝑡−𝑡𝑎𝑛−1 𝛼𝜔𝑡


We know that, the phase of the output sinusoidal signal is equal to the sum of the phase angles of
input sinusoidal signal and the transfer function.
So, in order to produce the phase lag at the output of this compensator, the phase angle of the
transfer function should be negative. This will happen when α >1.
Lead Compensator

The lead compensator is an electrical network which produces a sinusoidal output having phase
lead when a sinusoidal input is applied. The lead compensator circuit in the ‘s’ domain is shown
in the following figure.

Here, the capacitor is parallel to the resistor R1 and the output is measured across resistor R2.

The transfer function of this lead compensator is - 𝑉 𝑜𝑖(( 𝑠 ) = 𝛽(𝛽𝑠𝜏+1𝑠𝜏+1 )


𝑉 𝑠 )

Where, 𝜏 = 𝑅1𝐶 𝛽=𝑅 1𝑅+2𝑅2

From the transfer function, we can conclude that the lead compensator has pole at s=−1/β and
zero at s=−1/βτ.
Substitute, s=jω in the transfer function 𝑉 𝑜𝑖(( 𝑗𝜔 ) =
𝑉 𝑗𝜔 ) 𝛽(𝑗𝜔𝛽𝜏+1𝑗𝜔𝜏+1 )

Phase angle 𝜙 = 𝑡𝑎𝑛−1 𝜔𝑡−𝑡𝑎𝑛−1 𝛽𝜔𝑡


We know that, the phase of the output sinusoidal signal is equal to the sum of the phase angles of
input sinusoidal signal and the transfer function.
So, in order to produce the phase lead at the output of this compensator, the phase angle of the
transfer function should be positive. This will happen when 0<β<1. Therefore, zero will be nearer
to origin in pole-zero configuration of the lead compensator.

Lag-Lead Compensator

Lag-Lead compensator is an electrical network which produces phase lag at one frequency region
and phase lead at other frequency region. It is a combination of both the lag and the lead
compensators. The lag-lead compensator circuit in the ‘s’ domain is shown in the following
figure.
This circuit looks like both the compensators are cascaded. So, the transfer function of this circuit
will be the product of transfer functions of the lead and the lag compensators.

𝑉𝑜(𝑠) = 𝛽( 𝑠𝜏1 + 1 ) 1 ( 𝑠 + 1𝜏2 )


𝑉𝑖(𝑠) 𝛽𝑠𝜏1 + 1 𝛼 𝑠 + 1𝛼𝜏2

αβ=1, 𝑉𝑉𝑜𝑖((𝑠𝑠)) = 𝐾(𝑠+𝑠+11𝛽𝜏𝜏11)(𝑠+𝑠+11𝛼𝜏𝜏22)

Where, 𝜏1 = 𝑅1𝐶1 𝜏2 = 𝑅2𝐶2


Lead compensation essentially yields an appreciable improvement in transient response and a
small change in steady-state accuracy. It may accentuate high-frequency noise effects. Lag
compensation on the other hand, yields an appreciable improvement in steady-state accuracy at
the expense of increasing the transient-response time. Lag compensation will suppress the effects
of high-frequency noise singles. Lead-Lag compensation combines the characteristics of both
lead compensation and lag compensation. The use of a lead or lag compensator raises the order
of the system by (unless cancellation occurs between the zero of the compensator and a pole of
the uncompensated open-loop transfer function). The use of a lead-lag compensator raises the
order of the system by (unless cancellation occurs between zeros of the lead-lag compensator and
poles of the uncompensated open-loop transfer function), which means that the system becomes
more complex and it is more difficult to control the transient response behavior
Exercise 1: Lead Compensator
In order to examine the transient-response characteristics of the designed system, we shall obtain
the unit-step and unit-ramp response curves of the compensated and uncompensated system with
MATLAB. Note that the closed-loop transfer functions of the uncompensated and compensated
system are given, respectively,
𝐶(𝑠)
= 2+ 2𝑠 + 4
𝑅(𝑠) 𝑠
𝐶(𝑠) 166.8𝑠 + 735.588
= 3+ 20.4𝑠2 + 203.6𝑠 + 735.588 𝑅(𝑠) 𝑠
Solution: The MATLAB code for obtaining the unit step responses of both compensated and
uncompensated systems is *****Unit-Step Responses*****
num=[0 0 4]; den=[1
2 4];
numc=[0 0 166.8 735.588]; denc=[1
20.4 203.6 735.588]; t=0:0.2:6;
[c1,x1,t]=step(num,den,t);
[c2,x2,t]=step(numc,denc,t);
plot(t,c1,'*',t,c2,'+') grid
title('Unit-Step Responses of Compensated and Uncompensated Systems')
xlabel('t Sec') ylabel('Outputs')
text(0.4,1.31,'Compensated System') text(1.55,0.88,'Uncompensated
System')
Unit-Step Responses of Compensated and Uncompensated Systems
The MATLAB code for obtaining the ramp responses of both compensated and uncompensated
systems is
*****Unit-Ramp Responses*****
num1=[0 0 0 4]; den1=[1
2 4 0];
num1c=[0 0 0 166.8 735.588];
den1c=[1 20.4 203.6 735.588 0];
t=0:0.05:5;

[y1,z1,t]=step(num1,den1,t); [y2,z2,t]=step(num1c,den1c,t);
plot(t,y1,'*',t,y2,'+',t,t,'--') grid
title('Unit-Ramp Responses of Compensated and Uncompensated Systems')
xlabel('t Sec') ylabel('Outputs')
text(0.89,3.7,'Compensated System') text(2.25,1.1,'Uncompensated
System'
Unit-Ramp Responses of Compensated and Uncompensated Systems
Observations & conclusion:
1) Lead compensation -achieves the desired result through the merits of its phase–lead
contribution, whereas lag compensation accomplishes the result through the merits of its
attenuation property at high frequencies.
a. Lead compensation is commonly used for improving stability margins.
b. Lead compensation yields a higher gain crossover frequency than is possible with lag
compensation. The higher gain crossover frequency means larger band width. A large
band width means reduction in the settling time. The band width of a system with lead
compensation is always greater than that with lag compensation. Therefore, if a large
band width or fast response is desired, lead compensation should be employed. If,
however noise signals are present, then a large band width may not be desirable since
it makes the system more susceptible to noise signals because of increase in the high
frequency gain.
c. Lead compensation requires an additional increase in gain to offset the attenuation
inherent in the lead network. This means that lead compensation will require a larger
gain than that required by lag compensation. A larger gain, in most cases, implies
larger space, greater weight, and higher cost.
2. Lag compensation -reduces the system gain at higher frequencies without reducing the
system gain at lower frequencies. Since the system band width is reduced, the system has a slower
speed to respond. Because of the reduced high frequency gain, the total system gain can be
increased, and thereby low frequency gain can be increased and the steady state can be improved.
Also, any high frequency noises involved in the system can be attenuated.
3. If both fast responses and good static accuracy are desired, a lag –lead compensator may
be employed. By use of the lag–lead compensator, the low–frequency gain can be increased
(which means an improvement in steady- state accuracy), while at the same time the system band
width and stability margins can be increased. Although a large number of practical compensation
tasks can be accomplished with lead, lag –lead compensators; for complicated system simple
compensation by use of these compensators may not yield satisfactory results. Then, different
compensators having different pole-zero configurations must be employed.
Swami Keshvanand Institute of Technology, Management & Gramothan,
Ramnagaria, Jagatpura, Jaipur-302017, INDIA
Approved by AICTE, Ministry of HRD, Government of India
Recognized by UGC under Section 2(f) of the UGC Act, 1956
Tel. : +91-0141- 5160400 Fax: +91-0141-2759555
E-mail: [email protected] Web: www.skit.ac.in

EXPERIMENT NO.- 9

OBJECT: Simulation of P, PI and PID controllers.

Theory:

A proportional–integral–derivative controller (PID controller or three-term controller) is a control loop


mechanism employing feedback that is widely used in industrial control systems and a variety of other
applications requiring continuously modulated control. A PID controller continuously calculates an error
value e(t) as the difference between a desired setpoint (SP) and a measured process variable (PV) and
applies a correction based on proportional, integral, and derivative terms (denoted P, I, and D
respectively), hence the name.

In practical terms, it automatically applies an accurate and responsive correction to a control function. An
everyday example is the cruise control on a car, where ascending a hill would lower speed if only constant
engine power were applied. The controller's PID algorithm restores the measured speed to the desired
speed with minimal delay and overshoot by increasing the power output of the engine in a controlled
manner.

The first theoretical analysis and practical application was in the field of automatic steering systems for
ships, developed from the early 1920s onwards. It was then used for automatic process control in the
manufacturing industry, where it was widely implemented in at first pneumatic, and then electronic
controllers. Today the PID concept is used universally in applications requiring accurate and optimized
automatic control.
Figure 9.1. Tuning by Ziegler Nichols Method
Swami Keshvanand Institute of Technology, Management & Gramothan,
Ramnagaria, Jagatpura, Jaipur-302017, INDIA
Approved by AICTE, Ministry of HRD, Government of India
Recognized by UGC under Section 2(f) of the UGC Act, 1956
Tel. : +91-0141- 5160400 Fax: +91-0141-2759555
E-mail: [email protected] Web: www.skit.ac.in

Figure 9.2. Structure of PID Controller

The distinguishing feature of the PID controller is the ability to use the three control terms of proportional, integral
and derivative influence on the controller output to apply accurate and optimal control. The block diagram shows
the principles of how these terms are generated and applied. It shows a PID controller, which continuously
calculates an error as the difference between a desired and a measured process variable and applies a correction
based on proportional, integral, and derivative terms. The controller attempts to minimize the error over time by
adjustment of a control variableu(t), such as the opening of a control valve, to a new value determined by a
weighted sum of the control terms.

Term P is proportional to the current value of the SP − PV error e(t)}e(t). For example, if the error is large and
positive, the control output will be proportionately large and positive, taking into account the gain factor "K". Using
proportional control alone will result in an error between the setpoint and the actual process value because it
requires an error to generate the proportional response. If there is no error, there is no corrective response.

Term I accounts for past values of the SP − PV error and integrates them over time to produce the I term. For
example, if there is a residual SP − PV error after the application of proportional control, the integral term seeks to
eliminate the residual error by adding a control effect due to the historic cumulative value of the error. When the
error is eliminated, the integral term will cease to grow. This will result in the proportional effect diminishing as the
error decreases, but this is compensated for by the growing integral effect.
Swami Keshvanand Institute of Technology, Management & Gramothan,
Ramnagaria, Jagatpura, Jaipur-302017, INDIA
Approved by AICTE, Ministry of HRD, Government of India
Recognized by UGC under Section 2(f) of the UGC Act, 1956
Tel. : +91-0141- 5160400 Fax: +91-0141-2759555
E-mail: [email protected] Web: www.skit.ac.in

Term D is a best estimate of the future trend of the SP − PV error, based on its current rate of change. It is
sometimes called "anticipatory control", as it is effectively seeking to reduce the effect of the SP − PV
error by exerting a control influence generated by the rate of error change. The more rapid the change, the
greater the controlling or damping effect.

Tuning – The balance of these effects is achieved by loop tuning to produce the optimal control function.
The tuning constants are shown below as "K" and must be derived for each control application, as they
depend on the response characteristics of the complete loop external to the controller. These are dependent
on the behavior of the measuring sensor, the final control element (such as a control valve), any control
signal delays and the process itself. Approximate values of constants can usually be initially entered
knowing the type of application, but they are normally refined, or tuned, by "bumping" the process in
practice by introducing a setpoint change and observing the system response.Control action –

The mathematical model and practical loop use a direct control action for all the terms, which means an
increasing positive error results in an increasing positive control output correction. The system is called
reverse acting if it is necessary to apply negative corrective action. For instance, if the valve in the flow
loop was 100–0% valve opening for 0–100% control output – meaning that the controller action has to be
reversed. Some process control schemes and final control elements require this reverse action. An
example would be a valve for cooling water, where the fail-safe mode, in the case of loss of signal, would
be 100% opening of the valve; therefore 0% controller output needs to cause 100% valve opening.
Swami Keshvanand Institute of Technology, Management & Gramothan,
Ramnagaria, Jagatpura, Jaipur-302017, INDIA
Approved by AICTE, Ministry of HRD, Government of India
Recognized by UGC under Section 2(f) of the UGC Act, 1956
Tel. : +91-0141- 5160400 Fax: +91-0141-2759555
E-mail: [email protected] Web: www.skit.ac.in

Computer Program

% PID tunning Program


Num=1;
Den=[1 6 5 1];
G_close=tf(Num,Den);
t = 0:0.05:10;
c1=step(G_close,t);
Num_c=[6.322 18 12.811];
Den_c=[1 6 11.32 18 12.811];
G_compensator=tf(Num_c,Den_c);
c2=step(G_compensator,t)
plot(t,c1,'-',t,c2,'x')
title('Analysis of a control system with and without PID controller')
xlabel('Time') % x-axis label
ylabel('Response') % y-axis label
legend('c1 = System response without Controller','c2 = System response
with Controller')
Figure 9.3 PID controller Design

Observations: We observe that the settling time and rise time are optimal when we employ PID controller on a
given open loop system. In future, different control algorithms can be employed and tested on given system.
Swami Keshvanand Institute of Technology, Management & Gramothan,
Ramnagaria, Jagatpura, Jaipur-302017, INDIA
Approved by AICTE, Ministry of HRD, Government of India
Recognized by UGC under Section 2(f) of the UGC Act, 1956
Tel. : +91-0141- 5160400 Fax: +91-0141-2759555
E-mail: [email protected] Web: www.skit.ac.in

EXPERIMENT NO.- 10

OBJECT: Design of Temperature control system using PID controller.

Theory: Temperature control is a process in which change of temperature of a space (and objects
collectively there within), or of a substance, is measured or otherwise detected, and the passage of heat
energy into or out of the space or substance is adjusted to achieve a desired temperature.

Air-conditioners, space-heaters, refrigerators, water-heaters, etc. are examples of devices that perform
temperature control. These are often broadly classified as Thermostatically Controlled Loads (TCLs).
An object's or space's temperature increases when heat energy moves into it, increasing the average kinetic
energy of its atoms, e.g., of things and air in a room. Heat energy leaving an object or space lowers its
temperature. Heat flows from one place to another (always from a higher temperature to a lower one) by
one or more of three processes: conduction, convection and radiation. In conduction, energy is passed
from one atom to another by direct contact. In convection, heat energy moves by conduction into some
movable fluid (such as air or water) and the fluid moves from one place to another, carrying the heat with
it.
At some point the heat energy in the fluid is usually transferred to some other object by means conduction
again. The movement of the fluid can be driven by negative-buoyancy, as when cooler (and therefore
denser) air drops and thus upwardly displaces warmer (less-dense) air (natural convection), or by fans or
pumps (forced convection). In radiation, the heated atoms make electromagnetic emissions absorbed by
remote other atoms, whether nearby or at astronomical distance. For example, the Sun radiates heat as
both invisible and visible electromagnetic energy. What we know as "light" is but a narrow region of the
electromagnetic spectrum. If, in a place or thing, more energy is received than is lost, its temperature
increases. If the amount of energy coming in and going out are exactly the same, the temperature stays
constant—there is thermal balance, or thermal equilibrium.
Swami Keshvanand Institute of Technology, Management & Gramothan,
Ramnagaria, Jagatpura, Jaipur-302017, INDIA
Approved by AICTE, Ministry of HRD, Government of India
Recognized by UGC under Section 2(f) of the UGC Act, 1956
Tel. : +91-0141- 5160400 Fax: +91-0141-2759555
E-mail: [email protected] Web: www.skit.ac.in

Figure 10.1 Temperature Control System

When controlling the temperature of an industrial furnace, it is usually better to control the opening of the fuel valve
in proportion to the current needs of the furnace. This helps avoid thermal shocks and applies heat more effectively.
At low gains, only a small corrective action is applied when errors are detected. The system may be safe and stable,
but may be sluggish in response to changing conditions. Errors will remain uncorrected for relatively long periods
of time and the system is overdamped. If the proportional gain is increased, such systems become more responsive
and errors are dealt with more quickly. There is an optimal value for the gain setting when the overall system is said
to be critically damped. Increases in loop gain beyond this point lead to oscillations in the PV and such a system is
underdamped.

Figure 10.2 Structure of PID Controller

.
Swami Keshvanand Institute of Technology, Management & Gramothan,
Ramnagaria, Jagatpura, Jaipur-302017, INDIA
Approved by AICTE, Ministry of HRD, Government of India
Recognized by UGC under Section 2(f) of the UGC Act, 1956
Tel. : +91-0141- 5160400 Fax: +91-0141-2759555
E-mail: [email protected] Web: www.skit.ac.in

Adjusting gain to achieve critically damped behavior is known as tuning the control system. In the
underdamped case, the furnace heats quickly. Once the setpoint is reached, stored heat within the heater
sub-system and in the walls of the furnace will keep the measured temperature rising beyond what is
required. After rising above the setpoint, the temperature falls back and eventually heat is applied again.
Any delay in reheating the heater sub-system allows the furnace temperature to fall further below setpoint
and the cycle repeats. The temperature oscillations that an underdamped furnace control system produces
are undesirable. In a critically damped system, as the temperature approaches the setpoint, the heat input
begins to be reduced, the rate of heating of the furnace has time to slow and the system avoids overshoot.
Overshoot is also avoided in an overdamped system but an overdamped system is unnecessarily slow to
initially reach setpoint respond to external changes to the system, e.g. opening the furnace door.

Simulation Problem

According to the given conditions a suitable range of time and K and a are selected and increment
operators are decided. By employing different for loops all possible solutions are generated that can
satisfies the given design criterion. Following section presents the computer program and output
calculated from the program.
Swami Keshvanand Institute of Technology, Management & Gramothan,
Ramnagaria, Jagatpura, Jaipur-302017, INDIA
Approved by AICTE, Ministry of HRD, Government of India
Recognized by UGC under Section 2(f) of the UGC Act, 1956
Tel. : +91-0141- 5160400 Fax: +91-0141-2759555
E-mail: [email protected] Web: www.skit.ac.in

Computer Program:

Computer Program

t = 0:0.01:8;
k = 0;
size(t); %801
for K = 3:0.2:5; % assume step size 0.2
for a = 0.1:0.1:3; % assume step size 0.1
num = [4*K 8*K*a 4*K*a^2];
den = [1 6 8+4*K 4+8*K*a 4*K*a^2];
y = step(num,den,t);
s = 801;
while y(s)>0.98 & y(s)<1.02; % Plotting step response
s = s-1;
end; % End of While Loop
ts = (s-1)*0.01; % ts = settling time;
m = max(y); % Peak overshoot
if m<1.15 & m>1.10; % given Condition
if ts<3.00; % given design specification
k = k+1;
solution(k,:) = [K a m ts];
end % End of if Loop
end % End of if loop
end % End of for Loop
end % End of for Loop
sortsolution = sortrows(solution,3); % sort solution as per maximum overshoot
K = sortsolution(1,1), a = sortsolution(1,2); % store the solution in K and a
corresponing to minimum overshoot
num = [4*K 8*K*a 4*K*a^2];
den = [1 6 8+4*K 4+8*K*a 4*K*a^2];
y = step(num,den,t);
plot(t,y) % See Figure 8–24.
grid
title('Unit-Step Response')
xlabel('t sec')
Swami Keshvanand Institute of Technology, Management & Gramothan,
Ramnagaria, Jagatpura, Jaipur-302017, INDIA
Approved by AICTE, Ministry of HRD, Government of India
Recognized by UGC under Section 2(f) of the UGC Act, 1956
Tel. : +91-0141- 5160400 Fax: +91-0141-2759555
E-mail: [email protected] Web: www.skit.ac.in

As per given criterion the closed loop transfer function of the system can be given as:

12.8s 2  23.04 s  10.37


T (s)  (a)
s 4  6s 3  20.8s 2  27.04 s  10.37

Conclusion: The program is written for iterative tuning of PID controller as per given specifications, A
solution vector is obtained and an optimal design is selected by using sort command. Expression (a) shows
the designed compensated system as per design criterion.

You might also like