I have been developing an iterative method of tuning a PID controller to find the optimum coefficients for a given plant. There cannot be any overshoot.
I have decided to firstly perform a coarse search (say 200 iterations) through Kp, Ki and Kd. I will then discard any results which overshoot, select the 3 'best' responses and then perform finer iterations around those values.
So far I have the following code;
%% Servo Motor Position Control Parameters
%**Change file name at the code end to run for current model** % Electrical Variables
Ra = 0.1; %Armature Resistance (Ohm) La = 0.0041; %Armature Inductance (Henry) Kt = 5.4; %Torque Constant
% Mechanical Variables
J = 405; %Inertia (kgm^2) B = 0; %Damping (Ns/m)
Gi = 1; %Current Gain
% PID Iteration
for Kp = 0:100:600 for Ki = 0:100:600 for Kd = 0:100:600
NB Dynamic Model returns the step response of position, which is what we are tuning for.
This 'works' in the sense that it will return a plot of all the traces which pass the ‘no overshoot’ criteria (ie the coarse search mentioned above). The issue I have now is that I lose the information about which PID gains these correspond to.
- Is there a way I can output the PID gains for specific curves to the workspace?
- Further to this I will need to sort these into ‘best to worst response’, to perform the finer iterations.
I am relatively new to coding in Matlab so appreciate any references or help files that could be useful.