Index: firmware/App/Controllers/AirPump.c =================================================================== diff -u -rc049177f4d18a4740a357941b48a833d7115b581 -r07904e71ea9190b7df8edde6c671149513bb72f2 --- firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision c049177f4d18a4740a357941b48a833d7115b581) +++ firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision 07904e71ea9190b7df8edde6c671149513bb72f2) @@ -16,7 +16,9 @@ ***************************************************************************/ #include "AirPump.h" +#include "AirTrap.h" #include "AlarmMgmtTD.h" +#include "GLXferPump.h" #include "Messaging.h" #include "OperationModes.h" #include "PersistentAlarm.h" @@ -32,6 +34,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. @@ -45,6 +48,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. @@ -55,6 +59,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 ); /*********************************************************************//** @@ -73,6 +78,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; @@ -167,6 +174,9 @@ break; } + // Check stall condition + checkAirPumpStallCondition(); + publishAirPumpData(); } @@ -225,6 +235,35 @@ /*********************************************************************//** * @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 ); + // Stop H12 air pump + setAirPumpState( AIR_PUMP_STATE_OFF, AIR_PUMP_MOTOR_OFF ); + // Stop air trap control + endAirTrapControl(); + } + } + 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 @@ -241,6 +280,8 @@ AIR_PUMP_PAYLOAD_T data; data.h12State = getAirPumpState(); + data.h12Power = (U32)currentAirPumpPowerLevel; + data.h12Rpm = (U32)currentAirPumpRPM; data.h12Power = currentAirPumpPowerLevel; data.h12Rpm = (U32)currentAirPumpRPM; //TODO:remove after validating pump speed