Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -r19056bcb960b73405326d038abcea63b6862e344 -r45a5b4b93d1793860d5a000406591ee5cf6935d6 --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 19056bcb960b73405326d038abcea63b6862e344) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 45a5b4b93d1793860d5a000406591ee5cf6935d6) @@ -8,7 +8,7 @@ * @file LoadCell.c * * @author (last) Dara Navaei -* @date (last) 13-Jul-2022 +* @date (last) 21-Sep-2022 * * @author (original) Saeed Nejatali * @date (original) 25-Feb-2020 @@ -48,23 +48,23 @@ #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 1600 ///< Reservoirs empty weight in grams. -#define MAX_ALLOWED_EXTRA_WEIGHT_BEFORE_FIRST_TARE_GRAMS 300 ///< Max allowed extra weight before first tare in grams. -#define MAX_ALLOWED_EXTRA_WEIGHT_BEFORE_TARE_GRAMS 60 ///< Max allowed extra weight before tare in grams. +#define EMPTY_RESERVOIR_WEIGHT_GRAMS 1600.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 MAX_ALLOWED_EXTRA_WEIGHT_BEFORE_TARE_GRAMS 60.0F ///< Max allowed extra weight before tare in grams. #define LOAD_CELL_PRIMARY_BACKUP_MAX_ALLOWED_DRIFT_GRAMS 60.0F ///< Load cell primary and backup maximum allowed weight drift in grams. #define DATA_PUBLISH_COUNTER_START_COUNT 0 ///< Data publish counter start count. /// Load cell data structure. typedef struct { U32 rawReading; ///< Latest raw load cell reading. - OVERRIDE_F32_T weight; ///< Latest load cell weight. + F32 weight; ///< Latest load cell weight. F32 autoCalOffset; ///< Load cell auto-calibration offset. F32 loadCellVelocity_g_min; ///< Velocity (in g/min) of load cell. F32 smallFilterReadings[ SIZE_OF_SMALL_LOAD_CELL_AVG ]; ///< Load cell samples for small load cell moving average. F64 smallFilterTotal; ///< Small filter rolling total - used to calc small load cell moving average. - F32 smallFilteredWeight; ///< Load cell small filtered (100 100Hz raw sample) weight. + OVERRIDE_F32_T smallFilteredWeight; ///< Load cell small filtered (100 100Hz raw sample) weight. F32 largeFilterReadings[ SIZE_OF_LARGE_LOAD_CELL_AVG ]; ///< Load cell samples for large load cell moving average. F64 largeFilterTotal; ///< Large filter rolling total - used to calc small load cell moving average. @@ -76,12 +76,13 @@ static OVERRIDE_U32_T loadCellDataPublishInterval = { LOAD_CELL_REPORT_PERIOD, LOAD_CELL_REPORT_PERIOD, 0, 0 }; ///< Broadcast load cell data publish interval. static LOADCELL_T loadcells[ NUM_OF_LOAD_CELLS ]; ///< Load cell data structures. -static U32 loadCellFilterTimerCount = 0; ///< Load cell filtering timer count. +static U32 loadCellFilterTimerCount; ///< Load cell filtering timer count. static U32 loadCellDataPublicationTimerCounter; ///< Load cell data publication timer counter to CAN bus. 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. // ********** private function prototypes ********** @@ -105,21 +106,24 @@ loadCellDataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; loadCellFilterTimerCount = 0; + // Initialize load cell filter data and set calibration data as benign until loaded from non-volatile memory for ( i = 0; i < NUM_OF_LOAD_CELLS; i++ ) { benignPolynomialCalRecord( &loadCellsCalRecord.loadCells[ i ] ); - loadcells[ i ].rawReading = 0; - loadcells[ i ].weight.data = 0.0; - loadcells[ i ].weight.ovData = 0.0; - loadcells[ i ].weight.ovInitData = 0.0; - loadcells[ i ].weight.override = OVERRIDE_RESET; - loadcells[ i ].autoCalOffset = 0.0; - loadcells[ i ].largeFilterTotal = 0.0; - loadcells[ i ].largeFilteredWeight = 0.0; - loadcells[ i ].smallFilterTotal = 0.0; - loadcells[ i ].smallFilteredWeight = 0.0; + hasLoadCellBeenTared[ i ] = FALSE; + loadcells[ i ].rawReading = 0; + loadcells[ i ].weight = 0.0; + loadcells[ i ].autoCalOffset = 0.0; + loadcells[ i ].largeFilterTotal = 0.0; + loadcells[ i ].largeFilteredWeight = 0.0; + loadcells[ i ].smallFilterTotal = 0.0; + loadcells[ i ].smallFilteredWeight.data = 0.0; + loadcells[ i ].smallFilteredWeight.ovData = 0.0; + loadcells[ i ].smallFilteredWeight.ovInitData = 0.0; + loadcells[ i ].smallFilteredWeight.override = OVERRIDE_RESET; + for ( j = 0; j < SIZE_OF_SMALL_LOAD_CELL_AVG; j++ ) { loadcells[ i ].smallFilterReadings[ j ] = 0.0; @@ -198,11 +202,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.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 ].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 ].loadCellVelocity_g_min = ( getLoadCellWeight( (LOAD_CELL_ID_T)ii ) - loadcells[ ii ].smallFilterReadings[ smallReadingsIdx ] ) * (F32)SEC_PER_MIN; @@ -213,13 +217,13 @@ loadcells[ ii ].smallFilterTotal += getLoadCellWeight( (LOAD_CELL_ID_T)ii ); // Calculate the load cell value before applying calibration to it - loadcells[ ii ].smallFilteredWeight = (F32)( loadcells[ ii ].smallFilterTotal / (F64)SIZE_OF_SMALL_LOAD_CELL_AVG ); + loadcells[ ii ].smallFilteredWeight.data = (F32)( loadcells[ ii ].smallFilterTotal / (F64)SIZE_OF_SMALL_LOAD_CELL_AVG ); // Monitor the load cells weight monitorLoadCellsWeightOutOfRange( (LOAD_CELL_ID_T)ii ); // Apply the tare offset. NOTE: tare must be applied after checking the weight out of range. - loadcells[ ii ].smallFilteredWeight -= loadcells[ ii ].autoCalOffset; + loadcells[ ii ].smallFilteredWeight.data -= loadcells[ ii ].autoCalOffset; } smallReadingsIdx = INC_WRAP( smallReadingsIdx, 0, SIZE_OF_SMALL_LOAD_CELL_AVG - 1 ); @@ -231,8 +235,8 @@ { // Update large filter with new small filter weight sample loadcells[ ii ].largeFilterTotal -= loadcells[ ii ].largeFilterReadings[ largeReadingsIdx ]; - loadcells[ ii ].largeFilterReadings[ largeReadingsIdx ] = loadcells[ ii ].smallFilteredWeight; - loadcells[ ii ].largeFilterTotal += loadcells[ ii ].smallFilteredWeight; + loadcells[ ii ].largeFilterReadings[ largeReadingsIdx ] = getLoadCellSmallFilteredWeight((LOAD_CELL_ID_T) ii); + loadcells[ ii ].largeFilterTotal += getLoadCellSmallFilteredWeight((LOAD_CELL_ID_T) ii); loadcells[ ii ].largeFilteredWeight = (F32)( loadcells[ ii ].largeFilterTotal / (F64)SIZE_OF_LARGE_LOAD_CELL_AVG ); } @@ -325,7 +329,7 @@ F32 weight = getLoadCellSmallFilteredWeight( loadCellID ); // Check if the load cell is being tared for the first time - if ( fabs( loadcells[ loadCellID ].autoCalOffset ) < NEARLY_ZERO ) + if ( hasLoadCellBeenTared[ loadCellID ] != TRUE ) { // 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 @@ -340,7 +344,8 @@ if ( FALSE == isWeightOutOfRange ) { // Add old auto calibration offset to get back to actual weight value - loadcells[ loadCellID ].autoCalOffset = ( loadcells[ loadCellID ].smallFilteredWeight + loadcells[ loadCellID ].autoCalOffset ); + loadcells[ loadCellID ].autoCalOffset = ( loadcells[ loadCellID ].smallFilteredWeight.data + loadcells[ loadCellID ].autoCalOffset ); + hasLoadCellBeenTared[ loadCellID ] = TRUE; } else { @@ -373,14 +378,11 @@ *************************************************************************/ F32 getLoadCellWeight( LOAD_CELL_ID_T loadCellID ) { - F32 result = loadcells[ loadCellID ].weight.data; + F32 result = 0.0; if ( loadCellID < NUM_OF_LOAD_CELLS ) { - if ( OVERRIDE_KEY == loadcells[ loadCellID ].weight.override ) - { - result = loadcells[ loadCellID ].weight.ovData; - } + result = loadcells[ loadCellID ].weight; } else { @@ -405,7 +407,12 @@ if ( loadCellID < NUM_OF_LOAD_CELLS ) { - result = loadcells[ loadCellID ].smallFilteredWeight; + result = loadcells[ loadCellID ].smallFilteredWeight.data; + + if ( OVERRIDE_KEY == loadcells[ loadCellID ].smallFilteredWeight.override ) + { + result = loadcells[ loadCellID ].smallFilteredWeight.ovData; + } } else { @@ -469,6 +476,8 @@ * @brief * The monitorLoadCellsWeightOutOfRange function monitors the weight of the * load cells and if they are not in range, it raises an alarm. + * Function must be called prior to applying tare so that un-tared weight + * is checked for out of range. * @details Inputs: none * @details Outputs: none * @param loadCell which is the load cell ID that its range is checked @@ -477,7 +486,7 @@ static void monitorLoadCellsWeightOutOfRange( LOAD_CELL_ID_T loadCell ) { F32 weight = getLoadCellSmallFilteredWeight( loadCell ); - BOOL isWeightOutOfRange = ( weight < LOAD_CELL_MIN_ALLOWED_WEIGHT_GRAMS ) || ( weight > LOAD_CELL_MAX_ALLOWED_WEIGHT_GRAMS ); + BOOL isWeightOutOfRange = ( ( weight < LOAD_CELL_MIN_ALLOWED_WEIGHT_GRAMS ) || ( weight > LOAD_CELL_MAX_ALLOWED_WEIGHT_GRAMS ) ? TRUE : FALSE ); checkPersistentAlarm( ALARM_ID_DG_LOAD_CELL_WEIGHT_OUT_OF_RANGE, isWeightOutOfRange, weight, LOAD_CELL_MAX_ALLOWED_WEIGHT_GRAMS ); } @@ -551,8 +560,8 @@ { result = TRUE; // Add tare to given value so reported load will be what is requested when tare is subtracted later - loadcells[ loadCellID ].weight.ovData = value + loadcells[ loadCellID ].autoCalOffset; - loadcells[ loadCellID ].weight.override = OVERRIDE_KEY; + loadcells[ loadCellID ].smallFilteredWeight.ovData = value; + loadcells[ loadCellID ].smallFilteredWeight.override = OVERRIDE_KEY; } } @@ -576,8 +585,8 @@ if ( TRUE == isTestingActivated() ) { result = TRUE; - loadcells[ loadCellID ].weight.override = OVERRIDE_RESET; - loadcells[ loadCellID ].weight.ovData = loadcells[ loadCellID ].weight.ovInitData; + loadcells[ loadCellID ].smallFilteredWeight.override = OVERRIDE_RESET; + loadcells[ loadCellID ].smallFilteredWeight.ovData = loadcells[ loadCellID ].smallFilteredWeight.ovInitData; } } Index: firmware/App/Controllers/LoadCell.h =================================================================== diff -u -r8b9dd16bff3c3a7debdbd4c1f0c06759fe97d0bf -r45a5b4b93d1793860d5a000406591ee5cf6935d6 --- firmware/App/Controllers/LoadCell.h (.../LoadCell.h) (revision 8b9dd16bff3c3a7debdbd4c1f0c06759fe97d0bf) +++ firmware/App/Controllers/LoadCell.h (.../LoadCell.h) (revision 45a5b4b93d1793860d5a000406591ee5cf6935d6) @@ -7,8 +7,8 @@ * * @file LoadCell.h * -* @author (last) Sean Nash -* @date (last) 04-May-2021 +* @author (last) Dara Navaei +* @date (last) 19-Aug-2022 * * @author (original) Saeed Nejatali * @date (original) 25-Feb-2020 Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -r8b9dd16bff3c3a7debdbd4c1f0c06759fe97d0bf -r45a5b4b93d1793860d5a000406591ee5cf6935d6 --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 8b9dd16bff3c3a7debdbd4c1f0c06759fe97d0bf) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 45a5b4b93d1793860d5a000406591ee5cf6935d6) @@ -8,7 +8,7 @@ * @file TemperatureSensors.c * * @author (last) Dara Navaei -* @date (last) 25-May-2022 +* @date (last) 21-Sep-2022 * * @author (original) Dara Navaei * @date (original) 08-Apr-2020 @@ -76,15 +76,13 @@ #define CELSIUS_TO_KELVIN_CONVERSION 273.15F ///< Celsius to Kelvin temperature conversion. #define ADC_BOARD_TEMP_SENSORS_CONVERSION_CONST 272.5F ///< ADC board temperature sensors conversion constant. -#define TWELVE_BIT_RESOLUTION 4096U ///< 12 bit resolution conversion. #define ADC_BOARD_TEMP_SENSORS_CONST 0x800000 ///< ADC board temperature sensors constant. #define EXTERNAL_TEMP_SENSORS_ERROR_VALUE 0x80 ///< External temperature sensors error value. #define HEATERS_INTERNAL_TEMP_SENSOR_FAULT 0x01 ///< Heaters internal temperature sensor fault. #define TEMP_SENSORS_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Temperature sensors publish data time interval. #define TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Temperature sensors FPGA error timeout in milliseconds. -#define FPGA_RAW_ADC_READ_INTERVAL_COUNT 8 ///< Time interval in counts to read the raw ADC reads from FPGA. #define TEMP_SENSORS_ERROR_BIT_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Temperature sensors error bit timeout in milliseconds. #define TEMP_SENSORS_MIN_ALLOWED_DEGREE_C 0.0F ///< Temperature sensors minimum allowed temperature in C. @@ -94,16 +92,8 @@ #define TEMP_SENSORS_OUT_OF_RANGE_TIME_OUT_MS ( 5 * MS_PER_SECOND ) ///< Temperature sensor out of range persistent period in milliseconds. #define DATA_PUBLISH_COUNTER_START_COUNT 30 ///< Data publish counter start count. #define BARO_SENSOR_REFERENCE_TEMP_C 2000 ///< Barometric sensor reference temperature in C. +#define BARO_SENSOR_WAIT_FOR_COEFF_TIME_OUT_MS ( 20 * MS_PER_SECOND ) ///< Barometric sensor wait for coefficients timeout in milliseconds. -// The count cannot be within 0.1V of the rail on both sides therefore: -// ADC count = ((2^12) - 1 / ref voltage) * voltage -// Max allowed voltage = 3.0 - 0.1 = 2.0V -// Min allowed voltage = 0.1 - 0.0 = 0.1V -// Max count = ((2^12) - 1 / ref voltage) * voltage -> ((4096 - 1)/3.0) * (3.0 - 0.1) -// Min count = ((2^12) - 1 / ref voltage) * voltage -> ((4096 - 1)/3.0) * (0.1 - 0.0) -#define TEMP_SENSORS_MAX_ALLOWED_ADC_COUNT 3959U ///< Temperature sensors max allowed ADC count. -#define TEMP_SESNORS_MIN_ALLOWED_ADC_COUNT 137U ///< Temperature sensors min allowed ADC count. - /// Temperature sensor exec states. typedef enum tempSensors_Exec_States { @@ -122,7 +112,6 @@ S32 rawADCReads[ MAX_NUM_OF_RAW_ADC_SAMPLES ]; ///< Raw ADC reads array S32 adcNextIndex; ///< Next ADC read index S32 adcRunningSum; ///< ADC running sum - U32 readCount; ///< Read counts from FPGA OVERRIDE_F32_T temperatureValues; ///< Temperature values with override F32 maxAllowedTemp; ///< Maximum allowed temperature of the sensor U32 alarmStartTime; ///< Alarm start time @@ -137,13 +126,28 @@ { U16 refTemperature; ///< Barometric sensor reference temperature. U16 temperatureCoeff; ///< Barometric sensor temperature coefficient. + OVERRIDE_U32_T coeffsCRC; ///< Barometric sensor coefficients CRC. + U32 waitForCoeffStartTimeMS; ///< Barometric sensor wait for coefficients start time in milliseconds. + BOOL hasCRCBeenChecked; ///< Barometric sensor has CRC been checked flag. } BARO_SENSOR_CONSTS_T; +/// Barometric sensor coefficients +typedef struct +{ + U16 mfgInfo; ///< Barometric sensor manufacturing info. + U16 pressSensitivity; ///< Barometric sensor pressure sensitivity. + U16 pressOffset; ///< Barometric sensor pressure offset. + U16 tempCoeffOfPressSens; ///< Barometric sensor temperature coefficient of pressure sensor. + U16 tempCoeffPressOffset; ///< Barometric sensor temperature coefficient of pressure offset. + U16 referenceTemp; ///< Barometric sensor reference temperature. + U16 tempCoeffOfTemp; ///< Barometric sensor temperature coefficient of Temperature sensor. + U16 crc; ///< Barometric sensor CRC of the coefficients. +} BARO_SENSORS_COEFFS_T; + // ********** private data ********** static TEMPSENSORS_EXEC_STATES_T tempSensorsExecState; ///< TemperatureSensor exec state. static TEMP_SENSOR_T tempSensors [ NUM_OF_TEMPERATURE_SENSORS ]; ///< Temperature sensors' data structure. -static U32 fpgaRawADCReadInterval; ///< FPGA raw ADC read interval count. static U32 elapsedTime; ///< Elapsed time variable. static U32 internalHeatersConversionTimer; ///< Conversion timer variable to calculate the heaters internal temperature. static BARO_SENSOR_CONSTS_T baroConvConsts; ///< Barometric sensor conversion constants. @@ -176,8 +180,11 @@ static const U32 TWO_TO_POWER_OF_8 = ( 1 << 8 ); ///< 2^8. static const U32 TWO_TO_POWER_OF_23 = ( 1 << 23 ); ///< 2^23. -static U32 temporaryTODORemove[2][ 300 ]; -static U32 temporaryIdx = 0; +// The count cannot be within 0.1V of the rail on both sides therefore: +// Maximum ADC count -> (2^24) * ( 3.0V - 0.1V ) / 3V +// Minimum ADC count -> (2^24) * ( 0.1V - 0.0V ) / 3V +static const U32 TEMP_SENSORS_MAX_ADC_COUNT = ( BITS_24_FULL_SCALE * ( 3.0F - 0.1F ) ) / 3.0F; ///< Temperature sensors max allowed ADC count. +static const U32 TEMP_SESNORS_MIN_ADC_COUNT = ( BITS_24_FULL_SCALE * ( 0.1F - 0.0F ) ) / 3.0F; ///< Temperature sensors min allowed ADC count. // ********** private function prototypes ********** @@ -186,33 +193,35 @@ static F32 getADC2TempConversion( F32 avgADC, U32 gain, U32 refResistance, U32 zeroDegResistance, F32 adcConversionCoeff ); static void getHeaterInternalTemp( U32 TCIndex, U32 CJIndex ); -static void processTempSnsrsADCRead( U32 sensorIndex, U32 adc, U32 fpgaError, U32 fpgaCount, BOOL fpgaCheck ); -static void processHtrsTempSnsrsADCRead( U32 sensorIndex, U16 adc, U32 fpgaError, U32 fpgaCount ); -static BOOL isADCReadValid( U32 sensorIndex, U32 fpgaError, U32 fpgaCount ); +static void processTempSnsrsADCRead( U32 sensorIndex, U32 adc ); +static void processHtrsTempSnsrsADCRead( U32 sensorIndex, U16 adc ); static void processADCRead( U32 sensorIndex, S32 adc ); static void publishTemperatureSensorsData( void ); static void monitorTemperatureSenors( void ); -static void adjustTemperatureSensorsV3DVTRefResistance( void ); +static void checkBaroSensorCRC( void ); +static void adjustTemperatureSensorsRefResistance( void ); /*********************************************************************//** * @brief * The initTemperatureSensors function initializes the module. * @details Inputs: none * @details Outputs: tempSensorsSelfTestState, tempSensorsExecState, * elapsedTime, internalHeatersConversionTimer, dataPublicationTimerCounter, - * tempSensors, fpgaRawADCReadInterval, baroConvConsts + * tempSensors, baroConvConsts * @return none *************************************************************************/ void initTemperatureSensors( void ) { U08 i; - // Initialize the variables - tempSensorsExecState = TEMPSENSORS_EXEC_STATE_START; - elapsedTime = 0; - internalHeatersConversionTimer = 0; - dataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; - fpgaRawADCReadInterval = 0; + tempSensorsExecState = TEMPSENSORS_EXEC_STATE_START; + elapsedTime = 0; + internalHeatersConversionTimer = 0; + dataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; + baroConvConsts.coeffsCRC.data = 0; + baroConvConsts.hasCRCBeenChecked = FALSE; + baroConvConsts.waitForCoeffStartTimeMS = 0; + /* NOTE: The temperature sensors do not have conversion coefficient. * The conversion coefficients are used for the heaters internal temperature sensors and * the temperature will be calculated using a quadratic equation @@ -285,7 +294,7 @@ tempSensors[ TEMPSENSORS_TRIMMER_HEATER_INTERNAL ].maxAllowedTemp = HEATERS_INTERNAL_TEMP_SENSORS_MAX_ALLOWED_DEGREE_C; // FPGA board temperature conversion coefficient - tempSensors[ TEMPSENSORS_FPGA_BOARD_SENSOR ].conversionCoeff = 503.975 / (F32)TWELVE_BIT_RESOLUTION; + tempSensors[ TEMPSENSORS_FPGA_BOARD_SENSOR ].conversionCoeff = 503.975 / (F32)BITS_12_FULL_SCALE; tempSensors[ TEMPSENSORS_FPGA_BOARD_SENSOR ].maxAllowedTemp = NON_FLUID_PATH_TEMP_SENSORS_MAX_ALLOWED_DEGREE_C; F32 conversionCoeff = 1.0 / 13584.0; @@ -324,12 +333,12 @@ // Persistent alarm for the temperature sensors error bit fault check initPersistentAlarm( ALARM_ID_DG_TEMPERATURE_SENSOR_ERROR_BIT_FAULT, TEMP_SENSORS_ERROR_BIT_TIMEOUT_MS, TEMP_SENSORS_ERROR_BIT_TIMEOUT_MS ); - // Persistent alarm for temperature sensors ADC error - // When the FPGA read count does not increment for a period of time, it is considered as an internal error of the temperature sensors - // driver. This is internal because FPGA does not error out if the FPGA read count does not increment. - initPersistentAlarm( ALARM_ID_DG_TEMPERATURE_SENSORS_FPGA_FAULT, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS ); - - initFPGAPersistentAlarm( TWO_WIRE_ADC_TEMP_SENSORS, ALARM_ID_DG_TEMPERATURE_SENSORS_FPGA_FAULT, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS); + // Initialize the FPGA persistent alarms + initFPGAPersistentAlarm( TWO_WIRE_ADC_TEMP_SENSORS, ALARM_ID_DG_TWO_WIRE_SENSORS_FPGA_FAULT, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS); + initFPGAPersistentAlarm( THD_ADC_TEMP_SENSORS, ALARM_ID_DG_THD_SENSORS_FPGA_FAULT, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS); + initFPGAPersistentAlarm( TDI_ADC_TEMP_SENSORS, ALARM_ID_DG_TDI_SENSORS_FPGA_FAULT, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS); + initFPGAPersistentAlarm( TRO_ADC_TEMP_SENSORS, ALARM_ID_DG_TRO_SENSORS_FPGA_FAULT, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS); + initFPGAPersistentAlarm( BARO_SENSOR, ALARM_ID_DG_BARO_SENSOR_FPGA_FAULT, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS); } /*********************************************************************//** @@ -370,7 +379,7 @@ void execTemperatureSensors( void ) { // Check the status of the software configuration - adjustTemperatureSensorsV3DVTRefResistance(); + adjustTemperatureSensorsRefResistance(); // Read the sensors all the time switch ( tempSensorsExecState ) @@ -455,6 +464,8 @@ if ( sensorIndex < NUM_OF_TEMPERATURE_SENSORS ) { temperature = getF32OverrideValue( &tempSensors[ sensorIndex ].temperatureValues ); + +#ifndef _RELEASE_ // If the system is V3 and THd or its ADC internal temperature is requested, return TRo instead. V3 does not have // the electrical connection of THd sensor. if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) @@ -463,7 +474,13 @@ { temperature = getF32OverrideValue( &tempSensors[ TEMPSENSORS_OUTLET_REDUNDANT ].temperatureValues ); } + + if ( TEMPSENSORS_OUTLET_REDUNDANT == sensorIndex ) + { + temperature = getF32OverrideValue( &tempSensors[ TEMPSENSORS_INLET_DIALYSATE ].temperatureValues ); + } } +#endif } else { @@ -593,69 +610,52 @@ * @details Outputs: none * @param sensorIndex ID of temperature sensor to process * @param adc ADC value for the temperature sensor - * @param fpgaError reported FPGA error status - * @param fpgaCount reported FPGA read count - * @param fpgaCheck whether to check the FPGA error and count prior to converting - * the ADC to temperature * @return none *************************************************************************/ -static void processTempSnsrsADCRead( U32 sensorIndex, U32 adc, U32 fpgaError, U32 fpgaCount, BOOL fpgaCheck ) +static void processTempSnsrsADCRead( U32 sensorIndex, U32 adc ) { - BOOL isADCValid = TRUE; S32 convertedADC = (S32)( adc & MASK_OFF_U32_MSB ); - if ( TRUE == fpgaCheck ) - { - // All the sensors have ADC read and count values that have to be checked - // but the FPGA read and error counts are shared among some of the sensors so if that counts has been checked - // once, do not check it again - isADCValid = isADCReadValid( sensorIndex, fpgaError, fpgaCount ); - } - - // Some of the temperature sensors have an MSB bit that is used as an - // error flag. This flag will be a TRUE by default. - BOOL isTemperatureNotValid = FALSE; - switch( sensorIndex ) { - case TEMPSENSORS_LOAD_CELL_A1_B1: // 267 - case TEMPSENSORS_LOAD_CELL_A2_B2: // 279 - case TEMPSENSORS_CONDUCTIVITY_SENSOR_1: // 283 - case TEMPSENSORS_CONDUCTIVITY_SENSOR_2: // 287 - case TEMPSENSORS_OUTLET_PRIMARY_HEATER: // 291 - case TEMPSENSORS_INLET_PRIMARY_HEATER: // 295 - case TEMPSENSORS_INTERNAL_COND_TEMP_SENSOR: // 299 - case TEMPSENSORS_OUTLET_REDUNDANT: // 303 - case TEMPSENSORS_INTERNAL_TRO_RTD: // 307 - case TEMPSENSORS_INLET_DIALYSATE: // 311 - case TEMPSENSORS_INTERNAL_TDI_RTD: // 315 + case TEMPSENSORS_LOAD_CELL_A1_B1: + case TEMPSENSORS_LOAD_CELL_A2_B2: + case TEMPSENSORS_CONDUCTIVITY_SENSOR_1: + case TEMPSENSORS_CONDUCTIVITY_SENSOR_2: + case TEMPSENSORS_OUTLET_PRIMARY_HEATER: + case TEMPSENSORS_INLET_PRIMARY_HEATER: + case TEMPSENSORS_INTERNAL_COND_TEMP_SENSOR: + case TEMPSENSORS_OUTLET_REDUNDANT: + case TEMPSENSORS_INTERNAL_TRO_RTD: + case TEMPSENSORS_INLET_DIALYSATE: + case TEMPSENSORS_INTERNAL_TDI_RTD: case TEMPSENSORS_HEAT_DISINFECT: case TEMPSENSORS_INTERNAL_THD_RTD: { U08 i; + // Some of the temperature sensors have an MSB bit that is used as an + // error flag. This flag will be a TRUE by default. + BOOL isErrorBitNotValid = FALSE; + U32 faultySensorIndex = 0; + // Shift bits by 31 to right to check the error bit status tempSensors[ sensorIndex ].sensorErrorBitStatus = adc >> SHIFT_BITS_BY_31; - /*for ( i = 0; i < NUM_OF_TEMPERATURE_SENSORS; i++ ) + for ( i = 0; i < NUM_OF_TEMPERATURE_SENSORS; i++ ) { // If that bit is a 1, there is either CRC error or Status error that are ored on top of each other // NOTE: only a few sensors have the error bit available but for simplicity, all the sensors are looped. - // This variable is zeroed in the init function and the sensors that do not use this bit are never checked ( and set) to + // This variable is zeroed in the init function and the sensors that do not use this bit are never checked (and set) to // any other values so those sensors will never trigger this fault. // If any of the sensors have this bit to be 1, set the error occurred be 1 - isTemperatureNotValid |= ( tempSensors[ i ].sensorErrorBitStatus > 0 ? TRUE : FALSE ); - }*/ - -#ifndef DISABLE_FPGA_ALARMS_UNTIL_THE_NEW_PERSISTENT - // TODO for debugging only remove - if ( TRUE == isTemperatureNotValid ) - { - BOOL test = FALSE; + if ( tempSensors[ i ].sensorErrorBitStatus > 0 ) + { + isErrorBitNotValid = TRUE; + faultySensorIndex = i; + } } - // TODO remove for debugging only - checkPersistentAlarm( ALARM_ID_DG_TEMPERATURE_SENSOR_ERROR_BIT_FAULT, isTemperatureNotValid, sensorIndex, TEMP_SENSORS_ERROR_BIT_TIMEOUT_MS ); -#endif + checkPersistentAlarm( ALARM_ID_DG_TEMPERATURE_SENSOR_ERROR_BIT_FAULT, isErrorBitNotValid, faultySensorIndex, TEMP_SENSORS_ERROR_BIT_TIMEOUT_MS ); } break; @@ -666,12 +666,7 @@ break; } - // To update the moving average of a temperature sensor, both ADC and internal - // error flags must be valid - if ( ( TRUE == isADCValid ) && ( FALSE == isTemperatureNotValid ) ) - { - processADCRead( sensorIndex, convertedADC ); - } + processADCRead( sensorIndex, convertedADC ); } /*********************************************************************//** @@ -685,62 +680,13 @@ * @details Outputs: none * @param sensorIndex ID of temperature sensor to process * @param adc reported ADC value for temperature sensor - * @param fpgaError reported error status by FPGA - * @param fpgaCount reported read count by FPGA * @return none *************************************************************************/ -static void processHtrsTempSnsrsADCRead( U32 sensorIndex, U16 adc, U32 fpgaError, U32 fpgaCount ) +static void processHtrsTempSnsrsADCRead( U32 sensorIndex, U16 adc ) { - if ( TRUE == isADCReadValid( sensorIndex, fpgaError, fpgaCount ) ) - { - S16 convert = (S16)adc; - processADCRead( sensorIndex, (S32)convert ); - } -} + S16 convert = (S16)adc; -/*********************************************************************//** - * @brief - * The isADCReadValid function checks if there is an FPGA error and FPGA - * count. If there is any FPGA, it raises an alarm. If the count has changed - * and the ADC value is not the same as the previous ADC read, it returns a - * TRUE, signaling that the ADC is valid to be processed. - * @details Inputs: tempSensors - * @details Outputs: tempSensors - * @param sensorIndex Temperature sensor index - * @param fpgaError FPGA error count - * @param fpgaCount FPGA read count - * @return returns TRUE if ADC was valid otherwise FALSE - *************************************************************************/ -static BOOL isADCReadValid( U32 sensorIndex, U32 fpgaError, U32 fpgaCount ) -{ - U08 i; - BOOL isADCValid = FALSE; - BOOL isTemperatureNotValid = FALSE; - // Check the status of FPGA error and FPGA count - BOOL isFPGAErrorZero = ( 0 == fpgaError ? TRUE : FALSE ); - BOOL isFPGACountChanging = ( tempSensors[ sensorIndex ].readCount != fpgaCount ? TRUE : FALSE ); - - if ( ( TRUE == isFPGAErrorZero ) && ( TRUE == isFPGACountChanging ) ) - { - tempSensors[ sensorIndex ].readCount = fpgaCount; - isADCValid = TRUE; - } - - tempSensors[ sensorIndex ].fpgaErrorStatus = ( ( FALSE == isFPGACountChanging ) || ( FALSE == isFPGAErrorZero ) ? TRUE : FALSE ); - - for ( i = 0; i < NUM_OF_TEMPERATURE_SENSORS; i++ ) - { - // Loop through all the sensors and read their FPGA error status - isTemperatureNotValid |= tempSensors[ sensorIndex ].fpgaErrorStatus; - } - -#ifndef DISABLE_FPGA_ALARMS_UNTIL_THE_NEW_PERSISTENT - checkPersistentAlarm( ALARM_ID_DG_TEMPERATURE_SENSORS_FPGA_FAULT, isTemperatureNotValid, sensorIndex, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS ); - - return isADCValid; -#else - return TRUE; -#endif + processADCRead( sensorIndex, (S32)convert ); } /*********************************************************************//** @@ -762,24 +708,24 @@ BOOL isADCNotValid = FALSE; U32 index = tempSensors[ sensorIndex ].adcNextIndex; S32 indexValue = tempSensors[ sensorIndex ].rawADCReads [ index ]; + // Update the temperature sensors' structure tempSensors[ sensorIndex ].rawADCReads[ index ] = adc; tempSensors[ sensorIndex ].adcNextIndex = INC_WRAP( index, 0, MAX_NUM_OF_RAW_ADC_SAMPLES - 1 ); tempSensors[ sensorIndex ].adcRunningSum = tempSensors[ sensorIndex ].adcRunningSum - indexValue + adc; avgADCReads = tempSensors[ sensorIndex ].adcRunningSum >> SHIFT_BITS_BY_2_FOR_AVERAGING; // Calculate the average // Check if the average ADC is within the accepted range - tempSensors[ sensorIndex ].adcErrorStatus = ( ( (U32)avgADCReads < TEMP_SESNORS_MIN_ALLOWED_ADC_COUNT ) || - ( (U32)avgADCReads > TEMP_SENSORS_MAX_ALLOWED_ADC_COUNT ) ? TRUE : FALSE ); + tempSensors[ sensorIndex ].adcErrorStatus = ( ( (U32)avgADCReads < TEMP_SESNORS_MIN_ADC_COUNT ) || + ( (U32)avgADCReads > TEMP_SENSORS_MAX_ADC_COUNT ) ? TRUE : FALSE ); for ( i = 0; i < NUM_OF_TEMPERATURE_SENSORS; i++ ) { // Loop through the ADC errors isADCNotValid |= tempSensors[ sensorIndex ].adcErrorStatus; } -#ifndef DISABLE_FPGA_ALARMS_UNTIL_THE_NEW_PERSISTENT + checkPersistentAlarm( ALARM_ID_DG_TEMPERATURE_SENSORS_ADC_FAULT, isADCNotValid, sensorIndex, avgADCReads ); -#endif // Different sensors have different ADC to temperature conversion methods switch( sensorIndex ) @@ -820,7 +766,7 @@ case TEMPSENSORS_BAROMETRIC_TEMP_SENSOR: { tempSensors[ sensorIndex ].baroTempSnsrDiff = (S32)avgADCReads - ( baroConvConsts.refTemperature * TWO_TO_POWER_OF_8 ); - U64 baroSnsrTemperature = BARO_SENSOR_REFERENCE_TEMP_C + ( ( tempSensors[ sensorIndex ].baroTempSnsrDiff * + S64 baroSnsrTemperature = BARO_SENSOR_REFERENCE_TEMP_C + ( ( tempSensors[ sensorIndex ].baroTempSnsrDiff * baroConvConsts.temperatureCoeff ) / TWO_TO_POWER_OF_23 ); temperature = (F32)( (U32)( baroSnsrTemperature ) / 100 ); } @@ -843,7 +789,7 @@ * The handleExecStart function waits for a period of time and switches to * the state that reads the ADC values from FPGA. * @details Inputs: elapsedTime - * @details Outputs: elapsedTime + * @details Outputs: elapsedTime, baroCoeffsWaitToRcvStartTime * @return the next state of the state machine *************************************************************************/ static TEMPSENSORS_EXEC_STATES_T handleExecStart( void ) @@ -857,8 +803,9 @@ // A delay to let FPGA to boot up else if ( TRUE == didTimeout( elapsedTime, ADC_FPGA_READ_DELAY ) ) { - elapsedTime = 0; - state = TEMPSENSORS_EXEC_STATE_GET_ADC_VALUES; + elapsedTime = 0; + baroConvConsts.waitForCoeffStartTimeMS = getMSTimerCount(); + state = TEMPSENSORS_EXEC_STATE_GET_ADC_VALUES; } return state; @@ -878,80 +825,72 @@ U32 errorCount = 0; U32 readCount = 0; - // TODO remove - //temporaryTODORemove[0][temporaryIdx] = (U32)getFPGARTDErrorCount(); - //temporaryTODORemove[1][temporaryIdx] = (U32)getFPGARTDReadCount(); - //temporaryIdx = INC_WRAP(temporaryIdx, 0, 300); - // TODO remove + errorCount = (U32)getFPGARTDErrorCount(); + readCount = (U32)getFPGARTDReadCount(); - // Look at the error counter and the specific error flag to make sure the error is a temperature sensor - // Add a byte array to have bits for each sensor to find out exactly what sensor failed - //if ( ++fpgaRawADCReadInterval >= FPGA_RAW_ADC_READ_INTERVAL_COUNT ) - { - errorCount = (U32)getFPGARTDErrorCount(); - readCount = (U32)getFPGARTDReadCount(); - //checkFPGAPersistentAlarms( TWO_WIRE_ADC_TEMP_SENSORS, errorCount, readCount, TEMPSENSORS_INLET_PRIMARY_HEATER ); - processTempSnsrsADCRead( TEMPSENSORS_INLET_PRIMARY_HEATER, getFPGATPiTemp(), errorCount, readCount, TRUE ); - processTempSnsrsADCRead( TEMPSENSORS_OUTLET_PRIMARY_HEATER, getFPGATPoTemp(), errorCount, readCount, FALSE ); - processTempSnsrsADCRead( TEMPSENSORS_CONDUCTIVITY_SENSOR_1, getFPGACD1Temp(), errorCount, readCount, FALSE ); - processTempSnsrsADCRead( TEMPSENSORS_CONDUCTIVITY_SENSOR_2, getFPGACD2Temp(), errorCount, readCount, FALSE ); + checkFPGAPersistentAlarms( TWO_WIRE_ADC_TEMP_SENSORS, errorCount, readCount ); + processTempSnsrsADCRead( TEMPSENSORS_INLET_PRIMARY_HEATER, getFPGATPiTemp() ); + processTempSnsrsADCRead( TEMPSENSORS_OUTLET_PRIMARY_HEATER, getFPGATPoTemp() ); + processTempSnsrsADCRead( TEMPSENSORS_CONDUCTIVITY_SENSOR_1, getFPGACD1Temp() ); + processTempSnsrsADCRead( TEMPSENSORS_CONDUCTIVITY_SENSOR_2, getFPGACD2Temp() ); + processTempSnsrsADCRead( TEMPSENSORS_INTERNAL_COND_TEMP_SENSOR, getFPGACondSnsrInternalTemp() ); #ifndef _RELEASE_ - if ( ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) != SW_CONFIG_ENABLE_VALUE ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) + if ( ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) != SW_CONFIG_ENABLE_VALUE ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) #endif - { - errorCount = (U32)getFPGATHdErrorCount(); - readCount = (U32)getFPGATHdReadCount(); - processTempSnsrsADCRead( TEMPSENSORS_HEAT_DISINFECT, getFPGATHdTemp(), errorCount, readCount, TRUE ); - processTempSnsrsADCRead( TEMPSENSORS_INTERNAL_THD_RTD, getFPGATHdInternalTemp(), errorCount, readCount, FALSE ); + { + errorCount = (U32)getFPGATHdErrorCount(); + readCount = (U32)getFPGATHdReadCount(); - // Once FPGA is ready get the barometric sensor's temperature conversion constants - baroConvConsts.refTemperature = getFPGABaroReferenceTemperature(); - baroConvConsts.temperatureCoeff = getFPGABaroTempCoeffOfTemperature(); - errorCount = getFPGABaroErrorCount(); - readCount = getFPGABaroReadCount(); - processTempSnsrsADCRead( TEMPSENSORS_BAROMETRIC_TEMP_SENSOR, getFPGABaroTemperature(), errorCount, readCount, TRUE ); - } + checkFPGAPersistentAlarms( THD_ADC_TEMP_SENSORS, errorCount, readCount ); + processTempSnsrsADCRead( TEMPSENSORS_HEAT_DISINFECT, getFPGATHdTemp() ); + processTempSnsrsADCRead( TEMPSENSORS_INTERNAL_THD_RTD, getFPGATHdInternalTemp() ); - errorCount = (U32)getFPGATRoErrorCount(); - readCount = (U32)getFPGATRoReadCount(); - processTempSnsrsADCRead( TEMPSENSORS_OUTLET_REDUNDANT, getFPGATRoTemp(), errorCount, readCount, TRUE ); + // Make sure the baro sensor coefficients are not corrupted + checkBaroSensorCRC(); - errorCount = (U32)getFPGATDiErrorCount(); - readCount = (U32)getFPGATDiReadCount(); - processTempSnsrsADCRead( TEMPSENSORS_INLET_DIALYSATE, getFPGATDiTemp(), errorCount, readCount, TRUE ); + baroConvConsts.refTemperature = getFPGABaroReferenceTemperature(); + baroConvConsts.temperatureCoeff = getFPGABaroTempCoeffOfTemperature(); + errorCount = getFPGABaroErrorCount(); + readCount = getFPGABaroReadCount(); - errorCount = (U32)getFPGAPrimaryHeaterFlags(); - readCount = (U32)getFPGAPrimaryHeaterReadCount(); - processHtrsTempSnsrsADCRead( TEMPSENSORS_PRIMARY_HEATER_THERMO_COUPLE, getFPGAPrimaryHeaterTemp(), errorCount, readCount ); - processHtrsTempSnsrsADCRead( TEMPSENSORS_PRIMARY_HEATER_COLD_JUNCTION, getFPGAPrimaryColdJunctionTemp(), errorCount, readCount ); + checkFPGAPersistentAlarms( BARO_SENSOR, errorCount, readCount ); + processTempSnsrsADCRead( TEMPSENSORS_BAROMETRIC_TEMP_SENSOR, getFPGABaroTemperature() ); + } - errorCount = (U32)getFPGATrimmerHeaterFlags(); - readCount = (U32)getFPGATrimmerHeaterReadCount(); - processHtrsTempSnsrsADCRead( TEMPSENSORS_TRIMMER_HEATER_THERMO_COUPLE, getFPGATrimmerHeaterTemp(), errorCount, readCount ); - processHtrsTempSnsrsADCRead( TEMPSENSORS_TRIMMER_HEATER_COLD_JUNCTION, getFPGATrimmerColdJunctionTemp(), errorCount, readCount ); + errorCount = (U32)getFPGATRoErrorCount(); + readCount = (U32)getFPGATRoReadCount(); - // NOTE: FPGA board temperature sensor is different from the rest of the sensors. This sensor does not have FPGA count and error - // coming from FPGA. It is kept here to do moving average on the values. The supporting functions need to see the FPGA read count - // incrementing internally so there will not be any errors. - U32 simulatedCounter = tempSensors[ TEMPSENSORS_FPGA_BOARD_SENSOR ].readCount; - processTempSnsrsADCRead( TEMPSENSORS_FPGA_BOARD_SENSOR, getFPGABoardTemp(), 0, ++simulatedCounter, TRUE ); - processTempSnsrsADCRead( TEMPSENSORS_LOAD_CELL_A1_B1, getFPGALoadCellsA1B1Temp(), getFPGAADC1ErrorCount(), getFPGAADC1ReadCount(), TRUE ); - processTempSnsrsADCRead( TEMPSENSORS_LOAD_CELL_A2_B2, getFPGALoadCellsA2B2Temp(), getFPGAADC2ErrorCount(), getFPGAADC2ReadCount(), TRUE ); - processTempSnsrsADCRead( TEMPSENSORS_INTERNAL_TRO_RTD, getFPGATRoInternalTemp(), getFPGATRoErrorCount(), getFPGATRoReadCount(), TRUE ); - processTempSnsrsADCRead( TEMPSENSORS_INTERNAL_TDI_RTD, getFPGATDiInternalTemp(), getFPGATDiErrorCount(), getFPGATDiReadCount(), TRUE ); - processTempSnsrsADCRead( TEMPSENSORS_INTERNAL_COND_TEMP_SENSOR, getFPGACondSnsrInternalTemp(), getFPGARTDErrorCount(), getFPGARTDReadCount(), TRUE ); - processTempSnsrsADCRead( TEMPSENSORS_BAROMETRIC_TEMP_SENSOR, getFPGABaroTemperature(), getFPGABaroErrorCount(), getFPGABaroReadCount(), TRUE ); + checkFPGAPersistentAlarms( TRO_ADC_TEMP_SENSORS, errorCount, readCount ); + processTempSnsrsADCRead( TEMPSENSORS_OUTLET_REDUNDANT, getFPGATRoTemp() ); + processTempSnsrsADCRead( TEMPSENSORS_INTERNAL_TRO_RTD, getFPGATRoInternalTemp() ); - // Check if time has elapsed to calculate the internal temperature of the heaters - if ( ++internalHeatersConversionTimer >= HEATERS_INTERNAL_TEMPERTURE_CALCULATION_INTERVAL ) - { - getHeaterInternalTemp( TEMPSENSORS_PRIMARY_HEATER_THERMO_COUPLE, TEMPSENSORS_PRIMARY_HEATER_COLD_JUNCTION ); - getHeaterInternalTemp( TEMPSENSORS_TRIMMER_HEATER_THERMO_COUPLE, TEMPSENSORS_TRIMMER_HEATER_COLD_JUNCTION ); - internalHeatersConversionTimer = 0; - } + errorCount = (U32)getFPGATDiErrorCount(); + readCount = (U32)getFPGATDiReadCount(); - fpgaRawADCReadInterval = 0; + checkFPGAPersistentAlarms( TDI_ADC_TEMP_SENSORS, errorCount, readCount ); + processTempSnsrsADCRead( TEMPSENSORS_INLET_DIALYSATE, getFPGATDiTemp() ); + processTempSnsrsADCRead( TEMPSENSORS_INTERNAL_TDI_RTD, getFPGATDiInternalTemp() ); + + // The heaters' temperature sensors have read and error counts but the heaters' internal sensors are only updated for information + // and no alarm shall be raised on them including the read and error counts + processHtrsTempSnsrsADCRead( TEMPSENSORS_PRIMARY_HEATER_THERMO_COUPLE, getFPGAPrimaryHeaterTemp() ); + processHtrsTempSnsrsADCRead( TEMPSENSORS_PRIMARY_HEATER_COLD_JUNCTION, getFPGAPrimaryColdJunctionTemp() ); + processHtrsTempSnsrsADCRead( TEMPSENSORS_TRIMMER_HEATER_THERMO_COUPLE, getFPGATrimmerHeaterTemp() ); + processHtrsTempSnsrsADCRead( TEMPSENSORS_TRIMMER_HEATER_COLD_JUNCTION, getFPGATrimmerColdJunctionTemp() ); + + // The FPGA board sensor does not have read and error count. + // The load cells' temperature sensors are not read and a constant value is reported to firmware by FPGA + processTempSnsrsADCRead( TEMPSENSORS_FPGA_BOARD_SENSOR, getFPGABoardTemp() ); + processTempSnsrsADCRead( TEMPSENSORS_LOAD_CELL_A1_B1, getFPGALoadCellsA1B1Temp() ); + processTempSnsrsADCRead( TEMPSENSORS_LOAD_CELL_A2_B2, getFPGALoadCellsA2B2Temp() ); + + // Check if time has elapsed to calculate the internal temperature of the heaters + if ( ++internalHeatersConversionTimer >= HEATERS_INTERNAL_TEMPERTURE_CALCULATION_INTERVAL ) + { + getHeaterInternalTemp( TEMPSENSORS_PRIMARY_HEATER_THERMO_COUPLE, TEMPSENSORS_PRIMARY_HEATER_COLD_JUNCTION ); + getHeaterInternalTemp( TEMPSENSORS_TRIMMER_HEATER_THERMO_COUPLE, TEMPSENSORS_TRIMMER_HEATER_COLD_JUNCTION ); + internalHeatersConversionTimer = 0; } return TEMPSENSORS_EXEC_STATE_GET_ADC_VALUES; @@ -970,6 +909,7 @@ if ( ++dataPublicationTimerCounter >= getU32OverrideValue( &tempSensorsPublishInterval ) ) { TEMPERATURE_SENSORS_DATA_T data; + data.inletPrimaryHeater = getTemperatureValue( TEMPSENSORS_INLET_PRIMARY_HEATER ); data.heatDisinfect = getTemperatureValue( TEMPSENSORS_HEAT_DISINFECT ); data.outletPrimaryHeater = getTemperatureValue( TEMPSENSORS_OUTLET_PRIMARY_HEATER ); @@ -988,6 +928,7 @@ data.loadCellA2B2 = getTemperatureValue( TEMPSENSORS_LOAD_CELL_A2_B2 ); data.internalTHDORTD = getTemperatureValue( TEMPSENSORS_INTERNAL_TRO_RTD ); data.internalTDIRTD = getTemperatureValue( TEMPSENSORS_INTERNAL_TDI_RTD ); + data.interalTHDRTD = getTemperatureValue( TEMPSENSORS_INTERNAL_THD_RTD ); data.internalCondSnsrTemp = getTemperatureValue( TEMPSENSORS_INTERNAL_COND_TEMP_SENSOR ); broadcastData( MSG_ID_DG_TEMPERATURE_DATA, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); dataPublicationTimerCounter = 0; @@ -1010,43 +951,78 @@ #endif { U08 i; - F32 temperature = 0.0; + F32 temperature = 0.0F; BOOL isTemperatureOutOfRange = FALSE; + F32 alarmTemperature = 0.0F; + U08 alarmIndex = 0; for ( i = 0; i < NUM_OF_TEMPERATURE_SENSORS; i++ ) { - temperature = getTemperatureValue( i ); - - // Check both temperature and to be in range - if ( ( ( temperature < TEMP_SENSORS_MIN_ALLOWED_DEGREE_C ) || ( temperature > tempSensors[ i ].maxAllowedTemp ) ) && - ( getCurrentOperationMode() != DG_MODE_INIT ) ) + switch ( i ) { - isTemperatureOutOfRange |= TRUE; + case TEMPSENSORS_INLET_PRIMARY_HEATER: + case TEMPSENSORS_HEAT_DISINFECT: + case TEMPSENSORS_OUTLET_PRIMARY_HEATER: + case TEMPSENSORS_CONDUCTIVITY_SENSOR_1: + case TEMPSENSORS_CONDUCTIVITY_SENSOR_2: + case TEMPSENSORS_OUTLET_REDUNDANT: + case TEMPSENSORS_INLET_DIALYSATE: + case TEMPSENSORS_FPGA_BOARD_SENSOR: + case TEMPSENSORS_LOAD_CELL_A1_B1: + case TEMPSENSORS_LOAD_CELL_A2_B2: + case TEMPSENSORS_INTERNAL_TRO_RTD: + case TEMPSENSORS_INTERNAL_TDI_RTD: + case TEMPSENSORS_INTERNAL_THD_RTD: + case TEMPSENSORS_INTERNAL_COND_TEMP_SENSOR: + case TEMPSENSORS_BAROMETRIC_TEMP_SENSOR: + // All the temperature sensors are monitored except the heaters' temperature sensors. + // The heaters' temperature sensors are only broadcast for information + temperature = getTemperatureValue( i ); + + // Check both temperature and to be in range + if ( ( ( temperature < TEMP_SENSORS_MIN_ALLOWED_DEGREE_C ) || ( temperature > tempSensors[ i ].maxAllowedTemp ) ) && + ( getCurrentOperationMode() != DG_MODE_INIT ) ) + { + isTemperatureOutOfRange |= TRUE; + alarmIndex = i; + alarmTemperature = temperature; + } + break; + + default: + // Ignore the rest of the sensors + break; } + } - checkPersistentAlarm( ALARM_ID_DG_TEMPERATURE_SENSOR_OUT_OF_RANGE, isTemperatureOutOfRange, i, temperature ); + checkPersistentAlarm( ALARM_ID_DG_TEMPERATURE_SENSOR_OUT_OF_RANGE, isTemperatureOutOfRange, alarmIndex, alarmTemperature ); } } /*********************************************************************//** * @brief - * The adjustTemperatureSensorsV3DVTRefResistance function adjusts the temperature + * The adjustTemperatureSensorsRefResistance function adjusts the temperature * sensors V3 or DVT reference resistance values. * @details Inputs: tempSensors * @details Outputs: tempSensors * @return none *************************************************************************/ -static void adjustTemperatureSensorsV3DVTRefResistance( void ) +static void adjustTemperatureSensorsRefResistance( void ) { // The defaults are DVT values U32 primaryAndCondSensorsRefResistance = PRIMARY_HEATER_EXT_TEMP_SENSORS_REF_RESISTANCE; U32 externalTempSesnorsRefResitance = TRIMMER_HEATER_EXT_TEMP_SENSORS_REF_RESISTANCE; - if ( ( getCurrentOperationMode() != DG_MODE_INIT ) && ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) ) +#ifndef _RELEASE_ + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_V3_SYSTEM ) ) +#endif { - primaryAndCondSensorsRefResistance = PRIMARY_HEATER_EXT_TEMP_SENSORS_V3_REF_RESISTANCE; - externalTempSesnorsRefResitance = TRIMMER_HEATER_EXT_TEMP_SENSORS_V3_REF_RESISTANCE; + if ( getCurrentOperationMode() != DG_MODE_INIT ) + { + primaryAndCondSensorsRefResistance = PRIMARY_HEATER_EXT_TEMP_SENSORS_V3_REF_RESISTANCE; + externalTempSesnorsRefResitance = TRIMMER_HEATER_EXT_TEMP_SENSORS_V3_REF_RESISTANCE; + } } tempSensors[ TEMPSENSORS_INLET_PRIMARY_HEATER ].refResistance = primaryAndCondSensorsRefResistance; @@ -1058,7 +1034,52 @@ tempSensors[ TEMPSENSORS_INLET_DIALYSATE ].refResistance = externalTempSesnorsRefResitance; } +/*********************************************************************//** + * @brief + * The checkBaroSensorCRC function gets all the barometric sensor coefficients + * and calls crc4 function to calculate the CRC of the coefficients and compares + * them to the provided CRC by the manufacturer. + * @details Inputs: hasBaroCoeffsBeenChecked + * @details Outputs: hasBaroCoeffsBeenChecked + * @return none + *************************************************************************/ +static void checkBaroSensorCRC( void ) +{ + U32 baroCRC = (U32)getFPGABaroCoeffsCRC(); + BOOL hasCRCChanged = ( baroCRC != getU32OverrideValue( &baroConvConsts.coeffsCRC ) ? TRUE : FALSE ); + // Once FPGA is ready get the barometric sensor's temperature conversion constants + if ( TRUE == hasCRCChanged ) + { + U08 calculatedCRC; + BARO_SENSORS_COEFFS_T baroCoeffs; + + baroCoeffs.mfgInfo = getFPGABaroMfgInfo(); + baroCoeffs.pressSensitivity = getFPGABaroPressureSensitivity(); + baroCoeffs.pressOffset = getFPGABaroPressureOffset(); + baroCoeffs.tempCoeffOfPressSens = getFPGABaroTempCoeffOfPressSensitvity(); + baroCoeffs.tempCoeffPressOffset = getFPGABaroTempCoeffOfPressOffset(); + baroCoeffs.referenceTemp = getFPGABaroReferenceTemperature(); + baroCoeffs.tempCoeffOfTemp = getFPGABaroTempCoeffOfTemperature(); + baroCoeffs.crc = MASK_OFF_LSB & getFPGABaroCoeffsCRC(); + calculatedCRC = crc4( (U16*)&baroCoeffs, sizeof( baroCoeffs ) ); + baroConvConsts.coeffsCRC.data = baroCRC; + baroCRC = (U16)( baroCRC & MASK_OFF_MSB ) & MASK_OFF_NIBBLE_MSB; + baroConvConsts.hasCRCBeenChecked = TRUE; + + if ( calculatedCRC != baroCRC ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_BAROMETRIC_SENSOR_COEFFS_BAD_CRC, calculatedCRC, baroCoeffs.crc ); + } + } + else if ( ( TRUE == didTimeout( baroConvConsts.waitForCoeffStartTimeMS, BARO_SENSOR_WAIT_FOR_COEFF_TIME_OUT_MS ) ) && + ( FALSE == baroConvConsts.hasCRCBeenChecked ) ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_BAROMETRIC_SENSOR_COEFFS_BAD_CRC, 0, baroCRC ); + } +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Controllers/TemperatureSensors.h =================================================================== diff -u -r8b9dd16bff3c3a7debdbd4c1f0c06759fe97d0bf -r45a5b4b93d1793860d5a000406591ee5cf6935d6 --- firmware/App/Controllers/TemperatureSensors.h (.../TemperatureSensors.h) (revision 8b9dd16bff3c3a7debdbd4c1f0c06759fe97d0bf) +++ firmware/App/Controllers/TemperatureSensors.h (.../TemperatureSensors.h) (revision 45a5b4b93d1793860d5a000406591ee5cf6935d6) @@ -8,7 +8,7 @@ * @file TemperatureSensors.h * * @author (last) Dara Navaei -* @date (last) 13-Apr-2022 +* @date (last) 21-Sep-2022 * * @author (original) Dara Navaei * @date (original) 08-Apr-2020 @@ -59,7 +59,6 @@ NUM_OF_TEMPERATURE_SENSORS ///< Number of temperature sensors } TEMPERATURE_SENSORS_T; - // ********** public function prototypes ********** void initTemperatureSensors( void ); Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -r306b3f3fcbf1e641da8df38b595806c22a367ad3 -r45a5b4b93d1793860d5a000406591ee5cf6935d6 --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 306b3f3fcbf1e641da8df38b595806c22a367ad3) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 45a5b4b93d1793860d5a000406591ee5cf6935d6) @@ -8,7 +8,7 @@ * @file AlarmMgmt.c * * @author (last) Dara Navaei -* @date (last) 26-Mar-2022 +* @date (last) 09-Aug-2022 * * @author (original) Sean * @date (original) 04-Feb-2020 Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rcef8149cb8dfbd5c91c32f5318334c5db2366f7e -r45a5b4b93d1793860d5a000406591ee5cf6935d6 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision cef8149cb8dfbd5c91c32f5318334c5db2366f7e) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 45a5b4b93d1793860d5a000406591ee5cf6935d6) @@ -9,7 +9,7 @@ * @file FPGA.c * * @author (last) Dara Navaei -* @date (last) 24-May-2022 +* @date (last) 28-Aug-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -83,7 +83,11 @@ #define DRAIN_PUMP_DAC_SHIFT_BITS 4 ///< Drain pump DAC shift bits. #define FPGA_FLUIDLEAK_STATE_MASK 0x0004 ///< Bit mask for fluid leak detector. -#define FPGA_ENABLE_VALVES_CONTROL 0x015F ///< FPGA enable valves control +#define FPGA_ENABLE_VALVES_CONTROL 0x015F ///< FPGA enable valves control. +#define FPGA_VBF_PWM_PULL_IN_MS ( 3 * MS_PER_SECOND ) ///< FPGA VBf PWM pull in in milliseconds. +#define FPGA_VBF_PWM_LOW 9999 ///< FPGA VBf PWM low. +#define FPGA_VBF_PWM_PERIOD 16666 ///< FPGA VBf PWM period. +#define FPGA_ENABLE_VALVES_PWM 0x0020 ///< FPGA enable valves PWM. #define CONCENTRATE_CAP_SWITCH_MASK 0x10 ///< Concentrate cap switch bit mask. #define DIALYSATE_CAP_SWITCH_MASK 0x20 ///< Dialysate cap switch bit mask. #define FPGA_THD_CONTROL_COMMAND 0X01 ///< FPGA THd control command. @@ -383,19 +387,19 @@ memset( &fpgaActuatorSetPoints, 0, sizeof( FPGA_ACTUATORS_T ) ); // Set the THd control register to 0x1 to make sure its ADC is running - fpgaActuatorSetPoints.fpgaTHdControlReg = FPGA_THD_CONTROL_COMMAND; - fpgaActuatorSetPoints.fpgaValveStates = FPGA_ENABLE_VALVES_CONTROL; + fpgaActuatorSetPoints.fpgaTHdControlReg = FPGA_THD_CONTROL_COMMAND; + fpgaActuatorSetPoints.fpgaValveStates = FPGA_ENABLE_VALVES_CONTROL; + fpgaActuatorSetPoints.fpgaValvePWMEnable = FPGA_ENABLE_VALVES_PWM; + fpgaActuatorSetPoints.fpgaVBfPWMPullin = FPGA_VBF_PWM_PULL_IN_MS; + fpgaActuatorSetPoints.fpgaVBfPWMLow = FPGA_VBF_PWM_LOW; + fpgaActuatorSetPoints.fpgaVBFPWMPeriod = FPGA_VBF_PWM_PERIOD; // initialize fpga comm buffers memset( &fpgaWriteCmdBuffer, 0, FPGA_WRITE_CMD_BUFFER_LEN ); memset( &fpgaReadCmdBuffer, 0, FPGA_READ_CMD_BUFFER_LEN ); memset( &fpgaWriteResponseBuffer, 0, FPGA_WRITE_RSP_BUFFER_LEN ); memset( &fpgaReadResponseBuffer, 0, FPGA_READ_RSP_BUFFER_LEN ); - // Assume the read byte size is set for V3 since V3 contains less number of bytes. - // Once the V3 or DVT build switch is set resize the number of bytes to read. - fpgaReadByteSize = FPGA_SIZE_OF_V3_READ_BYTES; - // enable interrupt notifications for FPGA serial port sciEnableNotification( scilinREG, SCI_OE_INT | SCI_FE_INT ); @@ -775,7 +779,7 @@ fpgaReadCmdBuffer[ 0 ] = FPGA_READ_CMD_CODE; fpgaReadCmdBuffer[ 1 ] = GET_LSB_OF_WORD( FPGA_BULK_READ_START_ADDR ); fpgaReadCmdBuffer[ 2 ] = GET_MSB_OF_WORD( FPGA_BULK_READ_START_ADDR ); - fpgaReadCmdBuffer[ 3 ] = fpgaReadByteSize; //sizeof( DG_FPGA_SENSORS_T ); + fpgaReadCmdBuffer[ 3 ] = fpgaReadByteSize; crc = crc16( fpgaReadCmdBuffer, FPGA_READ_CMD_HDR_LEN ); fpgaReadCmdBuffer[ 4 ] = GET_MSB_OF_WORD( crc ); fpgaReadCmdBuffer[ 5 ] = GET_LSB_OF_WORD( crc ); @@ -786,7 +790,7 @@ // prep DMA for sending the bulk read cmd and receiving its response setupDMAForReadCmd( FPGA_READ_CMD_HDR_LEN + FPGA_CRC_LEN ); - setupDMAForReadResp( FPGA_READ_RSP_HDR_LEN + fpgaReadByteSize /*sizeof( DG_FPGA_SENSORS_T )*/ + FPGA_CRC_LEN ); + setupDMAForReadResp( FPGA_READ_RSP_HDR_LEN + fpgaReadByteSize + FPGA_CRC_LEN ); // set fpga comm flags for bulk write cmd and follow-up bulk read command fpgaWriteCommandInProgress = TRUE; @@ -822,7 +826,7 @@ // did FPGA Ack the read command? if ( fpgaReadResponseBuffer[ 0 ] == FPGA_READ_CMD_ACK ) { - U32 rspSize = FPGA_READ_RSP_HDR_LEN + fpgaReadByteSize; //sizeof( DG_FPGA_SENSORS_T ); + U32 rspSize = FPGA_READ_RSP_HDR_LEN + fpgaReadByteSize; U32 crcPos = rspSize; U16 crc = MAKE_WORD_OF_BYTES( fpgaReadResponseBuffer[ crcPos ], fpgaReadResponseBuffer[ crcPos + 1 ] ); @@ -831,7 +835,7 @@ { fpgaCommRetryCount = 0; // capture the read values - memcpy( &fpgaSensorReadings, &fpgaReadResponseBuffer[ FPGA_READ_RSP_HDR_LEN ], fpgaReadByteSize /*sizeof( DG_FPGA_SENSORS_T )*/ ); + memcpy( &fpgaSensorReadings, &fpgaReadResponseBuffer[ FPGA_READ_RSP_HDR_LEN ], fpgaReadByteSize ); result = FPGA_STATE_WRITE_ALL_ACTUATORS; } else // bad CRC @@ -1235,8 +1239,6 @@ fpgaActuatorSetPoints.fpgaCP2StepSpeed = stepSpeed; } -/****************************DVT Functions*******************************************/ - /*********************************************************************//** * @brief * The setFPGAAcidPumpControl function sets the DVT concentrate pump 1 @@ -2135,6 +2137,19 @@ /*********************************************************************//** * @brief + * The getFPGABaroMfgInfo function gets the FPGA barometric pressure + * sensor manufacturing information. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return barometric pressure sensor manufacturing information + *************************************************************************/ +U16 getFPGABaroMfgInfo( void ) +{ + return fpgaSensorReadings.fpgaBaroManufacInfo; +} + +/*********************************************************************//** + * @brief * The getFPGABaroPressureSensitivity function gets the FPGA barometric pressure * sensor sensitivity. * @details Inputs: fpgaSensorReadings @@ -2213,6 +2228,19 @@ /*********************************************************************//** * @brief + * The getFPGABaroCoeffsCRC function gets the FPGA barometric pressure + * sensor temperature coefficients' CRC. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return barometric pressure sensor temperature coefficients' CRC + *************************************************************************/ +U16 getFPGABaroCoeffsCRC( void ) +{ + return fpgaSensorReadings.fpgaBaroPROMCRC; +} + +/*********************************************************************//** + * @brief * The getFPGABaroPressure function gets the FPGA barometric pressure sensor * pressure. * @details Inputs: fpgaSensorReadings @@ -2352,4 +2380,28 @@ return fpgaSensorReadings.fpgaDialysateFlowSensorEdgeCount; } +/*********************************************************************//** + * @brief + * The getFPGAHeaterGateADC function gets Heater Gate ADC value. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return heater gate adc value + *************************************************************************/ +U16 getFPGAHeaterGateADC( void ) +{ + return fpgaSensorReadings.fpgaHeaterGateADC; +} + +/*********************************************************************//** + * @brief + * The getFPGAHeaterGndADC function gets Heater Ground ADC value. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return heater ground adc value + *************************************************************************/ +U16 getFPGAHeaterGndADC( void ) +{ + return fpgaSensorReadings.fpgaHeaterGNDADC; +} + /**@}*/ Index: firmware/App/Services/FPGA.h =================================================================== diff -u -rb9d28fa9e2605dbb331da473fcf166dbf5346be5 -r45a5b4b93d1793860d5a000406591ee5cf6935d6 --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision b9d28fa9e2605dbb331da473fcf166dbf5346be5) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision 45a5b4b93d1793860d5a000406591ee5cf6935d6) @@ -7,8 +7,8 @@ * * @file FPGA.h * -* @author (last) Dara Navaei -* @date (last) 14-Mar-2022 +* @author (last) Darren Cox +* @date (last) 11-Aug-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -145,12 +145,14 @@ U08 getFPGABaroReadCount( void ); U08 getFPGABaroErrorCount( void ); +U16 getFPGABaroMfgInfo( void ); U16 getFPGABaroPressureSensitivity( void ); U16 getFPGABaroPressureOffset( void ); U16 getFPGABaroTempCoeffOfPressSensitvity( void ); U16 getFPGABaroTempCoeffOfPressOffset( void ); U16 getFPGABaroReferenceTemperature( void ); U16 getFPGABaroTempCoeffOfTemperature( void ); +U16 getFPGABaroCoeffsCRC( void ); U32 getFPGABaroPressure( void ); U32 getFPGABaroTemperature( void ); @@ -166,6 +168,9 @@ U16 getFPGAROFlowSensorEdgeCount( void ); U16 getFPGADialysateFlowSensorEdgeCount( void ); +U16 getFPGAHeaterGateADC( void ); +U16 getFPGAHeaterGndADC( void ); + /**@}*/ #endif Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -rcef8149cb8dfbd5c91c32f5318334c5db2366f7e -r45a5b4b93d1793860d5a000406591ee5cf6935d6 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision cef8149cb8dfbd5c91c32f5318334c5db2366f7e) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 45a5b4b93d1793860d5a000406591ee5cf6935d6) @@ -8,7 +8,7 @@ * @file SystemComm.c * * @author (last) Dara Navaei -* @date (last) 23-May-2022 +* @date (last) 21-Sep-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -817,6 +817,10 @@ handleAlarmClear( message ); break; + case MSG_ID_RTC_EPOCH: + handleRTCSyncFromHD( message ); + break; + case MSG_ID_SET_DG_DIALYSATE_TEMP_TARGETS: handleSetDialysateTemperatureCmd( message ); break; @@ -890,6 +894,10 @@ handleDGScheduledRunsRequest( message ); break; + case MSG_ID_HD_REQUEST_DG_SERVICE_MODE: + handleServiceModeRequest( message ); + break; + // NOTE: This case must be last case MSG_ID_DG_TESTER_LOGIN_REQUEST: handleTesterLogInRequest( message ); @@ -1198,6 +1206,14 @@ handleResendAllAlarmsCommand( message ); break; + case MSG_ID_DG_SET_OP_MODE_REQUEST: + handleTestSetOpModeRequest( message ); + break; + + case MSG_ID_DG_RESERVOIR_TARE_REQUEST: + handleTestTareReservoirRequest( message ); + break; + default: // TODO - unrecognized message ID received - ignore break; Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -ra89d6b091874136d75a9bfbdbbc1ff00f42467b3 -r45a5b4b93d1793860d5a000406591ee5cf6935d6 --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision a89d6b091874136d75a9bfbdbbc1ff00f42467b3) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 45a5b4b93d1793860d5a000406591ee5cf6935d6) @@ -23,6 +23,7 @@ #include "DrainPump.h" #include "Fans.h" #include "Heaters.h" +#include "Integrity.h" #include "NVDataMgmt.h" #include "OperationModes.h" #include "Reservoirs.h" @@ -119,6 +120,9 @@ // Heaters controller execHeaters(); + + // Monitor RAM error status + execRAMMonitor(); #endif // Run non-volatile data management state machine that sends the data record Index: firmware/App/Tasks/TaskPriority.c =================================================================== diff -u -r19056bcb960b73405326d038abcea63b6862e344 -r45a5b4b93d1793860d5a000406591ee5cf6935d6 --- firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 19056bcb960b73405326d038abcea63b6862e344) +++ firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 45a5b4b93d1793860d5a000406591ee5cf6935d6) @@ -8,7 +8,7 @@ * @file TaskPriority.c * * @author (last) Dara Navaei -* @date (last) 23-May-2022 +* @date (last) 04-Aug-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019