Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -re12eefac42a3806a34f3ddac6df30bbb5ca51f6f -r1644c24b0b51661ceaba579e5ebee0d1d5bad85f --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision e12eefac42a3806a34f3ddac6df30bbb5ca51f6f) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 1644c24b0b51661ceaba579e5ebee0d1d5bad85f) @@ -373,10 +373,18 @@ heatersStatus[ heater ].heaterOnState = FALSE; control[ heater ].data = HEATERS_MIN_DUTY_CYCLE; heatersStatus[ heater ].state = HEATER_EXEC_STATE_OFF; - heatersStatus[ D5_HEAT ].controlIntervalCounter = D5_HEAT_CONTROL_INTERVAL_START_COUNT; - heatersStatus[ D45_HEAT ].controlIntervalCounter = 0; startupHeaterControl = TRUE; + //Update control interval counter + if ( D5_HEAT == heater ) + { + heatersStatus[ D5_HEAT ].controlIntervalCounter = D5_HEAT_CONTROL_INTERVAL_START_COUNT; + } + else + { + heatersStatus[ D45_HEAT ].controlIntervalCounter = 0; + } + // update duty cycle setHeaterControl( heater ); } @@ -608,7 +616,7 @@ F32 measuredTemperature = 0.0F; F32 ctrl = 0.0F; - if( ++heatersStatus[ heater ].controlIntervalCounter > controlInterval[ heater ] ) + if ( ++heatersStatus[ heater ].controlIntervalCounter >= controlInterval[ heater ] ) { if ( D5_HEAT == heater ) { @@ -619,9 +627,9 @@ if ( TRUE == startupHeaterControl ) { startupHeaterControl = FALSE; + F32 deltaTempC = targetTemperature - inletTemperature; //TODO : testing - //F32 deltaTempC = targetTemperature - inletTemperature; - F32 deltaTempC = 10.0F; // Hard code for testing, later remove it. + //F32 deltaTempC = 10.0F; // Hard code for testing, later remove it. F32 capDeltaTempC = MAX( deltaTempC, HEATERS_ZERO_DELTA_TEMP_C ); F32 flowrate = getTDDialysateFlowrate() / LITER_IN_ML ; F32 feedforward = calculateDutyCycle( flowrate, capDeltaTempC, PRIMARY_HEATER_MAX_PWR_WATTS, AC_HEATER_EFFICIENCY,