Index: firmware/App/Controllers/DrainPump.c =================================================================== diff -u -rfc78b1e5af6d7ab8f7656b410c4cacdfd76a49e6 -r52e31227bb0514145596b43bd2f39782c3648f0a --- firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision fc78b1e5af6d7ab8f7656b410c4cacdfd76a49e6) +++ firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 52e31227bb0514145596b43bd2f39782c3648f0a) @@ -122,7 +122,8 @@ static F32 targetDrainPumpOutletFlowLPM; ///< Target outlet pressure for the drain pump. static U32 drainControlTimerCtr; ///< Determines when to perform control on drain pump. static BOOL hasClosedLoopBeenRequested; ///< Closed loop pump control flag. -static OVERRIDE_U32_T drainPumpMeasuredRPM = { 0, 0, 0, 0 }; ///< Measured drain pump RPM from feedback. +static OVERRIDE_U32_T drainPumpHallMeasuredRPM = { 0, 0, 0, 0 }; ///< Measured drain pump RPM from feedback. +static OVERRIDE_U32_T drainPumpMaxonMeasuredRPM = { 0, 0, 0, 0 }; ///< Measured Maxon drain pump RPM. static OVERRIDE_F32_T drainPumpMeasuredCurrentA = { 0.0F, 0.0F, 0.0F, 0 }; ///< Measured drain pump current feedback. static OVERRIDE_U32_T drainPumpMeasuredDir = { 0, 0, 0, 0 }; ///< Measured drain pump direction. static BOOL signalNewRPMRequest; ///< Signal flag the indicates there is a new RPM request. @@ -333,11 +334,15 @@ *************************************************************************/ void execDrainPumpMonitor( void ) { - U16 fpgaADCSpeedCount = getFPGADrainPumpSpeed(); - U16 fpgaADCCurrentCount = getFPGADrainPumpCurrentFeedback(); - F32 currentA = getDrainPumpMeasuredCurrentA(); - U32 dirHallSensorErrorCount = (U32)( getFPGADrainPumpDirection() & DRAIN_PUMP_DIR_ERROR_CNT_BIT_MASK ); - drainPumpMeasuredRPM.data = ( DRAIN_PUMP_OFF_RPM_ADC_COUNT == fpgaADCSpeedCount ? 0 : (U32)( RPM_CONVERSION_COEFF / (F32)fpgaADCSpeedCount ) ); + U16 fpgaADCSpeedCount = getFPGADrainPumpSpeed(); + U16 fpgaMaxonADCSpeedCount = getFPGADrainPumpSpeedFeedback(); + U16 fpgaADCCurrentCount = getFPGADrainPumpCurrentFeedback(); + F32 currentA = getDrainPumpMeasuredCurrentA(); + U32 dirHallSensorErrorCount = (U32)( getFPGADrainPumpDirection() & DRAIN_PUMP_DIR_ERROR_CNT_BIT_MASK ); + + // Update the override variables + drainPumpMaxonMeasuredRPM.data = MAX_DRAIN_PUMP_RPM * ( (F32)fpgaMaxonADCSpeedCount / (F32)BITS_12_FULL_SCALE ); + drainPumpHallMeasuredRPM.data = ( DRAIN_PUMP_OFF_RPM_ADC_COUNT == fpgaADCSpeedCount ? 0 : (U32)( RPM_CONVERSION_COEFF / (F32)fpgaADCSpeedCount ) ); drainPumpMeasuredCurrentA.data = (F32)fpgaADCCurrentCount * CURRENT_CONVERSION_COEFF; drainPumpMeasuredDir.data = (U32)( ( getFPGADrainPumpDirection() & DRAIN_PUMP_DIR_BIT_MASK ) >> SHIFT_BITS_BY_7 ); @@ -346,7 +351,7 @@ #endif { #ifndef _RELEASE_ - if ( ( getHardwareConfigStatus() != HW_CONFIG_BETA ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) + if ( getHardwareConfigStatus() != HW_CONFIG_BETA ) #endif { checkFPGAPersistentErrorCountAlarm( FPGA_PERS_ERROR_DRAIN_PUMP_DIR_HALL_SENSOR, dirHallSensorErrorCount ); @@ -356,20 +361,23 @@ { case DRAIN_PUMP_OFF_STATE: { + BOOL isRPMTooHigh = FALSE; BOOL isOffCurrentOut = ( currentA > DRAIN_PUMP_MAX_CURRENT_WHEN_OFF_A ? TRUE : FALSE ); - BOOL isRPMTooHigh = ( getDrainPumpMeasuredRPM() > MIN_DRAIN_PUMP_RPM ? TRUE : FALSE ); - checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_RPM_OUT_OF_RANGE, FALSE, getDrainPumpMeasuredRPM(), MAX_ALLOWED_OPEN_LOOP_RPM_OUT_OF_RANGE ); - checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_OFF_FAULT, isRPMTooHigh, getDrainPumpMeasuredRPM(), MIN_DRAIN_PUMP_RPM ); + isRPMTooHigh |= ( getDrainPumpMeasuredRPM( DRAIN_PUMP_HALL_SNSR_FB ) > MIN_DRAIN_PUMP_RPM ? TRUE : FALSE ); + isRPMTooHigh |= ( getDrainPumpMeasuredRPM( DRAIN_PUMP_MAXON_SNSR_FB ) > MIN_DRAIN_PUMP_RPM ? TRUE : FALSE ); + checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_RPM_OUT_OF_RANGE, FALSE, getDrainPumpMeasuredRPM( DRAIN_PUMP_HALL_SNSR_FB ), MAX_ALLOWED_OPEN_LOOP_RPM_OUT_OF_RANGE ); + checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_OFF_FAULT, isRPMTooHigh, getDrainPumpMeasuredRPM( DRAIN_PUMP_HALL_SNSR_FB ), MIN_DRAIN_PUMP_RPM ); + // If the off fault alarm has become active, trigger the safety shutdown if ( TRUE == isAlarmActive( ALARM_ID_DG_DRAIN_PUMP_OFF_FAULT ) ) { activateSafetyShutdown(); } #ifndef _RELEASE_ - if ( ( getHardwareConfigStatus() != HW_CONFIG_BETA ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) + if ( getHardwareConfigStatus() != HW_CONFIG_BETA ) #endif { checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_CURRENT_OUT_OF_RANGE, isOffCurrentOut, currentA, DRAIN_PUMP_MAX_CURRENT_WHEN_OFF_A ); @@ -381,18 +389,30 @@ // The RPM is only checked in open loop state that the pump is run at a fixed RPM. case DRAIN_PUMP_OPEN_LOOP_STATE: { + U32 rpmHall = getDrainPumpMeasuredRPM( DRAIN_PUMP_HALL_SNSR_FB ); + U32 rpmMaxon = getDrainPumpMeasuredRPM( DRAIN_PUMP_MAXON_SNSR_FB ); + BOOL isRPMOutOfRange = FALSE; U32 direction = getDrainPumpMeasuredDirection(); BOOL isDirInvalid = ( direction != DRAIN_PUMP_FORWARD_DIR ? TRUE : FALSE ); - U32 rpmDiff = abs( getDrainPumpTargetRPM() - getDrainPumpMeasuredRPM() ); - BOOL isRPMOutOfRange = ( rpmDiff > MAX_ALLOWED_OPEN_LOOP_RPM_OUT_OF_RANGE ? TRUE : FALSE ); + U32 rpmHallDiff = abs( getDrainPumpTargetRPM() - rpmHall ); + U32 rpmMaxonDiff = abs( getDrainPumpTargetRPM() - rpmMaxon ); - checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_RPM_OUT_OF_RANGE, isRPMOutOfRange, getDrainPumpMeasuredRPM(), MAX_ALLOWED_OPEN_LOOP_RPM_OUT_OF_RANGE ); - checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_OFF_FAULT, FALSE, getDrainPumpMeasuredRPM(), MIN_DRAIN_PUMP_RPM ); + isRPMOutOfRange |= ( rpmHallDiff > MAX_ALLOWED_OPEN_LOOP_RPM_OUT_OF_RANGE ? TRUE : FALSE ); #ifndef _RELEASE_ - if ( ( getHardwareConfigStatus() != HW_CONFIG_BETA ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) + if ( getHardwareConfigStatus() != HW_CONFIG_BETA ) #endif { + isRPMOutOfRange |= ( rpmMaxonDiff > MAX_ALLOWED_OPEN_LOOP_RPM_OUT_OF_RANGE ? TRUE : FALSE ); + } + + checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_RPM_OUT_OF_RANGE, isRPMOutOfRange, rpmHall, MAX_ALLOWED_OPEN_LOOP_RPM_OUT_OF_RANGE ); + checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_OFF_FAULT, FALSE, rpmHall, MIN_DRAIN_PUMP_RPM ); + +#ifndef _RELEASE_ + if ( getHardwareConfigStatus() != HW_CONFIG_BETA ) +#endif + { checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_DIRECTION_INVALID, isDirInvalid, (F32)direction, DRAIN_PUMP_FORWARD_DIR ); } } @@ -404,7 +424,7 @@ BOOL isDirInvalid = ( direction != DRAIN_PUMP_FORWARD_DIR ? TRUE : FALSE ); #ifndef _RELEASE_ - if ( ( getHardwareConfigStatus() != HW_CONFIG_BETA ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) + if ( getHardwareConfigStatus() != HW_CONFIG_BETA ) #endif { checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_DIRECTION_INVALID, isDirInvalid, (F32)direction, DRAIN_PUMP_FORWARD_DIR ); @@ -414,17 +434,17 @@ default: // There are not out of range conditions, clear the alarms - checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_RPM_OUT_OF_RANGE, FALSE, getDrainPumpMeasuredRPM(), MAX_ALLOWED_OPEN_LOOP_RPM_OUT_OF_RANGE ); - checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_OFF_FAULT, FALSE, getDrainPumpMeasuredRPM(), MIN_DRAIN_PUMP_RPM ); + checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_RPM_OUT_OF_RANGE, FALSE, getDrainPumpMeasuredRPM( DRAIN_PUMP_HALL_SNSR_FB ), MAX_ALLOWED_OPEN_LOOP_RPM_OUT_OF_RANGE ); + checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_OFF_FAULT, FALSE, getDrainPumpMeasuredRPM( DRAIN_PUMP_HALL_SNSR_FB ), MIN_DRAIN_PUMP_RPM ); checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_DIRECTION_INVALID, FALSE, getFPGADrainPumpDirection(), DRAIN_PUMP_FORWARD_DIR ); break; } #ifndef _RELEASE_ - if ( ( getHardwareConfigStatus() != HW_CONFIG_BETA ) && ( getCurrentOperationMode() != DG_MODE_INIT ) ) + if ( getHardwareConfigStatus() != HW_CONFIG_BETA ) #endif { - // Check the persistent alarm for the maximum drain pump current + // Check the persistent alarm for the maximum drain pump current BOOL isCurrentOutOfRange = ( currentA > DRAIN_PUMP_MAX_CURRENT_A ? TRUE : FALSE ); checkPersistentAlarm( ALARM_ID_DG_DRAIN_PUMP_CURRENT_OUT_OF_RANGE, isCurrentOutOfRange, currentA, DRAIN_PUMP_MAX_CURRENT_A ); @@ -555,12 +575,22 @@ * pump RPM sensor. * @details Inputs: drainPumpMeasuredRPM * @details Outputs: none + * @param sensor to get its RPM from (Hall sensor or Maxon board in DVT) * @return drain pump RPM *************************************************************************/ -U32 getDrainPumpMeasuredRPM( void ) +U32 getDrainPumpMeasuredRPM( DRAIN_PUMP_SPEED_FB_SNSR_T sensor ) { - U32 rpm = getU32OverrideValue( &drainPumpMeasuredRPM ); + U32 rpm = 0; + if ( DRAIN_PUMP_HALL_SNSR_FB == sensor ) + { + rpm = getU32OverrideValue( &drainPumpHallMeasuredRPM ); + } + else if ( DRAIN_PUMP_MAXON_SNSR_FB == sensor ) + { + rpm = getU32OverrideValue( &drainPumpMaxonMeasuredRPM ); + } + return rpm; } @@ -783,10 +813,11 @@ drainPumpData.rpmSetPoint = getDrainPumpTargetRPM(); drainPumpData.pumpDACSet = drainPumpDACSet; drainPumpData.drainPumpState = (U32)drainPumpState; - drainPumpData.drainPumpRPM = getDrainPumpMeasuredRPM(); + drainPumpData.drainPumpHallRPM = getDrainPumpMeasuredRPM( DRAIN_PUMP_HALL_SNSR_FB ); drainPumpData.trgtOutletFlowLPM = targetDrainPumpOutletFlowLPM; drainPumpData.drainPumpCurrentA = getDrainPumpMeasuredCurrentA(); drainPumpData.drainPumpDirection = getDrainPumpMeasuredDirection(); + drainPumpData.drainPumpMaxonRPM = getDrainPumpMeasuredRPM( DRAIN_PUMP_MAXON_SNSR_FB ); broadcastData( MSG_ID_DRAIN_PUMP_DATA, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&drainPumpData, sizeof( DRAIN_PUMP_DATA_T ) ); @@ -936,21 +967,32 @@ * The testSetDrainPumpMeasuredRPMOverride function overrides the drain pump * measured RPM data. * @details Inputs: none - * @details Outputs: drainPumpMeasuredRPM + * @details Outputs: drainPumpHallMeasuredRPM, drainPumpMaxonMeasuredRPM + * @param sensor the type of sensor to pick (hall sensor or Maxon board) * @param value override drain pump measured data * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetDrainPumpMeasuredRPMOverride( U32 value ) +BOOL testSetDrainPumpMeasuredRPMOverride( U32 sensor, U32 value ) { BOOL status = FALSE; // Check if the user is logged in - if ( TRUE == isTestingActivated() ) + if ( ( TRUE == isTestingActivated() ) && ( (DRAIN_PUMP_SPEED_FB_SNSR_T)sensor < NUM_OF_DRAIN_PUMP_SNSR_FB ) ) { - drainPumpMeasuredRPM.ovData = value; - drainPumpMeasuredRPM.override = OVERRIDE_KEY; - drainPumpMeasuredRPM.ovInitData = drainPumpMeasuredRPM.data; - status = TRUE; + if ( DRAIN_PUMP_HALL_SNSR_FB == (DRAIN_PUMP_SPEED_FB_SNSR_T)sensor ) + { + drainPumpHallMeasuredRPM.ovData = value; + drainPumpHallMeasuredRPM.override = OVERRIDE_KEY; + drainPumpHallMeasuredRPM.ovInitData = drainPumpHallMeasuredRPM.data; + } + else if ( DRAIN_PUMP_MAXON_SNSR_FB == (DRAIN_PUMP_SPEED_FB_SNSR_T)sensor ) + { + drainPumpMaxonMeasuredRPM.ovData = value; + drainPumpMaxonMeasuredRPM.override = OVERRIDE_KEY; + drainPumpMaxonMeasuredRPM.ovInitData = drainPumpMaxonMeasuredRPM.data; + } + + status = TRUE; } return status; @@ -962,18 +1004,28 @@ * measured RPM data. * @details Inputs: none * @details Outputs: drainPumpMeasuredRPM + * @param sensor the type of sensor to pick (hall sensor or Maxon board) * @return TRUE if override reset successful, FALSE if not *************************************************************************/ -BOOL testResetDrainPumpMeasuredRPMOverride( void ) +BOOL testResetDrainPumpMeasuredRPMOverride( U32 sensor ) { BOOL status = FALSE; // Check if the user is logged in - if ( TRUE == isTestingActivated() ) + if ( ( TRUE == isTestingActivated() ) && ( (DRAIN_PUMP_SPEED_FB_SNSR_T)sensor < NUM_OF_DRAIN_PUMP_SNSR_FB ) ) { - drainPumpMeasuredRPM.ovData = drainPumpMeasuredRPM.ovInitData; - drainPumpMeasuredRPM.override = OVERRIDE_RESET; - status = TRUE; + if ( DRAIN_PUMP_HALL_SNSR_FB == (DRAIN_PUMP_SPEED_FB_SNSR_T)sensor ) + { + drainPumpHallMeasuredRPM.ovData = drainPumpHallMeasuredRPM.ovInitData; + drainPumpHallMeasuredRPM.override = OVERRIDE_RESET; + } + else if ( DRAIN_PUMP_MAXON_SNSR_FB == (DRAIN_PUMP_SPEED_FB_SNSR_T)sensor ) + { + drainPumpMaxonMeasuredRPM.ovData = drainPumpMaxonMeasuredRPM.ovInitData; + drainPumpMaxonMeasuredRPM.override = OVERRIDE_RESET; + } + + status = TRUE; } return status;