Chart of Mathematical Relationships in PID Tuning
| Component |
Mathematical Relationship |
Explanation |
| Error |
Error = Setpoint - Gyro (Measured Value) |
The difference between the desired position (Setpoint) and the actual position measured by the gyro. This error value is used as the basis for all PID calculations. |
| Proportional (P) |
P = kP * Error |
The P-term is directly proportional to the current error. It controls the immediate response of the system to minimize the error. The larger the kP, the stronger the corrective action. |
| Integral (I) |
I = I + kI * Error * dt |
The I-term accumulates over time (sum of errors) to address any systematic bias or drift. kI controls how fast the accumulated error is corrected. It smooths out small but persistent errors over time. |
| Derivative (D) |
D = kD * (dError / dt) |
The D-term is the rate of change of error over time. It predicts future error and helps to dampen the system to prevent oscillations. The higher the kD, the more the system is slowed to avoid overshoot. |
| PID Sum |
PID Sum = P + I + D |
The PID Sum is the total corrective signal sent to the actuators, calculated by adding the individual P, I, and D terms. This output adjusts motor speeds to correct the error. |
| Feed Forward (FF) |
FF = kFF * Setpoint |
Feed Forward applies a correction based directly on the Setpoint. This allows the system to anticipate the necessary response without waiting for an error to develop. |
| Control Output |
Output = PID Sum + FF |
The final Output to the motors or actuators is the sum of the PID terms and the Feed Forward. This dictates how much corrective action is taken at each moment. |
| Setpoint |
Setpoint = Desired System Value |
The Setpoint is the target value you want to maintain (e.g., target roll, pitch, or yaw angle). The controller works to keep the system at this value by adjusting the motor or servo output. |
| Gyro (Measured Value) |
Gyro = Measured System Value |
The Gyro provides feedback by measuring the current system state (e.g., the current roll or pitch angle). This measurement is continuously compared with the Setpoint to calculate the Error. |
| Rate of Change |
dError / dt |
The rate at which the error is changing over time. This is used in the D-term to predict future behavior and prevent overshoot. |
Example: PID Tuning Equation
For a single axis, say Roll:
Control Output = kP * Error + kI * (Integral of Error) + kD * (Rate of Error Change) + kFF * Setpoint
Description of Terms:
- Proportional (P): Responds to the current error. A high P value means quick reaction to errors but can lead to overshoot and oscillations.
- Integral (I): Corrects accumulated error over time. Helps to eliminate steady-state error but can lead to "wind-up" and overshoot if too aggressive.
- Derivative (D): Damps the system by looking at the rate of change of the error, providing smooth control and reducing overshoot. Too much D can cause slow response.
- Feed Forward (FF): Adjusts based on the Setpoint itself, giving the system an anticipatory action that makes the response more precise and quicker, especially for rapidly changing inputs.
- Setpoint: The desired target (like a specific roll, pitch, or yaw angle).
- Gyro (Measured Value): The actual sensor feedback (like the current roll, pitch, or yaw angle).
Visualization of Feedback Loop:
Setpoint (desired) → Error (difference between Setpoint and Gyro) → P, I, D → PID Sum → Control Output → Actuators → Correct Gyro (Measured Value).
|