Matlab Code
Matlab Code
1(Steady-State error) %(The problem being used in this example is adapted from: Modern Control Systems, ninth edition 2000) %Richard C. DORF and Robert H. BISHOP %G(s)=K(s+10)/s(s+1)(s+20)(s+50) %MATLAB-file written by Stjepan Blazevic %SOLUTION %PART 1: 'The system type' %If we consider denominator of the transfer function s(s+1)(s+20)(s+50) we can see that %the number of pure integrations in the forward path is equal to 1.So we can conclude %that given system is Type 1. 'Position coefficient Kp' K=input('Enter desired value of system gain K,K= ') numg=K*[1 10]; deng=poly([0 -1 -20 -50]); G=tf(numg,deng); Kp=dcgain(G) 'Velocity coefficient Kv' numgs=conv([1 0],numg); dengs=deng; Gs=tf(numgs,dengs) Gs=minreal(Gs); Kv=dcgain(Gs) 'Acceleration coefficient Ka' %Define numerator of sG(s) %Define denominator of sG(s) %Form sG(s) LTI object %Cancel common s in numerator and denominator %Calculate and display Kv %Define numerator of the system's transfer function %Define denominator of the system's transfer function %Form G(s) LTI object %Calculate and display the value of Kp TJ216.D67 2000
numgsa=conv([1 0 0],numg); > Gsa=tf(numgsa,dengsa); Ka=dcgain(Gsa) %Form s^2G(s) LTI object %Calculate and display acceleration coefficient Ka
'COMMENT:If we consider obtained results for Kp,Kv and Ka we can also conclude that' 'given system is Type 1 as only a Type 1 system has a finite Kv' 'Type 0 has Kv=0 and Type 2 has Kv=infinity'
'Step input' esss=1/(1+Kp) %Calculate and display steady state error for step input
'Ramp input' essr=1/Kv %Calculate and display steady state error for ramp input
'Parabolic input' essp=1/Ka %Calculate steady state error for parabolic input
%PART 2: %Find the value of gain K,to yield a 30% steady state error essrd=input('Enter desired value of steady state error essr1,ess1r= ') 'System gain for ess=30'
numg1=K1*[1 10]; deng1=poly([0 -1 -20 -50]); Gg=tf(numg1,deng1); 'Position coefficient Kp1' Kp1=dcgain(Gg) 'Velocity coefficient Kv1' numgs1=conv([1 0],numg1); dengs1=deng1; Gg1=tf(numgs1,dengs1); Gg1=minreal(Gg1); Kv1=dcgain(Gg1) 'Acceleration coefficient Ka1' numgsa1=conv([1 0 0],numg1); dengsa1=deng1; Gga1=tf(numgsa1,dengsa1); Ka1=dcgain(Gga1) %PART 3-c: 'Step input' esss1=1/(1+Kp1) 'Ramp input' essr1=1/Kv1
%Define numerator of system for K1 %Define denominator for K1 %Form Gg(s) LTI object
%Define numerator of the system %Define denominator of transfer function %Create Gg1(s) LTI object %Cancel common s in numerator and denominator of the system %Calculate and display Kv1
%Define numerator of the system transfer function %Define denominator-----"------"------%Form Gga1(s) LTI object %Calculate and display Ka1
'Press any key to go for K=100 output step response' pause %PART 3:The plot of output step response for K=100 and estimation %of Ts,Tr,max OS%,and Tp from the plot 'Step plot for K=100' T=feedback(G,1); step(T) %Form closed loop transfer function %Plot output step response
title('OUTPUT STEP RESPONSE FOR K=100') 'Press any key to go for output step response for K that gives ess=30%' pause
'Step plot for K that produces steady state error ess=30%' num1=K1*[1 10]; den1=poly([0 -1 -20 -50]); G1=tf(num1,den1); T1=feedback(G1,1); step(T1) %Define numerator of the system for K1 %Define denominator of the system %Form G1(s) LTI object %Form closed loop transfer function %Plot output step response for desire system gain K
title('OUTPUT STEP RESPONSE FOR K that give ess=30%') 'Press any key to go for the plots for K & K1 on the same graph' pause step(T,T1) %Plot output step responses for K &K1 on the same graph
MATLAB RESULTS
To get started, type one of these: helpwin, helpdesk, or demo. For product information, visit www.mathworks.com. EDU ans = The system type
ans = Position coefficient Kp Enter desired value of system gain K,K= 100 K= 100
Kp = Inf
Transfer function: 100 s^2 + 1000 s -------------------------------s^4 + 71 s^3 + 1070 s^2 + 1000 s
Kv = 1.0000
Ka = 0
ans =
COMMENT:If we consider obtained results for Kp,Kv and Ka we can also conclude that
esss = 0
essr = 1.0000
ans = Parabolic input Warning: Divide by zero. > In C:\MATLAB_SE_5.3\work\Example2_1.m at line 63 essp = Inf Enter desired value of steady state error essr1,ess1r= 30 essrd = 30
K1 = 3.3333
Kp1 = Inf
Kv1 = 0.0333
Ka1 = 0
esss1 = 0
essr1 =
30.0000
ans = Parabolic input Warning: Divide by zero. > In C:\MATLAB_SE_5.3\work\Example2_1.m at line 111 essp1 = Inf
ans = Press any key to go for output step response for K that give ess=30%
ans = Step plot for K that produces steady state error ess=30%
ans = Press any key to go for the plots for K & K1 on the same graph RESULTS SUMMARY 1. a) If we consider the denominator of the transfer function s(s+1)(s+20)(s+50) we can see that the number of pure integrations in the forward path is equal to 1. So we can conclude that the given system is Type 1. Moreover if we consider the obtained results for Kp, Kv and Ka (in part b) we can also conclude from those results that the given system is Type 1 as only a Type 1 system has a finite Kv. Type 0 has Kv=0 and Type 2 has Kv= . b) Position coefficient Velocity coefficient Kp= Kv=1
2. The value of gain K that yields a 30% error in steady state is K=3.3333 3. a) For obtained K=3.3333 b) Position coefficient Kp1 = Velocity coefficient Kv1 =0.0333 Acceleration coefficient Ka1 =0 c) Steady-state error for step input
From the obtained results for K=100 and K=3.333 we can see that decreasing system gain K from 100 to 3.333 the steady-state error increases from 1% to 30% due to the fact that for decreasing system gain velocity coefficient Kv decreases from Kv=1 for K=100 to Kv=0.0333 for K=3.333. Hence we can see from this example that increase of system gain will decrease steady-state error of the system. 4.
From the above plot of output step response (for K=100) the estimated (simulated) values of Ts, Tr, Tp and OS% are: Ts=7.8sec Tp=3.63sec Tp=1.6sec OS%=15% 5.
From the plot for K=3.333 Ts=115sec Tp=158sec Tr=64sec Comparing these values for different system gains we can see that for higher system gains the system response is much faster, but with higher percent overshoot. Decreasing system gain will cause slow system response i.e. decreasing gain will cause system response time to increase. All these system gain effects can be seen from the obtained output step responses for K=100 and K=3.333 plotted on the same graph below. The simulated values of Tr, Tp, Ts are already displayed in part 4 and part 5.
Furthermore this gain effect on system output response can be seen even more clearly from the animation. In addition the output step response for K that gives acceptable steady-state error within 10% criterion is shown on the graph below: