Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -rfbdff223ca110491c6f7776669fa46ac5fc56da4 -r12cb82342073207c23708afaa64b25f83f2cdfed --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision fbdff223ca110491c6f7776669fa46ac5fc56da4) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 12cb82342073207c23708afaa64b25f83f2cdfed) @@ -38,7 +38,8 @@ #define SIZE_OF_LARGE_LOAD_CELL_AVG 32 ///< Large load cell moving average has 32 samples. #define MAX_LOAD_CELL_CHANGE_G 70.0 ///< Maximum delta between new load cell sample and its small moving average (in g). -#define MAX_ACTIVE_LOAD_CELL_CHANGE_G 30.0 ///< Maximum delta between new load cell sample and its small moving average (in g) when associated reservoir is active in treatment. +#define MAX_ACTIVE_LOAD_CELL_CHANGE_G 30.0 ///< Maximum delta between new load cell sample and its small moving average (in g) when associated reservoir is active in treatment. +#define LOAD_CELL_CHANGE_PERSISTENCE 3 ///< Excessive load cell acceleration must persist for 3 samples (@ 10 Hz) to trigger alarm. /// States of the treatment reservoir management state machine. typedef enum TreatmentReservoirMgmt_States @@ -84,14 +85,16 @@ static F32 lgFilteredReservoirWeightInGrams[ NUM_OF_DG_RESERVOIRS ]; // load cell filtering data -/// holds load cell samples for small load cell moving average +/// Holds load cell samples for small load cell moving average. static F32 smLoadCellReadings[ NUM_OF_DG_RESERVOIRS ][ SIZE_OF_SMALL_LOAD_CELL_AVG ]; -static U32 smLoadCellReadingsIdx = 0; ///< index for next sample in small load cell rolling average sample array -static F32 smLoadCellReadingsTotal[ NUM_OF_DG_RESERVOIRS ]; ///< rolling total - used to calc small load cell moving average -/// holds load cell samples for large load cell moving average +static U32 smLoadCellReadingsIdx = 0; ///< Index for next sample in small load cell rolling average sample array. +static F32 smLoadCellReadingsTotal[ NUM_OF_DG_RESERVOIRS ]; ///< Rolling total - used to calc small load cell moving average. +/// Holds load cell samples for large load cell moving average. static F32 lgLoadCellReadings[ NUM_OF_DG_RESERVOIRS ][ SIZE_OF_LARGE_LOAD_CELL_AVG ]; -static U32 lgLoadCellReadingsIdx = 0; ///< index for next sample in large load cell rolling average sample array -static F32 lgLoadCellReadingsTotal[ NUM_OF_DG_RESERVOIRS ]; ///< rolling total - used to calc large load cell moving average +static U32 lgLoadCellReadingsIdx = 0; ///< Index for next sample in large load cell rolling average sample array. +static F32 lgLoadCellReadingsTotal[ NUM_OF_DG_RESERVOIRS ]; ///< Rolling total - used to calc large load cell moving average. +/// Persistence counters for excessive load cell acceleration alarm. +static U32 excessiveLoadCellAccelerationCtr[ NUM_OF_DG_RESERVOIRS ] = { 0, 0 }; // DG pumps data static F32 dgROPumpFlowRateMlMin = 0.0; ///< Latest RO water flow rate reported by the DG. @@ -686,11 +689,15 @@ // Trigger or clear excessive load cell acceleration condition if ( TRUE == deltaAlarmDetected ) { - SET_ALARM_WITH_2_F32_DATA( deltaAlarm, wt, smFilteredReservoirWeightInGrams[ res ] ); + if ( ++excessiveLoadCellAccelerationCtr[ res ] > LOAD_CELL_CHANGE_PERSISTENCE ) + { + SET_ALARM_WITH_2_F32_DATA( deltaAlarm, wt, smFilteredReservoirWeightInGrams[ res ] ); + } } else { - // clearAlarmCondition( deltaAlarm ); TODO - un-comment when merged with branch that has this function implemented. + excessiveLoadCellAccelerationCtr[ res ] = 0; + clearAlarmCondition( deltaAlarm ); } #endif smLoadCellReadingsTotal[ res ] -= smLoadCellReadings[ res ][ smLoadCellReadingsIdx ];