I completed my testing and PI tuning last night, I added anti-windup protection for the Integral term (only allowing I to accumulate within the proportional band) so the step response is pretty good, both when the system is powered up in an above set point state and under.
Final variance is now 0.108C measured and I cant get better than that when the ADC resolution is only 0.080924ºC per ADC value.
The whole PI loop is pretty simple, using integer math due to the low res ADC range.
Code:
//Read the ADC
ADCSRA.4 = TRUE;
uiNTC = ADCW;
//Calculate the error
iError = uiNTC;
iError-= SETPOINT;
//Only permit integral accumulation within the proportional band
if ((iPV > MIN_PV) && (iPV < MAX_PV))
{
//Update the integral value
iAccumError+= iError;
//Avoid integral wind-up beyond PV range
if (iAccumError / I_TUNE > MAX_PV) iAccumError = MAX_PV * I_TUNE;
if (iAccumError / I_TUNE < -MAX_PV) iAccumError = -MAX_PV * I_TUNE;
}
// PI calculation
iPV = iError + (iAccumError / I_TUNE);
//Range limit the Process Value
if (iPV > MAX_PV) iPV = MAX_PV;
if (iPV < MIN_PV) iPV = MIN_PV;
//PWM = Process Value
uiPWM = iPV;
The PWM is handled in a timer interrupt service routine.
The Derivative term (PID) does appear to be necessary, although I can add it once people have tested using smaller TEC's and blocks if needed.
I think it's ready for others to try. PM me if your interested. Frank - do you want me to ship you some boards now?