Index: firmware/App/Controllers/AirPump.c =================================================================== diff -u -r1b83a4555c4040a45cecfbea45b6570812ab281e -rd67d55445b427a78349d4456abb8a6a574535b36 --- firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision 1b83a4555c4040a45cecfbea45b6570812ab281e) +++ firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision d67d55445b427a78349d4456abb8a6a574535b36) @@ -35,6 +35,8 @@ #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) +#define AIR_PUMP_STALL_START_DELAY_MS 200 ///< Delay before evaluating stall condition +#define AIR_PUMP_STALL_START_DELAY_COUNT ( AIR_PUMP_STALL_START_DELAY_MS / TASK_GENERAL_INTERVAL ) ///< Air pump stall delay count interval #pragma pack(push, 1) /// Payload record structure for air pump test set command message payload. @@ -49,6 +51,7 @@ static AIR_PUMP_STATE_T currentAirPumpState; ///< Current air pump control state. static U08 airPumpStallCounter; ///< Air pump stall counter +static U08 airPumpStartDelayCounter; ///< Delay before evaluating air pump stall condition 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. @@ -80,6 +83,7 @@ currentAirPumpPowerLevel = AIR_PUMP_MOTOR_OFF; currentAirPumpRPM = 0; airPumpStallCounter = 0; + airPumpStartDelayCounter = 0; airPumpDataPublishInterval.data = AIR_PUMP_DATA_PUB_INTERVAL; airPumpDataPublishInterval.ovData = AIR_PUMP_DATA_PUB_INTERVAL; airPumpDataPublishInterval.ovInitData = AIR_PUMP_DATA_PUB_INTERVAL; @@ -243,22 +247,40 @@ *************************************************************************/ 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 ); - // Stop H12 air pump - setAirPumpState( AIR_PUMP_STATE_OFF, AIR_PUMP_MOTOR_OFF ); - // Stop air trap control - endAirTrapControl(); - } - } - else - { - airPumpStallCounter = 0; - } + if ( ( AIR_PUMP_STATE_ON == currentAirPumpState ) && ( currentAirPumpPowerLevel > 0 ) ) + { + // Allow RPM time to populate before evaluating stall condition + if ( airPumpStartDelayCounter < AIR_PUMP_STALL_START_DELAY_COUNT ) + { + airPumpStartDelayCounter++; + airPumpStallCounter = 0; + } + else if ( currentAirPumpRPM == 0 ) + { + // Air pump commanded on but RPM remains zero + if ( ++airPumpStallCounter >= AIR_PUMP_STALL_PERSISTENCE ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_AIR_PUMP_STALL, currentAirPumpPowerLevel, currentAirPumpRPM ); + // Stop H12 air pump + setAirPumpState( AIR_PUMP_STATE_OFF, AIR_PUMP_MOTOR_OFF ); + // Stop air trap control + endAirTrapControl(); + } + } + else + { + // RPM detected, clear stall counter + airPumpStallCounter = 0; + // Delay no longer needed while pump is running + airPumpStartDelayCounter = AIR_PUMP_STALL_START_DELAY_COUNT; + } + } + else + { + // Pump is off, reset counters + airPumpStartDelayCounter = 0; + airPumpStallCounter = 0; + } } /*********************************************************************//**