control.rootlocus_pid_designer(plant, gain='P', sign=1, input_signal='r', Kp0=0, Ki0=0, Kd0=0, tau=0.01, C_ff=0, derivative_in_feedback_path=False, plot=True)

Manual PID controller design based on root locus using Sisotool

Uses Sisotool to investigate the effect of adding or subtracting an amount deltaK to the proportional, integral, or derivative (PID) gains of a controller. One of the PID gains, Kp, Ki, or Kd, respectively, can be modified at a time. Sisotool plots the step response, frequency response, and root locus.

When first run, deltaK is set to 0; click on a branch of the root locus plot to try a different value. Each click updates plots and prints the corresponding deltaK. To tune all three PID gains, repeatedly call rootlocus_pid_designer, and select a different gain each time (‘P’, ‘I’, or ‘D’). Make sure to add the resulting deltaK to your chosen initial gain on the next iteration.

Example: to examine the effect of varying Kp starting from an intial value of 10, use the arguments gain=’P’, Kp0=10. Suppose a deltaK value of 5 gives satisfactory performance. Then on the next iteration, to tune the derivative gain, use the arguments gain=’D’, Kp0=15.

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).

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.

——> C_ff —— d | | |

r | e V V u y ——->O—> C_f —>O—>O—> plant —>

^- ^- | | | | | —– C_b <——-| ———————————

It is also possible to move the derivative term into the feedback path C_b using derivative_in_feedback_path=True. This may be desired to avoid that the plant is subject to an impulse function when the reference r is a step input. C_b is otherwise set to zero.

If plant is a 2-input system, the disturbance d is fed directly into its second input rather than being added to u.

Remark: It may be helpful to zoom in using the magnifying glass on the plot. Just ake 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.

  • plant (LTI (TransferFunction or StateSpace system)) – The dynamical system to be controlled

  • gain (string (optional)) – Which gain to vary by deltaK. Must be one of ‘P’, ‘I’, or ‘D’ (proportional, integral, or derative)

  • sign (int (optional)) – The sign of deltaK gain perturbation

  • input (string (optional)) – The input used for the step response; must be ‘r’ (reference) or ‘d’ (disturbance) (see figure above)

  • Kp0 (float (optional)) – Initial values for proportional, integral, and derivative gains, respectively

  • Ki0 (float (optional)) – Initial values for proportional, integral, and derivative gains, respectively

  • Kd0 (float (optional)) – Initial values for proportional, integral, and derivative gains, respectively

  • tau (float (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_ff (float or LTI system (optional)) – Feedforward controller. If LTI, must have timebase that is compatible with plant.

  • derivative_in_feedback_path (bool (optional)) – Whether to place the derivative term in feedback transfer function C_b instead of the forward transfer function C_f.

  • plot (bool (optional)) – Whether to create Sisotool interactive plot.


closedloop – The closed-loop system using initial gains.

Return type

class:StateSpace system