Index: firmware/App/Controllers/Fans.c =================================================================== diff -u -r22f1a58ac8e419353ec004b04e7c765c1d59df2b -r922516483829939a2a387d4a2fddeccdb4c454d4 --- firmware/App/Controllers/Fans.c (.../Fans.c) (revision 22f1a58ac8e419353ec004b04e7c765c1d59df2b) +++ firmware/App/Controllers/Fans.c (.../Fans.c) (revision 922516483829939a2a387d4a2fddeccdb4c454d4) @@ -51,7 +51,8 @@ /// Fans status struct typedef struct { - F32 targetDutyCycle; ///< Fan's target duty cycle that was fed to the fans. + F32 dutyCycle; ///< Fans duty cycle that was fed to the fans. + F32 targetRPM; ///< Fans target RPM. OVERRIDE_F32_T rpm[ NUM_OF_FANS_NAMES ]; ///< Fan's current tachometers reading in RPM. } FAN_STATUS_T; @@ -89,7 +90,7 @@ * @details Inputs: none * @details Outputs: fansExecState, fansStatus, fansControlCounter, * fansPublishCounter, fansMonitorCounter, isPOSTComplete, hasAlarmBeenRaised, - * rpmAlarmStartTimer + * rpmAlarmStartTimer, fansStatus * @return none *************************************************************************/ void initFans( void ) @@ -108,6 +109,8 @@ // Initialize the fans for ( fan = FAN_INLET_1; fan < NUM_OF_FANS_NAMES; fan++ ) { + fansStatus.dutyCycle = 0.0; + fansStatus.targetRPM = 0.0; fansStatus.rpm[ fan ].data = 0.0; fansStatus.rpm[ fan ].ovData = 0.0; fansStatus.rpm[ fan ].ovInitData = 0.0; @@ -265,37 +268,40 @@ // If the fans calculated duty cycle is greater than the previous calculated duty cycle, we are ramping up // otherwise, we are ramping down - if ( dutyCycle >= fansStatus.targetDutyCycle ) + if ( dutyCycle >= fansStatus.dutyCycle ) { // If the delta duty cycle from the previous duty cycle is greater than the max allowed ramp up duty cycle, // otherwise, only add the delta duty cycle - if ( ( dutyCycle - fansStatus.targetDutyCycle ) >= FANS_MAX_ALLOWED_RAMP_UP_DELTA_DUTY_CYCLE ) + if ( ( dutyCycle - fansStatus.dutyCycle ) >= FANS_MAX_ALLOWED_RAMP_UP_DELTA_DUTY_CYCLE ) { - fansStatus.targetDutyCycle += FANS_MAX_ALLOWED_RAMP_UP_DELTA_DUTY_CYCLE; + fansStatus.dutyCycle += FANS_MAX_ALLOWED_RAMP_UP_DELTA_DUTY_CYCLE; } else { - fansStatus.targetDutyCycle = dutyCycle; + fansStatus.dutyCycle = dutyCycle; } } else { // If the delta duty cycle from the previous duty cycle is greater than the max allowed ramp down duty cycle, // otherwise, only add the delta duty cycle - if ( ( fansStatus.targetDutyCycle - dutyCycle ) >= FANS_MAX_ALLOWED_RAMP_DOWN_DELTA_DUTY_CYCLE ) + if ( ( fansStatus.dutyCycle - dutyCycle ) >= FANS_MAX_ALLOWED_RAMP_DOWN_DELTA_DUTY_CYCLE ) { // If we are ramping down, set the target duty cycle to max allowed ramp down duty cycle - fansStatus.targetDutyCycle -= FANS_MAX_ALLOWED_RAMP_DOWN_DELTA_DUTY_CYCLE; + fansStatus.dutyCycle -= FANS_MAX_ALLOWED_RAMP_DOWN_DELTA_DUTY_CYCLE; } else { - fansStatus.targetDutyCycle = dutyCycle; + fansStatus.dutyCycle = dutyCycle; } } + // Calculate the target RPM for the the duty cycle + fansStatus.targetRPM = fansStatus.dutyCycle * FANS_MAX_ALLOWED_RPM; + // Set the PWM to inlet and outlet fans - setInletFansDutyCycle( fansStatus.targetDutyCycle ); - setOutletFansDutyCycle( fansStatus.targetDutyCycle ); + setInletFansDutyCycle( fansStatus.dutyCycle ); + setOutletFansDutyCycle( fansStatus.dutyCycle ); // Reset the counter fansControlCounter = 0; @@ -362,7 +368,7 @@ temperature = getTemperatureValue( TEMPSENSORS_LOAD_CELL_A2_B2 ); maxTemperature = ( temperature > maxTemperature ? temperature : maxTemperature ); - temperature = getTemperatureValue( TEMPSENSORS_INTERNAL_THDO_RTD ); + temperature = getTemperatureValue( TEMPSENSORS_INTERNAL_TRO_RTD ); maxTemperature = ( temperature > maxTemperature ? temperature : maxTemperature ); temperature = getTemperatureValue( TEMPSENSORS_INTERNAL_TDI_RTD ); @@ -410,8 +416,8 @@ /*********************************************************************//** * @brief * The monitorFans function monitors the fans for RPM. - * @details Inputs: fansMonitorCounter, fansStatus - * @details Outputs: fansMonitorCounter + * @details Inputs: fansMonitorCounter, rpmAlarmStartTimer, hasAlarmBeenRaised + * @details Outputs: fansMonitorCounter, rpmAlarmStartTimer, hasAlarmBeenRaised * @return none *************************************************************************/ static void monitorFans( void ) @@ -428,7 +434,7 @@ // The RPM is expected to be 5500 @ 100% duty cycle // The nominal RPM = duty cycle * 5500 / 1.0 // The RPM tolerance is -25% to +50% of the nominal RPM - F32 fansNominalRPM = fansStatus.targetDutyCycle * FANS_MAX_ALLOWED_RPM; + F32 fansNominalRPM = fansStatus.dutyCycle * FANS_MAX_ALLOWED_RPM; F32 fansMinAllowedRPM = fansNominalRPM - ( fansNominalRPM * FANS_MIN_RPM_OUT_OF_RANGE_TOL ); F32 fansMaxAllowedRPM = fansNominalRPM + ( fansNominalRPM * FANS_MAX_RPM_OUT_OF_RANGE_TOL ); @@ -440,12 +446,15 @@ // If the RPM out of range alarm has been raised, do not raise it again, until its alarm silence time has been elapsed hasAlarmBeenRaised = ( TRUE == isAlarmActive( ALARM_ID_DG_FAN_RPM_OUT_OF_RANGE ) ? TRUE : FALSE ); + // If the alarm has been raised and the alarm start timer is 0, start the timer if ( ( TRUE == hasAlarmBeenRaised ) && ( 0 == rpmAlarmStartTimer ) ) { rpmAlarmStartTimer = getMSTimerCount(); } } } + // If the alarm has been raised the silence the alarm time has elapsed, get ready to raise the alarm in case the RPM was out of range + // Once the alarm is raised, it is not raised again for 24 hours else if ( ( TRUE == hasAlarmBeenRaised ) && ( TRUE == didTimeout( rpmAlarmStartTimer, SECONDS_IN_A_DAY ) ) ) { hasAlarmBeenRaised = FALSE; @@ -489,13 +498,14 @@ { FANS_DATA_T fansData; - fansData.fansTargetDutyCycle = fansStatus.targetDutyCycle * FRACTION_TO_PERCENT_FACTOR; - fansData.fanInlet1RPM = getMeasuredFanRPM( FAN_INLET_1 ); - fansData.fanInlet2RPM = getMeasuredFanRPM( FAN_INLET_2 ); - fansData.fanInlet3RPM = getMeasuredFanRPM( FAN_INLET_3 ); - fansData.fanOutlet1RPM = getMeasuredFanRPM( FAN_OUTLET_1 ); - fansData.fanOutlet2RPM = getMeasuredFanRPM( FAN_OUTLET_2 ); - fansData.fanOutlet3RPM = getMeasuredFanRPM( FAN_OUTLET_3 ); + fansData.dutyCycle = fansStatus.dutyCycle * FRACTION_TO_PERCENT_FACTOR; + fansData.targetFansRPM = fansStatus.targetRPM; + fansData.fanInlet1RPM = getMeasuredFanRPM( FAN_INLET_1 ); + fansData.fanInlet2RPM = getMeasuredFanRPM( FAN_INLET_2 ); + fansData.fanInlet3RPM = getMeasuredFanRPM( FAN_INLET_3 ); + fansData.fanOutlet1RPM = getMeasuredFanRPM( FAN_OUTLET_1 ); + fansData.fanOutlet2RPM = getMeasuredFanRPM( FAN_OUTLET_2 ); + fansData.fanOutlet3RPM = getMeasuredFanRPM( FAN_OUTLET_3 ); broadcastFansData( &fansData );