# Pid Block

The **PID** block emits the output of a Proportional-Integral-Derivative feedback controller.

PID controllers are a simple and intuitive way to perform closed-loop feedback control. Generally speaking, the input signal is some error you wish to minimize, and the output signal controls some affector of the input signal. An example would be controlling an aircraft rudder to minimize yaw rate.

The output of the PID controller is the simple the sum of three terms: The Proportional (P), the Integral (I), and the Derivative (I), which each have their own gain to tune.

## Parameters

**Kp**(default = 1.0): Proportional gain to apply directly to the input signal**Ki**(default = 0.0): Gain to apply to the*integral*of the input signal. See Integral Block for more information on how integration is computed.**Kd**(default = 0.0): Gain to apply to the*derivative*of the input signal. See Derivative Block for more information on how derivatives are computed.**Kd_samples**(default = 3): Number of prior samples to use to compute the derivative over. More samples tends to smooth the derivative, but also introduces phase lag.**I_max**(default = 1e100): Maximum value the Integral term can attain. By default effectively set to infinity. Setting a lower value can help prevent integral windup.

## Example

PD Controller with Kp = 10, Kd = 0.5, attempting to control an imaginary actuator modeled simply as an integrator with lag. |