finds.dev← search

// the find

pms67/PID

★ 922 · C · MIT · updated Jul 2023

PID controller implementation written in C.

A minimal C implementation of a PID controller with derivative-on-measurement (avoids derivative kick on setpoint changes). It's a single .c/.h pair with no dependencies — useful as a drop-in for embedded systems or as a reference implementation.

Derivative-on-measurement is the right choice and the README explicitly explains the sign convention, which most toy PIDs skip. The implementation is small enough to audit in 10 minutes. Includes a test file. Ships a PDF explaining the math, which is genuinely useful for someone learning why the code is structured the way it is.

No anti-windup on the integral term — a hard omission for anything that will hit actuator limits. No output clamping built in. No support for variable sample rates; dt is baked into gains at init time, which breaks if your loop period drifts. Hasn't been touched since 2023 and has open issues, so don't expect upstream fixes.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →