Index: firmware/App/Controllers/Fans.c =================================================================== diff -u -rd00ad426d849083922332f832e88e7137a1cad60 -r62a4d7b976107f7ac4d5013ce06f38f4a0bf65bd --- firmware/App/Controllers/Fans.c (.../Fans.c) (revision d00ad426d849083922332f832e88e7137a1cad60) +++ firmware/App/Controllers/Fans.c (.../Fans.c) (revision 62a4d7b976107f7ac4d5013ce06f38f4a0bf65bd) @@ -1,4 +1,5 @@ +#include "etpwm.h" #include "Fans.h" #include "TaskGeneral.h" #include "Thermistors.h" @@ -42,25 +43,24 @@ /// Fans exec states typedef enum fans_Exec_States { - FANS_EXEC_STATE_WAIT_FOR_POST = 0, ///< Fans exec state start - FANS_EXEC_STATE_RUN, ///< Fans exec state run - NUM_OF_FANS_EXEC_STATES, ///< Number of fans exec states + FANS_EXEC_STATE_WAIT_FOR_POST = 0, ///< Fans exec state start + FANS_EXEC_STATE_RUN, ///< Fans exec state run + NUM_OF_FANS_EXEC_STATES, ///< Number of fans exec states } FANS_EXEC_STATES_T; /// Fans status struct typedef struct { F32 targetDutyCycle; ///< Fan's target duty cycle that was fed to the fans - F32 previousDutyCycle; ///< Fan's previous duty cycle from calculation U32 rpm[ NUM_OF_FANS_NAMES ]; ///< Fan's current tachometers reading in RPM } FAN_STATUS_T; -static FAN_STATUS_T fansStatus; ///< Fans status -static SELF_TEST_STATUS_T fansSelfTestReslt = SELF_TEST_STATUS_IN_PROGRESS; ///< Fans self test result -static FANS_SELF_TEST_STATES_T fansSelfTestState = FANS_SELF_TEST_START; ///< Fans self test state -static FANS_EXEC_STATES_T fansExecState = FANS_EXEC_STATE_WAIT_FOR_POST; ///< Fans exec state -static U32 fansControlCounter = 0; ///< Fans control interval counter -static U32 fansPublishCounter = 0; ///< Fans data publish interval counter +static FAN_STATUS_T fansStatus; ///< Fans status +static SELF_TEST_STATUS_T fansSelfTestReslt = SELF_TEST_STATUS_IN_PROGRESS; ///< Fans self test result +static FANS_SELF_TEST_STATES_T fansSelfTestState = FANS_SELF_TEST_START; ///< Fans self test state +static FANS_EXEC_STATES_T fansExecState = FANS_EXEC_STATE_WAIT_FOR_POST; ///< Fans exec state +static U32 fansControlCounter = 0; ///< Fans control interval counter +static U32 fansPublishCounter = 0; ///< Fans data publish interval counter /// Temperature to duty cycle conversion slope (duty cycle not in percent) static const F32 slope = ( FANS_MAX_DUTY_CYCLE - FANS_MIN_DUTY_CYCLE ) / ( MAX_ALLOWED_AMBINET_TEMPERATURE - MIN_ALLOWED_AMBIENT_TEMPERATURE ); @@ -316,11 +316,11 @@ // 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.previousDutyCycle ) + if ( dutyCycle >= fansStatus.targetDutyCycle ) { // 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.previousDutyCycle ) >= FANS_MAX_ALLOWED_RAMP_UP_DELTA_DUTY_CYCLE ) + if ( ( dutyCycle - fansStatus.targetDutyCycle ) >= FANS_MAX_ALLOWED_RAMP_UP_DELTA_DUTY_CYCLE ) { fansStatus.targetDutyCycle += FANS_MAX_ALLOWED_RAMP_UP_DELTA_DUTY_CYCLE; } @@ -335,9 +335,6 @@ fansStatus.targetDutyCycle -= FANS_MAX_ALLOWED_RAMP_DOWN_DELTA_DUTY_CYCLE; } - // Update the structure - fansStatus.previousDutyCycle = dutyCycle; - // Set the PWM to inlet and outlet fans setInletFansPWM( fansStatus.targetDutyCycle ); setOutletFansPWM( fansStatus.targetDutyCycle ); @@ -500,7 +497,6 @@ { FANS_DATA_T fansData; - fansData.fansCalculatedPWM = fansStatus.previousDutyCycle * 100; fansData.fansTargetPWM = fansStatus.targetDutyCycle * 100; fansData.fanInlet1RPM = fansStatus.rpm[ FAN_INLET_1 ]; fansData.fanInlet2RPM = fansStatus.rpm[ FAN_INLET_2 ];