notes/Resources/mathematics/Proportional Integral Derivative.md

30 lines
1.7 KiB
Markdown
Raw Normal View History

2023-05-09 12:35:31 +02:00
# Proportional-Integral-Derivative
PID `(Proportional-Integral-Derivative)` is a type of control algorithm commonly used in engineering and industrial applications to regulate a system's output based on its error or deviation from a desired setpoint value. The PID controller works by continuously measuring the system's output and comparing it to the setpoint value. It then uses a combination of proportional, integral, and derivative terms to adjust the system's input in order to minimize the error and bring the system closer to the desired setpoint.
The proportional term provides a direct relationship between the system's error and the controller's output. The integral term integrates the system's error over time to provide a corrective input that accounts for long-term changes. The derivative term provides a rate of change measurement to account for the system's responsiveness to changes.
Together, these three terms allow the PID controller to respond quickly to changes in the system's output while also providing stability and minimizing overshoot. PID controllers are commonly used in a variety of applications, such as temperature control in industrial processes, motion control in robotics, and speed control in motors.
![](introduction-to-pid-damped-controller.webp)
An example algorithm could look like
```typescript
function PIDController(Kp: number, Ki: number, Kd: number, setpoint: number, dt: number) {
let error = 0;
let integral = 0;
let derivative = 0;
let lastError = 0;
return function update(input: number) {
error = setpoint - input;
integral += error * dt;
derivative = (error - lastError) / dt;
lastError = error;
return Kp * error + Ki * integral + Kd * derivative;
};
}
```