Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -r0c296cef29037819be204c45a23d4d38a52b2718 -re7aa2915e4a36b3622f0f75ed7ecd48796fc8649 --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 0c296cef29037819be204c45a23d4d38a52b2718) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision e7aa2915e4a36b3622f0f75ed7ecd48796fc8649) @@ -71,6 +71,8 @@ #define RO_PUMP_LOOKUP_TABLE_SIZE 4 ///< Size of array used as RO pump speed lookup table. #define CONCENTRATE_PUMP_PRIME_EXTRA_SPEED_ML_MIN 5.0F ///< Concentrate pump additional speed during priming in mL/min. #define CONCENTRATE_TEST_TIME_OUT_MS ( 30 * MS_PER_SECOND ) ///< Concentrate test time out period in ms. +#define DELAY_FMP_CHECK_START_BY_MS ( 10 * MS_PER_SECOND ) ///< Delay start of FMP check during dialysate deliver state by this amount of time (in ms). + // 2m long tubing to cap = 19.5 mL (acid line) + 7.92 mL/m * 2 m (tubing to cap) + 20.82 mL (straw) = 56.15 mL // Prime time in seconds = ( 56.15 mL / 48 mL/min ) x 60 second/min + 25 seconds margin time = 95 seconds. #define PRIME_CONCENTRATE_LINES_TIME_OUT_MS ( 95 * MS_PER_SECOND ) ///< Time required to prime the concentrate lines. @@ -114,6 +116,7 @@ static U32 concentratePumpPrimeCount; ///< Interval count for concentrate pump prime. static F32 integratedVolumeML; ///< Total RO flow rate over period of time. +static BOOL didFMPCheckStart; ///< Flag indicates whether FMP flow vs. LC volume check has begun. static F32 acidConductivityTotal; ///< Total of acid conductivity during fill. static F32 bicarbConductivityTotal; ///< Total of bicarb conductivity during fill. static U32 conductivitySampleCount; ///< Sample count of conductivity during fill. @@ -170,6 +173,7 @@ dataPublishCounter = DATA_PUBLISH_COUNTER_START_COUNT; reservoirBaseWeight = 0.0F; integratedVolumeML = 0.0F; + didFMPCheckStart = FALSE; concentrateTestStartTime = 0; acidConductivityTotal = 0.0F; bicarbConductivityTotal = 0.0F; @@ -707,8 +711,8 @@ { setValveState( VPO, VALVE_STATE_FILL_C_TO_NC ); - reservoirBaseWeight = getReservoirWeight( getInactiveReservoir() ); dialysateFillStartTime = getMSTimerCount(); + fillStatus.isThisFirstFill = FALSE; result = DG_FILL_MODE_STATE_DELIVER_DIALYSATE; } @@ -744,7 +748,17 @@ // Set concentrate pumps speed based on the RO pump flow rate handleDialysateMixing( getMeasuredFlowRateLPM( RO_FLOW_SENSOR ) * ML_PER_LITER, acidMix, bicarbMix ); - integratedVolumeML += getMeasuredROFlowRateWithConcPumpsLPM() * ML_PER_LITER * FLOW_INTEGRATOR; + // Delay start of FMP check, then begin integrating flow to a volume + if ( TRUE == didTimeout( dialysateFillStartTime, DELAY_FMP_CHECK_START_BY_MS ) ) + { + if ( FALSE == didFMPCheckStart ) + { // When FMP check starts, set baseline weight of reservoir we are filling + didFMPCheckStart = TRUE; + reservoirBaseWeight = getReservoirWeight( getInactiveReservoir() ); + } + integratedVolumeML += getMeasuredROFlowRateWithConcPumpsLPM() * ML_PER_LITER * FLOW_INTEGRATOR; + } + usedAcidVolumeML.data += getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP1_ACID ) * FLOW_INTEGRATOR; usedBicarbVolumeML.data += getMeasuredPumpSpeed( CONCENTRATEPUMPS_CP2_BICARB ) * FLOW_INTEGRATOR; acidConductivityTotal += acidConductivity;