Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -ra8bb1da29825b5d666333629fda871652d16229a -r8467f8ff09e382e0991f14d02683080dc811e24e --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision a8bb1da29825b5d666333629fda871652d16229a) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 8467f8ff09e382e0991f14d02683080dc811e24e) @@ -24,6 +24,7 @@ #include "DGDefs.h" #include "Heaters.h" #include "OperationModes.h" +#include "PersistentAlarm.h" #include "PIControllers.h" #include "ROPump.h" #include "SafetyShutdown.h" @@ -129,10 +130,6 @@ static U32 heatersOnWithNoFlowTimer; ///< Heaters are on but there is no sufficient flow. static TEMPERATURE_SENSORS_T primaryHeatersFeedbackTempSensor = TEMPSENSORS_OUTLET_PRIMARY_HEATER; ///< Primary heaters feedback temperature sensors. static TEMPERATURE_SENSORS_T trimmerHeaterFeedbackTempSensor = TEMPSENSORS_OUTLET_REDUNDANT; ///< Trimmer heater feedback temperature sensors. -static U32 primaryHeatersInternalTempOutTimer = 0; ///< Primary heaters internal temperature out of range timer. -static U32 trimmerHeaterInternalTempOutTimer = 0; ///< Trimmer heater internal temperature out of range timer. -static BOOL isPrimaryHeatersTempOutOfRange = FALSE; ///< Boolean flag to indicate if the primary heaters internal temperature out of range. -static BOOL isTrimmerHeaterTempOutOfRange = FALSE; ///< Boolean flag to indicate if the trimmer heater internal temperature out of range. static BOOL isFlowBelowMin = FALSE; ///< Boolean flag to indicate if the flow is below the minimum. // ********** private function prototypes ********** @@ -177,10 +174,6 @@ selfTestElapsedTime = 0; primaryHeatersFeedbackTempSensor = TEMPSENSORS_OUTLET_PRIMARY_HEATER; trimmerHeaterFeedbackTempSensor = TEMPSENSORS_OUTLET_REDUNDANT; - primaryHeatersInternalTempOutTimer = 0; - trimmerHeaterInternalTempOutTimer = 0; - isPrimaryHeatersTempOutOfRange = FALSE; - isTrimmerHeaterTempOutOfRange = FALSE; isFlowBelowMin = FALSE; // Initialize the PI controller for the primary heaters @@ -190,6 +183,10 @@ // Initialize the PI controller for the trimmer heater initializePIController( PI_CONTROLLER_ID_TRIMMER_HEATER, HEATERS_MIN_DUTY_CYCLE, TRIMMER_HEATER_P_COEFFICIENT, TRIMMER_HEATER_I_COEFFICIENT, HEATERS_MIN_DUTY_CYCLE, TRIMMER_HEATER_MAX_DUTY_CYCLE ); + + // Initialize the persistent alarm for heaters' internal temperature out of range + initPersistentAlarm( ALARM_ID_DG_PRIMARY_HEATERS_INTERNAL_TEMP_OUT_OF_RANGE, 0, HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_TIMEOUT_MS ); + initPersistentAlarm( ALARM_ID_DG_TRIMMER_HEATER_INTERNAL_TEMP_OUT_OF_RANGE, 0, HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_TIMEOUT_MS ); } /*********************************************************************//** @@ -350,43 +347,20 @@ F32 trimmerHeaterInternalTemp = getTemperatureValue( TEMPSENSORS_TRIMMER_HEATER_INTERNAL ); // Check if the primary heaters' internal temperature is above the limit - if ( primaryHeatersInternalTemp > HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_C ) + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_DG_PRIMARY_HEATERS_INTERNAL_TEMP_OUT_OF_RANGE, + primaryHeatersInternalTemp > HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_C ) ) { + activateSafetyShutdown(); SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_PRIMARY_HEATERS_INTERNAL_TEMP_OUT_OF_RANGE, primaryHeatersInternalTemp ); - - // If it is above the range for the first time, stop the primary heaters - // and set the variables - if ( FALSE == isPrimaryHeatersTempOutOfRange ) - { - stopPrimaryHeater(); - isPrimaryHeatersTempOutOfRange = TRUE; - primaryHeatersInternalTempOutTimer = getMSTimerCount(); - } - // If the primary heaters internal temperature was out for more than the define period, activate the safety shutdown - else if ( TRUE == didTimeout( primaryHeatersInternalTempOutTimer, HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_TIMEOUT_MS ) ) - { - activateSafetyShutdown(); - } } // Check if the trimmer heater internal temperature is above the limit - if ( trimmerHeaterInternalTemp > HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_C ) + + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_DG_PRIMARY_HEATERS_INTERNAL_TEMP_OUT_OF_RANGE, + primaryHeatersInternalTemp > HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_C ) ) { + activateSafetyShutdown(); SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_TRIMMER_HEATER_INTERNAL_TEMP_OUT_OF_RANGE, trimmerHeaterInternalTemp ); - - // If it is above the range for the first time, stop the trimmer heater - // and set the variables - if ( FALSE == isTrimmerHeaterTempOutOfRange ) - { - stopTrimmerHeater(); - isTrimmerHeaterTempOutOfRange = TRUE; - trimmerHeaterInternalTempOutTimer = getMSTimerCount(); - } - // If the trimmer heater internal temperature was out for more than the define period, activate the safety shutdown - else if ( TRUE == didTimeout( trimmerHeaterInternalTempOutTimer, HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_TIMEOUT_MS ) ) - { - activateSafetyShutdown(); - } } #endif @@ -570,10 +544,9 @@ if ( fabs( convertedTemperature - SMALL_PRIMARY_AND_TRIMMER_HEATERS_POST_TARGET_TEMPERATURE ) > HEATERS_POST_TEMPERATURE_TOLERANCE ) { - //TODO alarm - // TODO POST failed heatersSelfTestResult = SELF_TEST_STATUS_FAILED; state = HEATERS_SELF_TEST_COMPLETE; + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_HEATERS_SELF_TEST_FAILURE, TEMPSENSORS_TRIMMER_HEATER_INTERNAL, convertedTemperature ) } else { @@ -608,9 +581,8 @@ if ( fabs( convertedTemperature - MAIN_PRIMARY_HEATER_POST_TARGET_TEMPERATURE ) > HEATERS_POST_TEMPERATURE_TOLERANCE ) { - //TODO alarm - // TODO POST failed heatersSelfTestResult = SELF_TEST_STATUS_FAILED; + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_HEATERS_SELF_TEST_FAILURE, TEMPSENSORS_PRIMARY_HEATER_INTERNAL, convertedTemperature ) } else {