Index: firmware/App/Controllers/AirPump.c =================================================================== diff -u -r395522dffef1348e176564925656012f529c1910 -r9d4aa5ab195ebacbfc6c569b89d841f89bfdc42c --- firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision 395522dffef1348e176564925656012f529c1910) +++ firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision 9d4aa5ab195ebacbfc6c569b89d841f89bfdc42c) @@ -17,6 +17,7 @@ #include "AirPump.h" #include "AlarmMgmtTD.h" +#include "GLXferPump.h" #include "Messaging.h" #include "OperationModes.h" #include "PersistentAlarm.h" @@ -32,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 +48,8 @@ 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). @@ -54,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 ); /*********************************************************************//** @@ -72,6 +77,8 @@ airPumpDataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; 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; @@ -128,6 +135,8 @@ *************************************************************************/ void execAirPumpController( void ) { + currentAirPumpRPM = getAirPumpMotorRPM(); + switch( currentAirPumpState ) { case AIR_PUMP_STATE_INIT: @@ -147,6 +156,9 @@ break; } + // Check stall condition + checkAirPumpStallCondition(); + publishAirPumpData(); } @@ -205,6 +217,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 @@ -222,6 +259,7 @@ data.h12State = getAirPumpState(); data.h12Power = (U32)currentAirPumpPowerLevel; + data.h12Rpm = (U32)currentAirPumpRPM; broadcastData( MSG_ID_TD_AIR_PUMP_DATA, COMM_BUFFER_OUT_CAN_TD_BROADCAST, (U08*)&data, sizeof( AIR_PUMP_PAYLOAD_T ) ); airPumpDataPublicationTimerCounter = 0;