Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -r801cb7a69212006b2572a91456b6b36ac3232392 -rbe027f8c9bee75f07267f7a9ab5635bbb02df86e --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 801cb7a69212006b2572a91456b6b36ac3232392) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision be027f8c9bee75f07267f7a9ab5635bbb02df86e) @@ -24,6 +24,7 @@ #include "AlarmMgmt.h" #include "Common.h" #include "Heaters.h" +#include "ROPump.h" #include "TemperatureSensors.h" #include "SystemCommMessages.h" #include "PIControllers.h" @@ -56,6 +57,9 @@ #define HEATERS_POST_HEAT_UP_TIME_SECONDS 50U ///< The time that the heaters are heated up to reach to the target temperature during POST #define HEATERS_POST_TEMPERATURE_TOLERANCE 1U ///< Tolerance of the sensors to the target temperature during POST +#define MINIMUM_TARGET_TEMPERATURE 10U ///< Minimum allowed target temperature for the heaters +#define MAXIMUM_TARGET_TEMPERATURE 90U ///< Maximum allowed target temperature for the heaters + /// Heaters self test enums typedef enum heaters_self_test_states { @@ -112,6 +116,8 @@ static OVERRIDE_U32_T heatersDataPublishInterval = { HEATERS_DATA_PUBLISH_INTERVAL, HEATERS_DATA_PUBLISH_INTERVAL, 0, 0 }; ///< Heaters data publish time interval static U32 selfTestElapsedTime; ///< Self test elapsed time variable +static BOOL hasStartPrimaryHeaterRequested; ///< Start primary heater request flag +static BOOL hasStartTrimmerHeaterRequested; ///< Start trimmer heater request flag // private functions prototypes @@ -213,20 +219,19 @@ * the primary heaters state and sets the main primary heater duty cycle * @details * Inputs : mainPrimaryHeaterDutyCycle, primaryHeaterTargetTemperature, - * isPrimaryHeaterOn - * Outputs : isPrimaryHeaterOn + * hasStartPrimaryHeaterRequested + * Outputs : hasStartPrimaryHeaterRequested * @param none * @return status *************************************************************************/ BOOL startPrimaryHeater ( void ) { BOOL status = FALSE; - if ( primaryHeaterTargetTemperature != 0.0 ) + if ( primaryHeaterTargetTemperature >= MINIMUM_TARGET_TEMPERATURE && + primaryHeaterTargetTemperature <= MAXIMUM_TARGET_TEMPERATURE ) { - resetHeaterState ( PRIMARY_HEATER ); - setMainPrimaryHeaterPWM ( mainPrimaryHeaterDutyCycle ); - isPrimaryHeaterOn = TRUE; + hasStartPrimaryHeaterRequested = TRUE; status = TRUE; } @@ -239,20 +244,19 @@ * trimmer heater's state and sets the duty cycle of the trimmer heater * @details * Inputs : trimmerHeaterDutyCycle, trimmerHeaterTargetTemperature, - * isTrimmerHeaterOn - * Outputs : isTrimmerHeaterOn + * trimmerHeaterTargetTemperature + * Outputs : trimmerHeaterTargetTemperature * @param none * @return status *************************************************************************/ BOOL startTrimmerHeater ( void ) { BOOL status = FALSE; - if ( trimmerHeaterTargetTemperature != 0.0 ) + if ( trimmerHeaterTargetTemperature >= MINIMUM_TARGET_TEMPERATURE && + trimmerHeaterTargetTemperature <= MAXIMUM_TARGET_TEMPERATURE ) { - resetHeaterState ( TRIMMER_HEATER ); - setTrimmerHeaterPWM ( trimmerHeaterDutyCycle ); - isTrimmerHeaterOn = TRUE; + hasStartTrimmerHeaterRequested = TRUE; status = TRUE; } @@ -300,8 +304,12 @@ *************************************************************************/ void execHeatersMonitor ( void ) { - // TODO Decide the parts of this function - + // If the RO pump is not on, turn off the heaters + if ( ! isReverseOsmosisPumpOn() ) + { + stopPrimaryHeater(); + stopTrimmerHeater(); + } } /*********************************************************************//** @@ -517,8 +525,8 @@ * The handlePrimaryHeaterStateOff function handles the primary heaters at * off state * @details - * Inputs : isPrimaryHeaterOn - * Outputs : state (PRIMARY_HEATERS_EXEC_STATES_T) + * Inputs : hasStartPrimaryHeaterRequested, isPrimaryHeaterOn + * Outputs : state (PRIMARY_HEATERS_EXEC_STATES_T), isPrimaryHeaterOn * @param none * @return state (PRIMARY_HEATERS_EXEC_STATES_T) *************************************************************************/ @@ -543,8 +551,11 @@ #endif // TODO remove this code for testing - if ( isPrimaryHeaterOn ) + if ( hasStartPrimaryHeaterRequested ) { + resetHeaterState ( PRIMARY_HEATER ); + setMainPrimaryHeaterPWM ( mainPrimaryHeaterDutyCycle ); + isPrimaryHeaterOn = TRUE; state = PRIMARY_HEATERS_EXEC_STATE_CONTROL_TO_TARGET; } @@ -622,8 +633,8 @@ * The handleTrimmerHeaterStateOff function handles the trimmer heater at * off state * @details - * Inputs : isTrimmerHeaterOn - * Outputs : state (TRIMMER_HEATER_EXEC_STATES_T) + * Inputs : hasStartTrimmerHeaterRequested, isTrimmerHeaterOn + * Outputs : state (TRIMMER_HEATER_EXEC_STATES_T), isTrimmerHeaterOn * @param none * @return state (TRIMMER_HEATER_EXEC_STATES_T) *************************************************************************/ @@ -652,8 +663,11 @@ #endif // TODO remove this code for testing - if ( isTrimmerHeaterOn ) + if ( hasStartTrimmerHeaterRequested ) { + resetHeaterState ( TRIMMER_HEATER ); + isTrimmerHeaterOn = TRUE; + setTrimmerHeaterPWM ( trimmerHeaterDutyCycle ); state = TRIMMER_HEATER_EXEC_STATE_CONTROL_TO_TARGET; }