Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -rc230be1bd4296324bf5dfc288c212eb7c2ce5d2d -r417631131615f93f77d6d1bfe44c385a8eab6d5b --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision c230be1bd4296324bf5dfc288c212eb7c2ce5d2d) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 417631131615f93f77d6d1bfe44c385a8eab6d5b) @@ -7,8 +7,8 @@ * * @file TemperatureSensors.c * -* @author (last) Dara Navaei -* @date (last) 15-Mar-2023 +* @author (last) Bill Bracken +* @date (last) 28-Mar-2023 * * @author (original) Dara Navaei * @date (original) 08-Apr-2020 @@ -121,7 +121,6 @@ U32 alarmStartTime; ///< Alarm start time U08 sensorErrorBitStatus; ///< Temperature sensor error bit status BOOL fpgaErrorStatus; ///< Temperature sensor FPGA error status - BOOL adcErrorStatus; ///< Temperature sensor ADC error status S32 baroTempSnsrDiff; ///< Barometric sensor temperature difference } TEMP_SENSOR_T; @@ -184,12 +183,6 @@ static const U32 TWO_TO_POWER_OF_8 = ( 1 << 8 ); ///< 2^8. static const U32 TWO_TO_POWER_OF_23 = ( 1 << 23 ); ///< 2^23. -// 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 ********** static TEMPSENSORS_EXEC_STATES_T handleExecStart( void ); @@ -333,7 +326,6 @@ initPersistentAlarm( ALARM_ID_DG_TEMPERATURE_SENSOR_OUT_OF_RANGE, TEMP_SENSORS_OUT_OF_RANGE_TIME_OUT_MS, TEMP_SENSORS_OUT_OF_RANGE_TIME_OUT_MS ); // Persistent alarm for the temperature sensors range check - initPersistentAlarm( ALARM_ID_DG_TEMPERATURE_SENSORS_ADC_FAULT, TEMP_SENSORS_OUT_OF_RANGE_TIME_OUT_MS, TEMP_SENSORS_OUT_OF_RANGE_TIME_OUT_MS ); initPersistentAlarm( ALARM_ID_DG_DIALYSATE_TEMPERATURE_SENSORS_OUT_OF_RANGE, 0, DIALYSATE_TEMP_SNSRS_OUT_OF_RANGE_TIMEOUT_MS ); // Initialize the FPGA persistent alarms @@ -435,6 +427,7 @@ case DG_MODE_GENE: case DG_MODE_FILL: case DG_MODE_DRAI: + case DG_MODE_STAN: if ( TRUE == isAlarmActive( ALARM_ID_INLET_WATER_TEMPERATURE_IN_HIGH_RANGE ) ) { isWaterTempInHighRange = ( temperature <= MIN_WATER_TEMPERATURE_WARNING_HIGH_RANGE ? FALSE : TRUE ); @@ -456,8 +449,6 @@ case DG_MODE_HEAT: case DG_MODE_HCOL: case DG_MODE_CHEM: - case DG_MODE_INIT: - case DG_MODE_STAN: case DG_MODE_CHFL: if ( VALVE_STATE_OPEN == getValveStateName( VPI ) ) { @@ -771,10 +762,8 @@ *************************************************************************/ static void processADCRead( U32 sensorIndex, S32 adc ) { - U08 i; F32 temperature; F32 avgADCReads; - BOOL isADCNotValid = FALSE; U32 index = tempSensors[ sensorIndex ].adcNextIndex; S32 indexValue = tempSensors[ sensorIndex ].rawADCReads [ index ]; @@ -784,23 +773,6 @@ 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_ADC_COUNT ) || - ( (U32)avgADCReads > TEMP_SENSORS_MAX_ADC_COUNT ) ? TRUE : FALSE ); - - for ( i = 0; i < NUM_OF_TEMPERATURE_SENSORS; i++ ) - { - // Loop through the temperature sensors and check the ADC range except the heater's temperature sensors. They are only - // used to display the temperature inside the heaters - if ( ( i != TEMPSENSORS_PRIMARY_HEATER_THERMO_COUPLE ) && ( i != TEMPSENSORS_TRIMMER_HEATER_THERMO_COUPLE ) && - ( i != TEMPSENSORS_PRIMARY_HEATER_COLD_JUNCTION ) && ( i != TEMPSENSORS_TRIMMER_HEATER_COLD_JUNCTION ) ) - { - isADCNotValid |= tempSensors[ sensorIndex ].adcErrorStatus; - } - } - - checkPersistentAlarm( ALARM_ID_DG_TEMPERATURE_SENSORS_ADC_FAULT, isADCNotValid, sensorIndex, avgADCReads ); - // Different sensors have different ADC to temperature conversion methods switch( sensorIndex ) { @@ -896,56 +868,51 @@ *************************************************************************/ static TEMPSENSORS_EXEC_STATES_T handleExecGetADCValues( void ) { - U32 errorCount = 0; U32 readCount = 0; - errorCount = (U32)getFPGARTDErrorCount(); readCount = (U32)getFPGARTDReadCount(); - checkFPGAPersistentAlarms( FPGA_PERS_ERROR_TWO_WIRE_ADC_TEMP_SENSORS, errorCount, readCount ); + checkFPGAPersistentAlarms( FPGA_PERS_ERROR_TWO_WIRE_ADC_TEMP_SENSORS, 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 ( getHardwareConfigStatus() != HW_CONFIG_BETA ) + if ( ( getHardwareConfigStatus() != HW_CONFIG_BETA ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) #endif { - if ( getCurrentOperationMode() != DG_MODE_INIT ) - { - errorCount = (U32)getFPGATHdErrorCount(); - readCount = (U32)getFPGATHdReadCount(); + readCount = (U32)getFPGATHdReadCount(); - checkFPGAPersistentAlarms( FPGA_PERS_ERROR_THD_ADC_TEMP_SENSORS, errorCount, readCount ); - processTempSnsrsADCRead( TEMPSENSORS_HEAT_DISINFECT, getFPGATHdTemp() ); - processTempSnsrsADCRead( TEMPSENSORS_INTERNAL_THD_RTD, getFPGATHdInternalTemp() ); + checkFPGAPersistentAlarms( FPGA_PERS_ERROR_THD_ADC_TEMP_SENSORS, readCount ); + processTempSnsrsADCRead( TEMPSENSORS_HEAT_DISINFECT, getFPGATHdTemp() ); - // Make sure the baro sensor coefficients are not corrupted - checkBaroSensorCRC(); + // Make sure the baro sensor coefficients are not corrupted + checkBaroSensorCRC(); - baroConvConsts.refTemperature = getFPGABaroReferenceTemperature(); - baroConvConsts.temperatureCoeff = getFPGABaroTempCoeffOfTemperature(); - errorCount = getFPGABaroErrorCount(); - readCount = getFPGABaroReadCount(); + processTempSnsrsADCRead( TEMPSENSORS_INTERNAL_THD_RTD, getFPGATHdInternalTemp() ); - checkFPGAPersistentAlarms( FPGA_PERS_ERROR_BARO_SENSOR, errorCount, readCount ); - processTempSnsrsADCRead( TEMPSENSORS_BAROMETRIC_TEMP_SENSOR, getFPGABaroTemperature() ); - } + // Make sure the baro sensor coefficients are not corrupted + checkBaroSensorCRC(); + + baroConvConsts.refTemperature = getFPGABaroReferenceTemperature(); + baroConvConsts.temperatureCoeff = getFPGABaroTempCoeffOfTemperature(); + readCount = getFPGABaroReadCount(); + + checkFPGAPersistentAlarms( FPGA_PERS_ERROR_BARO_SENSOR, readCount ); + processTempSnsrsADCRead( TEMPSENSORS_BAROMETRIC_TEMP_SENSOR, getFPGABaroTemperature() ); } - errorCount = (U32)getFPGATRoErrorCount(); readCount = (U32)getFPGATRoReadCount(); - checkFPGAPersistentAlarms( FPGA_PERS_ERROR_TRO_ADC_TEMP_SENSORS, errorCount, readCount ); + checkFPGAPersistentAlarms( FPGA_PERS_ERROR_TRO_ADC_TEMP_SENSORS, readCount ); processTempSnsrsADCRead( TEMPSENSORS_OUTLET_REDUNDANT, getFPGATRoTemp() ); processTempSnsrsADCRead( TEMPSENSORS_INTERNAL_TRO_RTD, getFPGATRoInternalTemp() ); - errorCount = (U32)getFPGATDiErrorCount(); readCount = (U32)getFPGATDiReadCount(); - checkFPGAPersistentAlarms( FPGA_PERS_ERROR_TDI_ADC_TEMP_SENSORS, errorCount, readCount ); + checkFPGAPersistentAlarms( FPGA_PERS_ERROR_TDI_ADC_TEMP_SENSORS, readCount ); processTempSnsrsADCRead( TEMPSENSORS_INLET_DIALYSATE, getFPGATDiTemp() ); processTempSnsrsADCRead( TEMPSENSORS_INTERNAL_TDI_RTD, getFPGATDiInternalTemp() ); @@ -1047,17 +1014,9 @@ 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 + // All other temperature sensors are only broadcast for logging/dialin purposes. temperature = getTemperatureValue( sensorId ); - // Check both temperature and to be in range if ( ( ( temperature < TEMP_SENSORS_MIN_ALLOWED_DEGREE_C ) || ( temperature > tempSensors[ sensorId ].maxAllowedTemp ) ) && ( getCurrentOperationMode() != DG_MODE_INIT ) )