FWIW there is a PID library for arduino http://playground.arduino.cc/Code/PIDLibrary