Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -r69a0d10f21ce28bec3b07ae275fb74b2f4dd5140 -r078bf48235ba345c57559e412438846f4d5ac9b3 --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 69a0d10f21ce28bec3b07ae275fb74b2f4dd5140) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 078bf48235ba345c57559e412438846f4d5ac9b3) @@ -49,7 +49,6 @@ #define LOAD_CELL_MIN_ALLOWED_WEIGHT_BEFORE_TARE_GRAMS 1600.0F ///< Load cell minimum allowed weight before tare in grams. #define LOAD_CELL_WEIGHT_OUT_RANGE_PERSISTENT_PERIOD_MS (5 * MS_PER_SECOND) ///< Load cell weight out of range persistent period in milliseconds. #define LOAD_CELL_PRIMARY_BACKUP_MAX_DRIFT_PERSISTENT_PERIOD_MS (5 * MS_PER_SECOND) ///< Load cell primary and backup maximum allowed weight drift persistent period in milliseconds. -#define EMPTY_RESERVOIR_WEIGHT_GRAMS 1700.0F ///< Reservoirs empty weight in grams. #define MAX_ALLOWED_EXTRA_WEIGHT_BEFORE_FIRST_TARE_GRAMS 300.0F ///< Max allowed extra weight before first tare in grams. #define HEAT_ACTIVE_COOL_MAX_ALLOWED_EXTRA_WEIGHT_TARE_GRAMS 200.0F ///< Heat disinfect active cool max allowed weight before tare in grams. #define MAX_ALLOWED_EXTRA_WEIGHT_BEFORE_TARE_GRAMS 60.0F ///< Max allowed extra weight before tare in grams. @@ -88,7 +87,8 @@ static U32 smallReadingsIdx; ///< Index for next sample in load cell small rolling average sample array. static U32 largeReadingsIdx; ///< Index for next sample in load cell large rolling average sample array. static DG_LOAD_CELLS_CAL_RECORD_T loadCellsCalRecord; ///< Load cells calibration record. -static BOOL hasLoadCellBeenTared[ NUM_OF_LOAD_CELLS ]; ///< Flags indicating whether loadcells have been tared yet. +static DG_RESERVOIR_VOLUME_RECORD_T reservoirsCalRecord; ///< DG reservoirs non-volatile record. +static BOOL hasLoadCellBeenTared[ NUM_OF_LOAD_CELLS ]; ///< Flags indicating whether load cells have been tared yet. // ********** private function prototypes ********** @@ -202,14 +202,17 @@ // Check if a new calibration is available if ( TRUE == isNewCalibrationRecordAvailable() ) { + getNVRecord2Driver( GET_CAL_RSRVRS_VOL_RECORD, (U08*)&reservoirsCalRecord, sizeof( DG_RESERVOIR_VOLUME_RECORD_T ), + NUM_OF_CAL_DATA_RSRVRS, ALARM_ID_DG_RESERVOIRS_INVALID_CAL_RECORD ); + 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 ); - // Zero the current tare values when new calibration data is available - loadcells[ LOAD_CELL_RESERVOIR_1_PRIMARY ].autoCalOffset = EMPTY_RESERVOIR_WEIGHT_GRAMS; - loadcells[ LOAD_CELL_RESERVOIR_1_BACKUP ].autoCalOffset = EMPTY_RESERVOIR_WEIGHT_GRAMS; - loadcells[ LOAD_CELL_RESERVOIR_2_PRIMARY ].autoCalOffset = EMPTY_RESERVOIR_WEIGHT_GRAMS; - loadcells[ LOAD_CELL_RESERVOIR_2_BACKUP ].autoCalOffset = EMPTY_RESERVOIR_WEIGHT_GRAMS; + // 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 @@ -303,10 +306,14 @@ SELF_TEST_STATUS_T execLoadCellsSelfTest ( void ) { SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; + BOOL calStatus = FALSE; - 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_CAL_RECORD ); + 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_CAL_RECORD ); + calStatus |= getNVRecord2Driver( GET_CAL_RSRVRS_VOL_RECORD, (U08*)&reservoirsCalRecord, sizeof( DG_RESERVOIR_VOLUME_RECORD_T ), + NUM_OF_CAL_DATA_RSRVRS, ALARM_ID_DG_RESERVOIRS_INVALID_CAL_RECORD ); + if ( TRUE == calStatus ) { result = SELF_TEST_STATUS_PASSED; @@ -360,7 +367,7 @@ { // For the first tare, the weight of the reservoir should be considered so the weight tolerance is bigger // The current weight of the load cell should not be greater than the weight of the reservoir + the extra weight - isWeightOutOfRange = ( weight > MAX_ALLOWED_EXTRA_WEIGHT_BEFORE_FIRST_TARE_GRAMS ? TRUE : FALSE ); + isWeightOutOfRange = ( fabs( weight ) > MAX_ALLOWED_EXTRA_WEIGHT_BEFORE_FIRST_TARE_GRAMS ? TRUE : FALSE ); } else {