Index: firmware/App/Controllers/Temperatures.c =================================================================== diff -u -r19a8bf98a7154e24c35da25225d4b55bf70ddd09 -r921034ee7092206a50183eacfaa73b436d2dee5f --- firmware/App/Controllers/Temperatures.c (.../Temperatures.c) (revision 19a8bf98a7154e24c35da25225d4b55bf70ddd09) +++ firmware/App/Controllers/Temperatures.c (.../Temperatures.c) (revision 921034ee7092206a50183eacfaa73b436d2dee5f) @@ -74,15 +74,13 @@ static HD_TEMP_SENSORS_CAL_RECORD_T temperaturesCalRecord; ///< Temperatures calibration record. static BOOL isPOSTComplete; ///< Temperatures POST complete flag. -static const F32 THERMISTOR_VOLTAGE_CONV_COEFF = THERMISTOR_REFERENCE_VOLTAGE / - (F32)TWELVE_BIT_RESOLUTION; ///< On board thermistor ADC to voltage conversion coefficient. -static const F32 ON_BOARD_THERMISTOR_REF_TEMP_INV = 1.0 / THERMISTOR_REFERENCE_TEMPERATURE; ///< On board thermistor reference inverse. -static const F32 FGPA_BOARD_TEMP_CONVERSION_COEFF = 503.975 / (F32)TWELVE_BIT_RESOLUTION; ///< FPGA board temperature conversion coefficient. -static const F32 VENOUS_PRESS_SENSOR_TEMP_CONVERSION_COEFF = 200.0 / 2047.0; ///< Venous pressure sensor temperature conversion coefficient. -static const F32 VENOUS_PRESS_SENSOR_TEMP_CONVERSION_CONSTANT = 50.0; ///< Venous pressure sensor temperature conversion constant. -static const F32 ADC_BOARD_TEMP_SENSOR_CONVERSION_COEFF = 1.0 / 13584.0; ///< ADC board temperatures sensor conversion coefficient. -static const F32 ART_PRESS_SENSOR_TEMP_CONVERSION_COEFF = 200.0 / 2047.0; ///< Arterial pressure sensor temperature conversion coefficient. -static const F32 ART_PRESS_SENSOR_TEMP_CONVERSION_CONSTANT = 50.0; ///< Arterial pressure sensor temperature conversion constant. +static const F32 THERMISTOR_VOLTAGE_CONV_COEFF = THERMISTOR_REFERENCE_VOLTAGE / + (F32)TWELVE_BIT_RESOLUTION; ///< On board thermistor ADC to voltage conversion coefficient. +static const F32 ON_BOARD_THERMISTOR_REF_TEMP_INV = 1.0 / THERMISTOR_REFERENCE_TEMPERATURE; ///< On board thermistor reference inverse. +static const F32 FGPA_BOARD_TEMP_CONVERSION_COEFF = 503.975 / (F32)TWELVE_BIT_RESOLUTION; ///< FPGA board temperature conversion coefficient. +static const F32 VENOUS_ART_PRES_SENSOR_TEMP_CONV_COEFF = 200.0 / 2047.0; ///< Arterial and venous pressure sensor temperature conversion coefficient. +static const F32 VENOUS_ART_PRES_SENSOR_TEMP_CONV_CONSTANT = 50.0; ///< Arterial and venous pressure sensor temperature conversion constant. +static const F32 ADC_BOARD_TEMP_SENSOR_CONVERSION_COEFF = 1.0 / 13584.0; ///< ADC board temperatures sensor conversion coefficient. // ********** private function prototypes ********** @@ -210,14 +208,7 @@ // Check if the temperature sensor is in range if ( sensorID < NUM_OF_TEMPERATURES ) { - if ( OVERRIDE_KEY == temperaturesStatus[ sensorID ].temperatureValue.override ) - { - temperature = temperaturesStatus[ sensorID ].temperatureValue.ovData; - } - else - { - temperature = temperaturesStatus[ sensorID ].temperatureValue.data; - } + temperature = getF32OverrideValue( &temperaturesStatus[ sensorID ].temperatureValue ); } else { @@ -242,8 +233,8 @@ // Give a short time for FPGA to boot up and start sending the ADC reads if ( ( ++adcReadCounter > ADC_FPGA_READ_DELAY_COUNT ) && ( TRUE == isPOSTComplete ) ) { - state = TEMPERATURES_EXEC_STATE_GET_ADC_VALUES_STATE; adcReadCounter = 0; + state = TEMPERATURES_EXEC_STATE_GET_ADC_VALUES_STATE; } return state; @@ -265,19 +256,12 @@ if ( ++adcReadCounter >= TEMPERATURES_ADC_READ_INTERVAL ) { // Get all the raw readings in ADC - temperaturesStatus[ THERMISTOR_ONBOARD_NTC ].rawADCRead = getIntADCReading( INT_ADC_BOARD_THERMISTOR ); - temperaturesStatus[ THERMISTOR_POWER_SUPPLY_1 ].rawADCRead = getIntADCReading( INT_ADC_PS_THERMISTOR ); - temperaturesStatus[ TEMPSENSOR_FPGA_BOARD_SENSOR ].rawADCRead = getFPGABoardTemperature(); - temperaturesStatus[ TEMPSENSOR_VENOUS_PRESSURE_SENSOR ].rawADCRead = getFPGAVenousPressureTemperature(); - temperaturesStatus[ TEMPSENSOR_PBA_ADC_SENSOR ].rawADCRead = getFPGAPBAADCTemperature(); + temperaturesStatus[ THERMISTOR_ONBOARD_NTC ].rawADCRead = getIntADCReading( INT_ADC_BOARD_THERMISTOR ); + temperaturesStatus[ THERMISTOR_POWER_SUPPLY_1 ].rawADCRead = getIntADCReading( INT_ADC_PS_THERMISTOR ); + temperaturesStatus[ TEMPSENSOR_FPGA_BOARD_SENSOR ].rawADCRead = getFPGABoardTemperature(); + temperaturesStatus[ TEMPSENSOR_VENOUS_PRESSURE_SENSOR ].rawADCRead = getFPGAVenousPressureTemperature(); + temperaturesStatus[ TEMPSENSOR_ARTERIAL_PRESSURE_SENSOR ].rawADCRead = getFPGADVTArterialTemperature(); -#ifndef _RELEASE_ - if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_DVT_ARTERIAL_PRESSURE_SENSOR ) ) -#endif - { - temperaturesStatus[ TEMPSENSOR_ARTERIAL_PRESSURE_SENSOR ].rawADCRead = getFPGADVTArterialTemperature(); - } - // Zero the counter for the next round of reading adcReadCounter = 0; } @@ -296,7 +280,6 @@ static void monitorTemperatures( void ) { TEMPERATURES_T sensor; - BOOL isTempOutOfRange = FALSE; F32 temperature = 0.0; U32 lastFaultSensor = 0; @@ -311,14 +294,6 @@ isTempOutOfRange = TRUE; lastFaultSensor = sensor; faultSensorTemp = temperature; - -#ifndef _RELEASE_ - if ( ( TEMPSENSOR_ARTERIAL_PRESSURE_SENSOR == sensor ) && - ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_DVT_ARTERIAL_PRESSURE_SENSOR ) != SW_CONFIG_ENABLE_VALUE ) ) - { - isTempOutOfRange = FALSE; - } -#endif } } @@ -361,43 +336,11 @@ break; case TEMPSENSOR_VENOUS_PRESSURE_SENSOR: + case TEMPSENSOR_ARTERIAL_PRESSURE_SENSOR: // Temperature (C) = ((ADC / 2047) * 200) - 50 - temperature = ( rawADC * VENOUS_PRESS_SENSOR_TEMP_CONVERSION_COEFF ) - VENOUS_PRESS_SENSOR_TEMP_CONVERSION_CONSTANT; + temperature = ( rawADC * VENOUS_ART_PRES_SENSOR_TEMP_CONV_COEFF ) - VENOUS_ART_PRES_SENSOR_TEMP_CONV_CONSTANT; break; - case TEMPSENSOR_PBA_ADC_SENSOR: - -#ifndef _RELEASE_ - // If the software configuration is not enabled to read the DVT arterial pressure, set the temperature to 30 to make sure - // there is no temperature error because the sensor is not available. The old arterial sensor did not have a temperature sensor - // inside it. NOTE: this line of code should be remove later. - if ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_DVT_ARTERIAL_PRESSURE_SENSOR ) != SW_CONFIG_ENABLE_VALUE ) -#endif - { - // Temperature (C) = ((ADC - 0x800000) / 13584) - 272.5 - temperature = ( ( rawADC - ADC_BOARD_TEMP_SENSOR_CONVERSION_CONST_2 ) * ADC_BOARD_TEMP_SENSOR_CONVERSION_COEFF ) - - ADC_BOARD_TEMP_SENSOR_CONVERSION_CONST_1; - } - temperature = 30.0; // TODO PBA_ADC temperature sensor has been remove from all of the devices. Remove the feature in DEN-12224. - break; - - case TEMPSENSOR_ARTERIAL_PRESSURE_SENSOR: - -#ifndef _RELEASE_ - // TODO - // If the software configuration is not enable to read the DVT arterial pressure, set the temperature to 30 to make sure - // there is no temperature error because the sensor is not available. The old arterial sensor did not have a temperature sensor - // inside it. NOTE: this line of code should be remove later. - temperature = 30.0; - - if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_DVT_ARTERIAL_PRESSURE_SENSOR ) ) -#endif - { - // Temperature (C) = ((ADC / 2047) * 200) - 50 - temperature = ( rawADC * ART_PRESS_SENSOR_TEMP_CONVERSION_COEFF ) - ART_PRESS_SENSOR_TEMP_CONVERSION_CONSTANT; - } - break; - #ifndef _VECTORCAST_ // The default cannot be reached in VectorCAST since the cases are run in a for loop default: @@ -413,20 +356,14 @@ // structure can be updated permanently. This way the PBA sensor will be replaced with the new arterial sensor. This is to make sure the // calibration structure does not fail in different devices with different sensors temperaturesStatus[ sensor ].temperatureValue.data = temperature; + // Apply the calibration record the temperature values prior to updating the structures + temperaturesStatus[ sensor ].temperatureValue.data = + pow( temperature, 4 ) * temperaturesCalRecord.hdTemperatureSensors[ (CAL_DATA_HD_TEMEPERATURE_SENSORS_T)sensor ].fourthOrderCoeff + + pow( temperature, 3 ) * temperaturesCalRecord.hdTemperatureSensors[ (CAL_DATA_HD_TEMEPERATURE_SENSORS_T)sensor ].thirdOrderCoeff + + pow( temperature, 2 ) * temperaturesCalRecord.hdTemperatureSensors[ (CAL_DATA_HD_TEMEPERATURE_SENSORS_T)sensor ].secondOrderCoeff + + temperature * temperaturesCalRecord.hdTemperatureSensors[ (CAL_DATA_HD_TEMEPERATURE_SENSORS_T)sensor ].gain + + temperaturesCalRecord.hdTemperatureSensors[ (CAL_DATA_HD_TEMEPERATURE_SENSORS_T)sensor ].offset; -#ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_DVT_ARTERIAL_PRESSURE_SENSOR ) != SW_CONFIG_ENABLE_VALUE ) -#endif - { - // Apply the calibration record the temperature values prior to updating the structures - temperaturesStatus[ sensor ].temperatureValue.data = - pow(temperature, 4) * temperaturesCalRecord.hdTemperatureSensors[ (CAL_DATA_HD_TEMEPERATURE_SENSORS_T)sensor ].fourthOrderCoeff + - pow(temperature, 3) * temperaturesCalRecord.hdTemperatureSensors[ (CAL_DATA_HD_TEMEPERATURE_SENSORS_T)sensor ].thirdOrderCoeff + - pow(temperature, 3) * temperaturesCalRecord.hdTemperatureSensors[ (CAL_DATA_HD_TEMEPERATURE_SENSORS_T)sensor ].secondOrderCoeff + - temperature * temperaturesCalRecord.hdTemperatureSensors[ (CAL_DATA_HD_TEMEPERATURE_SENSORS_T)sensor ].gain + - temperaturesCalRecord.hdTemperatureSensors[ (CAL_DATA_HD_TEMEPERATURE_SENSORS_T)sensor ].offset; - } - } } @@ -497,13 +434,11 @@ if ( ++dataPublishCounter > getPublishTemperaturesDataInterval() ) { TEMPERATURES_DATA_T sensorsData; - // Get all the sensors/thermistors temperature values for publication sensorsData.onboardThermistor = getTemperatureValue( THERMISTOR_ONBOARD_NTC ); sensorsData.powerSupply1Thermistor = getTemperatureValue( THERMISTOR_POWER_SUPPLY_1 ); sensorsData.venousPressSensorTemp = getTemperatureValue( TEMPSENSOR_VENOUS_PRESSURE_SENSOR ); sensorsData.fpgaBoardTempSensor = getTemperatureValue( TEMPSENSOR_FPGA_BOARD_SENSOR ); - sensorsData.pbaADCTempSensor = getTemperatureValue( TEMPSENSOR_PBA_ADC_SENSOR ); sensorsData.arterialPressSensorTemp = getTemperatureValue( TEMPSENSOR_ARTERIAL_PRESSURE_SENSOR ); // Broadcast the temperatures data