simple_pid library

Classes

PID
A simple PID controller. No fuss. Directly ported from python: https://github.com/m-lundberg/simple-pid Kp is the value for the proportional gain. Ki is the value for the integral gain. Kd is the value for the derivative gain. setPoint is the initial setpoint that the PID will try to achieve. sampleTime is the time in seconds which the controller should wait before generating a new output value. The PID works best when it is constantly called (eg. during a loop), but with the sampleTime set so that the time difference between each update is (close to) constant. If not set it will default to 0.01 seconds. minOutput is minimum output to use. maxOutput is the maximum output limit to use. If neither limit is set it defaults to a very large and very small number. These limits also avoid integral windup, since the integral term will never be allowed to grow outside of the limits. autoMode is whether the controller should be enabled (in auto mode) or not (in manual mode). proportionalOnMeasurement is whether the proportional term should be calculated on the input directly rather than on the error (which is the traditional way). Using proportional-on-measurement avoids overshoot for some types of systems.

Functions

clamp(double value, double min, double max) double