Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -rb1dc3df084a8517ca1575bdbf741fecd96d56a12 -ra3e3feea8cfb6a1e0137bf09031f0484a3c73332 --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision b1dc3df084a8517ca1575bdbf741fecd96d56a12) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision a3e3feea8cfb6a1e0137bf09031f0484a3c73332) @@ -54,15 +54,15 @@ #define CONDUCTIVITY_ERROR_PERSISTENCE_PERIOD_MS ( 5 * MS_PER_SECOND ) ///< Persistence period for conductivity error. -/// Multiplier to conver flow (mL/min) into volume (mL) for period of general task interval. +/// Multiplier to convert flow (L/min) into volume (mL) for period of general task interval. static const F32 RO_FLOW_INTEGRATOR = ( ( ML_PER_LITER * TASK_GENERAL_INTERVAL ) / ( SEC_PER_MIN * MS_PER_SECOND ) ); // ********** private data ********** static DG_FILL_MODE_STATE_T fillState; ///< Currently active fill state. static U32 dialysateFillStartTime; ///< Current time when starting to fill dialysate. static F32 reservoirBaseWeight; ///< Fill reservoir base weight. -static F32 totalROFlowRate; ///< Total RO flow rate over period of time. +static F32 totalROFlowRate_LPM; ///< Total RO flow rate over period of time. static U32 concentrateTestStartTime; ///< Starting time for concentrate test. // ********** private function prototypes ********** @@ -89,7 +89,7 @@ fillState = DG_FILL_MODE_STATE_START; dialysateFillStartTime = 0; reservoirBaseWeight = 0.0; - totalROFlowRate = 0.0; + totalROFlowRate_LPM = 0.0; concentrateTestStartTime = 0; initPersistentAlarm( ALARM_ID_ACID_CONDUCTIVITY_OUT_OF_RANGE, CONDUCTIVITY_ERROR_PERSISTENCE_PERIOD_MS, CONDUCTIVITY_ERROR_PERSISTENCE_PERIOD_MS ); @@ -356,7 +356,7 @@ { DG_FILL_MODE_STATE_T result = DG_FILL_MODE_STATE_DELIVER_DIALYSATE; DG_RESERVOIR_ID_T inactiveReservoir = getInactiveReservoir(); - totalROFlowRate += getMeasuredROFlowRate(); + totalROFlowRate_LPM += getMeasuredROFlowRate(); handleDialysateMixing(); @@ -372,13 +372,13 @@ // if we've reached our target fill to volume (by weight), we're done filling - go back to re-circ mode if ( hasTargetFillVolumeBeenReached( inactiveReservoir ) ) { - F32 const filledWeight = getReservoirWeight( inactiveReservoir ) - reservoirBaseWeight; - F32 const integratedVolume = totalROFlowRate * RO_FLOW_INTEGRATOR * ACID_BICARB_CONCENTRATE_ADDITION_MULTIPLER; - F32 const integratedVolumeToLoadCellReadingPercent = 1 - ( filledWeight / integratedVolume ); + F32 const filledVolume_mL = getReservoirWeight( inactiveReservoir ) - reservoirBaseWeight; + F32 const integratedVolume_mL = totalROFlowRate_LPM * RO_FLOW_INTEGRATOR * ACID_BICARB_CONCENTRATE_ADDITION_MULTIPLER; + F32 const integratedVolumeToLoadCellReadingPercent = fabs( 1 - ( filledVolume_mL / integratedVolume_mL ) ); if ( integratedVolumeToLoadCellReadingPercent > FLOW_INTEGRATED_VOLUME_CHECK_TOLERANCE ) { - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_FLOW_METER_CHECK_FAILURE, filledWeight, integratedVolume ); + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_FLOW_METER_CHECK_FAILURE, filledVolume_mL, integratedVolume_mL ); } requestNewOperationMode( DG_MODE_CIRC );