Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -r0129388bed299f82b51af0230dd4e1fcb30e1bcf -re9f4774b8c6c4b5d064bca8076e084dd9b72da76 --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 0129388bed299f82b51af0230dd4e1fcb30e1bcf) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision e9f4774b8c6c4b5d064bca8076e084dd9b72da76) @@ -164,17 +164,16 @@ *************************************************************************/ void execLoadCell( void ) { - U32 ii; + LOAD_CELL_ID_T ii; + LOAD_CELL_ID_T alarmID; U32 a1 = getFPGALoadCellA1(); U32 a2 = getFPGALoadCellA2(); U32 b1 = getFPGALoadCellB1(); U32 b2 = getFPGALoadCellB2(); + F32 weight = 0.0F; + BOOL isLoadCellOutOfRange = FALSE; + F32 alarmLoadCell = 0.0F; - 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 ); @@ -213,7 +212,7 @@ } // Rolling average of last 100 raw samples in small filter - for ( ii = 0; ii < NUM_OF_LOAD_CELLS; ++ii ) + for ( ii = LOAD_CELL_RESERVOIR_1_PRIMARY; ii < NUM_OF_LOAD_CELLS; ++ii ) { F32 loadCell = (F32)loadcells[ ii ].rawReading * ADC2GRAM; @@ -230,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 = weight; + } loadcells[ ii ].loadCellVelocity_g_min = ( getLoadCellWeight( (LOAD_CELL_ID_T)ii ) - loadcells[ ii ].smallFilterReadings[ smallReadingsIdx ] ) * (F32)SEC_PER_MIN; @@ -248,14 +250,14 @@ // 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 ); // filter every 100ms if ( ++loadCellFilterTimerCount >= LOAD_CELL_REPORT_PERIOD ) { - for ( ii = 0; ii < NUM_OF_LOAD_CELLS; ++ii ) + for ( ii = LOAD_CELL_RESERVOIR_1_PRIMARY; ii < NUM_OF_LOAD_CELLS; ++ii ) { // Update large filter with new small filter weight sample loadcells[ ii ].largeFilterTotal -= loadcells[ ii ].largeFilterReadings[ largeReadingsIdx ];