A c library for computing a PID
C Shell C++
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
tests
.gitignore
Makefile
README.mkd

README.mkd

PID

A simple c PID library for interfacing with arduinos. For further discussion on PID algorithms and control see wikipedia.

Usage

PID *pid;

void setup() {
  input = analogRead(0);
  pid = PID_create(
    analogRead(0), // current input
    100,           // setpoint (desired output)
    300,           // sample time in ms
    0,             // min output
    250            // max output
    2,             // Kp
    5,             // Ki
    1              // Kd
  )
}

void loop() {
  if (PID_should_compute(pid)) {
    analogWrite(3, PID_next(pid, analogRead(0)));
  }
}