[][src]Crate pid_lite

A small PID controller library.

This crate implements the classic independent PID formulation.

Introduction

PID controllers are an integral part of control systems, and provide a way to perform error correction. It's used to control things like throughput or resource allocation: as the resource approaches capacity, the returned correction decreases. And because it is aware of a time factor, it can deal with rapid changes as well.

Loop Tuning

However PID controllers are not a silver bullet: they are a tool in a wider toolbox. To maximally benefit from them they need to be tuned to the workload. This is done through three parameters: proportional_gain, integral_gain and derivative_gain. Automated algorithms exist to tune these parameters based on sample workloads, but those are out of scope for this crate.

Read more on loop tuning.

Examples

use pid_lite::Controller;

let target = 80.0;
let mut controller = Controller::new(target, 0.25, 0.01, 0.01);

loop {
    let correction = controller.update(measure());
    apply_correction(correction);
    if correction == 0.0 { break }
}

Structs

Controller

PID controller