Arduino PID Library by Brett Beauregard contact: email@example.com
The PID Library is available in the Arduino IDE Library Manager
PID Front-End using Processing.org
From Wikipedia: "A PID controller calculates an 'error' value as the difference between a measured [Input] and a desired setpoint. The controller attempts to minimize the error by adjusting [an Output]."
So, you tell the PID what to measure (the "Input",) Where you want that measurement to be (the "Setpoint",) and the variable to adjust that can make that happen (the "Output".) The PID then adjusts the output trying to make the input equal the setpoint.
For reference, in a car, the Input, Setpoint, and Output would be the speed, desired speed, and gas pedal angle respectively.
The black magic of PID comes in when we talk about HOW it adjusts the Output to drive the Input towards Setpoint. There are 3 Tuning Parameters (or "Tunings"): Kp, Ki & Kd. Adjusting these values will change the way the output is adjusted. Fast? Slow? God-awful? All of these can be achieved depending on the values of Kp, Ki, and Kd.
So what are the "right" tuning values to use? There isn't one right answer. The values that work for one application may not work for another, just as the driving style that works for a truck may not work for a race car. With each new application you will need to try Several Tuning values until you find a set that gives you what you want.
Note: there is also now a PID Autotune Library that can help you determine tuning parameters.
PID is a pretty impressive control algorithm, but it's not magic. You should at least be able to answer "yes" to these questions:
(This list will probably grow as I think of more criteria. These are the big ones though)
Even though a PID controller is designed to work with an analog output, it is possible to connect to a discrete output such as a relay. Be sure to look at the RelayOutput example below.
Try the newly created Google group.
Using The PID Library has two benefits in my mind