This is a simple PID controller library written in C++23. It doesn't have any external dependencies.
It implements "derivative on measurement" to prevent output spikes when the goal point changes.
It is assumed that it will be run on a microcontroller or some other device that can guarantee that the Update function can be called at the set period_time rate. Running a PID control system with irregular refresh rate will cause the PID to be unreliable and needs to stabilise again.
- C++23 compatible compiler (g++ recommended)
# Build the PID controller object file
make pid.o
# Build the heater example application
make heaterThe heater executable demonstrates the PID controller in action, simulating a temperature control system.
Run ./heater to run the simulation and generate output of the simulated heater and make plot_heater to see the visualisations.
This command executes both linear and nonlinear heater simulations, outputting heater.out and heater_nonlinear.out data files, then automatically generates visualizations using the Python plotting script.
matplotlib is used to plot the graphs and is required as a dependency for visualisation.