From 20199df2172880ae5a6009011e484e707dd708ee Mon Sep 17 00:00:00 2001 From: Brett Beauregard Date: Sun, 18 Dec 2011 08:28:52 -0500 Subject: [PATCH] in the Compute() function, timeChange is now declared as "unsigned long" formerly, if left in manual mode for a long time (e.g. during an autotune,) the "int" timeChange would wrap causeing the PID not to calculate for an unacceptable period of time. --- PID_v1/PID_v1.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PID_v1/PID_v1.cpp b/PID_v1/PID_v1.cpp index fa67494..a5a76ae 100644 --- a/PID_v1/PID_v1.cpp +++ b/PID_v1/PID_v1.cpp @@ -46,7 +46,7 @@ void PID::Compute() { if(!inAuto) return; unsigned long now = millis(); - int timeChange = (now - lastTime); + unsigned long timeChange = (now - lastTime); if(timeChange>=SampleTime) { /*Compute all the working error variables*/