Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -rd7926685f2fe3086bab183166119f0965a192a69 -r34ed52c598042fdcfa5526e3b1d46fa09b040199 --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision d7926685f2fe3086bab183166119f0965a192a69) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 34ed52c598042fdcfa5526e3b1d46fa09b040199) @@ -344,6 +344,7 @@ *************************************************************************/ void execHeatersMonitor( void ) { + // TODO check for the heaters' fault flags and fault if any of them are at fault it should alarm #ifndef IGNORE_HEATERS_MONITOR F32 primaryHeatersInternalTemp = getTemperatureValue( TEMPSENSORS_PRIMARY_HEATER_INTERNAL ); F32 trimmerHeaterInternalTemp = getTemperatureValue( TEMPSENSORS_TRIMMER_HEATER_INTERNAL ); @@ -390,23 +391,29 @@ #endif /* - * If any of the heaters are on, check if the flow is below than the minimum value + * If any of the heaters are on or any of the heaters' PWMs are not zero, check if the flow is below than the minimum value * If the flow is below minimum for the first time, set the variables * If the flow is below minimum for more than the defined time, stop the heaters and raise the alarm * If the flow is in range, reset the variables + * This is to make sure that any of the heaters do not stay on while there is no flow */ - if ( ( TRUE == isPrimaryHeaterOn ) || ( TRUE == isTrimmerHeaterOn ) ) + BOOL isHeaterOn = ( TRUE == isPrimaryHeaterOn ) || ( TRUE == isTrimmerHeaterOn ); + BOOL isPWMNonZero = ( mainPrimaryHeaterDutyCycle > HEATERS_MIN_DUTY_CYCLE ) || ( smallPrimaryHeaterDutyCycle > HEATERS_MIN_DUTY_CYCLE ) || + ( trimmerHeaterDutyCycle > HEATERS_MIN_DUTY_CYCLE ); + + if ( ( TRUE == isHeaterOn ) || ( TRUE == isPWMNonZero ) ) { - //TODO add a check for the pwm to not be 0 F32 measuredFlow = getMeasuredROFlowRate(); if ( measuredFlow < MIN_RO_FLOWRATE_LPM ) { + // Flow is below minimum for the first time if ( FALSE == isFlowBelowMin ) { isFlowBelowMin = TRUE; heatersOnWithNoFlowTimer = getMSTimerCount(); } + // Flow is below minimum for a long time so raise the alarm else if ( TRUE == didTimeout( heatersOnWithNoFlowTimer, HEATERS_ON_NO_FLOW_TIMEOUT_MS ) ) { stopPrimaryHeater(); @@ -835,12 +842,12 @@ *************************************************************************/ static void resetHeaterState( NAME_OF_HEATER_T heater ) { - if ( heater == PRIMARY_HEATER ) + if ( PRIMARY_HEATER == heater ) { mainPrimaryHeaterDutyCycle = MAIN_PRIMARY_HEATER_MAX_DUTY_CYCLE; resetPIController( PI_CONTROLLER_ID_PRIMARY_HEATER, MAIN_PRIMARY_HEATER_MAX_DUTY_CYCLE ); } - else if ( heater == TRIMMER_HEATER ) + else if ( TRIMMER_HEATER == heater ) { trimmerHeaterDutyCycle = TRIMMER_HEATER_MAX_DUTY_CYCLE; resetPIController( PI_CONTROLLER_ID_TRIMMER_HEATER, TRIMMER_HEATER_MAX_DUTY_CYCLE );