Hai,
Iam using Code Warrior Development studio V.10.6, and controller MC9s08DZ128.
Here is the bit of code we want to investgate.
if(count > (rpm_setpoint-4) && count <(rpm_setpoint+4))//fine tune PID constants when setpoint reached
{
PID=PID_Compute(0.5,0.2,0.01,1,-5,5);//kp, ki, kd, dt(time intervell) , outmin, outmax
}
else
{
PID=PID_Compute(1,0.5,0.25,1,-20,20);//kp,ki,kd,dt,outmin,outmax
}
//////////////////////////////////////////////////
count -- it is the feedback value .here it is generator RPM input
rpm_setpoint --- set point
PID_Compute---- PID function
PID---- it is the output
outmin,outmax -- Iterm minimum and max value.
In the first loop , PID value is small and in the second loop PID value is high compared to first.
So if there is a large error the second loop will run and faster the adjustments.