Index: firmware/App/Controllers/DrainPump.c =================================================================== diff -u -r6a1cc50b6b021fd416783d76df53cbfcfdb44a1b -r1abaeb395cb7ffb2cb0ea9c1ba65c353d9c416f8 --- firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 6a1cc50b6b021fd416783d76df53cbfcfdb44a1b) +++ firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 1abaeb395cb7ffb2cb0ea9c1ba65c353d9c416f8) @@ -70,7 +70,7 @@ #define SET_DRAIN_PUMP_ENABLE() {mibspiREG3->PC3 |= DRAIN_PUMP_ENABLE_SPI3_PORT_MASK;} ///< Drain pump enable set macro. #define CLR_DRAIN_PUMP_ENABLE() {mibspiREG3->PC3 &= ~DRAIN_PUMP_ENABLE_SPI3_PORT_MASK;} ///< Drain pump enable clear macro. -#define SAFETY_SHUTDOWN_TIMEOUT_COUNT ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Drain pump safety shutdown activation timeout in counts. +#define SAFETY_SHUTDOWN_TIMEOUT MS_PER_SECOND ///< Drain pump safety shutdown activation timeout. /// Enumeration of drain pump states. typedef enum DrainPump_States @@ -108,7 +108,6 @@ static U32 drainControlTimerCounter = 0; ///< Determines when to perform control on drain pump. static BOOL hasClosedLoopBeenRequested = FALSE; ///< Closed loop pump control flag. static U32 currentDrainPumpRPM = 0; ///< Current drain pump RPM from feedback. -static U32 safetyShutdownTimeoutCounter = 0; ///< Timeout counter to activate safety shutdown. /* TODO These variables are used for POST. POST will be implemented later static DRAIN_PUMP_SELF_TEST_STATE_T drainPumpSelfTestState = DRAIN_PUMP_SELF_TEST_STATE_START; ///< Current drain pump self test state. @@ -131,15 +130,14 @@ * @brief * The initDrainPump function initializes the DrainPump module. * @details Inputs: none - * @details Outputs: hasClosedLoopBeenRequested, safetyShutdownTimeoutCounter + * @details Outputs: hasClosedLoopBeenRequested * @return none *************************************************************************/ void initDrainPump( void ) { stopDrainPump(); hasClosedLoopBeenRequested = FALSE; - safetyShutdownTimeoutCounter = 0; // Initialize the drain pump PI controller initializePIController( PI_CONTROLLER_ID_DRAIN_PUMP, DRAIN_PUMP_MIN_DAC, @@ -149,6 +147,10 @@ // Initialize the persistent alarm for open loop RPM out of range initPersistentAlarm( PERSISTENT_ALARM_DRAIN_PUMP_RPM_OUT_OF_RANGE, ALARM_ID_DRAIN_PUMP_RPM_OUT_OF_RANGE, TRUE, OPEN_LOOP_RPM_OUT_OF_RANGE_TIME_OUT, OPEN_LOOP_RPM_OUT_OF_RANGE_TIME_OUT ); + + // Initialize the persistent alarm for RPM not to be less than the min RPM when the pump is off + initPersistentAlarm( PERSISTENT_ALARM_DRAIN_PUMP_OFF_ERROR, ALARM_ID_DRAIN_PUMP_OFF_FAULT, TRUE, + SAFETY_SHUTDOWN_TIMEOUT, SAFETY_SHUTDOWN_TIMEOUT ); } /*********************************************************************//** @@ -243,8 +245,8 @@ * The execDrainPumpMonitor function executes the drain pump monitor. * RPM = ( 1 / ADC ) * conversion coefficient. * ADC = ( 1 / RPM ) * conversion coefficient. - * @details Inputs: currentDrainPumpRPM, safetyShutdownTimeoutCounter - * @details Outputs: currentDrainPumpRPM, safetyShutdownTimeoutCounter + * @details Inputs: currentDrainPumpRPM + * @details Outputs: currentDrainPumpRPM * @return none *************************************************************************/ void execDrainPumpMonitor( void ) @@ -267,13 +269,16 @@ } // Check if the pump is in off state and the RPM is greater than the minimum RPM - if ( ( drainPumpState == DRAIN_PUMP_OFF_STATE ) && ( currentDrainPumpRPM > MIN_DRAIN_PUMP_RPM ) ) + if ( drainPumpState == DRAIN_PUMP_OFF_STATE ) { - // Check if the RPM is not 0 for more that the specified time and if it is, activate the safety shutdown - if ( ++safetyShutdownTimeoutCounter > SAFETY_SHUTDOWN_TIMEOUT_COUNT ) + BOOL isRPMTooHigh = currentDrainPumpRPM > MIN_DRAIN_PUMP_RPM; + + checkPersistentAlarm( PERSISTENT_ALARM_DRAIN_PUMP_OFF_ERROR, isRPMTooHigh, currentDrainPumpRPM, MIN_DRAIN_PUMP_RPM ); + + // If the off fault alarm has become active, trigger the safety shutdown + if ( isAlarmActive( ALARM_ID_DRAIN_PUMP_OFF_FAULT ) ) { activateSafetyShutdown(); - safetyShutdownTimeoutCounter = 0; } }