Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -r6499ea25921fcf67826fa0c35bb03caf411ba542 -r44459c11d7f3d39967b3eb6ec284403358d6a287 --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 6499ea25921fcf67826fa0c35bb03caf411ba542) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 44459c11d7f3d39967b3eb6ec284403358d6a287) @@ -162,17 +162,18 @@ *************************************************************************/ void execLoadCell( void ) { - U32 ii; + U08 ii; U32 a1 = getFPGALoadCellA1(); U32 a2 = getFPGALoadCellA2(); U32 b1 = getFPGALoadCellB1(); U32 b2 = getFPGALoadCellB2(); - BOOL isLoadCellOutOfRange = FALSE; - BOOL isCurrentLoadCellOut = FALSE; - U08 loadCellOutID = 0; - F32 weight = 0.0F; + F32 weight = 0.0F; + BOOL isLoadCellOutOfRange = FALSE; + U08 alarmID = 0; + F32 alarmLoadCell = 0.0F; + // Check error bits from new readings U32 a1Err = ( a1 >> SHIFT_BITS_BY_31 ); U32 a2Err = ( a2 >> SHIFT_BITS_BY_31 ); @@ -228,9 +229,12 @@ // 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 ); + if ( ( weight < LOAD_CELL_MIN_ALLOWED_WEIGHT_GRAMS ) || ( weight > LOAD_CELL_MAX_ALLOWED_WEIGHT_GRAMS ) ) + { + isLoadCellOutOfRange = TRUE; + alarmID = ii; + alarmLoadCell = loadCell; + } loadcells[ ii ].loadCellVelocity_g_min = ( getLoadCellWeight( (LOAD_CELL_ID_T)ii ) - loadcells[ ii ].smallFilterReadings[ smallReadingsIdx ] ) * (F32)SEC_PER_MIN; @@ -246,7 +250,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 ); + checkPersistentAlarm( ALARM_ID_DG_LOAD_CELL_WEIGHT_OUT_OF_RANGE, isLoadCellOutOfRange, alarmID, alarmLoadCell ); smallReadingsIdx = INC_WRAP( smallReadingsIdx, 0, SIZE_OF_SMALL_LOAD_CELL_AVG - 1 );