Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -r5109bb981cab2025fcb9de33e303d046085efa18 -rb909022e776df298f2fdad4f944afae29ad2d396 --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 5109bb981cab2025fcb9de33e303d046085efa18) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision b909022e776df298f2fdad4f944afae29ad2d396) @@ -99,6 +99,7 @@ U32 controlIntervalCounter; ///< Heater control interval counter. BOOL isThisFirstControl; ///< Heater is this first control interval. BOOL useLastDutyCycle; ///< Heater has use previous duty cycle been requested flag. + F32 prevDiaTargetFlowLPM; ///< Heater previous target dialysate flow in L/min. } HEATER_STATUS_T; static HEATER_STATUS_T heatersStatus[ NUM_OF_DG_HEATERS ]; ///< Heaters status. @@ -156,6 +157,7 @@ heatersStatus[ heater ].controlIntervalCounter = 0; heatersStatus[ heater ].isThisFirstControl = TRUE; heatersStatus[ heater ].useLastDutyCycle = FALSE; + heatersStatus[ heater ].prevDiaTargetFlowLPM = 0.0F; } // Initialize the persistent alarms @@ -717,12 +719,14 @@ HEATERS_STATE_T state = HEATER_EXEC_STATE_TRIMMER_CONTROL_TO_TARGET; F32 tempDutyCycle = 0.0F; DG_HEATERS_T heater = DG_TRIMMER_HEATER; + F32 targetFlowLPM = getTargetDialysateFlowLPM(); U32 controlInterval = ( TRUE == heatersStatus[ heater ].isThisFirstControl ? TRIMMER_HEATER_INITIAL_CONTROL_INTERVAL_COUNT : TRIMMER_HEATER_CONTROL_INTERVAL_COUNT ); - // If the inactive reservoir has changed from the last run transition to ramp state to recalculate the + // If the inactive reservoir has changed from the last run or the target dialysate flow has changed, transition to ramp state to recalculate the // duty cycle for the next delivery - if ( heatersStatus[ heater ].inactiveRsrvr != getInactiveReservoir() ) + if ( ( heatersStatus[ heater ].inactiveRsrvr != getInactiveReservoir() ) || + ( fabs( heatersStatus[ heater ].prevDiaTargetFlowLPM - targetFlowLPM ) > NEARLY_ZERO ) ) { state = HEATER_EXEC_STATE_TRIMMER_RAMP_TO_TARGET; } @@ -736,7 +740,6 @@ // dialysate inlet temperature sensor is used rather than the theoretical calculations. F32 dialysateInletTemperature = getTemperatureValue( TEMPSENSORS_OUTLET_REDUNDANT ); F32 targetTemperature = heatersStatus[ heater ].targetTempC; - F32 targetFlowLPM = getTargetDialysateFlowLPM(); F32 dutyCycle = calculateTrimmerHeaterDutyCycle( targetTemperature, dialysateInletTemperature, targetFlowLPM, TRUE ); tempDutyCycle = heatersStatus[ heater ].dutyCycle.data + dutyCycle; @@ -746,6 +749,8 @@ setHeaterDutyCycle( heater ); } + heatersStatus[ heater ].prevDiaTargetFlowLPM = targetFlowLPM; + return state; }