Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -ra5723df5741ceaf13cd6cf9cab50a55bfea15501 -ra5e4e578efe1af6c82530e73d58b09b2b7ad625c --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision a5723df5741ceaf13cd6cf9cab50a55bfea15501) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision a5e4e578efe1af6c82530e73d58b09b2b7ad625c) @@ -329,20 +329,19 @@ if ( TRUE == heaterCmdPtr->startHeater ) { -#ifndef DISABLE_TRIMMER_HEATER - if ( ( MINIMUM_TARGET_TEMPERATURE <= heaterCmdPtr->targetTemp ) && ( heaterCmdPtr->targetTemp <= MAXIMUM_TARGET_TEMPERATURE ) ) + if ( ( heaterCmdPtr->targetTemp >= MINIMUM_TARGET_TEMPERATURE ) && ( heaterCmdPtr->targetTemp <= MAXIMUM_TARGET_TEMPERATURE ) ) { cmdResponse.rejected = FALSE; + + heatersStatus[ DG_TRIMMER_HEATER ].targetTemp = heaterCmdPtr->targetTemp; // TODo do we need to remove this since the trimmer heater is set in the reservoirs #ifndef DISABLE_HEATERS_AND_TEMPS - heatersStatus[ DG_TRIMMER_HEATER ].targetTemp = heaterCmdPtr->targetTemp; heatersStatus[ DG_TRIMMER_HEATER ].startHeaterSignal = TRUE; #endif } else { cmdResponse.rejectCode = DG_CMD_REQUEST_REJECT_REASON_INVALID_PARAMETER; } -#endif } else { @@ -624,12 +623,11 @@ HEATERS_STATE_T state = HEATER_EXEC_STATE_TRIMMER_CONTROL_TO_TARGET; DG_HEATERS_T heater = DG_TRIMMER_HEATER; - //if ( TRUE == haveHeaterControlConditionsChanged( heater ) ) // TODO do we need this kind of check from trimmer?? + if ( TRUE == haveHeaterControlConditionsChanged( heater ) ) // TODO do we need this kind of check from trimmer?? { - //state = HEATER_EXEC_STATE_TRIMMER_RAMP_TO_TARGET; + state = HEATER_EXEC_STATE_TRIMMER_RAMP_TO_TARGET; } - return state; } @@ -675,23 +673,24 @@ /*if ( TRUE == checkEfficiency ) { - F32 lastFillTemperature = getLastFillTemperature(); + F32 lastFillTemperature = getLastFillTemperature(); + F32 trimmerTargetTemperature = heatersStatus[ DG_TRIMMER_HEATER ].targetTemp; // If the last fill temperature > target temperature, it means the primary heater overshot the duty cycle // so with its efficiency is toned down for the next fill cycle - // If the heater undershoots the duty cycle, the efficiency increases the duty cycle for the next fill cycle - if ( lastFillTemperature - targetTemperature > MAXIMUM_ALLOWED_TARGET_TEMPERATURE_DEVIATION_C ) + // If the heater under-shoots the duty cycle, the efficiency increases the duty cycle for the next fill cycle + if ( lastFillTemperature - trimmerTargetTemperature > MAXIMUM_ALLOWED_TARGET_TEMPERATURE_DEVIATION_C ) { - heaterEfficiency -= ( lastFillTemperature - targetTemperature ) * PRIMARY_HEATER_DUTY_CYCLE_PER_TEMPERATURE_C; + heaterEfficiency -= ( lastFillTemperature - trimmerTargetTemperature ) * PRIMARY_HEATER_DUTY_CYCLE_PER_TEMPERATURE_C; } - else if ( lastFillTemperature - targetTemperature <= MAXIMUM_ALLOWED_TARGET_TEMPERATURE_DEVIATION_C ) + else if ( lastFillTemperature - trimmerTargetTemperature <= MAXIMUM_ALLOWED_TARGET_TEMPERATURE_DEVIATION_C ) { - heaterEfficiency += ( lastFillTemperature - targetTemperature ) * PRIMARY_HEATER_DUTY_CYCLE_PER_TEMPERATURE_C; + heaterEfficiency += ( lastFillTemperature - trimmerTargetTemperature ) * PRIMARY_HEATER_DUTY_CYCLE_PER_TEMPERATURE_C; } // Update the heaters efficiency heatersStatus[ DG_PRIMARY_HEATER ].heaterEfficiency = heaterEfficiency; - }*/ // TODO bring this part back + }*/ // Duty cycle = ( 69.73 * flow rate * deltaT / primary heater maximum power ) ^ 1/2 // Multiply the duty cycle to the heater efficiency @@ -718,7 +717,7 @@ * efficiency * @return calculated duty cycle *************************************************************************/ -static F32 calculateTrimmerHeaterDutyCycle( F32 targetTemperature, F32 currentTemperature, F32 flow, BOOL checkEfficiency ) +static F32 calculateTrimmerHeaterDutyCycle( F32 targetTemperature, F32 currentTemperature, F32 flow, BOOL checkEfficiency ) { // Get the primary heater's efficiency and the last fill temperature from the ModeFill F32 heaterEfficiency = heatersStatus[ DG_TRIMMER_HEATER ].heaterEfficiency; @@ -727,7 +726,7 @@ if ( TRUE == checkEfficiency ) { - // TODO add the trimmer efficiency + // TODO Do we need to recalculate the efficiency? } dutyCycle = flow * WATER_SPECIFIC_HEAT_DIVIDED_BY_MINUTES * ( targetTemperature - currentTemperature ) * heaterEfficiency; @@ -752,7 +751,7 @@ static BOOL haveHeaterControlConditionsChanged( DG_HEATERS_T heater ) { BOOL status = FALSE; - F32 targetFlow = getTargetROPumpFlowRate(); + F32 targetFlow = ( DG_PRIMARY_HEATER == heater ? getTargetROPumpFlowRate() : getTargetDialysateFlowLPM() ); BOOL hasFlowChanged = ( fabs( targetFlow - heatersStatus[ heater ].targetROFlow ) > NEARLY_ZERO ? TRUE : FALSE ); // Check if the target flow has changed or the target temperature has changed.