Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- close all
- s=tf('s');
- T1 = 3;
- T2 = 0.5;
- T3=2;
- k = 3;
- kr=1; %4.86 crit, 2.43 for P controller
- kcrit=4.86;
- Td = [12.5 25 50];
- Ti = [12.5 25 50];
- K=(k)/((1+3*s)*(1+0.5*s)*(1+2*s)); %plant
- Kcontpd1=K*(kr*(1+s*Td(1)));
- Kcontpd2=K*(kr*(1+s*Td(2)));
- Kcontpd3=K*(kr*(1+s*Td(3)));
- Kcontpi1=K*(kr*(1+1/(s*Ti(1))));
- Kcontpi2=K*(kr*(1+1/(s*Ti(2))));
- Kcontpi3=K*(kr*(1+1/(s*Ti(3))));
- P = bodeoptions('cstprefs');
- P.FreqScale = 'linear';
- P.MagUnits = 'abs';
- P.MagScale = 'linear';
- N = nyquistoptions('cstprefs');
- N.ShowFullContour = 'off';
- %rlocus(K)
- %bode(K,P)%%find phase and gain margin from it
- [Gm,Pm,wgm,wpm]= margin(K)
- % rlocus(K)
- % nyquist(K,N)
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%% TASK 6 %%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % for i = 1:3
- % figure(i)
- % rlocus(K*Kpdcont(i))
- % title(['root locus of system with PD controller with Td =' num2str(Td(i))])
- % figure(i+3)
- % rlocus(K*Kpicont(i))
- % title(['root locus of system with PI controller with Ti =' num2str(Ti(i))])
- % figure(i+6)
- % step(K*Kpdcont(i)/(1+K*Kpdcont(i)))
- % title(['time response of system with PD controller with Td =' num2str(Td(i))])
- % figure(i+9)
- % step(K*Kpicont(i)/(1+K*Kpicont(i)))
- % title(['time response of system with PI controller with Ti =' num2str(Ti(i))])
- % end
- figure(1)
- step(Kcontpd1/(1+Kcontpd1))
- title(['step response of PD controlled system for Td = ' num2str(Td(1))])
- hold on;
- figure(2)
- step(Kcontpd2/(1+Kcontpd2))
- title(['step response of PD controlled system for Td = ' num2str(Td(2))])
- hold on;
- figure(3)
- step(Kcontpd3/(1+Kcontpd3))
- title(['step response of PD controlled system for Td = ' num2str(Td(3))])
- figure(4)
- step(Kcontpi1/(1+Kcontpi1))
- title(['step response of PI controlled system for Ti = ' num2str(Ti(1))])
- hold on;
- figure(5)
- step(Kcontpi2/(1+Kcontpi2))
- title(['step response of PI controlled system for Ti = ' num2str(Ti(2))])
- hold on;
- figure(6)
- step(Kcontpi3/(1+Kcontpi3))
- title(['step response of PI controlled system for Ti = ' num2str(Ti(3))])
- figure(7)
- rlocus(Kcontpd1)
- title(['root locus of PD controlled system for Td = ' num2str(Td(1))])
- figure(8)
- rlocus(Kcontpd2)
- title(['root locus of PD controlled system for Td = ' num2str(Td(2))])
- figure(9)
- rlocus(Kcontpd3)
- title(['root locus of PD controlled system for Td = ' num2str(Td(3))])
- figure(10)
- rlocus(Kcontpi1)
- title(['root locus of PD controlled system for Ti = ' num2str(Ti(1))])
- figure(11)
- rlocus(Kcontpi2)
- title(['root locus of PD controlled system for Ti = ' num2str(Ti(2))])
- figure(12)
- rlocus(Kcontpi3)
- title(['root locus of PD controlled system for Ti = ' num2str(Ti(3))])
- % sysr=minreal(Kpdcont(1)*K)
- % rlocus(sysr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement