Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -r44f739bf3e9dfe0bfb5910a6a32fc4c5b1533af3 -r56f14d709de1a3de6a3a450e994d59b7e434e638 --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 44f739bf3e9dfe0bfb5910a6a32fc4c5b1533af3) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 56f14d709de1a3de6a3a450e994d59b7e434e638) @@ -59,7 +59,7 @@ typedef struct { U32 rawReading; ///< Latest raw load cell reading. - F32 weight; ///< Latest load cell weight. + OVERRIDE_F32_T weight; ///< Latest load cell weight. F32 autoCalOffset; ///< Load cell auto-calibration offset. F32 loadCellVelocity_g_min; ///< Velocity (in g/min) of load cell. @@ -114,7 +114,10 @@ hasLoadCellBeenTared[ i ] = FALSE; loadcells[ i ].rawReading = 0; - loadcells[ i ].weight = 0.0F; + loadcells[ i ].weight.data = 0.0F; + loadcells[ i ].weight.ovData = 0.0F; + loadcells[ i ].weight.ovInitData = 0.0F; + loadcells[ i ].weight.override = OVERRIDE_RESET; loadcells[ i ].autoCalOffset = 0.0F; loadcells[ i ].largeFilterTotal = 0.0F; loadcells[ i ].largeFilteredWeight = 0.0F; @@ -198,11 +201,11 @@ // Apply the calibration factors to the data. // load_cell_weight = fourth_order_coeff * (load_cell^4) + third_order_coeff * (load_cell^3) + second_order_coeff * (load_cell^2) + gain * load_cell + offset - loadcells[ ii ].weight = pow( loadCell, 4 ) * loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].fourthOrderCoeff + - pow( loadCell, 3 ) * loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].thirdOrderCoeff + - pow( loadCell, 2 ) * loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].secondOrderCoeff + - loadCell * loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].gain + - loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].offset; + loadcells[ ii ].weight.data = pow( loadCell, 4 ) * loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].fourthOrderCoeff + + pow( loadCell, 3 ) * loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].thirdOrderCoeff + + pow( loadCell, 2 ) * loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].secondOrderCoeff + + loadCell * loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].gain + + loadCellsCalRecord.loadCells[ (CAL_DATA_DG_LOAD_CELLS_T)ii ].offset; loadcells[ ii ].loadCellVelocity_g_min = ( getLoadCellWeight( (LOAD_CELL_ID_T)ii ) - loadcells[ ii ].smallFilterReadings[ smallReadingsIdx ] ) * (F32)SEC_PER_MIN; @@ -378,7 +381,12 @@ if ( loadCellID < NUM_OF_LOAD_CELLS ) { - result = loadcells[ loadCellID ].weight; + result = loadcells[ loadCellID ].weight.data; + + if ( OVERRIDE_KEY == loadcells[ loadCellID ].weight.override ) + { + result = loadcells[ loadCellID ].weight.ovData; + } } else { @@ -518,15 +526,14 @@ ( loadCellBDrift > LOAD_CELL_PRIMARY_BACKUP_MAX_ALLOWED_DRIFT_GRAMS ) ) { isDriftOutOfRange = TRUE; - drift = ( loadCellADrift > LOAD_CELL_PRIMARY_BACKUP_MAX_ALLOWED_DRIFT_GRAMS ? loadCellADrift : loadCellBDrift ); } else { isDriftOutOfRange = FALSE; - // Pick the biggest drift in between the two load cells when none of the is above range - drift = ( loadCellADrift > loadCellBDrift ? loadCellADrift : loadCellBDrift ); } + // Pick the biggest drift to log w/ alarm if triggered + drift = ( loadCellADrift > loadCellBDrift ? loadCellADrift : loadCellBDrift ); checkPersistentAlarm( ALARM_ID_DG_LOAD_CELL_PRIMARY_BACKUP_DRIFT_OUT_OF_RANGE, isDriftOutOfRange, drift, LOAD_CELL_PRIMARY_BACKUP_MAX_ALLOWED_DRIFT_GRAMS ); } @@ -544,9 +551,11 @@ * @details Outputs: load cell filtered weight * @param loadCellID ID of the load cell to override * @param value override filtered load cell weight + * @param raw flag indicates whether override should apply to raw calibrated + * reading or filtered & tared reading * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetLoadCellOverride( U32 loadCellID, F32 value ) +BOOL testSetLoadCellOverride( U32 loadCellID, F32 value, BOOL raw ) { BOOL result = FALSE; @@ -555,9 +564,16 @@ if ( TRUE == isTestingActivated() ) { result = TRUE; - // Add tare to given value so reported load will be what is requested when tare is subtracted later - loadcells[ loadCellID ].smallFilteredWeight.ovData = value; - loadcells[ loadCellID ].smallFilteredWeight.override = OVERRIDE_KEY; + if ( TRUE == raw ) + { + loadcells[ loadCellID ].weight.ovData = value; + loadcells[ loadCellID ].weight.override = OVERRIDE_KEY; + } + else + { + loadcells[ loadCellID ].smallFilteredWeight.ovData = value; + loadcells[ loadCellID ].smallFilteredWeight.override = OVERRIDE_KEY; + } } } @@ -570,9 +586,11 @@ * @details Inputs: none * @details Outputs: load cell filtered weight * @param loadCellID ID of the load cell to override + * @param raw flag indicates whether override should apply to raw calibrated + * reading or filtered & tared reading * @return TRUE if reset successful, FALSE if not *************************************************************************/ -BOOL testResetLoadCellOverride( U32 loadCellID ) +BOOL testResetLoadCellOverride( U32 loadCellID, BOOL raw ) { BOOL result = FALSE; @@ -581,8 +599,16 @@ if ( TRUE == isTestingActivated() ) { result = TRUE; - loadcells[ loadCellID ].smallFilteredWeight.override = OVERRIDE_RESET; - loadcells[ loadCellID ].smallFilteredWeight.ovData = loadcells[ loadCellID ].smallFilteredWeight.ovInitData; + if ( TRUE == raw ) + { + loadcells[ loadCellID ].weight.override = OVERRIDE_RESET; + loadcells[ loadCellID ].weight.ovData = loadcells[ loadCellID ].smallFilteredWeight.ovInitData; + } + else + { + loadcells[ loadCellID ].smallFilteredWeight.override = OVERRIDE_RESET; + loadcells[ loadCellID ].smallFilteredWeight.ovData = loadcells[ loadCellID ].smallFilteredWeight.ovInitData; + } } }