Simulink and Matlab PID time response difference
显示 更早的评论
Hi everyone,
I'm working on a flight dynamics assignment (pitch angle control for a UAV) and I am facing an issue where my MATLAB script and my Simulink model yield completely different step responses for the exact same system and gains.
I am designing a PID controller. The plant is a 4x4 state-space model (A, B, Ctheta, D), and I generated the transfer function tf_theta.
- My gains are: Kp = 12, Ti = 0.5, Td = 0.2.
- The reference step is theta_0 = 0.1571 rad.
The issue:
- In MATLAB: Using the pid object with a derivative filter (Tf = 0.01), the step response is extremely fast (settling time < 0.2s). (See attached MATLAB plot).
- In Simulink: I built the PID manually using a Derivative block (set to numerical derivative $\frac{\Delta u}{\Delta t}$ with c = inf). The step response is much slower, settling around 3 to 4 seconds. (See attached Simulink plot).
Here is the relevant part of my MATLAB code:
% Plant Transfer Function
theta_ss = ss(A, B, [0 0 0 1], 0);
tf_theta = tf(-theta_ss); % Minus sign required by assignment for positive DC gain
% Controller Gains
theta_0 = 0.1571;
Kp = 12;
Ti = 0.5;
Td = 0.2;
c = 0.01; % Derivative filter time constant
% PID Definition (Ideal format)
K_pid = pid(Kp, Kp/Ti, Kp*Td, c);
% Closed Loop
CL = feedback(K_pid * tf_theta, 1);
% Plot
figure;
step(CL * theta_0);
grid on;
title('Step response: Closed Loop Pitch angle');
Here are the screens :


采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Real-Time PID Autotuning 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!