how do i use pidtune in matlab

To use pidtune function in MATLAB, follow the steps below:

  1. Create a pidtune object using the system to tune, desired response type, and other options:
main.m
sys = tf(1,[1 2 3]);   % Define the system to tune
opt = pidtuneOptions('CrossoverFrequency',10);   % Define options
pidObj = pidtune(sys,'pid',opt);    % Create a pidtune object
179 chars
4 lines
  1. To view the initial response, use step command:
main.m
step(sys)
title('Initial System Response')
43 chars
3 lines
  1. Tune the PID gains using pidtune function:
main.m
[C,info] = pidtune(sys,'pid',opt);
35 chars
2 lines

This will calculate the appropriate gains and returns the closed loop system and performance information.

  1. Apply the tuned PID controller to the system:
main.m
sys_cl = feedback(sys*C,1);
step(sys_cl)
title('Closed Loop System Response')
78 chars
4 lines

This will create the closed-loop system around the plant sys , using the optimized PID controllers C, and produce the step response of the system.

Note that there are many other techniques and options available in pidtune function to design PID controllers in MATLAB.

References:

  1. MATLAB Documentation on pidtune: https://www.mathworks.com/help/control/ref/pidtune.html

related categories

gistlibby LogSnag