Index: firmware/App/Controllers/AirPump.c =================================================================== diff -u -r28d0fee79edb31bd1813045997c747bbcd0c6af1 -rc8738ed391f9dab772b8ced446ee595d8075186f --- firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision 28d0fee79edb31bd1813045997c747bbcd0c6af1) +++ firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision c8738ed391f9dab772b8ced446ee595d8075186f) @@ -33,6 +33,7 @@ #define AIR_PUMP_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Air pump data publish interval. #define DATA_PUBLISH_COUNTER_START_COUNT 13 ///< Air pump data publish start counter. +#define AIR_PUMP_STALL_PERSISTENCE ( 150 / TASK_GENERAL_INTERVAL ) ///< Stall duration before alarm (150 ms) #pragma pack(push, 1) /// Payload record structure for air pump test set command message payload. @@ -46,6 +47,7 @@ // ********** private data ********** static AIR_PUMP_STATE_T currentAirPumpState; ///< Current air pump control state. +static U08 airPumpStallCounter; ///< Air pump stall counter. static U16 currentAirPumpRPM; ///< Current air pump RPM. static F32 currentAirPumpPowerLevel; ///< Current air pump power level setting in % duty cycle (0..100%). static U32 airPumpDataPublicationTimerCounter; ///< Air pump data broadcast timer counter. @@ -56,6 +58,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 ); /*********************************************************************//** @@ -75,6 +78,7 @@ currentAirPumpState = AIR_PUMP_STATE_INIT; currentAirPumpPowerLevel = AIR_PUMP_MOTOR_OFF; currentAirPumpRPM = 0; + airPumpStallCounter = 0; airPumpDataPublishInterval.data = AIR_PUMP_DATA_PUB_INTERVAL; airPumpDataPublishInterval.ovData = AIR_PUMP_DATA_PUB_INTERVAL; airPumpDataPublishInterval.ovInitData = AIR_PUMP_DATA_PUB_INTERVAL; @@ -169,6 +173,9 @@ break; } + // Check stall condition + checkAirPumpStallCondition(); + publishAirPumpData(); } @@ -227,6 +234,31 @@ /*********************************************************************//** * @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 ) ) + { + // we are commanding air pump to run but zero measured pump speed indicates it is not running + if ( ++airPumpStallCounter >= AIR_PUMP_STALL_PERSISTENCE ) + { + 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