Index: firmware/App/Controllers/AirPump.c =================================================================== diff -u -r6e9a94b2ef0a617a1ee2321a42545a3f5526baeb -r80f6d7e9c3876b11cf751112025a81395e4db495 --- firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision 6e9a94b2ef0a617a1ee2321a42545a3f5526baeb) +++ firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision 80f6d7e9c3876b11cf751112025a81395e4db495) @@ -47,6 +47,7 @@ static AIR_PUMP_STATE_T currentAirPumpState; ///< Current air pump control state. static U08 currentAirPumpPowerLevel; ///< Current air pump power level setting. +static U08 airPumpStallCounter; ///< Air pump stall counter. static U16 currentAirPumpRPM; ///< Current air pump RPM. static U32 airPumpDataPublicationTimerCounter; ///< Air pump data broadcast timer counter. static OVERRIDE_U32_T airPumpDataPublishInterval; ///< Air pump data broadcast interval (in ms). @@ -56,6 +57,7 @@ static AIR_PUMP_STATE_T handleAirPumpStartState( void ); static AIR_PUMP_STATE_T handleAirPumpOffState( void ); static AIR_PUMP_STATE_T handleAirPumpOnState ( void ); +static void checkAirPumpStallCondition( void ); static void publishAirPumpData( void ); /*********************************************************************//** @@ -152,6 +154,9 @@ break; } + // Check stall condition + checkAirPumpStallCondition(); + publishAirPumpData(); } @@ -210,6 +215,34 @@ /*********************************************************************//** * @brief + * The checkAirPumpStallCondition function detects an air pump stall. + * @details \b Alarm: ALARM_ID_TD_AIR_PUMP_STALL when the air pump is + * commanded on and the measured RPM is zero for multiple controller cycles. + * @details \b Inputs: currentAirPumpPowerLevel, currentAirPumpRPM + * @details \b Outputs: airPumpStallCounter + * @return none + *************************************************************************/ +static void checkAirPumpStallCondition( void ) +{ + if ( ( currentAirPumpPowerLevel > 0 ) && ( currentAirPumpRPM == 0 ) ) + { + if ( airPumpStallCounter < 3 ) + { + airPumpStallCounter++; + } + if ( airPumpStallCounter >= 3 ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_AIR_PUMP_STALL, currentAirPumpPowerLevel, currentAirPumpRPM ); + } + } + else + { + airPumpStallCounter = 0; + } +} + +/*********************************************************************//** + * @brief * The publishAirPumpData function constructs and sends the air pump data * broadcast message. * @details \b Message \b Sent: MSG_ID_TD_AIR_PUMP_DATA