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.
This commit is contained in:
Brett Beauregard 2011-12-18 08:28:52 -05:00
parent 98d2779e18
commit 20199df217
1 changed files with 1 additions and 1 deletions

View File

@ -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*/