Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r606c80dafe7c1de63b99d775e032a0cc28922a49 -r70d33c50c8c3fd987f39eaa1f3b294860d569830 --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 606c80dafe7c1de63b99d775e032a0cc28922a49) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 70d33c50c8c3fd987f39eaa1f3b294860d569830) @@ -730,10 +730,10 @@ // Calculate UF volumes and provide to dialysate outlet pump controller updateUFVolumes(); - // If we have reached target UF volume, UF is complete + // If we have reached target UF volume, UF is complete - set UF rate to zero for remainder of treatment if ( refUFVolume >= maxUFVolumeML ) { - result = UF_COMPLETED_STATE; + setUFRate = 0.0; } // Handle saline bolus start request from user else if ( TRUE == salineBolusStartRequested ) @@ -903,15 +903,12 @@ F32 bolusTargetVolume = (F32)getTreatmentParameterU32( TREATMENT_PARAM_SALINE_BOLUS_VOLUME ); F32 bldFlowRate = getMeasuredBloodFlowRate(); // TODO - should I use raw flow instead of filtered here??? F32 volSinceLastUpdateMl = bldFlowRate * timeSinceLastVolumeUpdateMin; - U32 bldPumpMotorCount = getBloodPumpMotorCount(); - U32 bldPumpMotorDelta = u32DiffWithWrap( bolusSalineLastMotorCount, bldPumpMotorCount ); // Update saline bolus volumes bolusSalineLastVolumeTimeStamp = getMSTimerCount(); bolusSalineVolumeDelivered += volSinceLastUpdateMl; totalSalineVolumeDelivered += volSinceLastUpdateMl; - bolusSalineMotorCount += bldPumpMotorDelta; - bolusSalineLastMotorCount = bldPumpMotorCount; + bolusSalineMotorCount = u32DiffWithWrap( bolusSalineLastMotorCount, getBloodPumpMotorCount() ) / BP_HALL_EDGE_COUNTS_PER_REV; bolusSalineVolumeDelivered_Safety = ( (F32)bolusSalineMotorCount * VOLUME_PER_BP_MOTOR_REV_ML ); // TODO - include upstream pressure compensation to this calc #ifndef DISABLE_SALINE_BOLUS_CHECKS