Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -rae41ed6848314b972f2f21521ef817e844c16342 -r5e88efbadfacd95cbf2c3620a9520fe4f9b6fd46 --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision ae41ed6848314b972f2f21521ef817e844c16342) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 5e88efbadfacd95cbf2c3620a9520fe4f9b6fd46) @@ -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; @@ -209,11 +212,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; @@ -390,7 +393,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 { @@ -555,9 +563,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; @@ -566,9 +576,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; + } } } @@ -581,9 +598,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; @@ -592,8 +611,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; + } } } Index: firmware/App/Controllers/LoadCell.h =================================================================== diff -u -r2e21405574597474db0ebae86cdd7fa2d517f71c -r5e88efbadfacd95cbf2c3620a9520fe4f9b6fd46 --- firmware/App/Controllers/LoadCell.h (.../LoadCell.h) (revision 2e21405574597474db0ebae86cdd7fa2d517f71c) +++ firmware/App/Controllers/LoadCell.h (.../LoadCell.h) (revision 5e88efbadfacd95cbf2c3620a9520fe4f9b6fd46) @@ -44,8 +44,8 @@ F32 getLoadCellLargeFilteredWeight( LOAD_CELL_ID_T loadCellID ); F32 getLoadCellVelocity( LOAD_CELL_ID_T loadCellID ); -BOOL testSetLoadCellOverride( U32 loadCellID, F32 value ); -BOOL testResetLoadCellOverride( U32 loadCellID ); +BOOL testSetLoadCellOverride( U32 loadCellID, F32 value, BOOL raw ); +BOOL testResetLoadCellOverride( U32 loadCellID, BOOL raw ); BOOL testSetLoadCellDataPublishIntervalOverride( U32 value ); BOOL testResetLoadCellDataPublishIntervalOverride( void ); Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r2e21405574597474db0ebae86cdd7fa2d517f71c -r5e88efbadfacd95cbf2c3620a9520fe4f9b6fd46 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 2e21405574597474db0ebae86cdd7fa2d517f71c) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 5e88efbadfacd95cbf2c3620a9520fe4f9b6fd46) @@ -1656,20 +1656,26 @@ *************************************************************************/ void handleTestLoadCellOverrideRequest( MESSAGE_T *message ) { - TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + typedef struct + { + TEST_OVERRIDE_ARRAY_PAYLOAD_T ovRecord; + BOOL flag; + } LC_OVERRIDE_PAYLOAD_T; + + LC_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; // verify payload length - if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + if ( sizeof( LC_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); - if ( FALSE == payload.reset ) + memcpy( &payload, message->payload, sizeof( LC_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.ovRecord.reset ) { - result = testSetLoadCellOverride( payload.index, payload.state.f32 ); + result = testSetLoadCellOverride( payload.ovRecord.index, payload.ovRecord.state.f32, payload.flag ); } else { - result = testResetLoadCellOverride( payload.index ); + result = testResetLoadCellOverride( payload.ovRecord.index, payload.flag ); } }