wolfhece.pidcontroller

Module Contents

class wolfhece.pidcontroller.PIDController(kp, ki, kd)[source]

Tuning a PID controller – https://dewesoft.com/blog/what-is-pid-controller

Tuning the PID parameters Kp, Ki and Kd is crucial in PID controller design. Tuning must be customized for each of the many PID applications. Key tuning parameters include:

  • Proportional Gain (Kp): This parameter determines the proportion of the error signal contributing to the controller output. A higher Kp value results in a stronger response to the current error. Too high a Kp can lead to oscillations or instability, while too low a value can result in a sluggish response.

  • Integral Gain (Ki): The integral term considers the accumulation of past errors and amplifies them over time. It helps eliminate steady-state error by continuously adjusting the control signal. A higher Ki value helps reduce steady-state error but can lead to overshoot or instability if set too high.

  • Derivative Gain (Kd): The derivative term predicts the future behavior of the error based on its current rate of change. It helps dampen oscillations by counteracting rapid changes in the error signal. Increasing Kd enhances damping and reduces overshoot, but too high a value can lead to instability or sensitivity to noise.

The tuning process involves adjusting these parameters to achieve desired system performance, such as stability, responsiveness, and minimal overshoot. Several methods are used for PID tuning, including manual tuning, Ziegler-Nichols method, and optimization algorithms. Let’s take a closer look at each of these methods:

In manual tuning, the engineer adjusts the parameters based on their understanding of the system dynamics and the desired performance criteria. This method involves iteratively tweaking the parameters while observing the system’s response until satisfactory performance is achieved.

The Ziegler-Nichols Method provides a systematic approach to PID tuning based on step response experiments. The integral and derivative gains are set to zero and gradually increased until the system oscillates at a constant amplitude. The proportional gain and oscillation period are determined from the oscillation period and amplitude, which are then used to calculate suitable PID parameters. Several other tuning methods exist, including Cohen-Coon, Lambda, and Dead Time.

Optimization algorithms such as gradient descent, genetic algorithms, or particle swarm optimization automatically search for optimal PID parameters based on specified performance criteria and system models.

PID tuning is a critical step in control system design. It ensures that the controller effectively regulates the system while meeting performance requirements.

calculate(setpoint, feedback)[source]

Compute the PID response.

Parameters:
  • setpoint (float) – Objective value to achieve.

  • feedback (float) – Current measured value.

Returns:

PID control output.

Return type:

float

wolfhece.pidcontroller.pid_controller[source]