Index: firmware/App/Drivers/PressureSensor.c =================================================================== diff -u -re2e51b0219db0132cebb6f65f3dbd803e1f01e30 -rfefb47e88a5285e99498efb830fdceb9e95c2c3e --- firmware/App/Drivers/PressureSensor.c (.../PressureSensor.c) (revision e2e51b0219db0132cebb6f65f3dbd803e1f01e30) +++ firmware/App/Drivers/PressureSensor.c (.../PressureSensor.c) (revision fefb47e88a5285e99498efb830fdceb9e95c2c3e) @@ -20,6 +20,7 @@ #include "Messaging.h" #include "PersistentAlarm.h" #include "PressureSensor.h" +#include "TemperatureSensors.h" /** * @addtogroup PressureSensor @@ -29,17 +30,39 @@ // ********** private definitions ********** #define PRES_SENSORS_COUNT_ERROR_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Pressure sensors read and error count timeout in milliseconds. +#define ONE_BAR_TO_MILLI_BAR 1000 ///< 1 bar to milli-bar conversion. +#define COUNTS_TO_MILLI_BAR 100 ///< Counts to milli-bar conversion. +#define BAR_TO_MMHG ( 750.062F ) ///< Conversion factor for converting bar to mmHg. + +/// Barometric sensor conversion coefficients +typedef struct +{ + U16 pressureSensitivity; ///< Barometric sensor pressure sensitivity constant. + U16 pressureOffset; ///< Barometric sensor pressure offset constant. + U16 pressureSensitivityTempCoeff; ///< Barometric sensor pressure sensitivity temperature coefficient. + U16 pressureOffsetTempCoeff; ///< Barometric sensor pressure offset temperature coefficient. +} BARO_SENSOR_CONSTS_T; // ********** private data ********** static OVERRIDE_F32_T currentPressureReadings[ NUM_OF_PRESSURE_SENSORS ]; ///< Current pressure sensor pressure readings (overrideable). static OVERRIDE_F32_T currentPresTempReadings[ NUM_OF_PRESSURE_SENSORS ]; ///< Current pressure sensor temperature readings (overrideable). static OVERRIDE_U32_T lastPressureReadCounter[ NUM_OF_PRESSURE_SENSORS ]; ///< Last pressure sensor read count (Overrideable). static OVERRIDE_U32_T lastPressureErrorCounter[ NUM_OF_PRESSURE_SENSORS ]; ///< Last pressure sensor error count (Overrideable). +static BARO_SENSOR_CONSTS_T baroConvConsts; ///< Barometric sensor conversion constants. + +static const U32 TWO_TO_POWER_OF_6 = ( 1 << 6 ); ///< 2^6. +static const U32 TWO_TO_POWER_OF_7 = ( 1 << 7 ); ///< 2^7. +static const U32 TWO_TO_POWER_OF_15 = ( 1 << 15 ); ///< 2^15. +static const U32 TWO_TO_POWER_OF_16 = ( 1 << 16 ); ///< 2^16. +static const U32 TWO_TO_POWER_OF_17 = ( 1 << 17 ); ///< 2^17. +static const U32 TWO_TO_POWER_OF_21 = ( 1 << 21 ); ///< 2^21. // ********** private function prototypes ********** static void checkPressureSensors( void ); +static F32 convertBaroPressureReading2mmHg( U32 rawPressure ); +static F32 calculateBaroPressure( U32 pressure ); /*********************************************************************//** * @brief @@ -76,6 +99,12 @@ lastPressureErrorCounter[ i ].override = OVERRIDE_RESET; } + //Initialize baro variable + baroConvConsts.pressureOffset = 0; + baroConvConsts.pressureOffsetTempCoeff = 0; + baroConvConsts.pressureSensitivity = 0; + baroConvConsts.pressureSensitivityTempCoeff = 0; + // Initialize the FPGA persistent alarms initFPGAPersistentAlarm( FPGA_PERS_ERROR_HYDRAULICS_OUTLET_PRESSURE, ALARM_ID_DD_HYD_OUTLET_PRES_TIMEOUT_FAULT, PRES_SENSORS_COUNT_ERROR_TIMEOUT_MS, PRES_SENSORS_COUNT_ERROR_TIMEOUT_MS ); @@ -110,6 +139,7 @@ currentPressureReadings[ PRESSURE_SENSOR_SPENT_DIALYSATE ].data = convertPressureReading2mmHg( getFPGAPDsRawPressure() ); currentPressureReadings[ PRESSURE_SENSOR_FRESH_DIALYSATE ].data = convertPressureReading2mmHg( getFPGAPDfRawPressure() ); currentPressureReadings[ PRESSURE_SENSOR_TRANSMEMBRANE ].data = convertPressureReading2mmHg( getFPGAPtmRawPressure() ); + currentPressureReadings[ PRESSURE_SENSOR_BAROMETRIC ].data = convertBaroPressureReading2mmHg( getFPGABaroPressure() ); // Update and convert raw pressure sensor temperatures to deg C currentPresTempReadings[ PRESSURE_SENSOR_HYDRAULICS_OUTLET ].data = convertPressureTempReading2DegC( getFPGAPnRawTemperature() ); @@ -137,6 +167,52 @@ /*********************************************************************//** * @brief + * The convertBaroPressureReading2mmHg function converts the raw pressure counts + * in to mmHg unit. + * @details \b Inputs: FPGA + * @details \b Outputs: baroConvConsts + * @param rawPressure the raw baro sensor reading from FPGA. + * @return the converted baro pressure (in mmHg). + *************************************************************************/ +static F32 convertBaroPressureReading2mmHg( U32 rawPressure ) +{ + F32 baroPressure = 0.0F; + + baroConvConsts.pressureSensitivity = getFPGABaroPressureSensitivity(); + baroConvConsts.pressureSensitivityTempCoeff = getFPGABaroTempCoeffOfPressSensitvity(); + baroConvConsts.pressureOffset = getFPGABaroPressureOffset(); + baroConvConsts.pressureOffsetTempCoeff = getFPGABaroTempCoeffOfPressOffset(); + baroPressure = calculateBaroPressure( rawPressure ); + + return baroPressure; +} + +/*********************************************************************//** + * @brief + * The calculateBaroPressure function performs the required calculations + * to compute the baro pressure readings. + * @details \b Inputs: baroConvConsts + * @details \b Outputs: none + * @param pressure the raw baro sensor reading from FPGA. + * @return converted baro pressure (in mmHg). + *************************************************************************/ +static F32 calculateBaroPressure( U32 pressure ) +{ + S32 tempDiff = getBaroSensorTemperatureDiff(); + S64 tempOffset = ( baroConvConsts.pressureOffsetTempCoeff * tempDiff ) / TWO_TO_POWER_OF_6; + S64 presOffset = baroConvConsts.pressureOffset * TWO_TO_POWER_OF_17; + S64 offset = presOffset + tempOffset; + S64 tempSensitivity = ( baroConvConsts.pressureSensitivityTempCoeff * tempDiff ) / TWO_TO_POWER_OF_7; + S64 presSensitivity = baroConvConsts.pressureSensitivity * TWO_TO_POWER_OF_16; + S64 sensitivity = tempSensitivity + presSensitivity; + S32 pres = (S32)( ( ( pressure * sensitivity ) / TWO_TO_POWER_OF_21 ) - offset ) / TWO_TO_POWER_OF_15; + F32 presmmHg = ( (F32)pres / (F32)( COUNTS_TO_MILLI_BAR * ONE_BAR_TO_MILLI_BAR ) ) * BAR_TO_MMHG; + + return presmmHg; +} + +/*********************************************************************//** + * @brief * The checkPressureSensors function checks the read and error counters for * each pressure sensor. * @details \b Alarm: ALARM_ID_DD_HYD_OUTLET_PRES_TIMEOUT_FAULT if the Index: firmware/App/Drivers/PressureSensor.h =================================================================== diff -u -re2e51b0219db0132cebb6f65f3dbd803e1f01e30 -rfefb47e88a5285e99498efb830fdceb9e95c2c3e --- firmware/App/Drivers/PressureSensor.h (.../PressureSensor.h) (revision e2e51b0219db0132cebb6f65f3dbd803e1f01e30) +++ firmware/App/Drivers/PressureSensor.h (.../PressureSensor.h) (revision fefb47e88a5285e99498efb830fdceb9e95c2c3e) @@ -40,7 +40,8 @@ PRESSURE_SENSOR_BIBAG, ///< Dry Bicarb pressure (PDB/PCb) PRESSURE_SENSOR_SPENT_DIALYSATE, ///< Spent Dialysate pressure (PDs) PRESSURE_SENSOR_FRESH_DIALYSATE, ///< Fresh Dialysate pressure (PDf) - PRESSURE_SENSOR_TRANSMEMBRANE, ///< Transmembrane pressure (Ptm) + PRESSURE_SENSOR_TRANSMEMBRANE, ///< Transmembrane pressure (Ptm) + PRESSURE_SENSOR_BAROMETRIC, ///< barometric pressure sensor NUM_OF_PRESSURE_SENSORS ///< Number of pressure sensors } PRESSURE_SENSORS_T; Index: firmware/App/Drivers/TemperatureSensors.c =================================================================== diff -u --- firmware/App/Drivers/TemperatureSensors.c (revision 0) +++ firmware/App/Drivers/TemperatureSensors.c (revision fefb47e88a5285e99498efb830fdceb9e95c2c3e) @@ -0,0 +1,613 @@ +/************************************************************************** +* +* Copyright (c) 2024-2024 Diality Inc. - All Rights Reserved. +* +* THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +* WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +* +* @file TemperatureSensors.c +* +* @author (last) Vinayakam Mani +* @date (last) 23-Sep-2024 +* +* @author (original) Vinayakam Mani +* @date (original) 23-Sep-2024 +* +***************************************************************************/ +#include // For temperature calculation +#include // For memset() + +#include "FpgaDD.h" +#include "MessageSupport.h" +#include "Messaging.h" +//#include "NVDataMgmt.h" +#include "OperationModes.h" +#include "PersistentAlarm.h" +#include "TemperatureSensors.h" +#include "Timers.h" +#include "Utilities.h" + +/** + * @addtogroup TemperatureSensors + * @{ + */ + +// ********** private definitions ********** + +#define PRIMARY_HEATER_TEMP_SENSORS_GAIN 8U ///< Primary heater temperature sensors gain. +#define PRIMARY_HEATER_TEMP_SENSORS_REF_RESISTANCE 20000 ///< Primary heater temperature sensors reference resistance. +#define PRIMARY_HEATER_TEMP_SENSORS_0_DEGREE_RESISTANCE 1000U ///< Primary heater temperature sensors zero degree resistance. +#define PRIMARY_HEATER_TEMP_SENSORS_V3_REF_RESISTANCE 19600 ///< Primary heater temperature sensors V3 reference resistance. + +#define TEMP_SENSORS_ADC_BITS 24U ///< External temperature sensors ADC bits. +#define MAX_NUM_OF_RAW_ADC_SAMPLES 4U ///< Number of ADC reads for moving average calculations. +#define SHIFT_BITS_BY_2 2U ///< Shift bits by 2 to create a 4 for averaging 4 samples. +#define SHIFT_BITS_BY_2_FOR_AVERAGING 2U ///< Shift the ADCs of the temperature sensors by 2 to average them. + +#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 ADC_BOARD_TEMP_SENSORS_CONST 0x800000 ///< ADC board temperature sensors constant. + +#define TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Temperature sensors FPGA error timeout in milliseconds. + +#define TEMP_SENSORS_MIN_ALLOWED_DEGREE_C 0.0F ///< Temperature sensors minimum allowed temperature in C. +#define TEMP_SENSORS_MAX_ALLOWED_DEGREE_C 120.0F ///< Temperature sensors maximum allowed temperature in C. +#define HEATERS_INTERNAL_TEMP_SENSORS_MAX_ALLOWED_DEGREE_C 200.0F ///< Heaters' internal temperature sensors maximum allowed temperature in C. +#define NON_FLUID_PATH_TEMP_SENSORS_MAX_ALLOWED_DEGREE_C 80.0F ///< Non fluid temperature sensors path maximum allowed temperature in C. +#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. + +/// Temperature sensor struct. +typedef struct +{ + F32 gain; ///< ADC gain + F32 refResistance; ///< ADC reference resistance + F32 conversionCoeff; ///< ADC conversion coefficient + F32 zeroDegreeResistance; ///< ADC zero degree resistance + S32 rawADCReads[ MAX_NUM_OF_RAW_ADC_SAMPLES ]; ///< Raw ADC reads array + S32 adcNextIndex; ///< Next ADC read index + S32 adcRunningSum; ///< ADC running sum + OVERRIDE_F32_T temperatureValue; ///< Temperature values with override + F32 maxAllowedTemp; ///< Maximum allowed temperature of the sensor + S32 baroTempSnsrDiff; ///< Barometric sensor temperature difference +} TEMP_SENSOR_T; + +/// Barometric sensor temperature conversion +typedef struct +{ + 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 - 6 type of 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 TEMP_SENSOR_T tempSensors [ NUM_OF_TEMPERATURE_SENSORS ]; ///< Temperature sensors' data structure. +static OVERRIDE_U32_T lastTemperatureReadCounter; ///< Temperature sensors read count from FPGA. +static OVERRIDE_U32_T lastBaroTempReadCounter; ///< Barometric sensor read count from FPGA. +static BARO_SENSOR_CONSTS_T baroConvConsts; ///< Barometric sensor conversion constants. + +//static DD_TEMP_SENSORS_CAL_RECORD_T tempSensorCalRecord; ///< Temperature sensors calibration record. + +static const U32 TEMP_EQUATION_RESISTOR_CALC = 1 << ( TEMP_SENSORS_ADC_BITS - 1 ); ///< Temperature sensors resistor calculation (2^(24 - 1)). +static const F32 TEMP_EQUATION_COEFF_A = 3.9083E-3; ///< ADC to temperature conversion coefficient A. +static const F32 TEMP_EQUATION_COEFF_B = -5.775E-7; ///< ADC to temperature conversion coefficient B. +static const U32 TWO_TO_POWER_OF_8 = ( 1 << 8 ); ///< 2^8. +static const U32 TWO_TO_POWER_OF_23 = ( 1 << 23 ); ///< 2^23. + +// ********** private function prototypes ********** + +static F32 getADC2TempConversion( F32 avgADC, U32 gain, U32 refResistance, U32 zeroDegResistance, F32 adcConversionCoeff ); +static void processTempSnsrsADCRead( U32 sensorIndex, U32 adc ); +static void processADCRead( U32 sensorIndex, S32 adc ); +static void checkBaroSensorCRC( void ); +static void checkTemperatureSensors( void ); +static void getCalibrationAppliedTemperatureValue( U32 sesnorIndex, F32* temperature ); + +/*********************************************************************//** + * @brief + * The initTemperatureSensors function initializes the temperature sensors unit. + * @details \b Inputs: none + * @details \b Outputs: unit variables initialized + * @return none + *************************************************************************/ +void initTemperatureSensors( void ) +{ + U08 i; + F32 conversionCoeff = 1.0F / 13584.0F; + + baroConvConsts.coeffsCRC.data = 0; + baroConvConsts.hasCRCBeenChecked = FALSE; + baroConvConsts.waitForCoeffStartTimeMS = 0; + + for ( i = 0; i < NUM_OF_TEMPERATURE_SENSORS; ++i ) + { + memset( &tempSensors[ i ], 0x0, sizeof( TEMP_SENSOR_T ) ); + //benignPolynomialCalRecord( &tempSensorCalRecord.tempSensors[ i ] ); + } + + // Initialize the barometric sensor's temperature conversion constants + memset( &baroConvConsts, 0x0, sizeof( BARO_SENSOR_CONSTS_T ) ); + + // Initialize TH1 (primary heater), TH2(outlet Heat Exchanger), TAUX ( Inlet Heat exchanger), + // TH3 ( Trim Heater) constants. For now, assume same gain across all sensors. + tempSensors[ TEMPSENSORS_INLET_HEAT_EXCHANGER ].gain = PRIMARY_HEATER_TEMP_SENSORS_GAIN; + tempSensors[ TEMPSENSORS_INLET_HEAT_EXCHANGER ].refResistance = PRIMARY_HEATER_TEMP_SENSORS_REF_RESISTANCE; + tempSensors[ TEMPSENSORS_INLET_HEAT_EXCHANGER ].zeroDegreeResistance = PRIMARY_HEATER_TEMP_SENSORS_0_DEGREE_RESISTANCE; + tempSensors[ TEMPSENSORS_INLET_HEAT_EXCHANGER ].maxAllowedTemp = TEMP_SENSORS_MAX_ALLOWED_DEGREE_C; + + tempSensors[ TEMPSENSORS_OUTLET_HEAT_EXCHANGER ].gain = PRIMARY_HEATER_TEMP_SENSORS_GAIN; + tempSensors[ TEMPSENSORS_OUTLET_HEAT_EXCHANGER ].refResistance = PRIMARY_HEATER_TEMP_SENSORS_REF_RESISTANCE; + tempSensors[ TEMPSENSORS_OUTLET_HEAT_EXCHANGER ].zeroDegreeResistance = PRIMARY_HEATER_TEMP_SENSORS_0_DEGREE_RESISTANCE; + tempSensors[ TEMPSENSORS_OUTLET_HEAT_EXCHANGER ].maxAllowedTemp = TEMP_SENSORS_MAX_ALLOWED_DEGREE_C; + + tempSensors[ TEMPSENSORS_HYDRAULICS_PRIMARY_HEATER ].gain = PRIMARY_HEATER_TEMP_SENSORS_GAIN; + tempSensors[ TEMPSENSORS_HYDRAULICS_PRIMARY_HEATER ].refResistance = PRIMARY_HEATER_TEMP_SENSORS_REF_RESISTANCE; + tempSensors[ TEMPSENSORS_HYDRAULICS_PRIMARY_HEATER ].zeroDegreeResistance = PRIMARY_HEATER_TEMP_SENSORS_0_DEGREE_RESISTANCE; + tempSensors[ TEMPSENSORS_HYDRAULICS_PRIMARY_HEATER ].maxAllowedTemp = HEATERS_INTERNAL_TEMP_SENSORS_MAX_ALLOWED_DEGREE_C; + + tempSensors[ TEMPSENSORS_TRIMMER_HEATER ].gain = PRIMARY_HEATER_TEMP_SENSORS_GAIN; + tempSensors[ TEMPSENSORS_TRIMMER_HEATER ].refResistance = PRIMARY_HEATER_TEMP_SENSORS_REF_RESISTANCE; + tempSensors[ TEMPSENSORS_TRIMMER_HEATER ].zeroDegreeResistance = PRIMARY_HEATER_TEMP_SENSORS_0_DEGREE_RESISTANCE; + tempSensors[ TEMPSENSORS_TRIMMER_HEATER ].maxAllowedTemp = TEMP_SENSORS_MAX_ALLOWED_DEGREE_C; + + // Board temperature sensors conversion coefficient + tempSensors[ TEMPSENSORS_BOARD_TEMPERATURE ].conversionCoeff = conversionCoeff; + tempSensors[ TEMPSENSORS_BOARD_TEMPERATURE ].maxAllowedTemp = NON_FLUID_PATH_TEMP_SENSORS_MAX_ALLOWED_DEGREE_C; + + tempSensors[ TEMPSENSORS_BAROMETRIC_TEMP_SENSOR ].maxAllowedTemp = NON_FLUID_PATH_TEMP_SENSORS_MAX_ALLOWED_DEGREE_C; + + // Persistent alarm for the temperature sensors range check + initPersistentAlarm( ALARM_ID_DD_TEMPERATURE_SENSOR_OUT_OF_RANGE, TEMP_SENSORS_OUT_OF_RANGE_TIME_OUT_MS, TEMP_SENSORS_OUT_OF_RANGE_TIME_OUT_MS ); + + // Initialize the FPGA persistent alarms + initFPGAPersistentAlarm( FPGA_PERS_ERROR_RTD_ADC_TEMP_SENSORS, ALARM_ID_DD_RTD_SENSORS_FPGA_FAULT, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS); + initFPGAPersistentAlarm( FPGA_PERS_ERROR_BARO_SENSOR, ALARM_ID_DD_BARO_SENSOR_FPGA_FAULT, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS); +} + +/*********************************************************************//** + * @brief + * The getTemperatureValue function gets the temperature of the requested + * sensor. + * @details \b Inputs: tempSensors + * @details \b Outputs: none + * @details \b Alarms: ALARM_ID_DD_SOFTWARE_FAULT when invalid temperature + * sensor is seen. + * @param sensorIndex which is the temperature sensor index + * @return temperature of the requested sensor + *************************************************************************/ +F32 getTemperatureValue( U32 sensorIndex ) +{ + F32 temperature = 0.0F; + + if ( sensorIndex < NUM_OF_TEMPERATURE_SENSORS ) + { + temperature = getF32OverrideValue( &tempSensors[ sensorIndex ].temperatureValue ); + } + else + { + // Wrong sensor was called, raise an alarm + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_TEMPERATURE_SENSOR_SELECTED1, sensorIndex ); + } + + return temperature; +} + +/*********************************************************************//** + * @brief + * The getBaroSensorTemperatureDiff function returns the barometric pressure + * sensor's temperature difference. + * @details \b Inputs: tempSensors + * @details \b Outputs: none + * @return barometric pressure sensor temperature difference + *************************************************************************/ +S32 getBaroSensorTemperatureDiff( void ) +{ + return tempSensors[ TEMPSENSORS_BAROMETRIC_TEMP_SENSOR ].baroTempSnsrDiff; +} + +/*********************************************************************//** + * @brief + * The setBaroSensorCoefficientReadStartTime function populates the start + * time of baro sensor coefficient read transaction initiated to FPGA. + * @details \b Inputs: none + * @details \b Outputs: baroConvConsts + * @return none + *************************************************************************/ +void setBaroSensorCoefficientReadStartTime( void ) +{ + baroConvConsts.waitForCoeffStartTimeMS = getMSTimerCount(); +} + +/*********************************************************************//** + * @brief + * The readTemperatureSensors function reads the temperature sensor + * value from FPGA. + * @details \b Inputs: FPGA + * @details \b Outputs: lastTemperatureReadCounter,lastBaroTempReadCounter + * @return none + *************************************************************************/ +void readTemperatureSensors( void ) +{ + // Temperature sensor read count from FPGA + lastTemperatureReadCounter.data = (U32)getFPGARTDReadCount(); + + //Read temperature sensors + processTempSnsrsADCRead( TEMPSENSORS_INLET_HEAT_EXCHANGER, getFPGAInletHeatExchangerTemp() ); + processTempSnsrsADCRead( TEMPSENSORS_OUTLET_HEAT_EXCHANGER, getFPGAOutletHeatExchangerTemp() ); + processTempSnsrsADCRead( TEMPSENSORS_HYDRAULICS_PRIMARY_HEATER, getFPGAHydraulicsPrimaryHeaterTemp() ); + processTempSnsrsADCRead( TEMPSENSORS_TRIMMER_HEATER, getFPGATrimmerHeaterTemp() ); + + //TODO: Read Board temperture + //processTempSnsrsADCRead( TEMPSENSORS_INTERNAL_COND_TEMP_SENSOR, getFPGACondSnsrInternalTemp() ); + + //Read Baro temperature sensor + if ( getCurrentOperationMode() != DD_MODE_INIT ) + { + // Make sure the baro sensor coefficients are not corrupted + checkBaroSensorCRC(); + + baroConvConsts.refTemperature = getFPGABaroReferenceTemperature(); + baroConvConsts.temperatureCoeff = getFPGABaroTempCoeffOfTemperature(); + lastBaroTempReadCounter.data = (U32)getFPGABaroReadCount(); + + processTempSnsrsADCRead( TEMPSENSORS_BAROMETRIC_TEMP_SENSOR, getFPGABaroTemperature() ); + } +} + +/*********************************************************************//** + * @brief + * The getTemperatureSensorsReadCount function gets the current temperature sensor + * read count for the RTD temperature sensors. + * @details \b Inputs: lastTemperatureReadCounter + * @details \b Outputs: none + * @return The RTD temperature sensor read count. + *************************************************************************/ +U32 getTemperatureSensorsReadCount( void ) +{ + U32 result = 0; + + result = lastTemperatureReadCounter.data; + if ( OVERRIDE_KEY == lastTemperatureReadCounter.override ) + { + result = lastTemperatureReadCounter.ovData; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The getBaroTempSensorsReadCount function gets the barometric temperature sensor + * read count. + * @details \b Inputs: lastBaroTempReadCounter + * @details \b Outputs: none + * @return The barometric temperature sensor read count. + *************************************************************************/ +U32 getBaroTempSensorsReadCount( void ) +{ + U32 result = 0; + + result = lastBaroTempReadCounter.data; + if ( OVERRIDE_KEY == lastBaroTempReadCounter.override ) + { + result = lastBaroTempReadCounter.ovData; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The checkTemperatureSensors function checks the temperature sensor + * freshness and see if there is any read failures from FPGA. + * @details \b Inputs: FPGA + * @details \b Outputs: none + * @details \b Alarms: ALARM_ID_DD_RTD_SENSORS_FPGA_FAULT when temperature sensor + * read count not updated periodically + * @details \b Alarms: ALARM_ID_DD_BARO_SENSOR_FPGA_FAULT when baro temperature sensor + * read count not updated periodically + * @return none + *************************************************************************/ +static void checkTemperatureSensors( void ) +{ + checkFPGAPersistentAlarms( FPGA_PERS_ERROR_RTD_ADC_TEMP_SENSORS, getTemperatureSensorsReadCount() ); + checkFPGAPersistentAlarms( FPGA_PERS_ERROR_BARO_SENSOR, getBaroTempSensorsReadCount() ); +} + +/*********************************************************************//** + * @brief + * The getADC2TempConversion function calculates the temperature from the + * moving average ADC samples. + * @details \b Inputs: tempEquationCoeffA, tempEquationCoeffB + * @details \b Outputs: none + * @param avgADC moving average ADC + * @param gain ADC gain + * @param refResistance ADC reference resistance + * @param zeroDegResistance ADC zero degree resistance + * @param adcConversionCoeff ADC conversion coefficient + * @return calculated temperature + *************************************************************************/ +static F32 getADC2TempConversion( F32 avgADC, U32 gain, U32 refResistance, U32 zeroDegResistance, F32 adcConversionCoeff ) +{ + F32 temperature = 0.0F; + + if ( fabs( adcConversionCoeff ) <= NEARLY_ZERO ) + { + // R(RTD) = R(ref) * ( adc – 2^(N - 1) ) / ( G * 2^(N - 1) ); + F32 resistance = ( refResistance * ( avgADC - TEMP_EQUATION_RESISTOR_CALC ) ) / ( gain * TEMP_EQUATION_RESISTOR_CALC ); + // T = (-A + √( A^2 - 4B * ( 1 - R_T / R_0 ) ) ) / 2B + F32 secondSqrtPart = 4 * TEMP_EQUATION_COEFF_B * ( 1 - ( resistance / zeroDegResistance ) ); + temperature = ( -TEMP_EQUATION_COEFF_A + sqrt( pow( TEMP_EQUATION_COEFF_A, 2 ) - secondSqrtPart ) ) / ( 2 * TEMP_EQUATION_COEFF_B ); + } + else + { + temperature = avgADC * adcConversionCoeff; + } + + return temperature; +} + +/*********************************************************************//** + * @brief + * The processTemperatureSensorsADCRead function masks the MSB of the ADC + * read from FPGA and converts it to an S32. Then it calls the routine + * that checks if the read ADC is valid or not and if it is, to process + * the ADC value and covert it to temperature. + * @details \b Inputs: none + * @details \b Outputs: none + * @param sensorIndex ID of temperature sensor to process + * @param adc ADC value for the temperature sensor + * @return none + *************************************************************************/ +static void processTempSnsrsADCRead( U32 sensorIndex, U32 adc ) +{ + S32 convertedADC = (S32)( adc & MASK_OFF_U32_MSB ); + + // Make sure the error bit is not true before + processADCRead( sensorIndex, convertedADC ); +} + +/*********************************************************************//** + * @brief + * The processADCRead function receives the ADC value and the sensor + * index and calculates the running sum and the moving average of the ADCs + * The temperatureSensorsADCRead and tempSensorsAvgADCValues are updated. + * @details \b Inputs: tempSensors + * @details \b Outputs: tempSensors + * @details \b Alarms: ALARM_ID_DD_SOFTWARE_FAULT when invalid temperature + * sensor is seen. + * @param sensorIndex Temperature sensor index + * @param adc adc reading from FPGA + * @return none + *************************************************************************/ +static void processADCRead( U32 sensorIndex, S32 adc ) +{ + F32 temperature; + F32 avgADCReads; + 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 + + // Different sensors have different ADC to temperature conversion methods + switch( sensorIndex ) + { + case TEMPSENSORS_INLET_HEAT_EXCHANGER: + case TEMPSENSORS_OUTLET_HEAT_EXCHANGER: + case TEMPSENSORS_HYDRAULICS_PRIMARY_HEATER: + case TEMPSENSORS_TRIMMER_HEATER: + temperature = getADC2TempConversion( avgADCReads, (U32)tempSensors [ sensorIndex ].gain, (U32)tempSensors [ sensorIndex ].refResistance, + (U32)tempSensors [ sensorIndex ].zeroDegreeResistance, tempSensors [ sensorIndex ].conversionCoeff ); + break; + + case TEMPSENSORS_BOARD_TEMPERATURE: + //TODO : Need details on calculations. + break; + + case TEMPSENSORS_BAROMETRIC_TEMP_SENSOR: + { + S32 baroTempSensorsDiff = (S32)avgADCReads - ( baroConvConsts.refTemperature * TWO_TO_POWER_OF_8 ); + S64 differenceTimesCoefficient = (S64)baroTempSensorsDiff * (S64)baroConvConsts.temperatureCoeff; + S64 baroSnsrTemperature = BARO_SENSOR_REFERENCE_TEMP_C + ( differenceTimesCoefficient / TWO_TO_POWER_OF_23 ); + + temperature = (F32)( baroSnsrTemperature / 100.0F ); + tempSensors[ sensorIndex ].baroTempSnsrDiff = baroTempSensorsDiff; + } + break; + + default: + // Wrong sensor was called, raise an alarm + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_TEMPERATURE_SENSOR_SELECTED2, sensorIndex ); + // Wrong sensor, return temperature to be -1 + temperature = -1.0F; + break; + } + + getCalibrationAppliedTemperatureValue( sensorIndex, &temperature ); + // Update the temperature + tempSensors[ sensorIndex ].temperatureValue.data = temperature; +} + + +/*********************************************************************//** + * @brief + * The monitorTemperatureSensors function monitors the temperature sensors' + * temperature value and raises an alarm if any of them are out of range + * for more than the specified time. + * @details \b Inputs: tempSensors + * @details \b Outputs: tempSensors + * @details \b Alarms: ALARM_ID_DD_TEMPERATURE_SENSOR_OUT_OF_RANGE when the + * measured temperature exceeds the maximum limit temperature. + * @return none + *************************************************************************/ +void monitorTemperatureSenors( void ) +{ + TEMPERATURE_SENSORS_T sensorId; + TEMPERATURE_SENSORS_T sensorInAlarm = TEMPSENSORS_FIRST; + F32 temperature = 0.0F; + BOOL isTemperatureOutOfRange = FALSE; + F32 alarmTemperature = 0.0F; + + for ( sensorId = TEMPSENSORS_FIRST; sensorId < NUM_OF_TEMPERATURE_SENSORS; sensorId++ ) + { + switch ( sensorId ) + { + case TEMPSENSORS_INLET_HEAT_EXCHANGER: + case TEMPSENSORS_OUTLET_HEAT_EXCHANGER: + case TEMPSENSORS_HYDRAULICS_PRIMARY_HEATER: + case TEMPSENSORS_TRIMMER_HEATER: + case TEMPSENSORS_BAROMETRIC_TEMP_SENSOR: + // Get temperature value. + temperature = getTemperatureValue( sensorId ); + // Check both temperature and to be in range + if ( ( ( temperature < TEMP_SENSORS_MIN_ALLOWED_DEGREE_C ) || ( temperature > tempSensors[ sensorId ].maxAllowedTemp ) ) && + ( getCurrentOperationMode() != DD_MODE_INIT ) ) + { + isTemperatureOutOfRange |= TRUE; + sensorInAlarm = sensorId; + alarmTemperature = temperature; + } + break; + + default: + // Ignore the other sensors + break; + } + + } + + checkPersistentAlarm( ALARM_ID_DD_TEMPERATURE_SENSOR_OUT_OF_RANGE, isTemperatureOutOfRange, sensorInAlarm, alarmTemperature ); + + //check freshness of temperature read + checkTemperatureSensors(); +} + +/*********************************************************************//** + * @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 \b Inputs: hasBaroCoeffsBeenChecked + * @details \b Outputs: hasBaroCoeffsBeenChecked + * @details \b Alarms: ALARM_ID_DD_BAROMETRIC_SENSOR_COEFFS_BAD_CRC when baro + * temperature sensor coefficient CRC changes. + * @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_DD_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_DD_BAROMETRIC_SENSOR_COEFFS_BAD_CRC, 0, baroCRC ); + } +} + +/*********************************************************************//** + * @brief + * The getCalibrationAppliedTemperatureValue function applies the calibration + * values to the provided temperature value + * @details \b Inputs: tempSensorCalRecord + * @details \b Outputs: none + * @param sensorIndex Temperature sensor index + * @param temperature pointer to the calculated temperature value + * @return none + *************************************************************************/ +static void getCalibrationAppliedTemperatureValue( U32 sesnorIndex, F32* temperature ) +{ + //CAL_DATA_DD_TEMP_SENSORS_T calId; + F32 tempTemperature = *temperature; + + switch( sesnorIndex ) + { + case TEMPSENSORS_INLET_HEAT_EXCHANGER: + //calId = CAL_DATA_INLET_HEAT_EXCHANGER_TEMP; + break; + + case TEMPSENSORS_OUTLET_HEAT_EXCHANGER: + //calId = CAL_DATA_OUTLET_HEAT_EXCHANGER_TEMP; + break; + + case TEMPSENSORS_HYDRAULICS_PRIMARY_HEATER: + //calId = CAL_DATA_HYD_PRIMARY_HEATER_TEMP; + break; + + case TEMPSENSORS_TRIMMER_HEATER: + //calId = CAL_DATA_TRIM_HEATER_TEMP; + break; + + case TEMPSENSORS_BAROMETRIC_TEMP_SENSOR: + //calId = CAL_DATA_BARMOTERIC_TEMP; + break; + + default: + // Set the calibration temperature value as num of meaning calibration is not needed for the provided sensor + //calId = NUM_OF_CAL_DATA_TEMP_SENSORS; + break; + } + +// if ( calId != NUM_OF_CAL_DATA_TEMP_SENSORS ) +// { +// *temperature = pow( tempTemperature, 4 ) * tempSensorCalRecord.tempSensors[ calId ].fourthOrderCoeff + +// pow( tempTemperature, 3 ) * tempSensorCalRecord.tempSensors[ calId ].thirdOrderCoeff + +// pow( tempTemperature, 2 ) * tempSensorCalRecord.tempSensors[ calId ].secondOrderCoeff + +// tempTemperature * tempSensorCalRecord.tempSensors[ calId ].gain + +// tempSensorCalRecord.tempSensors[ calId ].offset; +// } +} + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/**@}*/ Index: firmware/App/Drivers/TemperatureSensors.h =================================================================== diff -u --- firmware/App/Drivers/TemperatureSensors.h (revision 0) +++ firmware/App/Drivers/TemperatureSensors.h (revision fefb47e88a5285e99498efb830fdceb9e95c2c3e) @@ -0,0 +1,62 @@ +/************************************************************************** +* +* Copyright (c) 2024-2024 Diality Inc. - All Rights Reserved. +* +* THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +* WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +* +* @file TemperatureSensors.h +* +* @author (last) Vinayakam Mani +* @date (last) 24-Sep-2024 +* +* @author (original) Vinayakam Mani +* @date (original) 24-Sep-2024 +* +***************************************************************************/ + +#ifndef __TEMPERATURE_SENSORS_H__ +#define __TEMPERATURE_SENSORS_H__ + +#include "DDCommon.h" +//#include "NVDataMgmt.h" + +/** + * @defgroup TemperatureSensors TemperatureSensors + * @brief Temperature Sensors driver module. Reads and processes the temperature sensors. + * 2 wire/ 3 wire RTD : PT1000 temperature sensor interfaced to FPGA ADC. + * + * @addtogroup TemperatureSensors + * @{ + */ + +// ********** public definitions ********** + +/// Enumeration of temperature sensors. +typedef enum SENSORS_NAME +{ + TEMPSENSORS_INLET_HEAT_EXCHANGER = 0, ///< First temp sensor to scan + TEMPSENSORS_FIRST = TEMPSENSORS_INLET_HEAT_EXCHANGER, ///< Heat exchanger Inlet temperature sensor + TEMPSENSORS_OUTLET_HEAT_EXCHANGER, ///< Heat exchanger Outlet temperature sensor + TEMPSENSORS_HYDRAULICS_PRIMARY_HEATER, ///< Hydraulics primary heater temperature sensor + TEMPSENSORS_TRIMMER_HEATER, ///< Trimmer heater temperature sensor + TEMPSENSORS_BAROMETRIC_TEMP_SENSOR, ///< Barometric temperature sensor + TEMPSENSORS_BOARD_TEMPERATURE, ///< DD board temperature sensor ( thermistor ) + NUM_OF_TEMPERATURE_SENSORS ///< Number of temperature sensors +} TEMPERATURE_SENSORS_T; + +// ********** public function prototypes ********** + +void initTemperatureSensors( void ); + +F32 getTemperatureValue( U32 sensorIndex ); +S32 getBaroSensorTemperatureDiff( void ); +void readTemperatureSensors( void ); +void monitorTemperatureSenors( void ); +U32 getTemperatureSensorsReadCount( void ); +U32 getBaroTempSensorsReadCount( void ); +void setBaroSensorCoefficientReadStartTime( void ); + +/**@}*/ + +#endif Index: firmware/App/Monitors/Pressure.c =================================================================== diff -u -re2e51b0219db0132cebb6f65f3dbd803e1f01e30 -rfefb47e88a5285e99498efb830fdceb9e95c2c3e --- firmware/App/Monitors/Pressure.c (.../Pressure.c) (revision e2e51b0219db0132cebb6f65f3dbd803e1f01e30) +++ firmware/App/Monitors/Pressure.c (.../Pressure.c) (revision fefb47e88a5285e99498efb830fdceb9e95c2c3e) @@ -33,6 +33,7 @@ #define PRESSURE_TEMP_SAMPLE_FILTER_MS ( 200 ) ///< Filter temperature data for given time #define SIZE_OF_PRESSURE_ROLLING_AVG ( PRESSURE_SAMPLE_FILTER_MS / TASK_PRIORITY_INTERVAL ) ///< Filtered pressure moving average. #define SIZE_OF_PRESSURETEMP_ROLLING_AVG ( PRESSURE_TEMP_SAMPLE_FILTER_MS / TASK_PRIORITY_INTERVAL ) ///< Filtered pressure temprature w/ 1 second moving average. +#define MMHG_TO_PSI_CONVERSION 0.0193368F ///< MMHG to PSI conversion. /// Defined states for the pressures monitor state machine. typedef enum PresMonitor_States @@ -64,6 +65,7 @@ static OVERRIDE_F32_T filteredcurrentPressureReadings[ NUM_OF_PRESSURE_SENSORS ]; ///< filtered current pressure sensor pressure readings (overrideable). static OVERRIDE_F32_T filteredcurrentPresTempReadings[ NUM_OF_PRESSURE_SENSORS ]; ///< filtered current pressure sensor temperature readings (overrideable). +//static DD_PRES_SENSORS_CAL_RECORD_T pressuresCalRecord; ///< Pressures calibration record. static FILTER_PRESSURE_READINGS_T filteredPressureReadings[NUM_OF_PRESSURE_SENSORS]; ///< Filtered pressure reading for pressure sensors. static FILTER_PRESSURE_TEMPERATURE_READINGS_T filteredPressureTempReadings[NUM_OF_PRESSURE_SENSORS]; ///< Filtered pressure reading for pressure sensors. @@ -76,6 +78,8 @@ static void filterPressureSensorReadings( void ); static void filterPressureSensorTemperatureReadings( void ); +//static F32 getCalibrationAppliedPressure( U08 sensorId, F32 pressure ); +static F32 getConvertedPressure( PRESSURE_SENSORS_T sensor, F32 pressure ); static PRESSURE_STATE_T handlePressuresInitState( void ); static PRESSURE_STATE_T handlePressuresContReadState( void ); static void publishPressuresData( void ); @@ -136,7 +140,6 @@ //Filter pressure sensor temperature reading filterPressureSensorTemperatureReadings(); - } /*********************************************************************//** @@ -245,7 +248,8 @@ for ( i = (U32)PRESSURE_SENSOR_FIRST; i < (U32)NUM_OF_PRESSURE_SENSORS; i++ ) { - F32 pressure = getPressure( (PRESSURE_SENSORS_T)i ); + F32 pressureinmmHG = getPressure( (PRESSURE_SENSORS_T)i ); + F32 pressure = getConvertedPressure( (PRESSURE_SENSORS_T)i, pressureinmmHG ); if ( filteredPressureReadings[i].pressureReadingsCount >= SIZE_OF_PRESSURE_ROLLING_AVG ) { @@ -286,6 +290,45 @@ filteredcurrentPresTempReadings[i].data = filteredPressureTempReadings[i].pressureTempReadingsTotal / (F32)filteredPressureTempReadings[i].pressureTempReadingsCount; } } + +/*********************************************************************//** + * @brief + * The getConvertedPressure function converts the pressure in PSI unit and + * calibration applied to it. + * @details \b Inputs: none + * @details \b Outputs: none + * @return next state + *************************************************************************/ +static F32 getConvertedPressure( PRESSURE_SENSORS_T sensor, F32 pressure ) +{ + F32 baroPressurePSI = getPressure( PRESSURE_SENSOR_BAROMETRIC ) * MMHG_TO_PSI_CONVERSION; + F32 pressurePSI = pressure * MMHG_TO_PSI_CONVERSION; + + // calibrated pressure + //F32 calPressure = getCalibrationAppliedPressure( sensor, gaugePressure ); + + return pressurePSI; +} + +/*********************************************************************//** + * @brief + * The getCalibrationAppliedPressure function applies the calibration values + * to the provided pressure and returns the values. + * @details \b Inputs: pressuresCalRecord + * @details \b Outputs: none + * @param sensorId the ID of the pressure sensor + * @param pressure the pressure before applying calibration to it + * @return calibration applied pressure + *************************************************************************/ +//static F32 getCalibrationAppliedPressure( U08 sensorId, F32 pressure ) +//{ +// F32 calPressure = pow( pressure, 4 ) * pressuresCalRecord.pressureSensors[ (PRESSURE_SENSORS_T)sensorId ].fourthOrderCoeff + +// pow( pressure, 3 ) * pressuresCalRecord.pressureSensors[ (PRESSURE_SENSORS_T)sensorId ].thirdOrderCoeff + +// pow( pressure, 2 ) * pressuresCalRecord.pressureSensors[ (PRESSURE_SENSORS_T)sensorId ].secondOrderCoeff + +// pressure * pressuresCalRecord.pressureSensors[ (PRESSURE_SENSORS_T)sensorId ].gain + +// pressuresCalRecord.pressureSensors[ (PRESSURE_SENSORS_T)sensorId ].offset; +// return calPressure; +//} /*********************************************************************//** * @brief Index: firmware/App/Monitors/Temperature.c =================================================================== diff -u --- firmware/App/Monitors/Temperature.c (revision 0) +++ firmware/App/Monitors/Temperature.c (revision fefb47e88a5285e99498efb830fdceb9e95c2c3e) @@ -0,0 +1,228 @@ +/************************************************************************** +* +* Copyright (c) 2024-2024 Diality Inc. - All Rights Reserved. +* +* THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +* WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +* +* @file Temperature.c +* +* @author (last) Vinayakam Mani +* @date (last) 23-Sep-2024 +* +* @author (original) Vinayakam Mani +* @date (original) 23-Sep-2024 +* +***************************************************************************/ + +#include "Messaging.h" +#include "MessageSupport.h" +#include "OperationModes.h" +#include "Temperature.h" +#include "Timers.h" +#include "TaskPriority.h" +#include "Utilities.h" + +/** + * @addtogroup Temperature + * @{ + */ + +// ********** private definitions ********** +#define ADC_FPGA_READ_DELAY 30U ///< Delay in ms before reading the ADC values from FPGA. + +#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 DATA_PUBLISH_COUNTER_START_COUNT 30 ///< Data publish counter start count. + +/// Temperature sensor exec states. +typedef enum tempSensors_Exec_States +{ + TEMPSENSORS_EXEC_STATE_START = 0, ///< Temperature sensors exec start + TEMPSENSORS_EXEC_STATE_GET_ADC_VALUES, ///< Temperature sensors exec get ADC values + NUM_OF_TEMPSENSORS_EXEC_STATES, ///< Total number of exec states +} TEMPSENSORS_EXEC_STATES_T; + +// ********** private data ********** + +static TEMPSENSORS_EXEC_STATES_T tempSensorsExecState; ///< TemperatureSensor exec state. +static U32 elapsedTime; ///< Elapsed time variable. + +static U32 dataPublicationTimerCounter; ///< Temperature sensors data publish timer counter. +static OVERRIDE_U32_T tempSensorsPublishInterval = { TEMP_SENSORS_DATA_PUBLISH_INTERVAL, + TEMP_SENSORS_DATA_PUBLISH_INTERVAL, 0, 0 }; ///< Temperature sensors publish time interval override. + +// ********** private function prototypes ********** + +static TEMPSENSORS_EXEC_STATES_T handleExecStart( void ); +static TEMPSENSORS_EXEC_STATES_T handleExecGetADCValues( void ); +static void publishTemperatureSensorsData( void ); + +/*********************************************************************//** + * @brief + * The initTemperature function initializes the temperature unit. + * @details \b Inputs: none + * @details \b Outputs: temperature unit variables initialized. + * @return none + *************************************************************************/ +void initTemperature( void ) +{ + elapsedTime = 0; + tempSensorsExecState = TEMPSENSORS_EXEC_STATE_START; + dataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; + + // Initialize the temperature sensors + initTemperatureSensors(); +} + +/*********************************************************************//** + * @brief + * The execTemperatureSensorsSelfTest function runs the TemperatureSensors + * POST during the self-test. + * @details \b Inputs: none + * @details \b Outputs: none + * @return tempSensorsSelfTestState which is the status of the self test + *************************************************************************/ +SELF_TEST_STATUS_T execTemperatureSensorsSelfTest( void ) +{ + SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; + + //BOOL calStatus = getNVRecord2Driver( GET_CAL_TEMP_SENSORS, (U08*)&tempSensorCalRecord, sizeof( DD_TEMP_SENSORS_CAL_RECORD_T ), + // NUM_OF_CAL_DATA_TEMP_SENSORS, ALARM_ID_DD_TEMPERATURE_SENSORS_INVALID_CAL_RECORD ); + BOOL calStatus = TRUE; + + if ( TRUE == calStatus ) + { + result = SELF_TEST_STATUS_PASSED; + } + else + { + result = SELF_TEST_STATUS_FAILED; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The execTemperatureSensors function executes the temperature sensors' + * state machine. + * @details \b Inputs: tempSensorsExecState + * @details \b Outputs: tempSensorsExecState + * @details \b Alarms: ALARM_ID_DD_SOFTWARE_FAULT when invalid temperature + * sensor is seen. + * @return none + *************************************************************************/ +void execTemperatureSensors( void ) +{ + // Check if a new calibration is available +// if ( TRUE == isNewCalibrationRecordAvailable() ) +// { +// getNVRecord2Driver( GET_CAL_TEMP_SENSORS, (U08*)&tempSensorCalRecord, sizeof( DD_TEMP_SENSORS_CAL_RECORD_T ), +// NUM_OF_CAL_DATA_TEMP_SENSORS, ALARM_ID_DD_TEMPERATURE_SENSORS_INVALID_CAL_RECORD ); +// } + + // Read the sensors all the time + switch ( tempSensorsExecState ) + { + case TEMPSENSORS_EXEC_STATE_START: + tempSensorsExecState = handleExecStart(); + break; + + case TEMPSENSORS_EXEC_STATE_GET_ADC_VALUES: + tempSensorsExecState = handleExecGetADCValues(); + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_TEMPERATURE_SENSORS_EXEC_INVALID_STATE, tempSensorsExecState ); + tempSensorsExecState = TEMPSENSORS_EXEC_STATE_GET_ADC_VALUES; + break; + } + + // Monitor the temperature values + monitorTemperatureSenors(); + + // Publish the data + publishTemperatureSensorsData(); +} + +/*********************************************************************//** + * @brief + * The handleExecStart function waits for a period of time and switches to + * the state that reads the ADC values from FPGA. + * @details \b Inputs: elapsedTime + * @details \b Outputs: elapsedTime, baroCoeffsWaitToRcvStartTime + * @return the next state of the state machine + *************************************************************************/ +static TEMPSENSORS_EXEC_STATES_T handleExecStart( void ) +{ + TEMPSENSORS_EXEC_STATES_T state = TEMPSENSORS_EXEC_STATE_START; + + if ( 0 == elapsedTime ) + { + elapsedTime = getMSTimerCount(); + } + // A delay to let FPGA to boot up + else if ( TRUE == didTimeout( elapsedTime, ADC_FPGA_READ_DELAY ) ) + { + elapsedTime = 0; + setBaroSensorCoefficientReadStartTime(); + state = TEMPSENSORS_EXEC_STATE_GET_ADC_VALUES; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleExecGetADCValues function reads the ADC values from FPGA and + * at the specified time intervals and calls required functions to calculate + * the actual tempetature from the raw ADC values. + * @details \b Inputs: FPGA + * @details \b Outputs: temperature value. + * @return the next state of the state machine + *************************************************************************/ +static TEMPSENSORS_EXEC_STATES_T handleExecGetADCValues( void ) +{ + // Read temperature sensors + readTemperatureSensors(); + + return TEMPSENSORS_EXEC_STATE_GET_ADC_VALUES; +} + +/*********************************************************************//** + * @brief + * The publishTemperatureSensorsData function broadcasts the temperature + * sensors data at the publication interval. + * @details \b Inputs: dataPublicationTimerCounter, tempValuesForPublication + * @details \b Outputs: dataPublicationTimerCounter, tempValuesForPublication + * @details \b Message \b Sent: MSG_ID_DD_TEMPERATURE_DATA publishes the temperature + * data in a periodic interval. + * @return none + *************************************************************************/ +static void publishTemperatureSensorsData( void ) +{ + if ( ++dataPublicationTimerCounter >= getU32OverrideValue( &tempSensorsPublishInterval ) ) + { + TEMPERATURE_SENSORS_DATA_T data; + + data.inletHeatExchanger = getTemperatureValue( TEMPSENSORS_INLET_HEAT_EXCHANGER ); + data.outletHeatExchanger = getTemperatureValue( TEMPSENSORS_OUTLET_HEAT_EXCHANGER ); + data.hydraulicsPrimaryHeater = getTemperatureValue( TEMPSENSORS_HYDRAULICS_PRIMARY_HEATER ); + data.trimmerHeater = getTemperatureValue( TEMPSENSORS_TRIMMER_HEATER ); + data.boardTemp = getTemperatureValue( TEMPSENSORS_BOARD_TEMPERATURE ); + data.baroTempSensor = getTemperatureValue( TEMPSENSORS_BAROMETRIC_TEMP_SENSOR ); + + broadcastData( MSG_ID_DD_TEMPERATURE_DATA, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&data, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); + dataPublicationTimerCounter = 0; + } +} + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/**@}*/ Index: firmware/App/Monitors/Temperature.h =================================================================== diff -u --- firmware/App/Monitors/Temperature.h (revision 0) +++ firmware/App/Monitors/Temperature.h (revision fefb47e88a5285e99498efb830fdceb9e95c2c3e) @@ -0,0 +1,55 @@ +/************************************************************************** +* +* Copyright (c) 2024-2024 Diality Inc. - All Rights Reserved. +* +* THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +* WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +* +* @file Temperature.h +* +* @author (last) Vinayakam Mani +* @date (last) 23-Sep-2024 +* +* @author (original) Vinayakam Mani +* @date (original) 23-Sep-2024 +* +***************************************************************************/ + +#ifndef __TEMPERATURE_H__ +#define __TEMPERATURE_H__ + +#include "DDCommon.h" +#include "TemperatureSensors.h" + +/** + * @defgroup Temperature Temperature + * @brief Temperature Monitor module. Reads and processes the temperature sensors. + * + * @addtogroup Temperature + * @{ + */ + +// ********** public definitions ********** + +/// Temperature sensors data structure. +typedef struct +{ + F32 inletHeatExchanger; ///< Inlet heat exchanger temperature sensor + F32 outletHeatExchanger; ///< Outlet heat exchanger temperature sensor + F32 hydraulicsPrimaryHeater; ///< Hydraulics primary heater temperature sensor + F32 trimmerHeater; ///< Trimmer heater temperature sensor + F32 boardTemp; ///< Board temperature sensor + F32 baroTempSensor; ///< Barometric temperature sensor +} TEMPERATURE_SENSORS_DATA_T; + + +// ********** public function prototypes ********** + +void initTemperature( void ); +SELF_TEST_STATUS_T execTemperatureSensorsSelfTest( void ); +void execTemperatureSensors( void ); + + +/**@}*/ + +#endif Index: firmware/App/Services/AlarmMgmtSWFaults.h =================================================================== diff -u -r3a87ca0e2a722318216623d7e1f4c354c58c506c -rfefb47e88a5285e99498efb830fdceb9e95c2c3e --- firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision 3a87ca0e2a722318216623d7e1f4c354c58c506c) +++ firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision fefb47e88a5285e99498efb830fdceb9e95c2c3e) @@ -115,7 +115,9 @@ SW_FAULT_ID_INVALID_CONDUCTIVITY_SENSOR_ID8 = 84, SW_FAULT_ID_CONCENTRATE_PUMP_EXEC_INVALID_STATE = 85, SW_FAULT_ID_CONCENTRATE_PUMP_INVALID_PUMP_ID = 86, - + SW_FAULT_ID_INVALID_TEMPERATURE_SENSOR_SELECTED1 = 87, + SW_FAULT_ID_INVALID_TEMPERATURE_SENSOR_SELECTED2 = 88, + SW_FAULT_ID_TEMPERATURE_SENSORS_EXEC_INVALID_STATE = 89, NUM_OF_SW_FAULT_IDS } SW_FAULT_ID_T; Index: firmware/App/Services/FpgaDD.c =================================================================== diff -u -r3a87ca0e2a722318216623d7e1f4c354c58c506c -rfefb47e88a5285e99498efb830fdceb9e95c2c3e --- firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision 3a87ca0e2a722318216623d7e1f4c354c58c506c) +++ firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision fefb47e88a5285e99498efb830fdceb9e95c2c3e) @@ -183,8 +183,28 @@ U08 fpgaValveUFStates; ///< Reg 352. Ultrafiltration Valves states U08 fpgaValveUFPWMStates; ///< Reg 353. Ultrafiltration Valves PWM states U08 fpgaCPACPBFault; ///< Reg 354. Concentrate pump fault register for CPA and CPB - U16 fpgaCPAHallSense; ///< Reg 356. Concentrate pump CPA hall sensor pulse width - U16 fpgaCPBHallSense; ///< Reg 358. Concentrate pump CPB hall sensor pulse width + U16 fpgaCPAHallSense; ///< Reg 355. Concentrate pump CPA hall sensor pulse width + U16 fpgaCPBHallSense; ///< Reg 357. Concentrate pump CPB hall sensor pulse width + + F32 fpgaTax1Temp; ///< Reg 359. Inlet heat exchanger temperature + F32 fpgaTH2Temp; ///< Reg 363. Inlet heat exchanger temperature + F32 fpgaTH1Temp; ///< Reg 367. Hydraulics primary heater temperature + F32 fpgaTH3Temp; ///< Reg 371. Trimmer heater temperature + U08 fpgaRTDReadCnt; ///< Reg 375. Read count for all RTD sensors + + U08 fpgaBaroReadCount; ///< Reg 376. Barometric sensor read count + U08 fpgaBaroErrorCount; ///< Reg 377. Barometric sensor error count + U16 fpgaBaroManufacInfo; ///< Reg 378. Barometric sensor manufacturing information + U16 fpgaBaroPROMCoeff1; ///< Reg 380. Barometric sensor PROM coefficient 1 + U16 fpgaBaroPROMCoeff2; ///< Reg 382. Barometric sensor PROM coefficient 2 + U16 fpgaBaroPROMCoeff3; ///< Reg 384. Barometric sensor PROM coefficient 3 + U16 fpgaBaroPROMCoeff4; ///< Reg 386. Barometric sensor PROM coefficient 4 + U16 fpgaBaroPROMCoeff5; ///< Reg 390. Barometric sensor PROM coefficient 5 + U16 fpgaBaroPROMCoeff6; ///< Reg 392. Barometric sensor PROM coefficient 6 + U16 fpgaBaroPROMCRC; ///< Reg 394. Barometric sensor PROM CRC + U32 fpgaBaroPressure; ///< Reg 396. Barometric sensor pressure value + U32 fpgaBaroTemperature; ///< Reg 400. Barometric sensor temperature sensor + } DD_FPGA_SENSORS_T; typedef struct @@ -1951,6 +1971,223 @@ /*********************************************************************//** * @brief + * The getFPGAInletHeatExchangerTemp function gets the inlet heat exchanger + * temperature. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return inlet heat exchanger temperature + *************************************************************************/ +U32 getFPGAInletHeatExchangerTemp( void ) +{ + return fpgaSensorReadings.fpgaTax1Temp; +} + +/*********************************************************************//** + * @brief + * The getFPGAOutletHeatExchangerTemp function gets the outlet heat exchanger + * temperature. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return outlet heat exchanger temperature + *************************************************************************/ +U32 getFPGAOutletHeatExchangerTemp( void ) +{ + return fpgaSensorReadings.fpgaTH2Temp; +} + +/*********************************************************************//** + * @brief + * The getFPGAHydraulicsPrimaryHeaterTemp function gets the hydraulics primary + * heater temperature. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return hydraulics primary heater temperature + *************************************************************************/ +U32 getFPGAHydraulicsPrimaryHeaterTemp( void ) +{ + return fpgaSensorReadings.fpgaTH1Temp; +} + +/*********************************************************************//** + * @brief + * The getFPGATrimmerHeaterTemp function gets the trimmer heater temperature. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return trimmer heater temperature + *************************************************************************/ +U32 getFPGATrimmerHeaterTemp( void ) +{ + return fpgaSensorReadings.fpgaTH3Temp; +} + +/*********************************************************************//** + * @brief + * The getFPGARTDReadCount function gets the RTD sensors group read count. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return RTD read count + *************************************************************************/ +U08 getFPGARTDReadCount( void ) +{ + return fpgaSensorReadings.fpgaRTDReadCnt; +} + +/*********************************************************************//** + * @brief + * The getFPGABaroReadCount function gets the FPGA barometric sensor read count. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return barometric pressure sensor read count + *************************************************************************/ +U08 getFPGABaroReadCount( void ) +{ + return fpgaSensorReadings.fpgaBaroReadCount; +} + +/*********************************************************************//** + * @brief + * The getFPGABaroErrorCount function gets the FPGA barometric sensor error count. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return barometric pressure sensor error count + *************************************************************************/ +U08 getFPGABaroErrorCount( void ) +{ + return fpgaSensorReadings.fpgaBaroErrorCount; +} + +/*********************************************************************//** + * @brief + * The getFPGABaroMfgInfo function gets the FPGA barometric pressure + * sensor manufacturing information. + * @details \b Inputs: fpgaSensorReadings + * @details \b 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 \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return barometric pressure sensor sensitivity + *************************************************************************/ +U16 getFPGABaroPressureSensitivity( void ) +{ + return fpgaSensorReadings.fpgaBaroPROMCoeff1; +} + +/*********************************************************************//** + * @brief + * The getFPGABaroPressureOffset function gets the FPGA barometric pressure + * sensor offset. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return barometric pressure sensor offset + *************************************************************************/ +U16 getFPGABaroPressureOffset( void ) +{ + return fpgaSensorReadings.fpgaBaroPROMCoeff2; +} + +/*********************************************************************//** + * @brief + * The getFPGABaroTempCoeffOfPressSensitvity function gets the FPGA barometric + * pressure sensor temperature coefficient of pressure sensitivity. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return barometric pressure sensor temperature coefficient of pressure sensitivity + *************************************************************************/ +U16 getFPGABaroTempCoeffOfPressSensitvity( void ) +{ + return fpgaSensorReadings.fpgaBaroPROMCoeff3; +} + +/*********************************************************************//** + * @brief + * The getFPGABaroTempCoeffOfPressOffset function gets the FPGA barometric + * pressure sensor temperature coefficient of pressure offset. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return barometric pressure sensor temperature coefficient of pressure offset + *************************************************************************/ +U16 getFPGABaroTempCoeffOfPressOffset( void ) +{ + return fpgaSensorReadings.fpgaBaroPROMCoeff4; +} + +/*********************************************************************//** + * @brief + * The getFPGABaroReferenceTemperature function gets the FPGA barometric pressure + * sensor reference temperature. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return barometric pressure sensor reference temperature + *************************************************************************/ +U16 getFPGABaroReferenceTemperature( void ) +{ + return fpgaSensorReadings.fpgaBaroPROMCoeff5; +} + +/*********************************************************************//** + * @brief + * The getFPGABaroTempCoeffOfTemperature function gets the FPGA barometric pressure + * sensor temperature coefficient of temperature. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return barometric pressure sensor temperature coefficient of temperature + *************************************************************************/ +U16 getFPGABaroTempCoeffOfTemperature( void ) +{ + return fpgaSensorReadings.fpgaBaroPROMCoeff6; +} + +/*********************************************************************//** + * @brief + * The getFPGABaroCoeffsCRC function gets the FPGA barometric pressure + * sensor temperature coefficients' CRC. + * @details \b Inputs: fpgaSensorReadings + * @details \b 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 \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return barometric pressure sensor pressure + *************************************************************************/ +U32 getFPGABaroPressure( void ) +{ + return ( fpgaSensorReadings.fpgaBaroPressure & MASK_OFF_U32_MSB ); +} + +/*********************************************************************//** + * @brief + * The getFPGABaroTemperature function gets the FPGA barometric pressure sensor + * temperature. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return barometric pressure sensor temperature + *************************************************************************/ +U32 getFPGABaroTemperature( void ) +{ + return ( fpgaSensorReadings.fpgaBaroTemperature & MASK_OFF_U32_MSB ); +} + +/*********************************************************************//** + * @brief * The checkFPGACommFailure function increments the FPGA comm failure * windowed timer and returns whether or not the number of failures in * the window have been reached. Index: firmware/App/Services/FpgaDD.h =================================================================== diff -u -r3a87ca0e2a722318216623d7e1f4c354c58c506c -rfefb47e88a5285e99498efb830fdceb9e95c2c3e --- firmware/App/Services/FpgaDD.h (.../FpgaDD.h) (revision 3a87ca0e2a722318216623d7e1f4c354c58c506c) +++ firmware/App/Services/FpgaDD.h (.../FpgaDD.h) (revision fefb47e88a5285e99498efb830fdceb9e95c2c3e) @@ -174,6 +174,27 @@ U16 getFPGALevelSensor1( void ); U16 getFPGALevelSensor2( void ); +//Temperature sensors +U32 getFPGAInletHeatExchangerTemp( void ); +U32 getFPGAOutletHeatExchangerTemp( void ); +U32 getFPGAHydraulicsPrimaryHeaterTemp( void ); +U32 getFPGATrimmerHeaterTemp( void ); +U08 getFPGARTDReadCount( void ); + +//Barometric sensor +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 ); + /**@}*/ #endif Index: firmware/App/Tasks/TaskPriority.c =================================================================== diff -u -r9bd502d3342764c0847258a81a212b446172a8b4 -rfefb47e88a5285e99498efb830fdceb9e95c2c3e --- firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 9bd502d3342764c0847258a81a212b446172a8b4) +++ firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision fefb47e88a5285e99498efb830fdceb9e95c2c3e) @@ -23,7 +23,7 @@ #include "InternalADC.h" #include "Pressure.h" #include "TaskPriority.h" -//#include "TemperatureSensors.h" +#include "Temperature.h" #include "Valves.h" #include "WatchdogMgmt.h" @@ -64,7 +64,7 @@ execPressureSensor(); // Temperature sensors read - //execTemperatureSensors(); + execTemperatureSensors(); // Verify the processor clock speed against the FPGA clock //execFPGAClockSpeedTest(); Index: firmware/source/sys_main.c =================================================================== diff -u -r3a87ca0e2a722318216623d7e1f4c354c58c506c -rfefb47e88a5285e99498efb830fdceb9e95c2c3e --- firmware/source/sys_main.c (.../sys_main.c) (revision 3a87ca0e2a722318216623d7e1f4c354c58c506c) +++ firmware/source/sys_main.c (.../sys_main.c) (revision fefb47e88a5285e99498efb830fdceb9e95c2c3e) @@ -74,6 +74,7 @@ #include "SystemCommDD.h" #include "TaskBG.h" #include "Timers.h" +#include "Temperature.h" #include "Utilities.h" #include "Valves.h" #include "WatchdogMgmt.h" @@ -161,6 +162,7 @@ initPressure(); initConductivity(); initValves(); + initTemperature(); initConcentratePump(); initCommBuffers(); initMsgQueues();