Problem with pidtune function
5 views (last 30 days)
Show older comments
For the following code I keep getting just an integral element to my controller even though I am specifying PID. I need PID to get the response I'm looking for but unsure of what I'm doing wrong. tfp4 comes from a state space which I am sure is correct and isn't causing any errors that should effect my response.
[C,info] = pidtune(tfp4, 'PID')
tuned = feedback(C*tfp4, 1);
t = linspace(0, 100, 1000);
u = 3*pi/180*heaviside(t);
[y42, t42] = lsim(tuned, u, t);
y42 = y42*180/pi;
figure()
plot(t42, y42)
2 Comments
Paul
on 28 Apr 2024
will be difficult for anyone to help w/o the tfp4 model, which can be saved in a .mat file and added to the question using the Paperclip icon in the Insert menu.
If I had to guess, I'd say that pidtune is able to meet its internally generated design goals with just the integral control; the call to pidtune isn't specifying any design goals in particular, i.e., the resopnse you're looking for.
Accepted Answer
Sam Chak
on 29 Apr 2024
According to the documentation, if the tuning algorithm can achieve satisfactory performance and robustness using a lower-order controller than what is specified for the desired PID controller type, the pidtune function will return a 'C' controller with fewer actions than specified. In your case, 'C' could be an Integral-only controller, even though the type is 'PID'.
Additionally, if no performance specifications are provided, the algorithm will choose a crossover frequency based on the plant dynamics and automatically design for a target phase margin of 60°
%% 4th-order transfer function plant (tfp4)
num = [-1 4 6 4 1];
den = [ 1 4 6 4 1];
Gp = tf(num, den)
%% Attempt to implement a PID Controller
% C0 = pidstd(1, 1, 1e-6); % baseline controller
% [C, info] = pidtune(Gp, C0)
[C, info] = pidtune(Gp, 'PID')
%% Closed-loop system
Gcl = feedback(C*Gp, 1)
%% Plot results
subplot(211)
step(Gp, 10), grid on, legend('Original Plant')
subplot(212)
step(Gcl), grid on, legend('Compensated Plant with I-only controller', 'location', 'East')
3 Comments
Sam Chak
on 1 May 2024
You're welcome! If you have additional questions on how to improve the performance, feel free to ask.
More Answers (0)
See Also
Categories
Find more on PID Controller Tuning in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
