Index: firmware/App/Controllers/ConcentratePumps.c =================================================================== diff -u -r368ded18d302d93a7c47192f7360bfefa5acecd8 -r00b244580f01f3cbd1b7d2d5a14ee61675bf4642 --- firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision 368ded18d302d93a7c47192f7360bfefa5acecd8) +++ firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision 00b244580f01f3cbd1b7d2d5a14ee61675bf4642) @@ -40,7 +40,8 @@ #define CONCENTRATE_PUMP_SPEED_INCREMENT 2.0F ///< Speed increase (mL/min) when controlling concentrate pump to target step speed. #define CONCENTRATE_PUMP_MIN_SPEED 3.0F ///< Minimum speed for concentrate pump in mL per min. -#define CONCENTRATE_PUMP_SPD_OUT_OF_RANGE_TOL_WHEN_ON_PCT 0.02F ///< Concentrate pump speed out of range tolerance when on in percentage. +#define CONCENTRATE_PUMP_TX_SPD_OUT_OF_RANGE_TOL_PCT 0.02F ///< Concentrate pump treatment speed out of range tolerance when on in percentage. +#define CONCENTRATE_PUMP_CLEANING_SPD_OUT_OF_RANGE_TOL_PCT 0.05F ///< Concentrate pump cleaning mode speed out of range tolerance when on in percentage. #define CONCENTRATE_PUMP_SPD_OUT_OF_RANGE_TOL_WHEN_SLOW_MLPM 1.0F ///< Concentrate pump speed out of range tolerance when slow in mL/min. #define CONCENTRATE_PUMP_LOW_SPEED_THRESHOLD_MLPM 10.0F ///< Concentrate pump low speed threshold in mL/min. #define CONCENTRATE_PUMP_ZERO_FLOW_RATE 0xFFFF ///< Pulse width value when zero flow rate or pump is off. @@ -575,7 +576,6 @@ if ( pumpId < NUM_OF_CONCENTRATE_PUMPS ) { speed = getF32OverrideValue( &concentratePumps[ pumpId ].measuredPumpSpeed ); - speed = ( CONCENTRATE_PUMP_REVERSE_DIR == concentratePumps[ pumpId ].direction ? speed * -1.0F : speed ); } else { @@ -990,17 +990,26 @@ *************************************************************************/ static void monitorPumpSpeed( CONCENTRATE_PUMPS_T pumpId, ALARM_ID_T alarm ) { - F32 cpTargetSpeed = concentratePumps[ pumpId ].currentPumpSpeed; - F32 cpError = fabs( fabs( getMeasuredPumpSpeedMLPM( pumpId ) ) - cpTargetSpeed ); - BOOL isCpSpeedOut = FALSE; - F32 tolerance = CONCENTRATE_PUMP_SPD_OUT_OF_RANGE_TOL_WHEN_SLOW_MLPM; + // NOTE: make all the values absolute to cover both negative and positive target/measured speeds + F32 cpTargetSpeed = fabs( concentratePumps[ pumpId ].currentPumpSpeed ); + F32 cpMeasSpeed = fabs( getMeasuredPumpSpeedMLPM( pumpId ) ); + F32 cpError = fabs( cpMeasSpeed - cpTargetSpeed ); + BOOL isCpSpeedOut = FALSE; + F32 tolerance = CONCENTRATE_PUMP_SPD_OUT_OF_RANGE_TOL_WHEN_SLOW_MLPM; + DG_OP_MODE_T opMode = getCurrentOperationMode(); if ( cpTargetSpeed > CONCENTRATE_PUMP_LOW_SPEED_THRESHOLD_MLPM ) { // Check if the pump is not in the off state and if it is not and greater than the minimum threshold, divide the error // to target speed. If the pump is off the target speed is 0 so the speed check is done differently + // The speed tolerance is looser in heat disinfect and flush than the rest of the modes that the concentrate pump are running. cpError = cpError / cpTargetSpeed; - tolerance = CONCENTRATE_PUMP_SPD_OUT_OF_RANGE_TOL_WHEN_ON_PCT; + tolerance = CONCENTRATE_PUMP_TX_SPD_OUT_OF_RANGE_TOL_PCT; + + if ( ( DG_MODE_HEAT == opMode ) || ( DG_MODE_FLUS == opMode ) ) + { + tolerance = CONCENTRATE_PUMP_CLEANING_SPD_OUT_OF_RANGE_TOL_PCT; + } } isCpSpeedOut = ( cpError > tolerance ? TRUE : FALSE ); @@ -1145,9 +1154,13 @@ if ( ( pumpId < NUM_OF_CONCENTRATE_PUMPS ) && ( TRUE == isTestingActivated() ) ) { - result = TRUE; - concentratePumps[ pumpId ].measuredPumpSpeed.ovData = value; - concentratePumps[ pumpId ].measuredPumpSpeed.override = OVERRIDE_KEY; + if ( value >= 0.0F ) + { + // Only accept the positive values for override since the measured speed cannot be negative + result = TRUE; + concentratePumps[ pumpId ].measuredPumpSpeed.ovData = value; + concentratePumps[ pumpId ].measuredPumpSpeed.override = OVERRIDE_KEY; + } } return result;