Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -rc1ef106ed0f97dc998230c6e154aa2362aa476d8 -r41c7186ac17200977b632102c9c6e3a07b3eb211 --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision c1ef106ed0f97dc998230c6e154aa2362aa476d8) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 41c7186ac17200977b632102c9c6e3a07b3eb211) @@ -47,16 +47,16 @@ #define TEMP_SENSORS_ADC_BITS 24U ///< External temperature sensors ADC bits. #define TEMP_SENSORS_ADC_MAX_COUNT ( pow(2,TEMP_SENSORS_ADC_BITS) - 1 ) ///< Temperature sensors max ADC count. -#define TEMP_EQUATION_COEFF_A (3.9083 * pow(10,-3)) ///< ADC to temperature conversion coefficient A. -#define TEMP_EQUATION_COEFF_B (-5.775 * pow(10,-7)) ///< ADC to temperature conversion coefficient B. +#define TEMP_EQUATION_COEFF_A ( 3.9083 * pow( 10, -3 ) ) ///< ADC to temperature conversion coefficient A. +#define TEMP_EQUATION_COEFF_B ( -5.775 * pow( 10, -7 ) ) ///< ADC to temperature conversion coefficient B. #define ADC_FPGA_READ_DELAY 30U ///< Delay in ms before reading the ADC values from FPGA. #define MAX_NUM_OF_RAW_ADC_SAMPLES 32U ///< Number of ADC reads for moving average calculations. #define MAX_ALLOWED_TEMP_DELTA_BETWEEN_SENSORS 2U ///< Maximum allowed temperature delta between sensors. #define MAX_ALLOWED_UNCHANGED_ADC_READS 4U ///< Maximum number of times that the read of a sensor cannot change. #define SHIFT_BITS_BY_2 2U ///< Shift bits by 2. #define SHIFT_BITS_BY_5_FOR_AVERAGING 5U ///< Shift the ADCs of the temperature sensors by 5 to average them. -#define INLET_WATER_TEMPERATURE_PERSISTENCE_COUNT (5 * MS_PER_SECOND / TASK_GENERAL_INTERVAL) ///< Number of persistence count for temperature sensors out of range error. +#define INLET_WATER_TEMPERATURE_PERSISTENCE_PERIOD ( 5 * MS_PER_SECOND ) ///< Persistence period for temperature sensors out of range error. #define MIN_WATER_INPUT_TEMPERATURE 10U ///< Minimum water input temperature. #define MAX_WATER_INPUT_TEMPERATURE 35U ///< Maximum water input temperature. @@ -71,9 +71,9 @@ #define EXTERNAL_TEMP_SENSORS_ERROR_VALUE 0x80 ///< External temperature sensors error value. #define HEATERS_INTERNAL_TEMP_SENSOR_FAULT 0x01 ///< Heaters internal temperature sensor fault. -#define TEMP_SENSORS_DATA_PUBLISH_INTERVAL (MS_PER_SECOND / TASK_PRIORITY_INTERVAL) ///< Temperature sensors publish data time interval. +#define TEMP_SENSORS_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Temperature sensors publish data time interval. #define MAX_TEMPERATURE_SENSOR_FAILURES 10 ///< Maximum number of temperature sensor errors within window period before alarm. -#define MAX_TEMPERATURE_SENSOR_FAILURE_WINDOW_MS (10 * MS_PER_SECOND) ///< Temperature sensor error window. +#define MAX_TEMPERATURE_SENSOR_FAILURE_WINDOW_MS ( 10 * MS_PER_SECOND ) ///< Temperature sensor error window. /// Temperature sensor self-test states. typedef enum tempSensors_Self_Test_States @@ -169,9 +169,8 @@ /*********************************************************************//** * @brief * The initTemperatureSensors function initializes the module - * @details - * Inputs : none - * Outputs : TemperatureSensors module initialized + * @details Inputs: none + * @details Outputs: TemperatureSensors module initialized * @return none *************************************************************************/ void initTemperatureSensors( void ) @@ -238,18 +237,17 @@ // Persistent alarms for inlet water high/low temperature initPersistentAlarm( PERSISTENT_ALARM_INLET_WATER_HIGH_TEMPERATURE, ALARM_ID_INLET_WATER_HIGH_TEMPERATURE, - TRUE, INLET_WATER_TEMPERATURE_PERSISTENCE_COUNT, INLET_WATER_TEMPERATURE_PERSISTENCE_COUNT ); + FALSE, INLET_WATER_TEMPERATURE_PERSISTENCE_PERIOD, INLET_WATER_TEMPERATURE_PERSISTENCE_PERIOD ); initPersistentAlarm( PERSISTENT_ALARM_INLET_WATER_LOW_TEMPERATURE, ALARM_ID_INLET_WATER_LOW_TEMPERATURE, - TRUE, INLET_WATER_TEMPERATURE_PERSISTENCE_COUNT, INLET_WATER_TEMPERATURE_PERSISTENCE_COUNT ); + FALSE, INLET_WATER_TEMPERATURE_PERSISTENCE_PERIOD, INLET_WATER_TEMPERATURE_PERSISTENCE_PERIOD ); } /*********************************************************************//** * @brief * The execTemperatureSensorsSelfTest function runs the TemperatureSensors * POST during the self-test. - * @details - * Inputs : tempSensorsSelfTestState - * Outputs : tempSensorsSelfTestState + * @details Inputs: tempSensorsSelfTestState + * @details Outputs: tempSensorsSelfTestState * @return tempSensorsSelfTestState *************************************************************************/ SELF_TEST_STATUS_T execTemperatureSensorsSelfTest( void ) @@ -284,9 +282,8 @@ /*********************************************************************//** * @brief * The execTemperatureSensors function executes the temperature sensors' state machine. - * @details - * Inputs : tempSensorsExecState - * Outputs : tempSensorsExecState + * @details Inputs: tempSensorsExecState + * @details Outputs: tempSensorsExecState * @return none *************************************************************************/ void execTemperatureSensors( void ) @@ -313,9 +310,8 @@ * @brief * The checkInletWaterTemperature checks inlet water temperature value * and triggers an alarm when temperature value is out of allowed range. - * @details - * Inputs : Inlet water temperature value - * Outputs : Trigger alarms when temperature is out of allowed range + * @details Inputs: Inlet water temperature value + * @details Outputs: Trigger alarms when temperature is out of allowed range * @return none *************************************************************************/ void checkInletWaterTemperature( void ) @@ -331,9 +327,8 @@ /*********************************************************************//** * @brief * The getTemperatureValue function gets the temperature of the requested sensor. - * @details - * Inputs : none - * Outputs : none + * @details Inputs: none + * @details Outputs: none * @param sensor temperature sensor index * @return temperature *************************************************************************/ @@ -359,9 +354,8 @@ /*********************************************************************//** * @brief * The getADC2TempConversion function calculates the temperature from ADC read from FPGA. - * @details - * Inputs : none - * Outputs : none + * @details Inputs: none + * @details Outputs: none * @param avgADC Running average ADC * @param gain ADC gain * @param refResistance ADC reference resistance @@ -392,9 +386,8 @@ /*********************************************************************//** * @brief * The getHeaterInternalTemp function calculates the heaters' internal temperature. - * @details - * Inputs : temperatureValues - * Outputs : temperatureValues + * @details Inputs: temperatureValues + * @details Outputs: temperatureValues * @param TCIndex thermocouple index * @param CJIndex cold junction index * @return none @@ -450,9 +443,8 @@ * read from FPGA and converts it to an S32. Then it calls another function * to check if the read ADC is valid or not and if it is, it calls another * function to process the ADC value and covert it to temperature. - * @details - * Inputs : none - * Outputs : Processed valid ADC reading + * @details Inputs: none + * @details Outputs: Processed valid ADC reading * @param sensorIndex ID of temperature sensor to process * @param adc ADC value for the temperature sensor * @param fpgaError reported FPGA error status @@ -476,9 +468,8 @@ * different bit shifts on them accordingly. Then it call another function to * check if the read ADC is valid and if it is, the function calls another function * process the ADC and convert it to temperature. - * @details - * Inputs : none - * Outputs : Processed heater ADC reading + * @details Inputs: none + * @details Outputs: Processed heater ADC reading * @param sensorIndex ID of temperature sensor to process * @param adc reported ADC value for temperature sensor * @param fpgaError reported error status by FPGA @@ -519,9 +510,8 @@ * count. If there is any FPGA, it raises an alarm. If the count has changed * and the ADC value is not the same as the previous ADC read, it returns a * TRUE, signaling that the ADC is valid to be processed. - * @details - * Inputs : readCount - * Outputs : readCount, internalErrorCount + * @details Inputs: readCount + * @details Outputs: readCount, internalErrorCount * @param sensorIndex Temperature sensor index * @param fpgaError FPGA error count * @param fpgaCount FPGA read count @@ -531,7 +521,9 @@ { BOOL isADCValid = FALSE; #ifndef _VECTORCAST_ - isADCValid = TRUE; // TODO remove this line. Temporary set to true until FPGA error count is fixed + // TODO remove these two lines. Temporary set to true until FPGA error count is fixed + isADCValid = TRUE; + fpgaError = 0; #endif if ( fpgaError == 0 ) { @@ -546,7 +538,8 @@ ++tempSensors[ sensorIndex ].internalErrorCount; if ( tempSensors[ sensorIndex ].internalErrorCount > MAX_ALLOWED_UNCHANGED_ADC_READS ) { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_TEMPERATURE_SENSORS_FAULT, sensorIndex ); + // TODO: Add back alarm when temperature sensor read count is stable + // SET_ALARM_WITH_1_U32_DATA( ALARM_ID_TEMPERATURE_SENSORS_FAULT, sensorIndex ); } } } @@ -566,9 +559,8 @@ * 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 - * Inputs : adcNextIndex, rawADCReads, adcRunningSum - * Outputs : adcNextIndex, rawADCReads, adcRunningSum, temperatureValues + * @details Inputs: adcNextIndex, rawADCReads, adcRunningSum + * @details Outputs: adcNextIndex, rawADCReads, adcRunningSum, temperatureValues * @param sensorIndex Temperature sensor index * @param adc adc reading from fpga * @return none @@ -597,9 +589,8 @@ /*********************************************************************//** * @brief * The handleSelfTestStart function transitions the self-test state to check ADC. - * @details - * Inputs : tempSensorsSelfTestResult - * Outputs : none + * @details Inputs: tempSensorsSelfTestResult + * @details Outputs: none * @return state (TEMPSENSORS_SELF_TEST_STATES_T) *************************************************************************/ static TEMPSENSORS_SELF_TEST_STATES_T handleSelfTestStart( void ) @@ -613,9 +604,8 @@ * The handleSelfTestADCCheck function checks whether the ADC reads. If the * reads are above the maximum 24bit ADC count, it will throw an alarm and * switches to the next state. - * @details - * Inputs : TPi ADC reading from FPGA - * Outputs : none + * @details Inputs: TPi ADC reading from FPGA + * @details Outputs: none * @return TEMPSENSORS_SELF_TEST_CONSISTENCY_CHECK (TEMPSENSORS_SELF_TEST_STATES_T) *************************************************************************/ static TEMPSENSORS_SELF_TEST_STATES_T handleSelfTestADCCheck( void ) @@ -637,9 +627,8 @@ * @brief * The handleSelfTestConsistencyCheck function checks the values of the * sensors to make sure they are within the allowed range from each other. - * @details - * Inputs : TPi and TPo ADC reading from FPGA - * Outputs : none + * @details Inputs: TPi and TPo ADC reading from FPGA + * @details Outputs: none * @return TEMPSENSORS_SELF_TEST_COMPLETE (TEMPSENSORS_SELF_TEST_STATES_T) *************************************************************************/ static TEMPSENSORS_SELF_TEST_STATES_T handleSelfTestConsistencyCheck( void ) @@ -676,9 +665,8 @@ * @brief * The handleExecStart function waits for a period of time and switches to * the state that reads the ADC values from FPGA. - * @details - * Inputs : none - * Outputs : elapsedTime + * @details Inputs: none + * @details Outputs: elapsedTime * @return state (TEMPSENSORS_EXEC_STATES_T) *************************************************************************/ static TEMPSENSORS_EXEC_STATES_T handleExecStart( void ) @@ -703,9 +691,8 @@ * The handleExecGetADCValues function reads the ADC values from FPGA and * at the specified time intervals and calls other functions to calculate * the internal temperature of the heaters. - * @details - * Inputs : none - * Outputs : internalHeatersConversionTimer, elapsedTime, temperatureValues + * @details Inputs: none + * @details Outputs: internalHeatersConversionTimer, elapsedTime, temperatureValues * @return state (TEMPSENSORS_EXEC_STATES_T) *************************************************************************/ static TEMPSENSORS_EXEC_STATES_T handleExecGetADCValues( void ) @@ -741,9 +728,8 @@ * @brief * The getPublishTemperatureSensorsDataInterval function returns the data * publication interval either from the data or from the override. - * @details - * Inputs : tempSensorsPublishInterval - * Outputs : none + * @details Inputs: tempSensorsPublishInterval + * @details Outputs: none * @return result *************************************************************************/ static U32 getPublishTemperatureSensorsDataInterval( void ) @@ -762,9 +748,8 @@ * @brief * The publishTemperatureSensorsData function broadcasts the temperature * sensors data at the publication interval - * @details - * Inputs : dataPublicationTimerCounter, tempValuesForPublication - * Outputs : dataPublicationTimerCounter, tempValuesForPublication + * @details Inputs: dataPublicationTimerCounter, tempValuesForPublication + * @details Outputs: dataPublicationTimerCounter, tempValuesForPublication * @return none *************************************************************************/ static void publishTemperatureSensorsData( void ) @@ -792,9 +777,8 @@ * @brief * The testSetMeasuredTemperatureOverride function sets the override value * for a specific temperature sensor. - * @details - * Inputs : temperatureValues - * Outputs : temperatureValues + * @details Inputs: temperatureValues + * @details Outputs: temperatureValues * @param sensorIndex temperature sensor index * @param temperature temperature value to override if testing activated * @return result @@ -820,9 +804,8 @@ * @brief * The testSetMeasuredTemperatureOverride function resets the override value * of a specified temperature sensor. - * @details - * Inputs : temperatureValues - * Outputs : temperatureValues + * @details Inputs: temperatureValues + * @details Outputs: temperatureValues * @param sensorIndex temperature sensor index * @return result *************************************************************************/ @@ -847,9 +830,8 @@ * @brief * The testSetTemperatureSensorsPublishIntervalOverride function overrides * the temperature sensors publish data interval. - * @details - * Inputs : tempSensorsPublishInterval - * Outputs : tempSensorsPublishInterval + * @details Inputs: tempSensorsPublishInterval + * @details Outputs: tempSensorsPublishInterval * @param value temperature sensor data broadcast interval (in ms) to override to * @return result *************************************************************************/ @@ -873,9 +855,8 @@ * @brief * The testResetTemperatureSensorsPublishIntervalOverride function resets * the override value of temperature sensors publish data interval. - * @details - * Inputs : tempSensorsPublishInterval - * Outputs : tempSensorsPublishInterval + * @details Inputs: tempSensorsPublishInterval + * @details Outputs: tempSensorsPublishInterval * @return result *************************************************************************/ BOOL testResetTemperatureSensorsPublishIntervalOverride( void )