control.rootlocus_pid_designer
- control.rootlocus_pid_designer(plant, gain='P', sign=1, input_signal='r', Kp0=0, Ki0=0, Kd0=0, deltaK=0.001, tau=0.01, C_ff=0, derivative_in_feedback_path=False, plot=True)[source]
Manual PID controller design based on root locus using Sisotool.
Uses
sisotool
to investigate the effect of adding or subtracting an amountdeltaK
to the proportional, integral, or derivative (PID) gains of a controller. One of the PID gains,Kp
,Ki
, orKd
, respectively, can be modified at a time.sisotool
plots the step response, frequency response, and root locus of the closed-loop system controlling the dynamical system specified byplant
. Can be used with either non- interactive plots (e.g. in a Jupyter Notebook), or interactive plots.To use non-interactively, choose starting-point PID gains
Kp0
,Ki0
, andKd0
(you might want to start with all zeros to begin with), select which gain you would like to vary (e.g.gain
= ‘P’, ‘I’, or ‘D’), and choose a value ofdeltaK
(default 0.001) to specify by how much you would like to change that gain. Repeatedly runrootlocus_pid_designer
with different values ofdeltaK
until you are satisfied with the performance for that gain. Then, to tune a different gain, e.g. ‘I’, make sure to add your chosendeltaK
to the previous gain you you were tuning.Example: to examine the effect of varying
Kp
starting from an initial value of 10, use the argumentsgain='P', Kp0=10
and try varying values ofdeltaK
. Suppose adeltaK
of 5 gives satisfactory performance. Then, to tune the derivative gain, add your selecteddeltaK
toKp0
in the next call using the argumentsgain='D', Kp0=15
, to see how adding different values ofdeltaK
to your derivative gain affects performance.To use with interactive plots, you will need to enable interactive mode if you are in a Jupyter Notebook, e.g. using
%matplotlib
. See Interactive Plots for more information. Click on a branch of the root locus plot to try different values ofdeltaK
. Each click updates plots and prints the correspondingdeltaK
. It may be helpful to zoom in using the magnifying glass on the plot to get more locations to click. Just make sure to deactivate magnification mode when you are done by clicking the magnifying glass. Otherwise you will not be able to be able to choose a gain on the root locus plot. When you are done,%matplotlib inline
returns to inline, non-interactive plotting.By default, all three PID terms are in the forward path C_f in the diagram shown below, that is,
C_f = Kp + Ki/s + Kd*s/(tau*s + 1).
------> C_ff ------ d | | | r | e V V u y ------->O---> C_f --->O--->O---> plant ---> ^- ^- | | | | | ----- C_b <-------| ---------------------------------
If
plant
is a discrete-time system, then the proportional, integral, and derivative terms are given instead by Kp, Ki*dt/2*(z+1)/(z-1), and Kd/dt*(z-1)/z, respectively.It is also possible to move the derivative term into the feedback path
C_b
usingderivative_in_feedback_path
= True. This may be desired to avoid that the plant is subject to an impulse function when the referencer
is a step input.C_b
is otherwise set to zero.If
plant
is a 2-input system, the disturbanced
is fed directly into its second input rather than being added tou
.- Parameters
- plant
LTI
(TransferFunction
orStateSpace
system) The dynamical system to be controlled.
- gainstring, optional
Which gain to vary by
deltaK
. Must be one of ‘P’, ‘I’, or ‘D’ (proportional, integral, or derivative).- signint, optional
The sign of deltaK gain perturbation.
- input_signalstring, optional
The input used for the step response; must be ‘r’ (reference) or ‘d’ (disturbance) (see figure above).
- Kp0, Ki0, Kd0float, optional
Initial values for proportional, integral, and derivative gains, respectively.
- deltaKfloat, optional
Perturbation value for gain specified by the
gain
keyword.- taufloat, optional
The time constant associated with the pole in the continuous-time derivative term. This is required to make the derivative transfer function proper.
- C_fffloat or
LTI
system, optional Feedforward controller. If
LTI
, must have timebase that is compatible with plant.- derivative_in_feedback_pathbool, optional
Whether to place the derivative term in feedback transfer function
C_b
instead of the forward transfer functionC_f
.- plotbool, optional
Whether to create Sisotool interactive plot.
- plant
- Returns
- closedloop
StateSpace
system The closed-loop system using initial gains.
- closedloop
Notes
When running using iPython or Jupyter, use
%matplotlib
to configure the session for interactive support.