PID module

class pid.pid.PID(kp=1.0, ki=0.0, kd=0.0, set_pressure=0.5, thresholds=(-10, 10), throttle_limits=((30, 60), (40, 65), (50, 70)), output_limits=(None, None), auto_mode=True)[源代码]

基类:object

PID controller of Mixlinker

__call__(input_pressure, input_gear, input_angle)[源代码]

Call the PID controller with input_gear, input_pressure, input_angle and calculate and return a control output.

__init__(kp=1.0, ki=0.0, kd=0.0, set_pressure=0.5, thresholds=(-10, 10), throttle_limits=((30, 60), (40, 65), (50, 70)), output_limits=(None, None), auto_mode=True)[源代码]
参数:
  • kp -- The value for the proportional gain kp
  • ki -- The value for the integral gain ki
  • kd -- The value for the derivative gain kd
  • set_pressure -- The initial set_pressure that the PID will try to achieve
  • thresholds -- the output threshold to decide whether to change
  • throttle_limits -- the limits of throttle on every gear of burner
  • output_limits -- The initial output limits to use, given as an iterable with 2 elements, for example: (lower, upper). The output will never go below the lower limit or above the upper limit. Either of the limits can also be set to None to have no limit in that direction. Setting output limits also avoids integral windup, since the integral term will never be allowed to grow outside of the limits.
  • auto_mode -- Whether the controller should be enabled (in auto mode) or not (in manual mode)
auto_mode

Whether the controller is currently enabled (in auto mode) or not

components

The P-, I- and D-terms from the last computation as separate components as a tuple. Useful for visualizing what the controller is doing or when tuning hard-to-tune systems.

output_limits

The current output limits as a 2-tuple: (lower, upper). See also the output_limts parameter in PID.__init__().

set_auto_mode(enabled, input_pressure=None)[源代码]

Enable or disable the PID controller, optionally setting the last output value. This is useful if some system has been manually controlled and if the PID should take over. In that case, pass the last output variable (the control variable) and it will be set as the starting I-term when the PID is set to auto mode. :param enabled: Whether auto mode should be enabled, True or False :param input_pressure: The last output, or the control variable, that the PID should start from

when going from manual mode to auto mode
tunings

The tunings used by the controller as a tuple: (kp, ki, kd)