0% found this document useful (0 votes)
10 views4 pages

Untitled Document

The document outlines a program for designing a lag compensator for a unity feedback control system with a specified open loop transfer function. It details the steps to calculate the necessary gain, phase margins, and the transfer function of the lag compensator, followed by comparisons of Bode plots and step responses for both compensated and uncompensated systems. The goal is to achieve a phase margin of 40 degrees and a steady state error for ramp input of less than or equal to 0.2.

Uploaded by

dnyanupiwal799
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views4 pages

Untitled Document

The document outlines a program for designing a lag compensator for a unity feedback control system with a specified open loop transfer function. It details the steps to calculate the necessary gain, phase margins, and the transfer function of the lag compensator, followed by comparisons of Bode plots and step responses for both compensated and uncompensated systems. The goal is to achieve a phase margin of 40 degrees and a steady state error for ramp input of less than or equal to 0.2.

Uploaded by

dnyanupiwal799
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Simulation of a lag compensator for a given system

%% Program to design the Lag compensator for a given system


% Consider a numerical from Advanced Control Theory, A Nagoor Kani
% Numerical 1.1: A unity feedback system has an open loop transfer function,
% G(s) =K/(s(1+2)). Design a suitable lag compensator so that the phase margin
% is 40 degree and the steady state error for ramp input is less than or equal
to 0.2
% Name of the Student:Dnyaneshwar Piwal
% Roll number:BE41
close all
clear all
clc
%% Uncompensated control system transfer function (assuming H(s)=1)
% Calculate the value of gain K from e_ss and use it.
num=[5];
den=[2 1 0];
G=tf(num,den);
%% Bode plot of the uncompensated system
figure(1)
bode(G), grid on % To check PM and GM of uncompensated system
title('Bode plot of uncompensated system')
[Gm,Pm,Wpc,Wgc ] = margin(G);
%% Lag compensator Design
Pmd=40; % Desired Phase Margin (PM)
Pmn=Pmd+5; % New Phase margin
Phigcn=Pmn-180; % Phase angle for the new PM
% From bode plot in figure(1), calculate Wgcn and Agcn for Phigcn and take
wout=Wgcn, mag=Agcn
Wgcn=0.5; % wout=Wgcn
Agcn=17; % mag=Agcn
% Pole and zero of the Lag compensator Gc(s)= (s+1/T)/(s+1/(beta*T))
beta=10^(Agcn/20);
T=10/Wgcn; % Place zero at 1/10th
% Transfer function of Lag compensator
numc=[1 1/T];
denc=[1 1/(beta*T)];
Gc=tf(numc, denc);
Gain=1/beta;
% Total forward transfer function of compensated system
Gt=Gain*Gc*G;
%% Bode plot of the compensated system
figure(5)
bode(Gt), grid on % To check PM and GM of compensated system
title('Bode plot of compensated system')
[Gmc,Pmc,Wpcc,Wgcc ] = margin(Gt);
%% Comparison of compensated and uncompensated bode plots
figure(2)
bode(G,'--r', Gt,'-'), grid on
legend('Uncompensated system', 'Compensated system')
title('Comparison of compensated and uncompensated bode plots')
%% Since H(s)=1, the feedback transfer function
Gc1u=feedback(G,1); % Closed loop TF of uncompensated system
Gclc=feedback(Gt,1); % Closed loop TF of compensated system
% Comparison of compensated and uncompensated step responses
figure(3)
step(Gc1u, '--r', Gclc, '-'); grid on
legend('Uncompensated system' , 'Compensated system')
title('Comparison of compensated and uncompensated step responses')
%% Comparison of compensated and uncompensated ramp responses
t=0:0.02:80;
figure(4)
[y1,z1]=step(5, [2 1 5 0],t); % Take num and den coefficients of Gclu with a
pole at origin
[y2,z2]=step([0.7063 0.03531], [2 1.014 0.7133 0.03531 0],t);
% Take num and den coefficients of Gclc with a
pole at origin
plot(t,y1,'.',t,y2,'-',t,t,'--'), grid on
legend('Uncompensated system', 'Compensated system', 'Reference')
title('Comparison of compensated and uncompensated ramp responses')

You might also like