Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -r7d0fd5ed6b9db0479af90477e5108f6d3fa8df17 -r8019022033c6d69a0748a11a1482de211aabf229 --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 7d0fd5ed6b9db0479af90477e5108f6d3fa8df17) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 8019022033c6d69a0748a11a1482de211aabf229) @@ -208,11 +208,16 @@ 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_CAL_RECORD ); - // Set the current tare values when the values are received from the cal record - loadcells[ LOAD_CELL_RESERVOIR_1_PRIMARY ].autoCalOffset = reservoirsCalRecord.reservoir[ CAL_DATA_RSRVR_1 ].rsrvrUnfilledWeight; - loadcells[ LOAD_CELL_RESERVOIR_1_BACKUP ].autoCalOffset = reservoirsCalRecord.reservoir[ CAL_DATA_RSRVR_1 ].rsrvrUnfilledWeight; - loadcells[ LOAD_CELL_RESERVOIR_2_PRIMARY ].autoCalOffset = reservoirsCalRecord.reservoir[ CAL_DATA_RSRVR_2 ].rsrvrUnfilledWeight; - loadcells[ LOAD_CELL_RESERVOIR_2_BACKUP ].autoCalOffset = reservoirsCalRecord.reservoir[ CAL_DATA_RSRVR_2 ].rsrvrUnfilledWeight; + if ( getCurrentOperationMode() != DG_MODE_SERV ) + { + // In the service mode once the calibration values are set, the NV data management sends the signal to all the drivers and therefore the + // the offset values are set to what is in the calibration records. This is not wanted in the service mode + // Set the current tare values when the values are received from the cal record + loadcells[ LOAD_CELL_RESERVOIR_1_PRIMARY ].autoCalOffset = reservoirsCalRecord.reservoir[ CAL_DATA_RSRVR_1 ].rsrvrUnfilledWeight; + loadcells[ LOAD_CELL_RESERVOIR_1_BACKUP ].autoCalOffset = reservoirsCalRecord.reservoir[ CAL_DATA_RSRVR_1 ].rsrvrUnfilledWeight; + loadcells[ LOAD_CELL_RESERVOIR_2_PRIMARY ].autoCalOffset = reservoirsCalRecord.reservoir[ CAL_DATA_RSRVR_2 ].rsrvrUnfilledWeight; + loadcells[ LOAD_CELL_RESERVOIR_2_BACKUP ].autoCalOffset = reservoirsCalRecord.reservoir[ CAL_DATA_RSRVR_2 ].rsrvrUnfilledWeight; + } } // Rolling average of last 100 raw samples in small filter @@ -362,6 +367,18 @@ BOOL isWeightOutOfRange = FALSE; F32 weight = getLoadCellSmallFilteredWeight( loadCellID ); + if ( ( DG_MODE_SERV == getCurrentOperationMode() ) && ( loadcells[ loadCellID ].autoCalOffset <= NEARLY_ZERO ) ) + { + // In service mode, some of the tests are done when the auto call offset is needed and some when is not needed. + // Once the tare command is issued, an auto cal value other than 0 is needed otherwise the tare will fail since the weight is at least 1700 grams + // which is the weight of the empty reservoirs. So for that matter, if the reservoirs have not been tared in the service mode meaning + // that the auto cal offset is zero, use the default values from the cal records. + CAL_DATA_DG_RESERVOIRS_T rsrvr = ( ( LOAD_CELL_RESERVOIR_1_PRIMARY == loadCellID ) || ( LOAD_CELL_RESERVOIR_1_BACKUP == loadCellID ) ? + CAL_DATA_RSRVR_1 : CAL_DATA_RSRVR_2 ); + + weight -= reservoirsCalRecord.reservoir[ rsrvr ].rsrvrUnfilledWeight; + } + // Check if the load cell is being tared for the first time if ( hasLoadCellBeenTared[ loadCellID ] != TRUE ) {