Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -r8fe65bf6222137cc7182ccacff3a5f2fb2f03753 -rab14e70c7bac24b0c3ebd02c6763285cdd3951ce --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 8fe65bf6222137cc7182ccacff3a5f2fb2f03753) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision ab14e70c7bac24b0c3ebd02c6763285cdd3951ce) @@ -59,7 +59,7 @@ #define HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_C 170.0F ///< Heaters max allowed internal temperature in C. #define HEATERS_MAX_ALLOWED_COLD_JUNCTION_TEMPERATURE_C 80.0F ///< Heaters max allowed cold junction temperature in C. #define HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_TIMEOUT_MS ( 2 * SEC_PER_MIN * MS_PER_SECOND ) ///< Heaters max allowed internal temperature timeout in milliseconds. -#define HEATERS_ON_NO_FLOW_TIMEOUT_MS ( 2 * SEC_PER_MIN * MS_PER_SECOND ) ///< Heaters on with no flow time out in milliseconds. +#define HEATERS_ON_NO_FLOW_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Heaters on with no flow time out in milliseconds. #define HEATERS_MAX_OPERATING_VOLTAGE_V 24.0F ///< Heaters max operating voltage in volts. #define HEATERS_VOLTAGE_MONITOR_TIME_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Heaters voltage monitor timer interval. #define HEATERS_MAX_VOLTAGE_OUT_OF_RANGE_TOL 0.2F ///< Heaters max voltage out of range tolerance. @@ -89,20 +89,19 @@ /// Heaters data structure typedef struct { - F32 targetTemp; ///< Heater target temperature. + F32 targetTemp; ///< Heater target temperature. HEATERS_STATE_T state; ///< Heater state. BOOL startHeaterSignal; ///< Heater start indication flag. BOOL isHeaterOn; ///< Heater on/off status flag. - F32 dutycycle; ///< Heater duty cycle. - F32 targetROFlow; ///< Heater target flow. - U32 heaterOnWithNoFlowTimer; // TODO remove ///< Heater on with no flow timer. + F32 dutycycle; ///< Heater duty cycle. + F32 dutyCyleBeforeFlow; + F32 targetROFlow; ///< Heater target flow. + U32 heaterOnWithNoFlowTimer; ///< Heater on with no flow timer. BOOL isFlowBelowMin; ///< Heater flow below minimum flag indicator. BOOL hasTargetTempChanged; ///< Heater target temperature change flag indicator. - F32 heaterEfficiency; ///< Heater efficiency during the run. + F32 heaterEfficiency; ///< Heater efficiency during the run. BOOL hasTargetBeenReached; ///< Heater flag to indicate whether the target temperature has been reached. - U32 tempOutOfRangeTimer; ///< Heater temperature out of range timer TODO remove once the mechanical thermal cutoff was implemented - BOOL isHeaterTempOutOfRange; ///< Heater temperature out of range flag indicator TODO remove once the mechanical thermal cutoff was implemented F32 temporaryInterimTemperature; ///< TODO remove } HEATER_STATUS_T; @@ -149,8 +148,6 @@ for ( heater = DG_PRIMARY_HEATER; heater < NUM_OF_DG_HEATERS; heater++ ) { heatersStatus[ heater ].startHeaterSignal = FALSE; - heatersStatus[ heater ].tempOutOfRangeTimer = 0; - heatersStatus[ heater ].isHeaterTempOutOfRange = FALSE; heatersStatus[ heater ].state = HEATER_EXEC_STATE_OFF; heatersStatus[ heater ].targetTemp = 0.0; heatersStatus[ heater ].dutycycle = 0.0; @@ -362,50 +359,58 @@ *************************************************************************/ void execHeatersMonitor( void ) { -#ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_HEATERS_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) -#endif + DG_HEATERS_T heater; + + for ( heater = DG_PRIMARY_HEATER; heater < NUM_OF_DG_HEATERS; heater++ ) { - DG_HEATERS_T heater; + F32 maxDutyCycle = MAX( heatersStatus[ heater ].dutyCyleBeforeFlow, heatersStatus[ heater ].dutycycle ); - for ( heater = DG_PRIMARY_HEATER; heater < NUM_OF_DG_HEATERS; heater++ ) + // Check if a heater is on and whether is duty cycle is not zero + if ( ( TRUE == heatersStatus[ heater ].isHeaterOn ) && ( maxDutyCycle > NEARLY_ZERO ) ) { - // Check if a heater is on and whether is duty cycle is not zero - if ( ( TRUE == heatersStatus[ heater ].isHeaterOn ) && ( ( heatersStatus[ heater ].dutycycle - HEATERS_MIN_DUTY_CYCLE ) > NEARLY_ZERO ) ) - { - // TODO add the function that gets the flow of the new flow sensor for DG. For now it is assumed that trimmer heater flow sensor - // is not 0 so the heater can run if needed - F32 measFlow = ( DG_PRIMARY_HEATER == heater ? getMeasuredROFlowRateLPM() : 50.0 ); - // TODO get the minimum new flow sensor flow sensor - F32 minFlow = ( DG_PRIMARY_HEATER == heater ? MIN_RO_FLOWRATE_LPM : MIN_RO_FLOWRATE_LPM ); - BOOL isFlowLow = ( measFlow < minFlow ? TRUE : FALSE ); + // TODO add the function that gets the flow of the new flow sensor for DG. For now it is assumed that trimmer heater flow sensor + // is not 0 so the heater can run if needed + F32 measFlow = ( DG_PRIMARY_HEATER == heater ? getMeasuredROFlowRateLPM() : 50.0 ); + // TODO get the minimum new flow sensor flow sensor + F32 minFlow = ( DG_PRIMARY_HEATER == heater ? MIN_RO_FLOWRATE_LPM : MIN_RO_FLOWRATE_LPM ); + BOOL isFlowLow = ( measFlow < minFlow ? TRUE : FALSE ); - if ( TRUE == isFlowLow ) + if ( TRUE == isFlowLow ) + { + // Check if the flow of the heater is below minimum for the first time + if ( FALSE == heatersStatus[ heater ].isFlowBelowMin ) { - // Check if the flow of the heater is below minimum for the first time - if ( FALSE == heatersStatus[ heater ].isFlowBelowMin ) - { - heatersStatus[ heater ].isFlowBelowMin = TRUE; - heatersStatus[ heater ].heaterOnWithNoFlowTimer = getMSTimerCount(); - } - else if ( TRUE == didTimeout( heatersStatus[ heater ].heaterOnWithNoFlowTimer, HEATERS_ON_NO_FLOW_TIMEOUT_MS ) ) - { - // Heater has been on with no flow time out - stopHeater( heater ); + heatersStatus[ heater ].isFlowBelowMin = TRUE; + heatersStatus[ heater ].heaterOnWithNoFlowTimer = getMSTimerCount(); + heatersStatus[ heater ].dutyCyleBeforeFlow = heatersStatus[ heater ].dutycycle; + } + else if ( TRUE == didTimeout( heatersStatus[ heater ].heaterOnWithNoFlowTimer, HEATERS_ON_NO_FLOW_TIMEOUT_MS ) ) + { + setHeaterDutyCycle( heater, HEATERS_MIN_DUTY_CYCLE ); - ALARM_ID_T alarm = ( DG_PRIMARY_HEATER == heater ? ALARM_ID_DG_PRIMARY_HEATER_ON_WITH_NO_FLOW_TIMEOUT : - ALARM_ID_DG_TRIMMER_HEATER_ON_WITH_NO_FLOW_TIMEOUT ); - activateAlarmNoData( alarm ); - } + /*ALARM_ID_T alarm = ( DG_PRIMARY_HEATER == heater ? ALARM_ID_DG_PRIMARY_HEATER_ON_WITH_NO_FLOW_TIMEOUT : + ALARM_ID_DG_TRIMMER_HEATER_ON_WITH_NO_FLOW_TIMEOUT ); + activateAlarmNoData( alarm ); TODO DEBUG_DENALI*/ } - else + } + else + { + if ( TRUE == heatersStatus[ heater ].isFlowBelowMin ) { - heatersStatus[ heater ].isFlowBelowMin = FALSE; - heatersStatus[ heater ].heaterOnWithNoFlowTimer = getMSTimerCount(); + setHeaterDutyCycle( heater, heatersStatus[ heater ].dutyCyleBeforeFlow ); } + + heatersStatus[ heater ].isFlowBelowMin = FALSE; + heatersStatus[ heater ].heaterOnWithNoFlowTimer = getMSTimerCount(); + } } + } +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_HEATERS_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) +#endif + { monitorHeatersVoltage(); } @@ -882,7 +887,7 @@ // Check trimmer heater's voltage if ( fabs( ( HEATERS_MAX_OPERATING_VOLTAGE_V * trimmer ) - trimmerVoltage ) > HEATERS_MAX_VOLTAGE_OUT_OF_RANGE_TOL * trimmerVoltage ) { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DG_TRIMMER_HEATER_VOLTAGE_OUT_OF_RANGE, trimmerVoltage ); + //SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DG_TRIMMER_HEATER_VOLTAGE_OUT_OF_RANGE, trimmerVoltage ); // TODO DEBUG_DENALI } voltageMonitorTimeCounter = 0;