Index: firmware/App/Controllers/Thermistors.c =================================================================== diff -u -rc0160362dc799802ec589d5b6cf4c2bd1face77e -re3705410a6e4df70c2a4f2d590e977326e11d7b3 --- firmware/App/Controllers/Thermistors.c (.../Thermistors.c) (revision c0160362dc799802ec589d5b6cf4c2bd1face77e) +++ firmware/App/Controllers/Thermistors.c (.../Thermistors.c) (revision e3705410a6e4df70c2a4f2d590e977326e11d7b3) @@ -1,12 +1,12 @@ #include // For temperature calculations -#include "Thermistors.h" #include "FPGA.h" -#include "TaskGeneral.h" #include "InternalADC.h" -#include "SystemCommMessages.h" #include "PersistentAlarm.h" +#include "SystemCommMessages.h" +#include "Thermistors.h" +#include "TaskGeneral.h" /** * @addtogroup Thermistors @@ -29,40 +29,32 @@ #define MAX_ALLOWED_TEMPERATURE 80.0 ///< Thermistors/sensors maximum allowed temperature reading. #define MAX_ALLOWED_TEMP_OUT_OF_RANGE_PERIOD ( 5 * MS_PER_SECOND ) ///< Thermistors/sensors maximum allowed temperature out of range period. -/// Thermistors self test states -typedef enum thermistors_Self_Test_States -{ - THERMISTROS_SELF_TEST_CHECK_RANGE_STATE = 0, ///< Thermistors self test range check state - THERMISTORS_SELF_TEST_COMPLETE_STATE, ///< Thermistors self test complete state - NUM_OF_THERMISTORS_SELF_TEST_STATES, ///< Number of thermistors self test states -} THERMISTORS_SELF_TEST_STATES_T; - /// Thermistors exec states typedef enum thermistors_Exec_States { - THERMISTORS_EXEC_STATE_START_STATE = 0, ///< Thermistors exec state start state - THERMISTORS_EXEC_STATE_GET_ADC_VALUES_STATE, ///< Thermistors exec state get ADC values state - NUM_OF_THERMISTORS_EXEC_STATES, ///< Number of thermistors exec state + THERMISTORS_EXEC_STATE_START_STATE = 0, ///< Thermistors exec state start state + THERMISTORS_EXEC_STATE_GET_ADC_VALUES_STATE, ///< Thermistors exec state get ADC values state + NUM_OF_THERMISTORS_EXEC_STATES, ///< Number of thermistors exec state } THERMISTORS_EXEC_STATES_T; /// Thermistor struct typedef struct { - S32 rawADCRead; ///< Thermistor raw ADC read - OVERRIDE_F32_T temperatureValue; ///< Thermistor temperature value - F32 betaValue; ///< Thermistor beta value used to calculate temperature + S32 rawADCRead; ///< Thermistor raw ADC read + OVERRIDE_F32_T temperatureValue; ///< Thermistor temperature value + F32 betaValue; ///< Thermistor beta value used to calculate temperature } THERMISTOR_T; -static THERMISTORS_EXEC_STATES_T thermistorsExecState = THERMISTORS_EXEC_STATE_START_STATE; ///< Thermistors exec state. -static THERMISTOR_T thermistorsStatus[ NUM_OF_THERMISTORS ]; ///< Thermistors array. +static THERMISTORS_EXEC_STATES_T thermistorsExecState = THERMISTORS_EXEC_STATE_START_STATE; ///< Thermistors exec state. +static THERMISTOR_T thermistorsStatus[ NUM_OF_THERMISTORS ]; ///< Thermistors array. static OVERRIDE_U32_T thermistorsPublishInterval = { THERMISTORS_DATA_PUBLISH_INTERVAL, - THERMISTORS_DATA_PUBLISH_INTERVAL, 0, 0 }; ///< Thermistors publish time interval override. -static U32 dataPublishCounter; ///< Thermistors data publish timer counter. -static U32 adcReadCounter; ///< Thermistors ADC read counter. + THERMISTORS_DATA_PUBLISH_INTERVAL, 0, 0 }; ///< Thermistors publish time interval override. +static U32 dataPublishCounter; ///< Thermistors data publish timer counter. +static U32 adcReadCounter; ///< Thermistors ADC read counter. static const F32 THERMISTOR_VOLTAGE_CONV_COEFF = THERMISTOR_REFERENCE_VOLTAGE / - (F32)TWELVE_BIT_RESOLUTION; ///< On board thermistor ADC to voltage conversion coefficient. -static const F32 ON_BOARD_THERMISTOR_REF_TEMP_INV = 1 / THERMISTOR_REFERENCE_TEMPERATURE; ///< On board thermistor reference inverse. + (F32)TWELVE_BIT_RESOLUTION; ///< On board thermistor ADC to voltage conversion coefficient. +static const F32 ON_BOARD_THERMISTOR_REF_TEMP_INV = 1 / THERMISTOR_REFERENCE_TEMPERATURE; ///< On board thermistor reference inverse. // ********** private function prototypes ********** @@ -71,7 +63,7 @@ static void monitorThermistors( void ); static void convertADC2Temperature( void ); -static F32 calculateTemperature( U32 adcValue, F32 betaValue ); +static F32 calculateOnBoardThemristorTemperature( U32 adcValue, F32 betaValue ); static void publishThermistorsData( void ); static U32 getPublishThermistorsDataInterval( void ); @@ -85,8 +77,8 @@ void initThermistors( void ) { // Reset the thermistors values for a run - thermistorsExecState = THERMISTORS_EXEC_STATE_START_STATE; - dataPublishCounter = 0; + thermistorsExecState = THERMISTORS_EXEC_STATE_START_STATE; + dataPublishCounter = 0; // Initialize the beta values of each thermistor thermistorsStatus[ THERMISTOR_ONBOARD_NTC ].betaValue = ONBOARD_THERMISTOR_BETA_VALUE; @@ -222,7 +214,7 @@ // Monitor the values for a gross range check // Monitor is called in this function because this driver is constantly reading - // the thermisotor values. Also the internal ADC values are processed with moving average in the internalADC driver + // the thermistor values. Also the internal ADC values are processed with moving average in the internalADC driver // So the thermistors drivers just gets the latest ADC value and converts it to temperature monitorThermistors(); @@ -265,7 +257,6 @@ * @details Inputs: thermistorsStatus, fpgaBoardTempSensorConvCoeff, * adcTempSensorsConversionCoeff1, adcTempSensorsConversionCoeff2 * @details Outputs: thermistorsStatus - * @param thermistor (also covers the temperature sensors) to convert its value * @return none *************************************************************************/ static void convertADC2Temperature( void ) @@ -279,14 +270,14 @@ { rawADC = thermistorsStatus[ thermistor ].rawADCRead; - temperature = calculateTemperature( rawADC, thermistorsStatus[ thermistor ].betaValue ); + temperature = calculateOnBoardThemristorTemperature( rawADC, thermistorsStatus[ thermistor ].betaValue ); thermistorsStatus[ thermistor ].temperatureValue.data = temperature; } } /*********************************************************************//** * @brief - * The calcualteOnBoardThemristorTemperature function converts the ADC value + * The calculateOnBoardThemristorTemperature function converts the ADC value * of the onboard thermistor into temperature in C. Below are the calculation * steps: * voltage = ADC x 3 / 2^12 @@ -300,10 +291,8 @@ * @param beta value which is used to calculate temperature from ADC * @return calculated temperature in C *************************************************************************/ -static F32 calculateTemperature( U32 adcValue, F32 betaValue ) +static F32 calculateOnBoardThemristorTemperature( U32 adcValue, F32 betaValue ) { - - // Voltage = ADC x 3 / 2^12 for 12 bits resolution and a 3V ADC // The value of 3 / 2^12 has been calculated in a const to prevent the division again F32 const thermistorVoltage = adcValue * THERMISTOR_VOLTAGE_CONV_COEFF;