Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -r61fc45d7a43557312d6abd00a6b01e6823b44f04 -rf86e5a345112e2f5079cd26447c9c18bb0aadd9b --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 61fc45d7a43557312d6abd00a6b01e6823b44f04) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision f86e5a345112e2f5079cd26447c9c18bb0aadd9b) @@ -89,7 +89,6 @@ // ********** private function prototypes ********** -static void monitorLoadCellsWeightOutOfRange( LOAD_CELL_ID_T loadCell ); static void monitorLoadCellsPrimaryBackupDriftOutOfRange( void ); /*********************************************************************//** @@ -169,6 +168,11 @@ U32 b1 = getFPGALoadCellB1(); U32 b2 = getFPGALoadCellB2(); + BOOL isLoadCellOutOfRange = FALSE; + BOOL isCurrentLoadCellOut = FALSE; + U08 loadCellOutID = 0; + F32 weight = 0.0F; + // Check error bits from new readings U32 a1Err = ( a1 >> SHIFT_BITS_BY_31 ); U32 a2Err = ( a2 >> SHIFT_BITS_BY_31 ); @@ -220,7 +224,13 @@ loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].offset; // Monitor the load cells weight - monitorLoadCellsWeightOutOfRange( (LOAD_CELL_ID_T)ii ); + // Since there is a single alarm value for all 4 load cells the persistence check must be + // executed if ANY of the load cell values are out of range. Only when all of the load + // cells are in range should the persistence for the alarm be cleared. + weight = getLoadCellWeight( ( LOAD_CELL_ID_T) ii ); + isCurrentLoadCellOut = ( ( weight < LOAD_CELL_MIN_ALLOWED_WEIGHT_GRAMS ) || ( weight > LOAD_CELL_MAX_ALLOWED_WEIGHT_GRAMS ) ? TRUE : FALSE ); + isLoadCellOutOfRange |= isCurrentLoadCellOut; + loadCellOutID = ( TRUE == isCurrentLoadCellOut ? ii : loadCellOutID ); loadcells[ ii ].loadCellVelocity_g_min = ( getLoadCellWeight( (LOAD_CELL_ID_T)ii ) - loadcells[ ii ].smallFilterReadings[ smallReadingsIdx ] ) * (F32)SEC_PER_MIN; @@ -236,6 +246,7 @@ // Apply the tare offset. NOTE: tare must be applied after checking the weight out of range. loadcells[ ii ].smallFilteredWeight.data -= loadcells[ ii ].autoCalOffset; } + checkPersistentAlarm( ALARM_ID_DG_LOAD_CELL_WEIGHT_OUT_OF_RANGE, isLoadCellOutOfRange, loadCellOutID, weight ); smallReadingsIdx = INC_WRAP( smallReadingsIdx, 0, SIZE_OF_SMALL_LOAD_CELL_AVG - 1 ); @@ -490,25 +501,6 @@ /*********************************************************************//** * @brief - * The monitorLoadCellsWeightOutOfRange function monitors the weight of the - * load cells and if they are not in range, it raises an alarm. - * Function must be called prior to applying tare so that un-tared weight - * is checked for out of range. - * @details Inputs: none - * @details Outputs: none - * @param loadCell which is the load cell ID that its range is checked - * @return none - *************************************************************************/ -static void monitorLoadCellsWeightOutOfRange( LOAD_CELL_ID_T loadCell ) -{ - F32 weight = getLoadCellWeight( loadCell ); - BOOL isWeightOutOfRange = ( ( weight < LOAD_CELL_MIN_ALLOWED_WEIGHT_GRAMS ) || ( weight > LOAD_CELL_MAX_ALLOWED_WEIGHT_GRAMS ) ? TRUE : FALSE ); - - checkPersistentAlarm( ALARM_ID_DG_LOAD_CELL_WEIGHT_OUT_OF_RANGE, isWeightOutOfRange, weight, LOAD_CELL_MAX_ALLOWED_WEIGHT_GRAMS ); -} - -/*********************************************************************//** - * @brief * The monitorLoadCellsPrimaryBackupDriftOutOfRange function monitors the * load cells' primary and backup drift. * @details Inputs: none