Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -re8c019d3d43b517cabfdfe75fa5d03749d036018 -r38c28a43b71d21d72906b07e9d60107b84bffb37 --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision e8c019d3d43b517cabfdfe75fa5d03749d036018) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 38c28a43b71d21d72906b07e9d60107b84bffb37) @@ -65,10 +65,10 @@ #define HEATERS_VOLTAGE_OUT_OF_RANGE_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Heaters voltage out of range time out in milliseconds. #define HEATERS_MAX_VOLTAGE_OUT_OF_RANGE_TOL 0.2F ///< Heaters max voltage out of range tolerance. #define HEATERS_MIN_RAMP_TIME_MS ( 6 * MS_PER_SECOND ) ///< Heaters minimum time that they have to stay in the ramp state in milliseconds. -#define TEMPERATURES_MOVING_AVG_SIZE 3U ///< Heaters ramp state temperatures moving average size. +#define TRIMMER_HEATER_MAX_POWER_W 66.5F ///< Trimmer heater maximum power in Watts. #define DELTA_TEMPERATURE_TIME_COSNTANT_C 8.6F ///< Delta temperature calculated from time constant. -#define MAXIMUM_ALLOWED_TARGET_TEMPERATURE_DEVIATION_C 0.25F ///< Maximum allowed temperature deviation from target temperature in C. +#define MAXIMUM_ALLOWED_TARGET_TEMPERATURE_DEVIATION_C 2.5F ///< Maximum allowed temperature deviation from target temperature in C. #define PRIMARY_HEATER_DUTY_CYCLE_PER_TEMPERATURE_C 0.03F ///< Primary heaters duty cycle per temperature in C. #define DATA_PUBLISH_COUNTER_START_COUNT 70 ///< Data publish counter start count. @@ -100,6 +100,7 @@ F32 heaterEfficiency; ///< Heater efficiency during the run. BOOL hasTargetBeenReached; ///< Heater flag to indicate whether the target temperature has been reached. F32 calculatedTemperature; ///< Heater calculated temperature. + DG_RESERVOIR_ID_T inactiveRsrvr; ///< Heater inactive reservoir. } HEATER_STATUS_T; static HEATER_STATUS_T heatersStatus[ NUM_OF_DG_HEATERS ]; ///< Heaters status. @@ -438,7 +439,6 @@ // Update the calculated target temperature heatersStatus[ DG_PRIMARY_HEATER ].calculatedTemperature = targetTemperature; - setHeaterDutyCycle( heater, dutyCycle ); return state; @@ -545,7 +545,7 @@ // Update the calculated target temperature heatersStatus[ DG_TRIMMER_HEATER ].calculatedTemperature = currentTemperature; - + heatersStatus[ DG_TRIMMER_HEATER ].inactiveRsrvr = getInactiveReservoir(); setHeaterDutyCycle( heater, dutyCycle ); return state; @@ -562,9 +562,10 @@ static HEATERS_STATE_T handleHeaterStateTrimmerControlToTarget( void ) { HEATERS_STATE_T state = HEATER_EXEC_STATE_TRIMMER_CONTROL_TO_TARGET; - DG_HEATERS_T heater = DG_TRIMMER_HEATER; - if ( TRUE == haveHeaterControlConditionsChanged( heater ) ) // TODO do we need this kind of check from trimmer?? + // If the inactive reservoir has changed from the last run transition to ramp state to recalculate the + // duty cycle for the next delivery + if ( heatersStatus[ DG_TRIMMER_HEATER ].inactiveRsrvr != getInactiveReservoir() ) { state = HEATER_EXEC_STATE_TRIMMER_RAMP_TO_TARGET; } @@ -640,7 +641,7 @@ heaterEfficiency += ( primaryTargetTemperature - lastFillTemperature ) * PRIMARY_HEATER_DUTY_CYCLE_PER_TEMPERATURE_C; } - heaterEfficiency = heaterEfficiency <= 0.0 ? 0.0 : heaterEfficiency; + heaterEfficiency = ( heaterEfficiency <= 0.0 ? 0.0 : heaterEfficiency ); // Update the heaters efficiency heatersStatus[ DG_PRIMARY_HEATER ].heaterEfficiency = heaterEfficiency; @@ -678,14 +679,17 @@ F32 heaterEfficiency = heatersStatus[ DG_TRIMMER_HEATER ].heaterEfficiency; F32 dutyCycle = 0.0; -#ifndef DISABLE_HEATERS_EFFICIENCY - if ( TRUE == checkEfficiency ) +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_HEATERS_EFFICIENCY ) != SW_CONFIG_ENABLE_VALUE ) +#endif { - // TODO Do we need to recalculate the efficiency? + if ( TRUE == checkEfficiency ) + { + // TODO Do we need to recalculate the efficiency? + } } -#endif - dutyCycle = flow * WATER_SPECIFIC_HEAT_DIVIDED_BY_MINUTES * ( targetTemperature - currentTemperature ) * heaterEfficiency; + dutyCycle = ( flow * WATER_SPECIFIC_HEAT_DIVIDED_BY_MINUTES * ( targetTemperature - currentTemperature ) * heaterEfficiency ) / TRIMMER_HEATER_MAX_POWER_W; // Check the boundaries of the calculated duty cycle dutyCycle = MIN( dutyCycle, HEATERS_MAX_DUTY_CYCLE ); @@ -714,7 +718,7 @@ if ( ( TRUE == hasFlowChanged ) || ( TRUE == heatersStatus[ heater ].hasTargetTempChanged ) ) { status = TRUE; - heatersStatus[ heater ].targetFlow = targetFlow; + heatersStatus[ heater ].targetFlow = targetFlow; heatersStatus[ heater ].hasTargetTempChanged = FALSE; }