Index: firmware/App/Controllers/DrainPump.c =================================================================== diff -u -r22176ce95e49213c48454f34ddf5d29b8109f2cb -r87ebf31788a90216c65e0264e2b8cb21d25e5b9b --- firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 22176ce95e49213c48454f34ddf5d29b8109f2cb) +++ firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 87ebf31788a90216c65e0264e2b8cb21d25e5b9b) @@ -8,7 +8,7 @@ * @file DrainPump.c * * @author (last) Dara Navaei -* @date (last) 20-Apr-2022 +* @date (last) 11-Jul-2022 * * @author (original) Sean * @date (original) 08-Apr-2020 @@ -58,7 +58,7 @@ FLOAT_TO_INT_ROUNDUP_OFFSET ) ///< RPM to DAC conversion equation. #define TOGGLE_PERIOD_RESOLUTION_SECONDS 0.000005F ///< Toggle period to resolution in seconds. -#define ROTATIONAL_TO_TOGGLE_PERIOD_CONVERSION 4 ///< Rotational to toggle period conversion coefficient. +#define ROTATIONAL_TO_TOGGLE_PERIOD_CONVERSION 4.0F ///< Rotational to toggle period conversion coefficient. #define DRAIN_PUMP_P_COEFFICIENT 0.5F ///< P term for drain pump delta pressure control. #define DRAIN_PUMP_I_COEFFICIENT 1.0F ///< I term for drain pump delta pressure control. @@ -123,7 +123,7 @@ static DG_DRAIN_PUMP_CAL_RECORD_T drainPumpCalRecord; ///< Drain pump calibration record. /// ADC to RPM conversion coefficient or RPM to ADC conversion. -static const F32 CONVERSION_COEFF = SEC_PER_MIN / ( 2 * TOGGLE_PERIOD_RESOLUTION_SECONDS * ROTATIONAL_TO_TOGGLE_PERIOD_CONVERSION ); +static const F32 CONVERSION_COEFF = (F32) SEC_PER_MIN / ( 2.0F * TOGGLE_PERIOD_RESOLUTION_SECONDS * ROTATIONAL_TO_TOGGLE_PERIOD_CONVERSION ); // ********** private function prototypes ********** @@ -183,7 +183,7 @@ // If this function was called, delayed command does not need to be executed // so the pending count down is zeroed. pendingDrainPumpCmdCountDown = 0; - result = TRUE; + result = TRUE; } else { @@ -324,18 +324,9 @@ *************************************************************************/ void execDrainPumpMonitor( void ) { - U16 const fpgaADCSpeedCount = getFPGADrainPumpSpeed(); + U16 fpgaADCSpeedCount = getFPGADrainPumpSpeed(); + drainPumpMeasuredRPM.data = ( DRAIN_PUMP_OFF_RPM_ADC_COUNT == fpgaADCSpeedCount ? 0 : ( CONVERSION_COEFF / fpgaADCSpeedCount ) ); - if ( DRAIN_PUMP_OFF_RPM_ADC_COUNT == fpgaADCSpeedCount ) - { - drainPumpMeasuredRPM.data = 0; - } - else - { - // Convert speed ADC to RPM - drainPumpMeasuredRPM.data = CONVERSION_COEFF / getFPGADrainPumpSpeed(); - } - #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_DRAIN_PUMP_MONITOR ) != SW_CONFIG_ENABLE_VALUE ) #endif @@ -358,9 +349,7 @@ else if ( DRAIN_PUMP_OPEN_LOOP_STATE == drainPumpState ) { // Using abs since the read RPM can be above or below the target - U32 rpmDiff = abs( getDrainPumpTargetRPM() - getDrainPumpMeasuredRPM() ); - - // Check if RPM is out of range + U32 rpmDiff = abs( getDrainPumpTargetRPM() - getDrainPumpMeasuredRPM() ); BOOL isRPMOutOfRange = ( rpmDiff > MAX_ALLOWED_OPEN_LOOP_RPM_OUT_OF_RANGE ? TRUE : FALSE ); checkPersistentAlarm( ALARM_ID_DRAIN_PUMP_RPM_OUT_OF_RANGE, isRPMOutOfRange, getDrainPumpMeasuredRPM(), MAX_ALLOWED_OPEN_LOOP_RPM_OUT_OF_RANGE );