Index: firmware/App/Controllers/Thermistors.c =================================================================== diff -u -r4fdc3246f14c8b3b04724d39803530f60b6caac8 -rfeb93744f73bc0a3d58841bb02bd05c38357f35d --- firmware/App/Controllers/Thermistors.c (.../Thermistors.c) (revision 4fdc3246f14c8b3b04724d39803530f60b6caac8) +++ firmware/App/Controllers/Thermistors.c (.../Thermistors.c) (revision feb93744f73bc0a3d58841bb02bd05c38357f35d) @@ -27,7 +27,7 @@ #define CELSIUS_TO_KELVIN_CONVERSION 273.15 ///< Celsius to Kelvin temperature conversion. #define MIN_ALLOWED_TEMPERATURE 5.0 ///< Thermistors/sensors minimum allowed temperature reading. #define MAX_ALLOWED_TEMPERATURE 70.0 ///< Thermistors/sensors maximum allowed temperature reading. -#define MAX_ALLOWED_TEMP_OUT_OF_RANGE_PERIOD ( MS_PER_SECOND / ( 4 * TASK_GENERAL_INTERVAL ) ) ///< Thermistors/sensors maximum allowed temperature out of range period. +#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 @@ -53,18 +53,18 @@ F32 betaValue; ///< Thermistor beta value used to calculate temperature } THERMISTOR_T; -static SELF_TEST_STATUS_T thermistorsSelfTestReslt = SELF_TEST_STATUS_IN_PROGRESS; ///< Thermistors self test result. +static SELF_TEST_STATUS_T thermistorsSelfTestReslt = SELF_TEST_STATUS_IN_PROGRESS; ///< Thermistors self test result. static THERMISTORS_SELF_TEST_STATES_T thermistorsSelfTestState = THERMISTROS_SELF_TEST_CHECK_RANGE_STATE; ///< Thermistors self test state. static THERMISTORS_EXEC_STATES_T thermistorsExecState = THERMISTORS_EXEC_STATE_START_STATE; ///< Thermistors exec state. -static THERMISTOR_T thermistorsStatus[ NUM_OF_THERMISTORS ]; ///< Thermistors array. +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 ********** @@ -284,14 +284,14 @@ // If time has elapsed to read the ADCs, read them all if ( ++adcReadCounter >= THERMISTORS_ADC_READ_INTERVAL ) { - // Monitor the values for a gross range check - monitorThermistors(); - // Get all the raw readings in ADC thermistorsStatus[ THERMISTOR_ONBOARD_NTC ].rawADCRead = getIntADCReading( INT_ADC_BOARD_THERMISTOR ); thermistorsStatus[ THERMISTOR_POWER_SUPPLY_1 ].rawADCRead = getIntADCReading( INT_ADC_POWER_SUPPLY_1_THERMISTOR ); thermistorsStatus[ THERMISTOR_POWER_SUPPLY_2 ].rawADCRead = getIntADCReading( INT_ADC_POWER_SUPPLY_2_THERMISTOR ); + // Monitor the values for a gross range check + monitorThermistors(); + // Zero the counter for the next round of reading adcReadCounter = 0; } @@ -319,11 +319,15 @@ { temperature = getThermistorTemperatureValue( thermistor ); - // If the thermisotrs and sensors read temperature out of range, raise an alarm - if ( temperature < MIN_ALLOWED_TEMPERATURE || temperature >= MAX_ALLOWED_TEMPERATURE ) + // If the thermistors and sensors read temperature out of range, raise an alarm + if ( temperature < MIN_ALLOWED_TEMPERATURE ) { - checkPersistentAlarm( PERSISTENT_ALARM_THERMISTOR_TEMPERATURE_OUT_OF_RANGE, TRUE, temperature ); + checkPersistentAlarm( PERSISTENT_ALARM_THERMISTOR_TEMPERATURE_OUT_OF_RANGE, TRUE, temperature, MIN_ALLOWED_TEMPERATURE ); } + else if ( temperature >= MAX_ALLOWED_TEMPERATURE ) + { + checkPersistentAlarm( PERSISTENT_ALARM_THERMISTOR_TEMPERATURE_OUT_OF_RANGE, TRUE, temperature, MAX_ALLOWED_TEMPERATURE ); + } } }