Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -ra9315539f527b92523b1598ff91e47db4d71dae2 -r0803f828b81e046166457564650acf6a9bbd3cc6 --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision a9315539f527b92523b1598ff91e47db4d71dae2) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 0803f828b81e046166457564650acf6a9bbd3cc6) @@ -26,7 +26,9 @@ #include "InternalADC.h" #include "MessageSupport.h" #include "ModeFill.h" +#include "NVDataMgmt.h" #include "OperationModes.h" +#include "PersistentAlarm.h" #include "Reservoirs.h" #include "ROPump.h" #include "SafetyShutdown.h" @@ -43,35 +45,35 @@ // ********** private definitions ********** -#define HEATERS_MAX_DUTY_CYCLE 1.00 ///< Heaters max duty cycle (100%). -#define HEATERS_MIN_DUTY_CYCLE 0.00 ///< Heaters minimum duty cycle (0.00%). -#define HEATERS_MIN_HEAT_DISINFECT_DUTY_CYCLE 0.6 ///< Heaters minimum duty cycle during heat disinfect. +#define HEATERS_MAX_DUTY_CYCLE 1.00F ///< Heaters max duty cycle (100%). +#define HEATERS_MIN_DUTY_CYCLE 0.00F ///< Heaters minimum duty cycle (0.00%). +#define HEATERS_MIN_HEAT_DISINFECT_DUTY_CYCLE 0.6F ///< Heaters minimum duty cycle during heat disinfect. #define HEATERS_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Heaters data publish interval. -#define MINIMUM_TARGET_TEMPERATURE 10.0 ///< Minimum allowed target temperature for the heaters. -#define MAXIMUM_TARGET_TEMPERATURE 90.0 ///< Maximum allowed target temperature for the heaters. -#define MAXIMUM_IDLE_DRAIN_TARGET_TEMPERATURE 58.0 ///< Maximum allowed target temperature for the idle and drain modes. +#define MINIMUM_TARGET_TEMPERATURE 10.0F ///< Minimum allowed target temperature for the heaters. +#define MAXIMUM_TARGET_TEMPERATURE 90.0F ///< Maximum allowed target temperature for the heaters. +#define MAXIMUM_IDLE_DRAIN_TARGET_TEMPERATURE 58.0F ///< Maximum allowed target temperature for the idle and drain modes. #define HEATERS_CONTROL_STATE_CHECK_INTERVAL_COUNT ( ( 10 * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ) ///< Temperature sensors interval count. #define HEATERS_ON_WITH_NO_FLOW_TIMEOUT_COUNT ( ( 3 * MS_PER_SECOND ) / TASK_PRIORITY_INTERVAL ) ///< Heaters are on but there is no sufficient flow timeout in counts. -#define HEATERS_MAX_ALLOWED_INTERNAL_TEMPERATURE_C 170.0 ///< Heaters max allowed internal temperature in C. -#define HEATERS_MAX_ALLOWED_COLD_JUNCTION_TEMPERATURE_C 80.0 ///< Heaters max allowed cold junction temperature in C. +#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_MAX_OPERATING_VOLTAGE_V 24.0 ///< 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.2 ///< Heaters max voltage out of range tolerance. +#define HEATERS_ON_NO_FLOW_TIMEOUT_MS ( 1 * 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_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 DELTA_TEMPERATURE_TIME_COSNTANT_C 8.6 ///< Delta temperature calculated from time constant. -#define MAXIMUM_ALLOWED_TARGET_TEMPERATURE_DEVIATION_C 0.25 ///< Maximum allowed temperature deviation from target temperature in C. -#define PRIMARY_HEATER_DUTY_CYCLE_PER_TEMPERATURE_C 0.03 ///< Primary heaters duty cycle per temperature in C. +#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 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. static const F32 WATER_SPECIFIC_HEAT_DIVIDED_BY_MINUTES = 4184 / SEC_PER_MIN; ///< Water specific heat in J/KgC / 60. -static const F32 PRIMARY_HEATERS_MAXIMUM_POWER_WATTS = 475 + 237.5; ///< Primary heaters maximum power (main primary = 475W and small primary = 237.5W). +static const F32 PRIMARY_HEATERS_MAXIMUM_POWER_WATTS = 475 + 237.5F; ///< Primary heaters maximum power (main primary = 475W and small primary = 237.5W). /// Heaters exec states typedef enum Heaters_Exec_States @@ -88,27 +90,22 @@ /// 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. - BOOL isFlowBelowMin; ///< Heater flow below minimum flag indicator. + F32 dutycycle; ///< Heater duty cycle. + F32 targetROFlow; ///< Heater target flow. 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; static HEATER_STATUS_T heatersStatus[ NUM_OF_DG_HEATERS ]; ///< Heaters status. 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. // ********** private function prototypes ********** @@ -141,23 +138,32 @@ void initHeaters( void ) { DG_HEATERS_T heater; - - voltageMonitorTimeCounter = 0; dataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; 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; - heatersStatus[ heater ].targetROFlow = 0.0; - heatersStatus[ heater ].hasTargetTempChanged = FALSE; - heatersStatus[ heater ].heaterEfficiency = 1.0; // Assuming 100% efficiency during initialization until it is updated - heatersStatus[ heater ].hasTargetBeenReached = FALSE; + heatersStatus[ heater ].targetTemp = 0.0; + heatersStatus[ heater ].state = HEATER_EXEC_STATE_OFF; + heatersStatus[ heater ].startHeaterSignal = FALSE; + heatersStatus[ heater ].isHeaterOn = FALSE; + heatersStatus[ heater ].dutycycle = 0.0; + heatersStatus[ heater ].targetROFlow = 0.0; + heatersStatus[ heater ].hasTargetTempChanged = FALSE; + heatersStatus[ heater ].heaterEfficiency = 1.0; // Assuming 100% efficiency during initialization until it is updated + heatersStatus[ heater ].hasTargetBeenReached = FALSE; } + + // Initialize the persistent alarms + initPersistentAlarm( ALARM_ID_DG_MAIN_PRIMARY_HEATER_VOLTAGE_OUT_OF_RANGE, HEATERS_VOLTAGE_OUT_OF_RANGE_TIMEOUT_MS, + HEATERS_VOLTAGE_OUT_OF_RANGE_TIMEOUT_MS ); + + initPersistentAlarm( ALARM_ID_DG_SMALL_PRIMARY_HEATER_VOLTAGE_OUT_OF_RANGE, HEATERS_VOLTAGE_OUT_OF_RANGE_TIMEOUT_MS, + HEATERS_VOLTAGE_OUT_OF_RANGE_TIMEOUT_MS ); + + initPersistentAlarm( ALARM_ID_DG_TRIMMER_HEATER_VOLTAGE_OUT_OF_RANGE, HEATERS_VOLTAGE_OUT_OF_RANGE_TIMEOUT_MS, + HEATERS_VOLTAGE_OUT_OF_RANGE_TIMEOUT_MS ); + + initPersistentAlarm( ALARM_ID_DG_FLOW_TOO_LOW_WHILE_HEATER_ON, HEATERS_ON_NO_FLOW_TIMEOUT_MS, HEATERS_ON_NO_FLOW_TIMEOUT_MS ); } /*********************************************************************//** @@ -324,12 +330,15 @@ { if ( ( heaterCmdPtr->targetTemp >= MINIMUM_TARGET_TEMPERATURE ) && ( heaterCmdPtr->targetTemp <= MAXIMUM_TARGET_TEMPERATURE ) ) { - cmdResponse.rejected = FALSE; + 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 - 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 { @@ -357,49 +366,33 @@ *************************************************************************/ void execHeatersMonitor( void ) { -#ifndef IGNORE_HEATERS_MONITOR DG_HEATERS_T heater; 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 heater is on and if it is, check the flow sensor's status + if ( TRUE == heatersStatus[ heater ].isHeaterOn ) { // 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 ? getMeasuredROFlowRate() : 50.0 ); - // TODO get the minimum new flow sensor flow sensor + F32 measFlow = ( DG_PRIMARY_HEATER == heater ? getMeasuredROFlowRateLPM() : 50.0 ); F32 minFlow = ( DG_PRIMARY_HEATER == heater ? MIN_RO_FLOWRATE_LPM : MIN_RO_FLOWRATE_LPM ); BOOL isFlowLow = ( measFlow < minFlow ? TRUE : FALSE ); - if ( TRUE == isFlowLow ) - { - // 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 - { - heatersStatus[ heater ].isFlowBelowMin = FALSE; - heatersStatus[ heater ].heaterOnWithNoFlowTimer = getMSTimerCount(); - } + checkPersistentAlarm( ALARM_ID_DG_FLOW_TOO_LOW_WHILE_HEATER_ON, isFlowLow, measFlow, minFlow ); } + else + { + checkPersistentAlarm( ALARM_ID_DG_FLOW_TOO_LOW_WHILE_HEATER_ON, FALSE, 0.0, 0.0 ); + } } - monitorHeatersVoltage(); +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_HEATERS_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) #endif + { + monitorHeatersVoltage(); + } // Check for data publication publishHeatersData(); @@ -630,17 +623,24 @@ *************************************************************************/ static void setHeaterDutyCycle( DG_HEATERS_T heater, F32 pwm ) { - if ( DG_PRIMARY_HEATER == heater ) + // Check if the requested duty cycle is different from what the heater's duty cycle is. + // If the same duty cycle is requested, then it is not needed to send it again. This is to make sure + // the same duty cycle is not sent to the hardware all the time. + if ( fabs( heatersStatus[ heater ].dutycycle - pwm ) > NEARLY_ZERO ) { - setMainPrimaryHeaterPWM( pwm ); - setSmallPrimaryHeaterPWM( pwm ); - } - else if ( DG_TRIMMER_HEATER == heater ) - { - setTrimmerHeaterPWM( pwm ); - } + if ( DG_PRIMARY_HEATER == heater ) + { + setMainPrimaryHeaterPWM( pwm ); + setSmallPrimaryHeaterPWM( pwm ); + } + else if ( DG_TRIMMER_HEATER == heater ) + { + setTrimmerHeaterPWM( pwm ); + } - heatersStatus[ heater ].dutycycle = pwm; + // Updated the heater's information + heatersStatus[ heater ].dutycycle = pwm; + } } /*********************************************************************//** @@ -659,30 +659,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 @@ -843,39 +846,36 @@ *************************************************************************/ static void monitorHeatersVoltage( void ) { - if ( ++voltageMonitorTimeCounter >= HEATERS_VOLTAGE_MONITOR_TIME_INTERVAL ) - { - F32 mainPriVoltage = getIntADCVoltageConverted( INT_ADC_PRIMARY_HEATER_24_VOLTS ); - // TODO it is assumed that the main and small primary heaters have equal voltage since the PWMs are divided into 2 - // before applying the PWMs to the heaters. Right now, there is no ADC channel available for the small primary - // heater so the main primary heater's ADC channel is used for the small primary heater as well. - F32 smallPriVoltage = getIntADCVoltageConverted( INT_ADC_PRIMARY_HEATER_24_VOLTS ); - F32 trimmerVoltage = getIntADCVoltageConverted( INT_ADC_TRIMMER_HEATER_24_VOLTS ); + F32 mainPriVoltage = getIntADCVoltageConverted( INT_ADC_PRIMARY_HEATER_24_VOLTS ); + // TODO it is assumed that the main and small primary heaters have equal voltage since the PWMs are divided into 2 + // before applying the PWMs to the heaters. Right now, there is no ADC channel available for the small primary + // heater so the main primary heater's ADC channel is used for the small primary heater as well. + F32 smallPriVoltage = getIntADCVoltageConverted( INT_ADC_PRIMARY_HEATER_24_VOLTS ); + F32 trimmerVoltage = getIntADCVoltageConverted( INT_ADC_TRIMMER_HEATER_24_VOLTS ); - // Voltage to PWM is reverse. If PWM = 0 -> V = 24V - F32 mainPri = 1.0 - heatersStatus[ DG_PRIMARY_HEATER ].dutycycle; - F32 smallPri = 1.0 - heatersStatus[ DG_PRIMARY_HEATER ].dutycycle; - F32 trimmer = 1.0 - heatersStatus[ DG_TRIMMER_HEATER ].dutycycle; + // Voltage to PWM is reverse. If PWM = 0 -> V = 24V + F32 mainPri = heatersStatus[ DG_PRIMARY_HEATER ].dutycycle > NEARLY_ZERO ? heatersStatus[ DG_PRIMARY_HEATER ].dutycycle : 1.0; + F32 smallPri = heatersStatus[ DG_PRIMARY_HEATER ].dutycycle > NEARLY_ZERO ? heatersStatus[ DG_PRIMARY_HEATER ].dutycycle : 1.0; + F32 trimmer = heatersStatus[ DG_TRIMMER_HEATER ].dutycycle > NEARLY_ZERO ? heatersStatus[ DG_TRIMMER_HEATER ].dutycycle : 1.0; - // Check main primary heater's voltage - // The corresponding voltage of the current PWM must be close to the sensed voltage - if ( fabs( ( HEATERS_MAX_OPERATING_VOLTAGE_V * mainPri ) - mainPriVoltage ) > HEATERS_MAX_VOLTAGE_OUT_OF_RANGE_TOL * mainPriVoltage ) - { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DG_MAIN_PRIMARY_HEATER_VOLTAGE_OUT_OF_RANGE, mainPriVoltage ); - } - // Check small primary heater's voltage - if ( fabs( ( HEATERS_MAX_OPERATING_VOLTAGE_V * smallPri ) - smallPriVoltage ) > HEATERS_MAX_VOLTAGE_OUT_OF_RANGE_TOL * smallPriVoltage ) - { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DG_SMALL_PRIMARY_HEATER_VOLTAGE_OUT_OF_RANGE, smallPriVoltage ); - } - // 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 ); - } + F32 mainPriVoltageTol = HEATERS_MAX_VOLTAGE_OUT_OF_RANGE_TOL * mainPriVoltage; + F32 smallPriVoltageTol = HEATERS_MAX_VOLTAGE_OUT_OF_RANGE_TOL * smallPriVoltage; + F32 trimmerVoltageTol = HEATERS_MAX_VOLTAGE_OUT_OF_RANGE_TOL * trimmerVoltage; - voltageMonitorTimeCounter = 0; + BOOL isMainPriOut = ( fabs( ( HEATERS_MAX_OPERATING_VOLTAGE_V * mainPri ) - mainPriVoltage ) > mainPriVoltageTol ? TRUE : FALSE ); + BOOL isSmallPriOut = ( fabs( ( HEATERS_MAX_OPERATING_VOLTAGE_V * smallPri ) - smallPriVoltage ) > smallPriVoltageTol ? TRUE : FALSE ); + BOOL isTrimmerOut = ( fabs( ( HEATERS_MAX_OPERATING_VOLTAGE_V * trimmer ) - trimmerVoltage ) > trimmerVoltageTol ? TRUE : FALSE ); + + checkPersistentAlarm( ALARM_ID_DG_MAIN_PRIMARY_HEATER_VOLTAGE_OUT_OF_RANGE, isMainPriOut, mainPri, mainPriVoltageTol ); + checkPersistentAlarm( ALARM_ID_DG_SMALL_PRIMARY_HEATER_VOLTAGE_OUT_OF_RANGE, isSmallPriOut, smallPri, smallPriVoltageTol ); + //checkPersistentAlarm( ALARM_ID_DG_TRIMMER_HEATER_VOLTAGE_OUT_OF_RANGE, isTrimmerOut, trimmer, trimmerVoltageTol ); // TODO check this voltage + + // TODO test code remove + if ( TRUE == isAlarmActive(ALARM_ID_DG_TRIMMER_HEATER_VOLTAGE_OUT_OF_RANGE)) + { + BOOL test = FALSE; } + // TODO test code remove } @@ -900,7 +900,7 @@ { U32 interval = value / TASK_PRIORITY_INTERVAL; - result = TRUE; + result = TRUE; heatersDataPublishInterval.ovData = interval; heatersDataPublishInterval.override = OVERRIDE_KEY; } @@ -922,7 +922,7 @@ if ( TRUE == isTestingActivated() ) { - result = TRUE; + result = TRUE; heatersDataPublishInterval.override = OVERRIDE_RESET; heatersDataPublishInterval.ovData = heatersDataPublishInterval.ovInitData; }