Index: firmware/App/Controllers/DrainPump.c =================================================================== diff -u -ra2c32d4d221603054ca9ad7a097112caebf08c4e -r6f1f269cd7d91f41c51797d17a85a7ea249e21f3 --- firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision a2c32d4d221603054ca9ad7a097112caebf08c4e) +++ firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 6f1f269cd7d91f41c51797d17a85a7ea249e21f3) @@ -297,7 +297,8 @@ targetDrainPumpRPM = 0; drainPumpState = DRAIN_PUMP_OFF_STATE; hasClosedLoopBeenRequested = FALSE; - drainPumpControlMode = NUM_OF_PUMP_CONTROL_MODES; // Set the control mode to none + drainPumpControlMode = PUMP_CONTROL_MODE_NONE; + drainPumpControlModeSet = drainPumpControlMode; drainControlTimerCounter = 0; } @@ -328,12 +329,13 @@ // The RPM is only checked in open loop state that the pump is run at a fixed RPM. // The persistent alarm waits for a couple of seconds before raising an alarm, this is supposed to cover // when the pump is turned on and it takes a while to ramp up to target RPM. - if( PUMP_CONTROL_MODE_OPEN_LOOP == drainPumpControlModeSet ) + if ( PUMP_CONTROL_MODE_OPEN_LOOP == drainPumpControlModeSet ) { - U32 targetRPM = getTargetDrainPumpRPM(); + // Using abs since the read RPM can be above or below the target + U32 rpmDiff = abs( getTargetDrainPumpRPM() - currentDrainPumpRPM ); - // Check if RPM is out of range. Using fabs since the read RPM can be above or below the target. - BOOL isRPMOutOfRange = fabs( targetRPM - currentDrainPumpRPM ) > MAX_ALLOWED_OPEN_LOOP_RPM_OUT_OF_RANGE; + // Check if RPM is out of range + BOOL isRPMOutOfRange = ( rpmDiff > MAX_ALLOWED_OPEN_LOOP_RPM_OUT_OF_RANGE ? TRUE : FALSE ); checkPersistentAlarm( ALARM_ID_DRAIN_PUMP_RPM_OUT_OF_RANGE, isRPMOutOfRange, currentDrainPumpRPM, MAX_ALLOWED_OPEN_LOOP_RPM_OUT_OF_RANGE ); }