Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -rf3ecaf3a7bc6d07225791f43196c468ff05ad016 -red2a4cf95e008d002016dd40d7bb79efc135ad36 --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision f3ecaf3a7bc6d07225791f43196c468ff05ad016) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision ed2a4cf95e008d002016dd40d7bb79efc135ad36) @@ -1059,8 +1059,9 @@ // Always keep the UF volume the same and change the UF rate upon changing the treatment time presMaxUFVolumeML = getTreatmentParameterF32( TREATMENT_PARAM_UF_VOLUME ) * (F32)ML_PER_LITER; + F32 newUFDiffML = ( ( presMaxUFVolumeML - getTotalMeasuredUFVolumeInMl() ) < 0.0F ? 0.0F : ( presMaxUFVolumeML - getTotalMeasuredUFVolumeInMl() ) ); // New UF rate is how much UF is left to be done / remaining treatment time - F32 newUFRateMLPM = ( presMaxUFVolumeML - getTotalMeasuredUFVolumeInMl() ) / (F32)( treatmentTime - CALC_ELAPSED_TREAT_TIME_IN_MIN() ); + F32 newUFRateMLPM = ( newUFDiffML ) / (F32)( treatmentTime - CALC_ELAPSED_TREAT_TIME_IN_MIN() ); U32 dialVolume = getTreatmentParameterU32( TREATMENT_PARAM_DIALYSATE_FLOW ) * treatmentTime; // In mL // The minimum treatment time is either in the range of the institutional record or the 1-minute treatment config has been requested which is an exception