Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u -r562500cc109d166b32b7cc09cdf5ecbb36942419 -r35396d8fe531506b5c89bb0003744782ea168b93 --- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 562500cc109d166b32b7cc09cdf5ecbb36942419) +++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 35396d8fe531506b5c89bb0003744782ea168b93) @@ -63,9 +63,6 @@ #define VENOUS_PRESSURE_MAX_MMHG ( 2000.0 ) ///< Maximum venous pressure reading (in mmHg) for range check. #define VENOUS_PRESSURE_MIN_MMHG ( -1500.0 ) ///< Minimum venous pressure reading (in mmHg) for range check. -#define VENOUS_PRESSURE_MIN_TEMP ( 0.0 ) ///< Minimum venous pressure sensor temperature. -#define VENOUS_PRESSURE_MAX_TEMP ( 80.0 ) ///< Maximum venous pressure sensor temperature. - #define MIN_OCCLUSION_COUNTS ( 2000 ) ///< Minimum occlusion sensor reading for range check. #define PSI_TO_MMHG ( 51.7149 ) ///< Conversion factor for converting PSI to mmHg. @@ -105,23 +102,23 @@ /// Defined states for the pressure and occlusion monitor state machine. typedef enum PresOccl_States { - PRESSURE_INIT_STATE = 0, ///< Initialization state. - PRESSURE_CONTINUOUS_READ_STATE, ///< Continuous read sensors state. - NUM_OF_PRESSURE_STATES ///< Number of pressure/occlusion monitor states. + PRESSURE_WAIT_FOR_POST_STATE = 0, ///< Wait for POST state. + PRESSURE_CONTINUOUS_READ_STATE, ///< Continuous read sensors state. + NUM_OF_PRESSURE_STATES ///< Number of pressure/occlusion monitor states. } PRESSURE_STATE_T; /// Defined states for the pressure and occlusion self-test state machine. typedef enum PresOccl_Self_Test_States { - PRESSURE_SELF_TEST_STATE_START = 0, ///< Self test start state. - PRESSURE_TEST_STATE_IN_PROGRESS, ///< Self test in progress state. - PRESSURE_TEST_STATE_COMPLETE, ///< Self test completed state. - NUM_OF_PRESSURE_SELF_TEST_STATES ///< Number of pressure/occlusion self-test states. + PRESSURE_SELF_TEST_STATE_START = 0, ///< Self test start state. + PRESSURE_TEST_STATE_IN_PROGRESS, ///< Self test in progress state. + PRESSURE_TEST_STATE_COMPLETE, ///< Self test completed state. + NUM_OF_PRESSURE_SELF_TEST_STATES ///< Number of pressure/occlusion self-test states. } PRESSURE_SELF_TEST_STATE_T; // ********** private data ********** -static PRESSURE_STATE_T presOcclState = PRESSURE_INIT_STATE; ///< Current state of pressure monitor state machine. +static PRESSURE_STATE_T presOcclState; ///< Current state of pressure monitor state machine. static U32 presOcclDataPublicationTimerCounter = 0; ///< Used to schedule pressure data publication to CAN bus. /// Interval (in ms) at which to publish pressure/occlusion data to CAN bus. @@ -157,11 +154,13 @@ static U32 venPressureReadingsShortIdx = 0; ///< Index for next sample in rolling average array. static F32 venPressureReadingsShortTotal = 0.0; ///< Rolling total - used to calc average. static U32 venPressureReadingsShortCount = 0; ///< Number of samples in flow rolling average buffer. +static PRESSURE_SELF_TEST_STATE_T presOcclPostState; ///< Pressure self test post state. static HD_PRESSURE_SENSORS_CAL_RECORD_T pressureSensorsCalRecord; ///< Pressure sensors calibration record. static HD_OCCLUSION_SENSORS_CAL_RECORD_T occlusionSensorsCalRecord; ///< Occlusion sensors calibration record. // ********** private function prototypes ********** - + +static PRESSURE_STATE_T handlePresOcclWaitForPOSTState( void ); static PRESSURE_STATE_T handlePresOcclContReadState( void ); static void convertInlinePressures( void ); static void convertOcclusionPressures( void ); @@ -187,25 +186,26 @@ initPersistentAlarm( ALARM_ID_VENOUS_PRESSURE_HIGH, 0, PRES_ALARM_PERSISTENCE ); initPersistentAlarm( ALARM_ID_HD_ARTERIAL_PRESSURE_READ_TIMEOUT_ERROR, 0, PRES_ALARM_PERSISTENCE ); initPersistentAlarm( ALARM_ID_HD_VENOUS_PRESSURE_READ_TIMEOUT_ERROR, 0, PRES_ALARM_PERSISTENCE ); - initPersistentAlarm( ALARM_ID_HD_VENOUS_PRESSURE_SENSOR_TEMP_OUT_OF_RANGE, 0, PRES_ALARM_PERSISTENCE ); initPersistentAlarm( ALARM_ID_HD_BP_OCCLUSION_READ_TIMEOUT_ERROR, 0, PRES_ALARM_PERSISTENCE ); initPersistentAlarm( ALARM_ID_HD_BP_OCCLUSION_SENSOR_ERROR, 0, PRES_ALARM_PERSISTENCE ); initPersistentAlarm( ALARM_ID_HD_ARTERIAL_PRESSURE_OUT_OF_RANGE, 0, PRES_ALARM_PERSISTENCE ); initPersistentAlarm( ALARM_ID_HD_VENOUS_PRESSURE_OUT_OF_RANGE, 0, PRES_ALARM_PERSISTENCE ); initPersistentAlarm( ALARM_ID_HD_BP_OCCLUSION_OUT_OF_RANGE, 0, PRES_ALARM_PERSISTENCE ); lastArterialPressureReadCtr = 0; - lastVenousPressureReadCtr = 0; + lastVenousPressureReadCtr = 0; if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_PRESSURE_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) { lastBPOcclReadCtr = 0; lastBPErrorCtr = 0; } - longFilteredArterialPressure = 0.0; - shortFilteredArterialPressure = 0.0; - shortFilteredVenousPressure = 0.0; + longFilteredArterialPressure = 0.0; + shortFilteredArterialPressure = 0.0; + shortFilteredVenousPressure = 0.0; presOcclDataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; + presOcclState = PRESSURE_WAIT_FOR_POST_STATE; + presOcclPostState = PRESSURE_SELF_TEST_STATE_START; if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_PRESSURE_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) { @@ -289,7 +289,9 @@ *************************************************************************/ void setOcclusionInstallLevel( void ) { +#ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_PRESSURE_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) +#endif { bloodPumpOcclusionAfterCartridgeInstall = getMeasuredBloodPumpOcclusion(); } @@ -307,8 +309,8 @@ // State machine switch ( presOcclState ) { - case PRESSURE_INIT_STATE: - presOcclState = PRESSURE_CONTINUOUS_READ_STATE; + case PRESSURE_WAIT_FOR_POST_STATE: + presOcclState = handlePresOcclWaitForPOSTState(); break; case PRESSURE_CONTINUOUS_READ_STATE: @@ -322,6 +324,26 @@ // Publish pressure/occlusion data on interval publishPresOcclData(); +} + +/*********************************************************************//** + * @brief + * The handlePresOcclWaitForPOSTState function handles the wait for POST + * state. + * @details Inputs: presOcclPostState + * @details Outputs: none + * @return next state + *************************************************************************/ +static PRESSURE_STATE_T handlePresOcclWaitForPOSTState( void ) +{ + PRESSURE_STATE_T result = PRESSURE_WAIT_FOR_POST_STATE; + + if ( PRESSURE_TEST_STATE_COMPLETE == presOcclPostState ) + { + result = PRESSURE_CONTINUOUS_READ_STATE; + } + + return result; } /*********************************************************************//** @@ -385,25 +407,28 @@ U16 fpgaVenPres = getFPGAVenousPressure(); U16 venPres = fpgaVenPres & 0x3FFF; // 14-bit data U08 venPresStatus = (U08)( fpgaVenPres >> SHIFT_14_BITS ); // High 2 bits is status code for venous pressure - F32 venTemp = getTemperatureValue( TEMPSENSOR_VENOUS_PRESSURE_SENSOR ); U08 venReadCtr = getFPGAVenousPressureReadCounter(); - if ( ( ARTERIAL_PRESSURE_NORMAL_OP == artPresStatus ) && - ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_DVT_ARTERIAL_PRESSURE_SENSOR ) ) ) + if ( ARTERIAL_PRESSURE_NORMAL_OP == artPresStatus ) { - U08 artReadCtr = getFPGADVTArterialPressureReadCounter(); - - // Check for stale venous pressure reading - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_ARTERIAL_PRESSURE_READ_TIMEOUT_ERROR, ( lastArterialPressureReadCtr == artReadCtr ) ) ) +#ifndef _RELEASE_ + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_DVT_ARTERIAL_PRESSURE_SENSOR ) ) +#endif { - activateAlarmNoData( ALARM_ID_HD_ARTERIAL_PRESSURE_READ_TIMEOUT_ERROR ); - } - // Record arterial pressure sensor read counter for next time around - lastArterialPressureReadCtr = artReadCtr; + U08 artReadCtr = getFPGADVTArterialPressureReadCounter(); - arterialPressure.data = ( (F32)(rawArterialPres - ARTERIAL_PRESSURE_OFFSET) * - (ARTERIAL_PRESSURE_MAX_PSI - ARTERIAL_PRESSURE_MIN_PSI) / (F32)ARTERIAL_PRESSURE_SCALE ) + ARTERIAL_PRESSURE_MIN_PSI; - arterialPressure.data = arterialPressure.data * PSI_TO_MMHG; + // Check for stale venous pressure reading + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_ARTERIAL_PRESSURE_READ_TIMEOUT_ERROR, ( lastArterialPressureReadCtr == artReadCtr ) ) ) + { + activateAlarmNoData( ALARM_ID_HD_ARTERIAL_PRESSURE_READ_TIMEOUT_ERROR ); + } + // Record arterial pressure sensor read counter for next time around + lastArterialPressureReadCtr = artReadCtr; + + arterialPressure.data = ( (F32)(rawArterialPres - ARTERIAL_PRESSURE_OFFSET) * + (ARTERIAL_PRESSURE_MAX_PSI - ARTERIAL_PRESSURE_MIN_PSI) / (F32)ARTERIAL_PRESSURE_SCALE ) + ARTERIAL_PRESSURE_MIN_PSI; + arterialPressure.data = arterialPressure.data * PSI_TO_MMHG; + } } // Convert arterial pressure to mmHg if no fault else if ( 0 == artPresAlarm ) @@ -427,7 +452,9 @@ } else { +#ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_PRESSURE_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) +#endif { SET_ALARM_WITH_1_U32_DATA( ALARM_ID_ARTERIAL_PRESSURE_SENSOR_FAULT, (U32)artPresAlarm ) } @@ -459,14 +486,6 @@ // SET_ALARM_WITH_1_U32_DATA( ALARM_ID_VENOUS_PRESSURE_SENSOR_FAULT, (U32)venPresStatus ) // TODO - persistence? YES, need persistence - getting a stale data status. OR maybe speed up ADC in FPGA. } } - // TODO Why are we monitoring this sensor here? it should be in the temperatures driver - // TODO Why doesn't venous pressure have error counter? - // Check venous pressure sensor temperature - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_VENOUS_PRESSURE_SENSOR_TEMP_OUT_OF_RANGE, - ( venTemp > VENOUS_PRESSURE_MAX_TEMP || venTemp < VENOUS_PRESSURE_MIN_TEMP ) ) ) - { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_VENOUS_PRESSURE_SENSOR_FAULT, venTemp ) - } // Filter inline pressure readings filterInlinePressureReadings( getMeasuredArterialPressure(), getMeasuredVenousPressure() ); @@ -522,8 +541,7 @@ { F32 artPres = getFilteredArterialPressure(); - // DEBUG_DENALI. FOR MAKING SURE THE ARTERIAL PRESSURE CHEKC DOES NOT LOOSE THE RACE - /*if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_ARTERIAL_PRESSURE_CHECK ) != SW_CONFIG_ENABLE_VALUE ) + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_ARTERIAL_PRESSURE_CHECK ) != SW_CONFIG_ENABLE_VALUE ) { // Check arterial pressure is in range if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_ARTERIAL_PRESSURE_OUT_OF_RANGE, @@ -561,7 +579,7 @@ isPersistentAlarmTriggered( ALARM_ID_ARTERIAL_PRESSURE_LOW, FALSE ); isPersistentAlarmTriggered( ALARM_ID_ARTERIAL_PRESSURE_HIGH, FALSE ); } - }*/ + } } /*********************************************************************//** @@ -904,6 +922,8 @@ calStatus |= getNVRecord2Driver( GET_CAL_OCCLUSION_SESNSORS, (U08*)&occlusionSensorsCalRecord, sizeof( HD_OCCLUSION_SENSORS_CAL_RECORD_T ), NUM_OF_CAL_DATA_OCCLUSION_SENSORS, ALARM_ID_NO_ALARM ); + presOcclPostState = PRESSURE_TEST_STATE_COMPLETE; + if ( TRUE == calStatus ) { result = SELF_TEST_STATUS_PASSED; Index: firmware/App/Controllers/Temperatures.c =================================================================== diff -u -r29a2c3c7d7618489c0ada9f98e1d30226b455392 -r35396d8fe531506b5c89bb0003744782ea168b93 --- firmware/App/Controllers/Temperatures.c (.../Temperatures.c) (revision 29a2c3c7d7618489c0ada9f98e1d30226b455392) +++ firmware/App/Controllers/Temperatures.c (.../Temperatures.c) (revision 35396d8fe531506b5c89bb0003744782ea168b93) @@ -51,7 +51,7 @@ /// Temperatures exec states typedef enum thermistors_Exec_States { - TEMPERATURES_EXEC_STATE_START_STATE = 0, ///< Temperatures exec state start state. + TEMPERATURES_EXEC_STATE_WAIT_FOR_POST_STATE = 0, ///< Temperatures exec state wait for POST state. TEMPERATURES_EXEC_STATE_GET_ADC_VALUES_STATE, ///< Temperatures exec state get ADC values state. NUM_OF_TEMPERATURES_EXEC_STATES, ///< Number of temperatures exec state. } TEMPERATURES_EXEC_STATES_T; @@ -72,6 +72,7 @@ static U32 dataPublishCounter; ///< Temperatures data publish timer counter. static U32 adcReadCounter; ///< Temperatures ADC read counter. 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. @@ -80,31 +81,35 @@ 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. // ********** private function prototypes ********** -static TEMPERATURES_EXEC_STATES_T handleExecStart( void ); +static TEMPERATURES_EXEC_STATES_T handleExecWaitForPOST( void ); static TEMPERATURES_EXEC_STATES_T handleExecGetADCValues( void ); static void monitorTemperatures( void ); static void convertADC2Temperature( void ); -static F32 calculateThemristorTemperature( S32 adcValue ); +static F32 calculateThemristorTemperature( S32 adcValue ); static void publishTemperaturesData( void ); -static U32 getPublishTemperaturesDataInterval( void ); +static U32 getPublishTemperaturesDataInterval( void ); /*********************************************************************//** * @brief * The initTemperatures function initializes the temperatures module. * @details Inputs: none - * @details Outputs: temperaturesExecState, dataPublishCounter, temperaturesStatus + * @details Outputs: temperaturesExecState, dataPublishCounter, temperaturesStatus, + * isPOSTComplete * @return none *************************************************************************/ void initTemperatures( void ) { U08 i; - temperaturesExecState = TEMPERATURES_EXEC_STATE_START_STATE; + temperaturesExecState = TEMPERATURES_EXEC_STATE_WAIT_FOR_POST_STATE; dataPublishCounter = DATA_PUBLISH_COUNTER_START_COUNT; + isPOSTComplete = FALSE; for ( i = 0; i < NUM_OF_TEMPERATURES; i++ ) { @@ -129,6 +134,7 @@ BOOL calStatus = getNVRecord2Driver( GET_CAL_TEMPERATURE_SESNORS, (U08*)&temperaturesCalRecord, sizeof( HD_TEMP_SENSORS_CAL_RECORD_T ), NUM_OF_CAL_DATA_HD_TEMP_SENSORS, ALARM_ID_NO_ALARM ); + isPOSTComplete = TRUE; if ( TRUE == calStatus ) { @@ -161,8 +167,8 @@ // Read the sensors all the time switch ( temperaturesExecState ) { - case TEMPERATURES_EXEC_STATE_START_STATE: - temperaturesExecState = handleExecStart(); + case TEMPERATURES_EXEC_STATE_WAIT_FOR_POST_STATE: + temperaturesExecState = handleExecWaitForPOST(); break; case TEMPERATURES_EXEC_STATE_GET_ADC_VALUES_STATE: @@ -223,18 +229,18 @@ /*********************************************************************//** * @brief - * The handleExecStart function handles the start state of the exec state - * machine. + * The handleExecWaitForPOST function handles the wait for POST state of the + * exec state machine. * @details Inputs: adcReadCounter * @details Outputs: adcReadCounter * @return next state of the exec state machine *************************************************************************/ -static TEMPERATURES_EXEC_STATES_T handleExecStart( void ) +static TEMPERATURES_EXEC_STATES_T handleExecWaitForPOST( void ) { - TEMPERATURES_EXEC_STATES_T state = TEMPERATURES_EXEC_STATE_START_STATE; + TEMPERATURES_EXEC_STATES_T state = TEMPERATURES_EXEC_STATE_WAIT_FOR_POST_STATE; // Give a short time for FPGA to boot up and start sending the ADC reads - if ( ++adcReadCounter > ADC_FPGA_READ_DELAY_COUNT ) + if ( ( ++adcReadCounter > ADC_FPGA_READ_DELAY_COUNT ) && ( TRUE == isPOSTComplete ) ) { state = TEMPERATURES_EXEC_STATE_GET_ADC_VALUES_STATE; adcReadCounter = 0; @@ -265,6 +271,13 @@ temperaturesStatus[ TEMPSENSOR_VENOUS_PRESSURE_SENSOR ].rawADCRead = getFPGAVenousPressureTemperature(); temperaturesStatus[ TEMPSENSOR_PBA_ADC_SENSOR ].rawADCRead = getFPGAPBAADCTemperature(); +#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; } @@ -283,25 +296,27 @@ static void monitorTemperatures( void ) { TEMPERATURES_T sensor; + BOOL isTempOutOfRange = FALSE; - F32 temperature = 0.0; - U32 lastFaultSensor = 0; - F32 faultSensorTemp = 0.0; + F32 temperature = 0.0; + U32 lastFaultSensor = 0; + F32 faultSensorTemp = 0.0; for ( sensor = THERMISTOR_ONBOARD_NTC; sensor < NUM_OF_TEMPERATURES; sensor++ ) { temperature = getTemperatureValue( sensor ); + if ( ( temperature > MAX_ALLOWED_TEMPERATURE ) || ( temperature < MIN_ALLOWED_TEMPERATURE ) ) { isTempOutOfRange = TRUE; - lastFaultSensor = sensor; - faultSensorTemp = temperature; + lastFaultSensor = sensor; + faultSensorTemp = temperature; } } if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_TEMPERATURES_OUT_OF_RANGE, isTempOutOfRange ) ) { - //SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_TEMPERATURES_OUT_OF_RANGE, lastFaultSensor, faultSensorTemp ); // DEBUG_DENALI + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_TEMPERATURES_OUT_OF_RANGE, lastFaultSensor, faultSensorTemp ); } } @@ -343,11 +358,38 @@ break; case TEMPSENSOR_PBA_ADC_SENSOR: - // 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; + +#ifndef _RELEASE_ + // 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 ( 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; + } break; + case TEMPSENSOR_ARTERIAL_PRESSURE_SENSOR: + +#ifndef _RELEASE_ + // 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; + default: // Wrong sensor was called, raise an alarm SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_HD_INVALID_TEMPERATURE_SENSOR_SELECTED, sensor ); @@ -356,13 +398,21 @@ break; } - // 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; + // TODO remove this code and the if statement. This configuration is until the new arterial sensor is implemented everywhere so the temperature calibration + // 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; + if ( getSoftwareConfigStatus( SW_CONFIG_ENABLE_DVT_ARTERIAL_PRESSURE_SENSOR ) != SW_CONFIG_ENABLE_VALUE ) + { + // 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; + } + } } @@ -435,11 +485,12 @@ 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.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 broadcastData( MSG_ID_HD_TEMPERATURES_DATA, COMM_BUFFER_OUT_CAN_HD_BROADCAST, (U08*)&sensorsData, sizeof( TEMPERATURES_DATA_T ) ); Index: firmware/App/Controllers/Temperatures.h =================================================================== diff -u -r24b2fe72608344e67ef37234085d15ad5e4fcc37 -r35396d8fe531506b5c89bb0003744782ea168b93 --- firmware/App/Controllers/Temperatures.h (.../Temperatures.h) (revision 24b2fe72608344e67ef37234085d15ad5e4fcc37) +++ firmware/App/Controllers/Temperatures.h (.../Temperatures.h) (revision 35396d8fe531506b5c89bb0003744782ea168b93) @@ -41,6 +41,7 @@ TEMPSENSOR_FPGA_BOARD_SENSOR, ///< FPGA board temperature sensor TEMPSENSOR_VENOUS_PRESSURE_SENSOR, ///< Venous pressure sensor temperature TEMPSENSOR_PBA_ADC_SENSOR, ///< PBA ADC temperature sensor + TEMPSENSOR_ARTERIAL_PRESSURE_SENSOR, ///< Arterial pressure sensor temperature NUM_OF_TEMPERATURES, ///< Number of temperatures } TEMPERATURES_T; @@ -52,6 +53,7 @@ F32 fpgaBoardTempSensor; ///< FPGA board temperature sensor F32 venousPressSensorTemp; ///< Venous pressure sensor temperature F32 pbaADCTempSensor; ///< PBA ADC temperature sensor + F32 arterialPressSensorTemp; ///< Arterial pressure sensor temperature } TEMPERATURES_DATA_T; // ********** public function prototypes **********