Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -re7dd4d4f0d9cbb0d8e7abb994a16f0389251e4ba -r239f565516c73aae797288effcfdf1fca0a361a0 --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision e7dd4d4f0d9cbb0d8e7abb994a16f0389251e4ba) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 239f565516c73aae797288effcfdf1fca0a361a0) @@ -109,7 +109,6 @@ static U32 dataPublicationTimerCounter; ///< Data publication timer counter. static OVERRIDE_U32_T heatersDataPublishInterval = { HEATERS_DATA_PUBLISH_INTERVAL, HEATERS_DATA_PUBLISH_INTERVAL, 0, 0 }; ///< Heaters data publish time interval. static U32 voltageMonitorTimeCounter = 0; ///< Heaters voltage monitor counter. -static U32 operationMode = 0; // ********** private function prototypes ********** @@ -129,8 +128,6 @@ static void setSmallPrimaryHeaterPWM( F32 pwm ); static void setTrimmerHeaterPWM( F32 pwm ); static void publishHeatersData( void ); -static void checkPrimaryHeaterTempSensors( void ); -static void checkTrimmerHeaterTempSensors( void ); static void monitorHeatersVoltage( void ); /*********************************************************************//** @@ -146,7 +143,6 @@ DG_HEATERS_T heater; voltageMonitorTimeCounter = 0; - operationMode = 0; dataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; for ( heater = DG_PRIMARY_HEATER; heater < NUM_OF_DG_HEATERS; heater++ ) @@ -366,14 +362,9 @@ *************************************************************************/ void execHeatersMonitor( void ) { -#if 0 // This code is disabled to prevent any heaters monitoring while the driver in in development. +#ifndef IGNORE_HEATERS_MONITOR DG_HEATERS_T heater; -#ifndef IGNORE_HEATERS_MONITOR - checkPrimaryHeaterTempSensors(); - checkTrimmerHeaterTempSensors(); -#endif - 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 @@ -411,9 +402,9 @@ } } } +#endif monitorHeatersVoltage(); -#endif // Check for data publication publishHeatersData(); @@ -499,7 +490,7 @@ state = HEATER_EXEC_STATE_CONTROL_TO_DISINFECT_TARGET; } - // TODO remove + // TODO remove once dialysate heating is done heatersStatus[ DG_PRIMARY_HEATER ].temporaryInterimTemperature = targetTemperature; // TODO remove @@ -673,9 +664,10 @@ // Get the primary heater's efficiency and the last fill temperature from the ModeFill F32 heaterEfficiency = heatersStatus[ DG_PRIMARY_HEATER ].heaterEfficiency; - if ( TRUE == checkEfficiency ) // TODO ignore the efficiency for now until it is fixed +#ifndef DISABLE_HEATERS_EFFICIENCY + if ( TRUE == checkEfficiency ) { - /*F32 lastFillTemperature = getLastFillTemperature(); + 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 @@ -685,17 +677,17 @@ { heaterEfficiency -= ( lastFillTemperature - primaryTargetTemperature ) * PRIMARY_HEATER_DUTY_CYCLE_PER_TEMPERATURE_C; } - else if ( lastFillTemperature - primaryTargetTemperature <= MAXIMUM_ALLOWED_TARGET_TEMPERATURE_DEVIATION_C ) + else { heaterEfficiency += ( primaryTargetTemperature - lastFillTemperature ) * PRIMARY_HEATER_DUTY_CYCLE_PER_TEMPERATURE_C; } heaterEfficiency = heaterEfficiency <= 0.0 ? 0.0 : heaterEfficiency; - //heaterEfficiency = heaterEfficiency >= 1.0 ? 1.0 : heaterEfficiency; // Update the heaters efficiency - heatersStatus[ DG_PRIMARY_HEATER ].heaterEfficiency = heaterEfficiency; */ + 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 @@ -728,11 +720,12 @@ F32 heaterEfficiency = heatersStatus[ DG_TRIMMER_HEATER ].heaterEfficiency; F32 dutyCycle = 0.0; - +#ifndef DISABLE_HEATERS_EFFICIENCY if ( TRUE == checkEfficiency ) { // TODO Do we need to recalculate the efficiency? } +#endif dutyCycle = flow * WATER_SPECIFIC_HEAT_DIVIDED_BY_MINUTES * ( targetTemperature - currentTemperature ) * heaterEfficiency; @@ -848,94 +841,6 @@ /*********************************************************************//** * @brief - * The checkPrimaryHeaterTempSensors function checks the primary heater's - * thermocouple and cold junction temperature sensors. - * @details Inputs: isPrimaryHeaterTempOutOfRange - * @details Outputs: isPrimaryHeaterTempOutOfRange - * @return none - *************************************************************************/ -static void checkPrimaryHeaterTempSensors( void ) -{ - F32 primaryHeaterInternalTemp = getTemperatureValue( TEMPSENSORS_PRIMARY_HEATER_INTERNAL ); - F32 primaryHeaterColdJunctionTemp = getTemperatureValue( TEMPSENSORS_PRIMARY_HEATER_COLD_JUNCTION ); - BOOL isTempOut = FALSE; - - // Check if the primary heater's internal temperature or the cold junction temperature is above the allowed limit - if ( primaryHeaterInternalTemp > HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_C ) - { - isTempOut = TRUE; - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_PRIMARY_HEATER_INTERNAL_TEMP_OUT_OF_RANGE, primaryHeaterInternalTemp ); - } - else if ( primaryHeaterColdJunctionTemp > HEATERS_MAX_ALLOWED_COLD_JUNCTION_TEMPERATURE_C ) - { - isTempOut = TRUE; - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_PRIMARY_HEATER_CJ_TEMP_OUT_OF_RANGE, primaryHeaterInternalTemp ); - } - -#ifndef IGNORE_HEATERS_MONITOR - // If any of the temperatures are above the range - if ( ( FALSE == isPrimaryHeaterTempOutOfRange ) && ( TRUE == isTempOut ) ) - { - stopPrimaryHeater(); - isPrimaryHeaterTempOutOfRange = TRUE; - primaryHeaterTempOutTimer = getMSTimerCount(); - } - // If the primary heaters internal temperature was out for more than the define period, activate the safety shutdown - else if ( ( TRUE == isPrimaryHeaterTempOutOfRange ) && - ( TRUE == didTimeout( primaryHeaterTempOutTimer, HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_TIMEOUT_MS ) ) ) - { - isPrimaryHeaterTempOutOfRange = FALSE; - activateSafetyShutdown(); - } -#endif -} - -/*********************************************************************//** - * @brief - * The checkTrimmerHeaterTempSensors function checks the trimmer heater's - * thermocouple and cold junction temperature sensors. - * @details Inputs: isTrimmerHeaterTempOutOfRange - * @details Outputs: isTrimmerHeaterTempOutOfRange - * @return none - *************************************************************************/ -static void checkTrimmerHeaterTempSensors( void ) -{ - F32 trimmerHeaterInternalTemp = getTemperatureValue( TEMPSENSORS_TRIMMER_HEATER_INTERNAL ); - F32 trimmerHeaterColdJunctionTemp = getTemperatureValue( TEMPSENSORS_TRIMMER_HEATER_COLD_JUNCTION ); - BOOL isTempOut = FALSE; - - // Check if the primary heater's internal temperature or the cold junction temperature is above the allowed limit - if ( trimmerHeaterInternalTemp > HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_C ) - { - isTempOut = TRUE; - //SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_TRIMMER_HEATER_INTERNAL_TEMP_OUT_OF_RANGE, trimmerHeaterInternalTemp ); - } - else if ( trimmerHeaterColdJunctionTemp > HEATERS_MAX_ALLOWED_COLD_JUNCTION_TEMPERATURE_C ) - { - isTempOut = TRUE; - //SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_TRIMMER_HEATER_CJ_TEMP_OUT_OF_RANGE, trimmerHeaterColdJunctionTemp ); - } - -#ifndef IGNORE_HEATERS_MONITOR - // If it is above the range for the first time, stop the trimmer heater - // and set the variables - if ( ( FALSE == isTrimmerHeaterTempOutOfRange ) && ( TRUE == isTempOut ) ) - { - stopTrimmerHeater(); - isTrimmerHeaterTempOutOfRange = TRUE; - trimmerHeaterTempOutTimer = getMSTimerCount(); - } - // If the trimmer heater internal temperature was out for more than the define period, activate the safety shutdown - else if ( ( TRUE == isTrimmerHeaterTempOutOfRange ) && - ( TRUE == didTimeout( trimmerHeaterTempOutTimer, HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_TIMEOUT_MS ) ) ) - { - activateSafetyShutdown(); - } -#endif -} - -/*********************************************************************//** - * @brief * The monitorHeatersVoltage function monitors the heaters' voltages * @details Inputs: voltageMonitorTimeCounter * @details Outputs: voltageMonitorTimeCounter