Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -r48ea28a08999dcf46985b20ea635fa504f569e57 -r6e3bbb4c27eae91fed11b118cced935a04c6b90a --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 48ea28a08999dcf46985b20ea635fa504f569e57) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 6e3bbb4c27eae91fed11b118cced935a04c6b90a) @@ -26,6 +26,7 @@ #include "InternalADC.h" #include "MessageSupport.h" #include "ModeFill.h" +#include "NVDataMgmt.h" #include "OperationModes.h" #include "Reservoirs.h" #include "ROPump.h" @@ -332,9 +333,13 @@ cmdResponse.rejected = FALSE; heatersStatus[ DG_TRIMMER_HEATER ].targetTemp = heaterCmdPtr->targetTemp; // TODo do we need to remove this since the trimmer heater is set in the reservoirs -#ifndef DISABLE_HEATERS_AND_TEMPS - heatersStatus[ DG_TRIMMER_HEATER ].startHeaterSignal = TRUE; + +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_TRIMMER_HEATER ) != SW_CONFIG_ENABLE_VALUE ) #endif + { + heatersStatus[ DG_TRIMMER_HEATER ].startHeaterSignal = TRUE; + } } else { @@ -362,50 +367,53 @@ *************************************************************************/ void execHeatersMonitor( void ) { -#ifndef IGNORE_HEATERS_MONITOR - DG_HEATERS_T heater; - - for ( heater = DG_PRIMARY_HEATER; heater < NUM_OF_DG_HEATERS; heater++ ) +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_HEATERS_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) +#endif { - // 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 ); + DG_HEATERS_T heater; - if ( TRUE == isFlowLow ) + 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 ) && ( ( heatersStatus[ heater ].dutycycle - HEATERS_MIN_DUTY_CYCLE ) > NEARLY_ZERO ) ) { - // Check if the flow of the heater is below minimum for the first time - if ( FALSE == heatersStatus[ heater ].isFlowBelowMin ) + // 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 ) { - heatersStatus[ heater ].isFlowBelowMin = TRUE; - heatersStatus[ heater ].heaterOnWithNoFlowTimer = getMSTimerCount(); + // 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 ); + + 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 ); + } } - else if ( TRUE == didTimeout( heatersStatus[ heater ].heaterOnWithNoFlowTimer, HEATERS_ON_NO_FLOW_TIMEOUT_MS ) ) + else { - // Heater has been on with no flow time out - stopHeater( heater ); - - 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 ); + heatersStatus[ heater ].isFlowBelowMin = FALSE; + heatersStatus[ heater ].heaterOnWithNoFlowTimer = getMSTimerCount(); } } - else - { - heatersStatus[ heater ].isFlowBelowMin = FALSE; - heatersStatus[ heater ].heaterOnWithNoFlowTimer = getMSTimerCount(); - } } + + monitorHeatersVoltage(); } - monitorHeatersVoltage(); -#endif - // Check for data publication publishHeatersData(); } @@ -664,30 +672,33 @@ // Get the primary heater's efficiency and the last fill temperature from the ModeFill F32 heaterEfficiency = heatersStatus[ DG_PRIMARY_HEATER ].heaterEfficiency; -#ifndef DISABLE_HEATERS_EFFICIENCY - if ( TRUE == checkEfficiency ) +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_HEATERS_EFFICIENCY ) != SW_CONFIG_ENABLE_VALUE ) +#endif { - F32 lastFillTemperature = getLastFillTemperature(); - F32 primaryTargetTemperature = heatersStatus[ DG_PRIMARY_HEATER ].targetTemp; - - // If the last fill temperature > target temperature, it means the primary heater overshot the duty cycle - // so with its efficiency is toned down for the next fill cycle - // If the heater under-shoots the duty cycle, the efficiency increases the duty cycle for the next fill cycle - if ( lastFillTemperature - primaryTargetTemperature > MAXIMUM_ALLOWED_TARGET_TEMPERATURE_DEVIATION_C ) + if ( TRUE == checkEfficiency ) { - heaterEfficiency -= ( lastFillTemperature - primaryTargetTemperature ) * PRIMARY_HEATER_DUTY_CYCLE_PER_TEMPERATURE_C; - } - else - { - heaterEfficiency += ( primaryTargetTemperature - lastFillTemperature ) * PRIMARY_HEATER_DUTY_CYCLE_PER_TEMPERATURE_C; - } + F32 lastFillTemperature = getLastFillTemperature(); + F32 primaryTargetTemperature = heatersStatus[ DG_PRIMARY_HEATER ].targetTemp; - heaterEfficiency = heaterEfficiency <= 0.0 ? 0.0 : heaterEfficiency; + // If the last fill temperature > target temperature, it means the primary heater overshot the duty cycle + // so with its efficiency is toned down for the next fill cycle + // If the heater under-shoots the duty cycle, the efficiency increases the duty cycle for the next fill cycle + if ( lastFillTemperature - primaryTargetTemperature > MAXIMUM_ALLOWED_TARGET_TEMPERATURE_DEVIATION_C ) + { + heaterEfficiency -= ( lastFillTemperature - primaryTargetTemperature ) * PRIMARY_HEATER_DUTY_CYCLE_PER_TEMPERATURE_C; + } + else + { + heaterEfficiency += ( primaryTargetTemperature - lastFillTemperature ) * PRIMARY_HEATER_DUTY_CYCLE_PER_TEMPERATURE_C; + } - // Update the heaters efficiency - heatersStatus[ DG_PRIMARY_HEATER ].heaterEfficiency = heaterEfficiency; + heaterEfficiency = heaterEfficiency <= 0.0 ? 0.0 : heaterEfficiency; + + // Update the heaters efficiency + heatersStatus[ DG_PRIMARY_HEATER ].heaterEfficiency = heaterEfficiency; + } } -#endif // Duty cycle = ( 69.73 * flow rate * deltaT / primary heater maximum power ) ^ 1/2 // Multiply the duty cycle to the heater efficiency