aprsc7

Acker_controller

Jan 21st, 2021
582
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. clc
  2. clear
  3.  
  4. numg = 0.072*conv([1 23],[1 0.05 0.04]); % Define numerator of G(s)
  5. deng = conv([1 0.08 0.04],poly([0.7 -1.7])); % Define denominator of G(s)
  6. G = tf(numg,deng) % Generate transfer function G(s)
  7.  
  8. %% STEP 1:
  9.  
  10. pos = 10;
  11. Ts = 0.5;
  12. z = (-log(pos/100))/(sqrt(pi^2+log(pos/100)^2));
  13. wn = 4/(z*Ts);
  14.  
  15. % Produce a second-order system that meets transient response requirements
  16. [num,den] = ord2(wn,z);
  17. r = roots(den);
  18. zeros = roots(numg);
  19. poles = [r(1) r(2) zeros(2) zeros(3)];
  20. Ds = poly(poles)
  21.  
  22. %% STEP 2:
  23.  
  24. % Find controller canonical form of state-space representation
  25. [Ac Bc Cc Dc] = tf2ss(numg,deng);
  26.  
  27. % Find controller canonical form of state-space representation
  28. P = flip(eye(order(G)));
  29.  
  30. % Transform Ac, Bc, Cc and Dc to phase-variable form
  31. Ap = inv(P)*Ac*P
  32. Bp = inv(P)*Bc
  33. Cp = Cc*P
  34. Dp = Dc
  35.  
  36. % Calculate controller gains in phase-variable form.
  37. Kp = acker(Ap,Bp,poles)
  38.  
  39. % Form compensated state-space model
  40. Apnew = Ap-Bp*Kp;
  41. Bpnew = Bp;
  42. Cpnew = Cp;
  43. Dpnew = Dp;
  44.  
  45. % Form transfer function of state-feedback controller
  46. [numt,dent] = ss2tf(Apnew,Bpnew,Cpnew,Dpnew);
  47. Tsc = tf(numt,dent)
  48.  
  49. % Plot
  50. step(Tsc);
  51. title('State Feedback Controller');
  52. xlim([0 0.6]);
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
RAW Paste Data