Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -r9ce06772b2f651c57144327e6cbf886e2bc22dee -raada74112204bc8e7c004510d0c86afb88cccc14 --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 9ce06772b2f651c57144327e6cbf886e2bc22dee) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision aada74112204bc8e7c004510d0c86afb88cccc14) @@ -17,13 +17,15 @@ #include +// TI PWM driver #include "etpwm.h" #include "AlarmMgmt.h" #include "DGDefs.h" #include "Heaters.h" -#include "ROPump.h" +#include "OperationModes.h" #include "PIControllers.h" +#include "ROPump.h" #include "SystemCommMessages.h" #include "TaskPriority.h" #include "TemperatureSensors.h" @@ -98,29 +100,31 @@ // ********** private data ********** -static SELF_TEST_STATUS_T heatersSelfTestResult; ///< Heaters self-test results. -static HEATERS_SELF_TEST_STATES_T heatersSelfTestState; ///< Heaters self-test state. -static PRIMARY_HEATERS_EXEC_STATES_T primaryHeatersExecState; ///< Primary heaters exec state. -static TRIMMER_HEATER_EXEC_STATES_T trimmerHeaterExecState; ///< Trimmer heater exec state. +static SELF_TEST_STATUS_T heatersSelfTestResult; ///< Heaters self-test results. +static HEATERS_SELF_TEST_STATES_T heatersSelfTestState; ///< Heaters self-test state. +static PRIMARY_HEATERS_EXEC_STATES_T primaryHeatersExecState; ///< Primary heaters exec state. +static TRIMMER_HEATER_EXEC_STATES_T trimmerHeaterExecState; ///< Trimmer heater exec state. -static F32 primaryHeaterTargetTemperature; ///< Primary heaters target temperature. -static F32 trimmerHeaterTargetTemperature; ///< Trimmer heater target temperature. +static F32 primaryHeaterTargetTemperature; ///< Primary heaters target temperature. +static F32 trimmerHeaterTargetTemperature; ///< Trimmer heater target temperature. -static F32 mainPrimaryHeaterDutyCycle; ///< Main primary heater duty cycle. -static F32 smallPrimaryHeaterDutyCycle; ///< Small primary heater duty cycle. -static F32 trimmerHeaterDutyCycle; ///< Trimmer heater duty cycle. -static U32 primaryHeaterTimerCounter; ///< Primary heater timer counter. -static U32 trimmerHeaterTimerCounter; ///< Trimmer heater timer counter. -static U32 dataPublicationTimerCounter; ///< Data publication timer counter. -static BOOL isPrimaryHeaterOn; ///< Flag to show if the primary heater is on. -static BOOL isTrimmerHeaterOn; ///< Flag to show if the trimmer heater is on. +static F32 mainPrimaryHeaterDutyCycle; ///< Main primary heater duty cycle. +static F32 smallPrimaryHeaterDutyCycle; ///< Small primary heater duty cycle. +static F32 trimmerHeaterDutyCycle; ///< Trimmer heater duty cycle. +static U32 primaryHeaterTimerCounter; ///< Primary heater timer counter. +static U32 trimmerHeaterTimerCounter; ///< Trimmer heater timer counter. +static U32 dataPublicationTimerCounter; ///< Data publication timer counter. +static BOOL isPrimaryHeaterOn; ///< Flag to show if the primary heater is on. +static BOOL isTrimmerHeaterOn; ///< Flag to show if the trimmer heater is on. 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. -static U32 heatersOnWithNoFlowTimeOut; ///< Heaters are on but there is no sufficient flow. + 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. +static U32 heatersOnWithNoFlowTimeOut; ///< Heaters are on but there is no sufficient flow. +static TEMPERATURE_SENSORS_T primaryHeatersFeedbackTempSensor = TEMPSENSORS_OUTLET_PRIMARY_HEATER; ///< Primary heaters feedback temperature sensors. +static TEMPERATURE_SENSORS_T trimmerHeaterFeedbackTempSensor = TEMPSENSORS_OUTLET_REDUNDANT; ///< Trimmer heater feedback temperature sensor. // ********** private function prototypes ********** @@ -151,17 +155,19 @@ *************************************************************************/ void initHeaters( void ) { - heatersSelfTestState = HEATERS_SELF_TEST_START; - primaryHeatersExecState = PRIMARY_HEATERS_EXEC_STATE_OFF; - trimmerHeaterExecState = TRIMMER_HEATER_EXEC_STATE_OFF; - primaryHeaterTargetTemperature = 0.0; - trimmerHeaterTargetTemperature = 0.0; - primaryHeaterTimerCounter = 0; - trimmerHeaterTimerCounter = 5; - dataPublicationTimerCounter = 0; - isPrimaryHeaterOn = FALSE; - isTrimmerHeaterOn = FALSE; - selfTestElapsedTime = 0; + heatersSelfTestState = HEATERS_SELF_TEST_START; + primaryHeatersExecState = PRIMARY_HEATERS_EXEC_STATE_OFF; + trimmerHeaterExecState = TRIMMER_HEATER_EXEC_STATE_OFF; + primaryHeaterTargetTemperature = 0.0; + trimmerHeaterTargetTemperature = 0.0; + primaryHeaterTimerCounter = 0; + trimmerHeaterTimerCounter = 5; + dataPublicationTimerCounter = 0; + isPrimaryHeaterOn = FALSE; + isTrimmerHeaterOn = FALSE; + selfTestElapsedTime = 0; + primaryHeatersFeedbackTempSensor = TEMPSENSORS_OUTLET_PRIMARY_HEATER; + trimmerHeaterFeedbackTempSensor = TEMPSENSORS_OUTLET_REDUNDANT; // Initialize the PI controller for the primary heaters initializePIController( PI_CONTROLLER_ID_PRIMARY_HEATER, HEATERS_MIN_DUTY_CYCLE, PRIMARY_HEATERS_P_COEFFICIENT, PRIMARY_HEATERS_I_COEFFICIENT, @@ -555,6 +561,15 @@ setMainPrimaryHeaterPWM( mainPrimaryHeaterDutyCycle ); isPrimaryHeaterOn = TRUE; hasStartPrimaryHeaterRequested = FALSE; + + // Check if the operation mode is heat disinfect. If the mode is + // heat disinfect, the feedback sensor will be Thd + if ( DG_MODE_HEAT == getCurrentOperationMode() ) + { + // Set the feedback temperature sensor + primaryHeatersFeedbackTempSensor = TEMPSENSORS_INLET_DIALYSATE; //TODO change this to Thd sensors once it is installed + } + state = PRIMARY_HEATERS_EXEC_STATE_CONTROL_TO_TARGET; } @@ -577,7 +592,7 @@ if ( ++primaryHeaterTimerCounter >= CONTROLLER_CHECK_INTERVAL_COUNT ) { - F32 outletTemp = getTemperatureValue( TEMPSENSORS_OUTLET_PRIMARY_HEATER ); + F32 outletTemp = getTemperatureValue( primaryHeatersFeedbackTempSensor ); mainPrimaryHeaterDutyCycle = runPIController( PI_CONTROLLER_ID_PRIMARY_HEATER, primaryHeaterTargetTemperature, outletTemp ); if ( mainPrimaryHeaterDutyCycle >= MAIN_PRIMARY_HEATER_MAX_DUTY_CYCLE ) @@ -625,6 +640,15 @@ isTrimmerHeaterOn = TRUE; hasStartTrimmerHeaterRequested = FALSE; setTrimmerHeaterPWM( trimmerHeaterDutyCycle ); + + // Check if the operation mode is heat disinfect. If the mode is + // heat disinfect, the feedback sensor will be Thd + if ( DG_MODE_HEAT == getCurrentOperationMode() ) + { + // Set the feedback temperature sensor + trimmerHeaterFeedbackTempSensor = TEMPSENSORS_INLET_DIALYSATE; //TODO change this to Thd sensors once it is installed + } + state = TRIMMER_HEATER_EXEC_STATE_CONTROL_TO_TARGET; } @@ -645,7 +669,7 @@ if ( ++trimmerHeaterTimerCounter >= CONTROLLER_CHECK_INTERVAL_COUNT ) { - F32 outletTemp = getTemperatureValue( TEMPSENSORS_OUTLET_REDUNDANT ); + F32 outletTemp = getTemperatureValue( trimmerHeaterFeedbackTempSensor ); trimmerHeaterDutyCycle = runPIController( PI_CONTROLLER_ID_TRIMMER_HEATER, trimmerHeaterTargetTemperature, outletTemp ); setTrimmerHeaterPWM( trimmerHeaterDutyCycle ); trimmerHeaterTimerCounter = 0;