Advertisement
Tamjow

cflab7

Apr 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.68 KB | None | 0 0
  1. close all
  2. s=tf('s');
  3. T1 = 3;
  4. T2 = 0.5;
  5. T3=2;
  6. k = 3;
  7. kr=1; %4.86 crit, 2.43 for P controller
  8. kcrit=4.86;
  9. Td = [12.5 25 50];
  10. Ti = [12.5 25 50];
  11.  
  12. K=(k)/((1+3*s)*(1+0.5*s)*(1+2*s)); %plant
  13. Kcontpd1=K*(kr*(1+s*Td(1)));
  14. Kcontpd2=K*(kr*(1+s*Td(2)));
  15. Kcontpd3=K*(kr*(1+s*Td(3)));
  16.  
  17. Kcontpi1=K*(kr*(1+1/(s*Ti(1))));
  18. Kcontpi2=K*(kr*(1+1/(s*Ti(2))));
  19. Kcontpi3=K*(kr*(1+1/(s*Ti(3))));
  20.  
  21. P = bodeoptions('cstprefs');
  22. P.FreqScale = 'linear';
  23. P.MagUnits = 'abs';
  24. P.MagScale = 'linear';
  25.  
  26. N = nyquistoptions('cstprefs');
  27. N.ShowFullContour = 'off';
  28.  
  29. %rlocus(K)
  30. %bode(K,P)%%find phase and gain margin from it
  31.  
  32. [Gm,Pm,wgm,wpm]= margin(K)
  33. % rlocus(K)
  34. % nyquist(K,N)
  35.  
  36. %%%%%%%%%%%%%%%%%%%%%%%%%%%%
  37. %%%%%%%%%% TASK 6 %%%%%%%%%%
  38. %%%%%%%%%%%%%%%%%%%%%%%%%%%%
  39.  
  40. % for i = 1:3
  41. %     figure(i)
  42. %     rlocus(K*Kpdcont(i))
  43. %     title(['root locus of system with PD controller with Td =' num2str(Td(i))])
  44. %     figure(i+3)
  45. %     rlocus(K*Kpicont(i))
  46. %     title(['root locus of system with PI controller with Ti =' num2str(Ti(i))])
  47. %     figure(i+6)
  48. %     step(K*Kpdcont(i)/(1+K*Kpdcont(i)))
  49. %     title(['time response of system with PD controller with Td =' num2str(Td(i))])
  50. %     figure(i+9)
  51. %     step(K*Kpicont(i)/(1+K*Kpicont(i)))
  52. %     title(['time response of system with PI controller with Ti =' num2str(Ti(i))])
  53. % end
  54.  
  55. figure(1)
  56. step(Kcontpd1/(1+Kcontpd1))
  57. title(['step response of PD controlled system for Td = ' num2str(Td(1))])
  58. hold on;
  59. figure(2)
  60. step(Kcontpd2/(1+Kcontpd2))
  61. title(['step response of PD controlled system for Td = ' num2str(Td(2))])
  62. hold on;
  63. figure(3)
  64. step(Kcontpd3/(1+Kcontpd3))
  65. title(['step response of PD controlled system for Td = ' num2str(Td(3))])
  66.  
  67. figure(4)
  68. step(Kcontpi1/(1+Kcontpi1))
  69. title(['step response of PI controlled system for Ti = ' num2str(Ti(1))])
  70. hold on;
  71. figure(5)
  72. step(Kcontpi2/(1+Kcontpi2))
  73. title(['step response of PI controlled system for Ti = ' num2str(Ti(2))])
  74. hold on;
  75. figure(6)
  76. step(Kcontpi3/(1+Kcontpi3))
  77. title(['step response of PI controlled system for Ti = ' num2str(Ti(3))])
  78.  
  79. figure(7)
  80. rlocus(Kcontpd1)
  81. title(['root locus of PD controlled system for Td = ' num2str(Td(1))])
  82.  
  83. figure(8)
  84. rlocus(Kcontpd2)
  85. title(['root locus of PD controlled system for Td = ' num2str(Td(2))])
  86. figure(9)
  87. rlocus(Kcontpd3)
  88. title(['root locus of PD controlled system for Td = ' num2str(Td(3))])
  89. figure(10)
  90. rlocus(Kcontpi1)
  91. title(['root locus of PD controlled system for Ti = ' num2str(Ti(1))])
  92. figure(11)
  93. rlocus(Kcontpi2)
  94. title(['root locus of PD controlled system for Ti = ' num2str(Ti(2))])
  95. figure(12)
  96. rlocus(Kcontpi3)
  97. title(['root locus of PD controlled system for Ti = ' num2str(Ti(3))])
  98.  
  99. % sysr=minreal(Kpdcont(1)*K)
  100. % rlocus(sysr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement