black_calculus

EXP 2

Feb 26th, 2020
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. % Linearization of Model
  2. Cf = 0.5, Ca = 1500, m = 1500
  3. spd = 60
  4. Ve = spd*0.44704
  5. A = [-2*(Cf*Ve)/m]
  6. B = [Ca/m]
  7. C = [1]
  8. D = [0]
  9. Pss = ss(A, B, C, D)
  10. Ptf = tf(Pss)
  11.  
  12. % step(Ptf)
  13.  
  14. % --- Simulink model setup ---
  15.  
  16. %Q3-5
  17. sim_spd = 60
  18. sim_spd_throttle = 60
  19.  
  20. x_e = sim_spd*0.44704
  21. x_throttle = sim_spd_throttle*0.44704
  22. u_e = (Cf/Ca)*(x_e^2)
  23. u_throttle = (Cf/Ca)*(x_throttle^2)
  24.  
  25. % --- PID Controller Design
  26.  
  27. w_c = 2/1.5
  28. w_c_d = w_c*180/pi
  29. PM = 60
  30. P = Ptf
  31. [M_p, Ph_p] = bode(P, w_c)
  32.  
  33. z = (w_c)/(tand(PM-90-Ph_p))
  34. K = (w_c)/(sqrt( (w_c^2) + (z^2) ) * M_p)
  35.  
  36. K_p = K
  37. K_i = K_p*z
  38.  
  39. C = tf([K K*z], [1 0])
  40.  
  41. L = C*P
  42.  
  43. PID_cont = pid(K_p, K_i)
Advertisement
Add Comment
Please, Sign In to add comment