Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -r35c07199fda6ba28c7ee417105a16ea3d14a2ad6 -r48ea28a08999dcf46985b20ea635fa504f569e57 --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 35c07199fda6ba28c7ee417105a16ea3d14a2ad6) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 48ea28a08999dcf46985b20ea635fa504f569e57) @@ -155,6 +155,7 @@ void execLoadCell( void ) { U32 ii; + U32 a1 = getFPGALoadCellA1(); U32 a2 = getFPGALoadCellA2(); U32 b1 = getFPGALoadCellB1(); @@ -176,11 +177,13 @@ SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_LOAD_CELL_ADC_ERROR, ( a1 | a2 | b1 | b2 ) ) } + // TODO use ALARM_ID_DG_LOAD_CELL_FPGA_READ_ERROR for read error + // Check if a new calibration is available if ( TRUE == isNewCalibrationRecordAvailable() ) { getNVRecord2Driver( GET_CAL_LOAD_CELL_SENSORS, (U08*)&loadCellsCalRecord, sizeof( DG_LOAD_CELLS_CAL_RECORD_T ), - NUM_OF_CAL_DATA_LOAD_CELLS, ALARM_ID_DG_LOAD_CELLS_INVALID_CALIBRATION ); + NUM_OF_CAL_DATA_LOAD_CELLS, ALARM_ID_DG_LOAD_CELLS_INVALID_CAL_RECORD ); // Zero the current tare values when new calibration data is available loadcells[ LOAD_CELL_RESERVOIR_1_PRIMARY ].autoCalOffset = 0.0; @@ -272,7 +275,7 @@ SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; BOOL calStatus = getNVRecord2Driver( GET_CAL_LOAD_CELL_SENSORS, (U08*)&loadCellsCalRecord, sizeof( DG_LOAD_CELLS_CAL_RECORD_T ), - NUM_OF_CAL_DATA_LOAD_CELLS, ALARM_ID_DG_LOAD_CELLS_INVALID_CALIBRATION ); + NUM_OF_CAL_DATA_LOAD_CELLS, ALARM_ID_DG_LOAD_CELLS_INVALID_CAL_RECORD ); if ( TRUE == calStatus ) { @@ -301,16 +304,16 @@ F32 weight = getLoadCellSmallFilteredWeight( loadCellID ); // Check if the load cell is being tared for the first time - if ( fabs(loadcells[ loadCellID ].autoCalOffset ) < NEARLY_ZERO ) + if ( fabs( loadcells[ loadCellID ].autoCalOffset ) < NEARLY_ZERO ) { // For the first tare, the weight of the reservoir should be considered // The current weight of the load cell should not be greater than the weight of the reservoir + the extra weight - F32 deltaWeight = fabs( weight - EMPTY_RESERVOIR_WEIGHT_GRAMS ); + F32 deltaWeight = fabs( weight - EMPTY_RESERVOIR_WEIGHT_GRAMS ); isWeightOutOfRange = ( deltaWeight > MAX_ALLOWED_EXTRA_WEIGHT_BEFORE_FIRST_TARE_GRAMS ? TRUE : FALSE ); } else { - isWeightOutOfRange = ( fabs(weight) > MAX_ALLOWED_EXTRA_WEIGHT_BEFORE_TARE_GRAMS ? TRUE : FALSE ); + isWeightOutOfRange = ( fabs( weight ) > MAX_ALLOWED_EXTRA_WEIGHT_BEFORE_TARE_GRAMS ? TRUE : FALSE ); } if ( FALSE == isWeightOutOfRange )