Index: firmware/App/Controllers/DrainPump.c =================================================================== diff -u -rd3671cad1447db7ad496ad6282324ef7570c5625 -r1f500f8e6159a3fbab85ea68389e918a6df66400 --- firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision d3671cad1447db7ad496ad6282324ef7570c5625) +++ firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 1f500f8e6159a3fbab85ea68389e918a6df66400) @@ -41,9 +41,9 @@ // ********** private definitions ********** -#define DRAIN_PUMP_MIN_DAC ( ((F32)MIN_DRAIN_PUMP_RPM * \ +#define DRAIN_PUMP_MIN_DAC ( ( (F32)MIN_DRAIN_PUMP_RPM * \ DRP_SPEED_RPM_TO_ADC_FACTOR ) + FLOAT_TO_INT_ROUNDUP_OFFSET ) ///<, Drain pump minimum RPM to DAC conversion -#define DRAIN_PUMP_MAX_DAC ( ((F32)MAX_DRAIN_PUMP_RPM * \ +#define DRAIN_PUMP_MAX_DAC ( ( (F32)MAX_DRAIN_PUMP_RPM * \ DRP_SPEED_RPM_TO_ADC_FACTOR ) + FLOAT_TO_INT_ROUNDUP_OFFSET ) ///< Drain pump maximum RPM to DAC conversion #define DRAIN_PUMP_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< interval (ms/task time) at which the Drain Pump data is published on the CAN bus @@ -247,12 +247,72 @@ drainPumpState = handleDrainPumpOpenLoopState(); break; - default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, 0, drainPumpState ) // TODO - replace 1st param with s/w fault enum + default: + // Wrong state was selected + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_DRAIN_PUMP_INVALID_EXEC_STATE, drainPumpState ) drainPumpState = DRAIN_PUMP_OFF_STATE; break; } } + +/*********************************************************************//** + * @brief + * The execDrainPumpTest function executes the state machine for the drain + * pump self-test. + * @details + * Inputs: none + * Outputs: none + * @return: the current state of the Drain Pump self test. + *************************************************************************/ +SELF_TEST_STATUS_T execDrainPumpTest( void ) +{ + SELF_TEST_STATUS_T result = SELF_TEST_STATUS_FAILED; + + // TODO - implement self-test(s) + + return result; +} + +/*********************************************************************//** + * @brief + * The getTargetDrainPumpSpeed function gets the current target drain pump + * speed. + * @details + * Inputs: targetDrainPumpSpeed + * Outputs : none + * @return: the current target drain pump speed. + *************************************************************************/ +U32 getTargetDrainPumpSpeed( void ) +{ + U32 result = targetDrainPumpSpeed.data; + + if ( OVERRIDE_KEY == targetDrainPumpSpeed.override ) + { + result = targetDrainPumpSpeed.ovData; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The getTargetDrainPumpDeltaP function gets the current target drain pump + * delta pressure. + * @details Inputs: targetDrainPumpDeltaPressure + * @details Outputs: targetDrainPumpDeltaPressure + * @return: the current target drain pump delta pressure. + *************************************************************************/ +F32 getTargetDrainPumpDeltaP( void ) +{ + F32 result = targetDrainPumpDeltaPressure.data; + + if ( OVERRIDE_KEY == targetDrainPumpDeltaPressure.override ) + { + result = targetDrainPumpDeltaPressure.ovData; + } + + return result; +} /*********************************************************************//** * @brief @@ -335,8 +395,8 @@ F32 inletDrainPressure = getMeasuredDGPressure ( PRESSURE_SENSOR_DRAIN_PUMP_INLET ); F32 outletDrainPressure = getMeasuredDGPressure ( PRESSURE_SENSOR_DRAIN_PUMP_OUTLET ); F32 pressureDiff = outletDrainPressure - inletDrainPressure; - F32 dac = runPIController( PI_CONTROLLER_ID_DRAIN_PUMP, targetDrainPumpDeltaPressure.data, pressureDiff ); //TODO use get for delta pressure - drainPumpDACSet = (U32)(dac + FLOAT_TO_INT_ROUNDUP_OFFSET); + F32 dac = runPIController( PI_CONTROLLER_ID_DRAIN_PUMP, getTargetDrainPumpDeltaP(), pressureDiff ); + drainPumpDACSet = (U32)( dac + FLOAT_TO_INT_ROUNDUP_OFFSET ); setFPGADrainPumpSpeed( drainPumpDACSet ); // From a merge from master @@ -426,70 +486,33 @@ } return result; -} - +} + /*********************************************************************//** * @brief - * The getTargetDrainPumpSpeed function gets the current target drain pump - * speed. - * @details - * Inputs: targetDrainPumpSpeed - * Outputs : none - * @return: the current target drain pump speed. - *************************************************************************/ -U32 getTargetDrainPumpSpeed( void ) -{ - U32 result = targetDrainPumpSpeed.data; - - if ( OVERRIDE_KEY == targetDrainPumpSpeed.override ) - { - result = targetDrainPumpSpeed.ovData; - } - - return result; -} - -/*********************************************************************//** - * @brief * The publishDrainPumpData function publishes drain pump data at the set interval. * @details - * Inputs: target speed - * Outputs: Drain pump data is published to CAN bus. + * @details Inputs: drainPumpDataPublicationTimerCounter + * @details Outputs: drainPumpDataPublicationTimerCounterus. * @return: none *************************************************************************/ static void publishDrainPumpData( void ) { // publish Drain pump data on interval if ( ++drainPumpDataPublicationTimerCounter >= getPublishDrainPumpDataInterval() ) - { - // TODO: This was a const in master, why? - U32 spdStPt = getTargetDrainPumpSpeed(); + { + DRAIN_PUMP_DATA_T drainPumpData; - F32 pressureDiff = getMeasuredDGPressure( PRESSURE_SENSOR_DRAIN_PUMP_INLET ) - getMeasuredDGPressure( PRESSURE_SENSOR_DRAIN_PUMP_OUTLET ) ; + // Populate the data structure for publication + drainPumpData.speedSetPoint = getTargetDrainPumpSpeed(); + drainPumpData.pumpDACSet = drainPumpDACSet; + drainPumpData.drainPumpState = (U32)drainPumpState; - broadcastDrainPumpData( spdStPt, drainPumpDACSet, pressureDiff, (U32)drainPumpState ); + broadcastDrainPumpData( &drainPumpData ); drainPumpDataPublicationTimerCounter = 0; } } - -/*********************************************************************//** - * @brief - * The execDrainPumpTest function executes the state machine for the drain - * pump self-test. - * @details - * Inputs: none - * Outputs: none - * @return: the current state of the Drain Pump self test. - *************************************************************************/ -SELF_TEST_STATUS_T execDrainPumpTest( void ) -{ - SELF_TEST_STATUS_T result = SELF_TEST_STATUS_FAILED; - - // TODO - implement self-test(s) - - return result; -} /**@}*/ Index: firmware/App/Controllers/DrainPump.h =================================================================== diff -u -raa36ab1ed13d099286cedcbd066f7dce11146d13 -r1f500f8e6159a3fbab85ea68389e918a6df66400 --- firmware/App/Controllers/DrainPump.h (.../DrainPump.h) (revision aa36ab1ed13d099286cedcbd066f7dce11146d13) +++ firmware/App/Controllers/DrainPump.h (.../DrainPump.h) (revision 1f500f8e6159a3fbab85ea68389e918a6df66400) @@ -22,7 +22,7 @@ /** * @defgroup DrainPump DrainPump - * @brief Drain Pump monitor/controller module. Controls and monitors the drain pump. + * @brief Drain Pump monitor/controller module. Controls and monitors the drain pump. * * @addtogroup DrainPump * @{ @@ -31,7 +31,15 @@ // ********** public definitions ********** #define MIN_DRAIN_PUMP_RPM 300 ///< Minimum RPM target for drain pump (though zero is allowed if turning pump off). -#define MAX_DRAIN_PUMP_RPM 3000 ///< Maximum RPM target for drain pump. +#define MAX_DRAIN_PUMP_RPM 3000 ///< Maximum RPM target for drain pump. + +/// Drain pump data publish +typedef struct +{ + U32 speedSetPoint; ///< Drain pump speed set point (for open loop) + U32 pumpDACSet; ///< Drain pump DAC set value + U32 drainPumpState; ///< Drain pump state machine state +} DRAIN_PUMP_DATA_T; // ********** public function prototypes ********** @@ -47,7 +55,9 @@ SELF_TEST_STATUS_T execDrainPumpTest( void ); -U32 getTargetDrainPumpSpeed( void ); +U32 getTargetDrainPumpSpeed( void ); + +F32 getTargetDrainPumpDeltaP( void ); BOOL testSetDrainPumpDataPublishIntervalOverride( U32 value ); BOOL testResetDrainPumpDataPublishIntervalOverride( void ); Index: firmware/App/Controllers/Fans.c =================================================================== diff -u -r45263215b372cd579e8e16bb8073c287c726c55d -r1f500f8e6159a3fbab85ea68389e918a6df66400 --- firmware/App/Controllers/Fans.c (.../Fans.c) (revision 45263215b372cd579e8e16bb8073c287c726c55d) +++ firmware/App/Controllers/Fans.c (.../Fans.c) (revision 1f500f8e6159a3fbab85ea68389e918a6df66400) @@ -12,67 +12,74 @@ // ********** private definitions ********** -#define FANS_MIN_PWM_PERCENT 0.1 ///< Fans min PWM. -#define FANS_MAX_PWM_PERCENT 0.95 ///< Fans max PWM. +#define FANS_MIN_DUTY_CYCLE 0.1 ///< Fans min PWM. +#define FANS_MAX_DUTY_CYCLE 0.95 ///< Fans max PWM. #define MIN_ALLOWED_AMBIENT_TEMPERATURE 20 ///< Min allowed ambient temperature. #define MAX_ALLOWED_AMBINET_TEMPERATURE 70 ///< Max allowed ambient temperature. -#define FANS_MAX_ALLOWED_RAMP_UP_PWM_CHANGE 0.3 ///< Fans max allowed ramp up PWM change. -#define FANS_MAX_ALLOWED_RAMP_DOWN_PWM_CHANGE 0.005 ///< Fans min allowed ramp down PWM change. +#define FANS_MAX_ALLOWED_RAMP_UP_DELTA_DUTY_CYCLE 0.3 ///< Fans max allowed ramp up PWM change. +#define FANS_MAX_ALLOWED_RAMP_DOWN_DELTA_DUTY_CYCLE 0.005 ///< Fans min allowed ramp down PWM change. #define ONE_MINUTE_TO_MICRO_SECONDS 60000000 ///< One minute to micro seconds conversion. #define TOGGLE_PERIOD_RESOLUTION 2.5 ///< FPGA fans toggle period resolution in micro seconds. #define ROTATIONAL_TO_TOGGLE_PERIOD_CONVERSION_COEFF 4 ///< FPGA rotational to toggle period conversion coefficient. -#define FANS_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Fans publish data time interval in counts. -#define FANS_CONTROL_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Fans control time interval in counts. -#define FANS_ZERO_RPM_TOGGLE_PERIOD_VALUE 0xFFFF ///< Fans zero RPM toggle period value. +#define FANS_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Fans publish data time interval in counts. +#define FANS_CONTROL_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Fans control time interval in counts. +#define FANS_ZERO_RPM_TOGGLE_PERIOD_VALUE 0xFFFF ///< Fans zero RPM toggle period value. +#define MIN_TARGET_RPM_IN_SELF_TEST 1000 ///< Fans min target RPM that they should be during POST. +#define FANS_SELF_TEST_WAIT_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Fans self test wait time for the fans to get to RPM. +#define FANS_SELF_TEST_TARGET_PWM 0.5 ///< Fans self test target PWM for testing the fans are running. /// Fans self test states typedef enum fans_Self_Test { FANS_SELF_TEST_START = 0, ///< Fans self test start state + FANS_SELF_TEST_CHECK_RPM, ///< Fans self test check RPM FAN_SELF_TEST_COMPLETE, ///< Fans self test complete state NUM_OF_SELF_TEST_STATES, ///< Number of fans self test } FANS_SELF_TEST_STATES_T; /// Fans exec states typedef enum fans_Exec_States { - FANS_EXEC_STATE_START = 0, ///< Fans exec state start + 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 targetPWM; ///< Fan's Target PWM - F32 calculatedPWM; ///< Fan's calculated PWM from the calculations - U32 rpm[ NUM_OF_FANS_NAMES ]; ///< Fan's current speed + 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_START; ///< Fans exec 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 const F32 slope = ( MAX_ALLOWED_AMBINET_TEMPERATURE - MIN_ALLOWED_AMBIENT_TEMPERATURE ) / - ( FANS_MAX_PWM_PERCENT - FANS_MIN_PWM_PERCENT ); ///< Temperature to PWM conversion slope +/// 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 ); /// FGPA Toggle to RPM conversion coefficient -static F32 const toggle2RPMCoefficient = ( ONE_MINUTE_TO_MICRO_SECONDS * ROTATIONAL_TO_TOGGLE_PERIOD_CONVERSION_COEFF ) / TOGGLE_PERIOD_RESOLUTION; +static const F32 toggle2RPMCoefficient = ( ONE_MINUTE_TO_MICRO_SECONDS * ROTATIONAL_TO_TOGGLE_PERIOD_CONVERSION_COEFF ) / TOGGLE_PERIOD_RESOLUTION; static OVERRIDE_U32_T fansPublishInterval = { FANS_DATA_PUBLISH_INTERVAL, FANS_DATA_PUBLISH_INTERVAL, 0, 0 }; ///< Fans publish time interval override -static FANS_EXEC_STATES_T handleFansExecStateStart( void ); -static FANS_EXEC_STATES_T handleFansExecStateRun( void ); +static FANS_SELF_TEST_STATES_T handleSelfTestStart( void ); +static FANS_SELF_TEST_STATES_T handleSelfTestCheckRPM( void ); +static FANS_EXEC_STATES_T handleExecStateWaitForPOST( void ); +static FANS_EXEC_STATES_T handleExecStateRun( void ); + static void setInletFansPWM( F32 pwm ); static void setOutletFansPWM( F32 pwm ); static F32 getMaximumTemperature( void ); -static void getFansRPM( void ); +static void convertFansTogglePeriod2RPM( void ); static U32 getPublishFansDataInterval( void ); static void publishFansData( void ); @@ -88,7 +95,7 @@ void initFans( void ) { // Initialize the variables - fansExecState = FANS_EXEC_STATE_START; + fansExecState = FANS_EXEC_STATE_WAIT_FOR_POST; fansSelfTestReslt = SELF_TEST_STATUS_IN_PROGRESS; fansSelfTestState = FANS_SELF_TEST_START; fansControlCounter = 0; @@ -107,8 +114,13 @@ switch ( fansSelfTestState ) { case FANS_SELF_TEST_START: + fansSelfTestState = handleSelfTestStart(); break; + case FANS_SELF_TEST_CHECK_RPM: + fansSelfTestState = handleSelfTestCheckRPM(); + break; + case FAN_SELF_TEST_COMPLETE: // Done with POST. Do nothing break; @@ -134,12 +146,12 @@ { switch ( fansExecState ) { - case FANS_EXEC_STATE_START: - fansExecState = handleFansExecStateStart(); + case FANS_EXEC_STATE_WAIT_FOR_POST: + fansExecState = handleExecStateWaitForPOST(); break; case FANS_EXEC_STATE_RUN: - fansExecState = handleFansExecStateRun(); + fansExecState = handleExecStateRun(); break; default: @@ -178,23 +190,95 @@ /*********************************************************************//** * @brief + * The handleSelfTestStart function handles the start state of the fans' + * self test. + * @details Inputs: fansStatus + * @details Outputs: none + * @return next state of self test + *************************************************************************/ +static FANS_SELF_TEST_STATES_T handleSelfTestStart( void ) +{ + FANS_SELF_TEST_STATES_T state = FANS_SELF_TEST_START; + FANS_NAMES_T fan; + + // Get the raw toggle periods from FPGA and convert them to RPM. They all should be 0 upon staring + // the device + convertFansTogglePeriod2RPM(); + + // Loop through all the fans to check their RPM + for( fan = FAN_INLET_1; fan < NUM_OF_FANS_NAMES; fan++ ) + { + if ( fansStatus.rpm[ fan ] > 0 ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_FAN_RPM_OUT_OF_RANGE, fan, fansStatus.rpm[ fan ] ); + } + } + + // Set the fans to the target PWM for the next stage + setInletFansPWM( FANS_SELF_TEST_TARGET_PWM ); + setOutletFansPWM( FANS_SELF_TEST_TARGET_PWM ); + state = FANS_SELF_TEST_CHECK_RPM; + + return state; +} + +/*********************************************************************//** + * @brief + * The handleSelfTestCheckRPM function handles the check RPM state of the + * fans' self test. + * @details Inputs: fansStatus + * @details Outputs: none + * @return next state of self test + *************************************************************************/ +static FANS_SELF_TEST_STATES_T handleSelfTestCheckRPM( void ) +{ + FANS_SELF_TEST_STATES_T state = FANS_SELF_TEST_CHECK_RPM; + FANS_NAMES_T fan; + + // Wait for the fans to run for a certain period of time before checking their RPM + if ( ++fansControlCounter > FANS_SELF_TEST_WAIT_INTERVAL ) + { + convertFansTogglePeriod2RPM(); + + // Loop through all the fans to check their RPM. They should above the specified RPM + for( fan = FAN_INLET_1; fan < NUM_OF_FANS_NAMES; fan++ ) + { + if ( fansStatus.rpm[ fan ] > MIN_TARGET_RPM_IN_SELF_TEST ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_FAN_RPM_OUT_OF_RANGE, fan, fansStatus.rpm[ fan ] ); + } + } + + // Turn off the fans, done with self test + setInletFansPWM( 0 ); + setOutletFansPWM( 0 ); + state = FAN_SELF_TEST_COMPLETE; + } + + return state; +} + +/*********************************************************************//** + * @brief * The handleFansExecStateStart function handles the start state of the * fans exec state machine. * @details Inputs: none * @details Outputs: none * @return the next state of the exec state machine *************************************************************************/ -static FANS_EXEC_STATES_T handleFansExecStateStart( void ) +static FANS_EXEC_STATES_T handleExecStateWaitForPOST( void ) { - FANS_EXEC_STATES_T state = FANS_EXEC_STATE_START; + FANS_EXEC_STATES_T state = FANS_EXEC_STATE_WAIT_FOR_POST; - // TODO do we need to wait for POST or something? + // Wait for the self test to finish before starting the fans + if ( fansSelfTestState == FAN_SELF_TEST_COMPLETE ) + { + // Start the fans with minimum PWM. The control will decide the next PWM automatically. + setInletFansPWM( FANS_MIN_DUTY_CYCLE ); + setOutletFansPWM( FANS_MIN_DUTY_CYCLE ); + state = FANS_EXEC_STATE_RUN; + } - // Start the fans with minimum PWM - setInletFansPWM( FANS_MIN_PWM_PERCENT ); - setOutletFansPWM( FANS_MIN_PWM_PERCENT ); - state = FANS_EXEC_STATE_RUN; - return state; } @@ -206,7 +290,7 @@ * @details Outputs: fansStatus, fansControlCounter * @return the next state of the exec state machine *************************************************************************/ -static FANS_EXEC_STATES_T handleFansExecStateRun( void ) +static FANS_EXEC_STATES_T handleExecStateRun( void ) { FANS_EXEC_STATES_T state = FANS_EXEC_STATE_RUN; @@ -216,36 +300,47 @@ // Get the maximum temperature among all the thermistors and sensors to run fan from the hottest F32 temperature = getMaximumTemperature(); - // Solve the linear equation to calculate the PWM from temperature - F32 const pwm = ( slope * temperature ) - ( slope * FANS_MIN_PWM_PERCENT ) + MIN_ALLOWED_AMBIENT_TEMPERATURE; + // Solve the linear equation to calculate the duty cycle from temperature + F32 dutyCycle = slope * ( temperature - MIN_ALLOWED_AMBIENT_TEMPERATURE ) + FANS_MIN_DUTY_CYCLE; - // If the fans calculated PWM is greater than the previous calculated PWM, we are ramping up + // Check whether the duty cycle is not outside of the range + // and cap it if needed + if ( dutyCycle < FANS_MIN_DUTY_CYCLE ) + { + dutyCycle = FANS_MIN_DUTY_CYCLE; + } + if ( dutyCycle > FANS_MAX_DUTY_CYCLE ) + { + dutyCycle = FANS_MAX_DUTY_CYCLE; + } + + // If the fans calculated duty cycle is greater than the previous calculated duty cycle, we are ramping up // otherwise, we are ramping down - if ( pwm >= fansStatus.calculatedPWM ) + if ( dutyCycle >= fansStatus.previousDutyCycle ) { - // If the new PWM is greater than maximum allowed ramp up PWM, set it to max - // otherwise, set it to the actual PWM - if ( pwm >= FANS_MAX_ALLOWED_RAMP_UP_PWM_CHANGE ) + // 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 ) { - fansStatus.targetPWM = FANS_MAX_ALLOWED_RAMP_UP_PWM_CHANGE; + fansStatus.targetDutyCycle += FANS_MAX_ALLOWED_RAMP_UP_DELTA_DUTY_CYCLE; } else { - fansStatus.targetPWM = pwm; + fansStatus.targetDutyCycle = dutyCycle; } } else { - // If we are ramping down, set the target PWM to max allowed ramp down PWM - fansStatus.targetPWM = FANS_MAX_ALLOWED_RAMP_DOWN_PWM_CHANGE; + // If we are ramping down, set the target duty cycle to max allowed ramp down PWM + fansStatus.targetDutyCycle -= FANS_MAX_ALLOWED_RAMP_DOWN_DELTA_DUTY_CYCLE; } - // Update the struct - fansStatus.calculatedPWM = pwm; + // Update the structure + fansStatus.previousDutyCycle = dutyCycle; // Set the PWM to inlet and outlet fans - setInletFansPWM( fansStatus.targetPWM ); - setOutletFansPWM( fansStatus.targetPWM ); + setInletFansPWM( fansStatus.targetDutyCycle ); + setOutletFansPWM( fansStatus.targetDutyCycle ); // Reset the counter fansControlCounter = 0; @@ -292,9 +387,8 @@ { F32 temperature; THERMISTORS_TEMP_SENSORS_T thermistor; + F32 maxTemperature = 0.0; - F32 maxTemperature = 0; - // Loop through the sensors and thermistors for ( thermistor = THERMISTOR_ONBOARD_NTC; thermistor < NUM_OF_THERMISTORS; thermistor++ ) { @@ -320,38 +414,38 @@ * @details Outputs: fansStatus * @return none ************************************************************************/ -static void getFansRPM( void ) +static void convertFansTogglePeriod2RPM( void ) { FANS_NAMES_T fan; - U32 RPM; + U32 togglePeriod; // Loop through the fans and get the pulse of each of them for ( fan = FAN_INLET_1; fan < NUM_OF_FANS_NAMES; fan++ ) { switch ( fan ) { case FAN_INLET_1: - RPM = getFPGAInletFan1Pulse(); //TODO is this the right place? + togglePeriod = getFPGAInletFan1TogglePeriod(); break; case FAN_INLET_2: - //TODO fill up + togglePeriod = getFPGAInletFan2TogglePeriod(); break; case FAN_INLET_3: - //TODO fill up + togglePeriod = getFPGAInletFan3TogglePeriod(); break; case FAN_OUTLET_1: - RPM = getFPGAInletFan2Pulse(); //TODO is this the right place? + togglePeriod = getFPGAOutletFan1TogglePeriod(); break; case FAN_OUTLET_2: - //TODO fill up + togglePeriod = getFPGAOutletFan2TogglePeriod(); break; case FAN_OUTLET_3: - //TODO fill up + togglePeriod = getFPGAOutletFan3TogglePeriod(); break; default: @@ -362,13 +456,13 @@ // If the pulse is close to 0 or 0, FPGA will report 0xFFFF // Otherwise, convert the pulse to RPM - if ( RPM == FANS_ZERO_RPM_TOGGLE_PERIOD_VALUE ) + if ( togglePeriod == FANS_ZERO_RPM_TOGGLE_PERIOD_VALUE ) { fansStatus.rpm[ fan ] = 0; } else { - fansStatus.rpm[ fan ] = RPM * toggle2RPMCoefficient; + fansStatus.rpm[ fan ] = togglePeriod * toggle2RPMCoefficient; } } } @@ -406,8 +500,8 @@ { FANS_DATA_T fansData; - fansData.fansCalculatedPWM = fansStatus.calculatedPWM * 100; - fansData.fansTargetPWM = fansStatus.targetPWM * 100; + fansData.fansCalculatedPWM = fansStatus.previousDutyCycle * 100; + fansData.fansTargetPWM = fansStatus.targetDutyCycle * 100; fansData.fanInlet1RPM = fansStatus.rpm[ FAN_INLET_1 ]; fansData.fanInlet2RPM = fansStatus.rpm[ FAN_INLET_2 ]; fansData.fanInlet3RPM = fansStatus.rpm[ FAN_INLET_3 ]; Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r45263215b372cd579e8e16bb8073c287c726c55d -r1f500f8e6159a3fbab85ea68389e918a6df66400 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 45263215b372cd579e8e16bb8073c287c726c55d) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 1f500f8e6159a3fbab85ea68389e918a6df66400) @@ -45,36 +45,37 @@ #define RO_PUMP_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Interval (ms/task time) at which the RO Pump data is published on the CAN bus. -#define MAX_RO_PUMP_PWM_STEP_CHANGE 0.01 ///< max duty cycle change for controller -#define MAX_RO_PUMP_PWM_DUTY_CYCLE 0.99 ///< max duty cycle -#define MIN_RO_PUMP_PWM_DUTY_CYCLE 0.00 ///< min duty cycle +#define MAX_RO_PUMP_PWM_STEP_CHANGE 0.01 ///< max duty cycle change for controller. +#define MAX_RO_PUMP_PWM_DUTY_CYCLE 0.99 ///< max duty cycle. +#define MIN_RO_PUMP_PWM_DUTY_CYCLE 0.00 ///< min duty cycle. -#define ROP_CONTROL_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< interval (ms/task time) at which the RO pump is controlled -#define ROP_P_COEFFICIENT 0.0020 ///< P term for RO pump pressure control -#define ROP_I_COEFFICIENT 0.0015 ///< I term for RO pump pressure control +#define ROP_CONTROL_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< interval (ms/task time) at which the RO pump is controlled. +#define ROP_P_COEFFICIENT 0.0020 ///< P term for RO pump pressure control. +#define ROP_I_COEFFICIENT 0.0015 ///< I term for RO pump pressure control. -#define ROP_RAMP_UP_P_COEFFICIENT 0.0 ///< P term for RO pump flow control -#define ROP_RAMP_UP_I_COEFFICIENT 0.1 ///< I term for RO pump flow control -#define ROP_FLOW_TARGET_TOLERANCE 0.05 ///< Tolerance in between the target flow rate and the actual flow rate in liter +#define ROP_RAMP_UP_P_COEFFICIENT 0.0 ///< P term for RO pump flow control. +#define ROP_RAMP_UP_I_COEFFICIENT 0.1 ///< I term for RO pump flow control. +#define ROP_FLOW_TARGET_TOLERANCE 0.05 ///< Tolerance in between the target flow rate and the actual flow rate in liter. -#define FLOW_SENSOR_ZERO_READING 0xFFFF ///< Flow sensor reading indicates zero flow (or flow lower than can be detected by sensor) +#define FLOW_SENSOR_ZERO_READING 0xFFFF ///< Flow sensor reading indicates zero flow (or flow lower than can be detected by sensor). #define FLOW_SAMPLES_TO_AVERAGE ( 250 / TASK_PRIORITY_INTERVAL ) ///< Averaging flow data over 250 ms intervals. -#define FLOW_AVERAGE_MULTIPLIER ( 1.0 / (F32)FLOW_SAMPLES_TO_AVERAGE ) ///< Optimization - multiplying is faster than dividing -#define FLOW_VERIFICATION_COUNTER_TARGET 40U ///< The time in counts to check the flow and make sure it is in range +#define FLOW_AVERAGE_MULTIPLIER ( 1.0 / (F32)FLOW_SAMPLES_TO_AVERAGE ) ///< Optimization - multiplying is faster than dividing. +#define FLOW_VERIFICATION_COUNTER_TARGET 40U ///< The time in counts to check the flow and make sure it is in range. #define RO_FLOW_ADC_TO_LPM_FACTOR 10909.0909 ///< conversion factor from ADC counts to LPM (liters/min) for RO flow rate (multiply this by inverse of FPGA reading). -// Initial PWM for the requested flow rate. It is assumed that 100% duty cycle will provide 1.2 LPM -#define ROP_FLOW_TO_PWM_DC(flow) ( (F32)(flow / 1.2) ) ///< Initial conversion factor from target flow rate to PWM duty cycle estimate +#define ROP_FLOW_TO_PWM_DC(flow) ( (F32)( flow / MAX_RO_FLOWRATE_LPM ) ) ///< Initial conversion factor from target flow rate to PWM duty cycle estimate. +/* TODO remove #define MAX_RO_PUMP_PWM_STEP_CHANGE 0.01 ///< Max duty cycle change for controller. #define MAX_RO_PUMP_PWM_DUTY_CYCLE 0.99 ///< Max duty cycle. #define MIN_RO_PUMP_PWM_DUTY_CYCLE 0.00 ///< Min duty cycle. #define ROP_CONTROL_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the RO pump is controlled. #define ROP_P_COEFFICIENT 0.0020 ///< P term for RO pump control. #define ROP_I_COEFFICIENT 0.0015 ///< I term for RO pump control. +*/ #define FLOW_SENSOR_ZERO_READING 0xFFFF ///< Flow sensor reading indicates zero flow (or flow lower than can be detected by sensor). @@ -118,7 +119,7 @@ static BOOL isROPumpOn = FALSE; ///< RO pump is currently running static F32 roPumpPWMDutyCyclePct = 0.0; ///< initial RO pump PWM duty cycle static F32 roPumpPWMDutyCyclePctSet = 0.0; ///< currently set RO pump PWM duty cycle -static PUMP_CONTROL_MODE_T roPumpControlMode = PUMP_CONTROL_MODE_CLOSED_LOOP; ///< requested RO pump control mode //TODO remove? +static PUMP_CONTROL_MODE_T roPumpControlMode = PUMP_CONTROL_MODE_CLOSED_LOOP; ///< requested RO pump control mode static PUMP_CONTROL_MODE_T roPumpControlModeSet = PUMP_CONTROL_MODE_CLOSED_LOOP; ///< currently set RO pump control mode static OVERRIDE_F32_T targetROPumpFlowRate = { 0, 0, 0, 0 }; ///< Target RO flow rate (in LPM) @@ -151,7 +152,10 @@ static RO_PUMP_STATE_T handleROPumpRampUpState( void ); static RO_PUMP_STATE_T handleROPumpVerifyFlowState( void ); static RO_PUMP_STATE_T handleROPumpControlToTargetState( void ); -static RO_PUMP_STATE_T handleROPumpOpenLoopState( void ); +static RO_PUMP_STATE_T handleROPumpOpenLoopState( void ); + +static BOOL setROPumpTargetPressure( U32 roPressure, PUMP_CONTROL_MODE_T mode ); +static BOOL setROPumpTargetPWM( F32 pwm ); static void setROPumpControlSignalPWM( F32 newPWM ); static void stopROPump( void ); static void publishROPumpData( void ); @@ -180,65 +184,28 @@ MIN_RO_PUMP_PWM_DUTY_CYCLE, MAX_RO_PUMP_PWM_DUTY_CYCLE ); } -//TODO TEST AND REMOVE /*********************************************************************//** * @brief - * The setROPumpTargetPressure function sets a new target pressure for the RO pump. - * @details - * Inputs : none - * Outputs : targetROPumpPressure, roPumpPWMDutyCyclePct - * @param roPressure new target RO pressure - * @param mode new control mode - * @return TRUE if new target pressure is set, FALSE if not - *************************************************************************/ -BOOL setROPumpTargetPressure( U32 roPressure, PUMP_CONTROL_MODE_T mode ) -{ - BOOL result = FALSE; - - // verify pressure - if ( roPressure >= 10 && roPressure <= 50 ) - { - targetROPumpPressure.data = roPressure; - roPumpControlMode = mode; - // set PWM duty cycle target to an estimated initial target based on target pressure - then we'll control to pressure going forward -#ifdef EMC_TEST_BUILD - roPumpPWMDutyCyclePct = 1.0; -#else - roPumpPWMDutyCyclePct = ROP_PSI_TO_PWM_DC( roPressure ); -#endif - - result = TRUE; - } - else // requested pressure out of range - { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, 0, roPressure ) // TODO - replace 1st param with s/w fault enum - } - - return result; -} -//TODO TEST AND REMOVE - -/*********************************************************************//** - * @brief * The setROPumpTargetPWM function sets the PWM that the pump should run * @details * Inputs: roPumpOpenLooptargetPWM, roPumpControlMode * Outputs: roPumpOpenLooptargetPWM, roPumpControlMode * @param: pwm * @return whether the value was set (TRUE) or not (FALSE) *************************************************************************/ -BOOL setROPumpTargetPWM( F32 pwm ) +static BOOL setROPumpTargetPWM( F32 pwm ) { BOOL result = FALSE; - if ( pwm > 0 ) + if ( pwm >= MIN_RO_PUMP_PWM_DUTY_CYCLE && pwm < MAX_RO_PUMP_PWM_DUTY_CYCLE ) { roPumpOpenLoopTargetPWM = pwm; - roPumpPWMDutyCyclePct = roPumpOpenLoopTargetPWM; //ROP_FLOW_TO_PWM_DC( getTargetROPumpFlowRate() ); + roPumpPWMDutyCyclePct = roPumpOpenLoopTargetPWM; roPumpPWMDutyCyclePctSet = roPumpPWMDutyCyclePct; roPumpControlMode = PUMP_CONTROL_MODE_OPEN_LOOP; result = TRUE; } + return result; } @@ -272,7 +239,7 @@ } else // requested pressure out of range { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, 0, roFlowRate ) // TODO - replace 1st param with s/w fault enum + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_RO_PUMP_INVALID_FLOW_RATE_SET, roFlowRate ) } return result; @@ -320,7 +287,7 @@ F32 avgROFlow = (F32)measuredFlowReadingsSum * FLOW_AVERAGE_MULTIPLIER; // If the flow is less than a certain value, FPGA will return 0xFFFF meaning that - // the flow is 0 + // the flow is 0. Otherwise, convert the count to flow rate in mL/min if ( ( roFlowReading == FLOW_SENSOR_ZERO_READING ) || ( roFlowReading == 0 ) ) { measuredROFlowRateLPM.data = 0.0; @@ -333,13 +300,14 @@ flowFilterCounter = 0; } - //measuredROPumpPressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_OUTLET ); TODO what do we do with this? + //measuredROPumpPressure = getMeasuredDGPressure( PRESSURE_SENSOR_RO_PUMP_OUTLET ); TODO what do we do with this? + // TODO - check pressure? // TODO - check flow? - // publish RO pump data on interval + // Publish RO pump data on interval publishROPumpData(); } @@ -376,7 +344,7 @@ break; default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, 0, roPumpState ) // TODO - replace 1st param with s/w fault enum + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_RO_PUMP_INVALID_EXEC_STATE, roPumpState ) roPumpState = RO_PUMP_OFF_STATE; break; } @@ -614,6 +582,42 @@ static RO_PUMP_STATE_T handleROPumpOpenLoopState( void ) { return RO_PUMP_OPEN_LOOP_STATE; +} + +/*********************************************************************//** + * @brief + * The setROPumpTargetPressure function sets a new target pressure for the RO pump. + * @details + * Inputs : none + * Outputs : targetROPumpPressure, roPumpPWMDutyCyclePct + * @param roPressure new target RO pressure + * @param mode new control mode + * @return TRUE if new target pressure is set, FALSE if not + *************************************************************************/ +static BOOL setROPumpTargetPressure( U32 roPressure, PUMP_CONTROL_MODE_T mode ) +{ + BOOL result = FALSE; + + // Verify pressure + if ( roPressure >= 10 && roPressure <= 50 ) + { + targetROPumpPressure.data = roPressure; + roPumpControlMode = mode; + // set PWM duty cycle target to an estimated initial target based on target pressure - then we'll control to pressure going forward +#ifdef EMC_TEST_BUILD + roPumpPWMDutyCyclePct = 1.0; +#else + roPumpPWMDutyCyclePct = ROP_PSI_TO_PWM_DC( roPressure ); +#endif + + result = TRUE; + } + else // requested pressure out of range + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, 0, roPressure ) // TODO - replace 1st param with s/w fault enum + } + + return result; } /*********************************************************************//** Index: firmware/App/Controllers/ROPump.h =================================================================== diff -u -rd3671cad1447db7ad496ad6282324ef7570c5625 -r1f500f8e6159a3fbab85ea68389e918a6df66400 --- firmware/App/Controllers/ROPump.h (.../ROPump.h) (revision d3671cad1447db7ad496ad6282324ef7570c5625) +++ firmware/App/Controllers/ROPump.h (.../ROPump.h) (revision 1f500f8e6159a3fbab85ea68389e918a6df66400) @@ -48,7 +48,7 @@ void execROPumpController( void ); BOOL setROPumpTargetFlowRate( F32 roFlowRate, F32 maxPressure ); -BOOL setROPumpTargetPWM( F32 pwm ); + void signalROPumpHardStop( void ); BOOL isReverseOsmosisPumpOn( void ); Index: firmware/App/Controllers/Thermistors.c =================================================================== diff -u -r45263215b372cd579e8e16bb8073c287c726c55d -r1f500f8e6159a3fbab85ea68389e918a6df66400 --- firmware/App/Controllers/Thermistors.c (.../Thermistors.c) (revision 45263215b372cd579e8e16bb8073c287c726c55d) +++ firmware/App/Controllers/Thermistors.c (.../Thermistors.c) (revision 1f500f8e6159a3fbab85ea68389e918a6df66400) @@ -14,26 +14,26 @@ // ********** private definitions ********** -#define THERMISTORS_DATA_PUBLISH_INTERVAL (MS_PER_SECOND / TASK_GENERAL_INTERVAL) ///< Thermistors publish data time interval. -#define THERMISTORS_ADC_READ_INTERVAL (MS_PER_SECOND / (2 * TASK_GENERAL_INTERVAL)) ///< Thermistors ADC read time interval. -#define ADC_FPGA_READ_DELAY_COUNT 1 ///< FGPA read delay upon startup. -#define ONBOARD_THERMISTOR_SOURCE_VOLTAGE 3 ///< Onboard thermistor source voltage. -#define ONBOARD_THERMISTOR_REFERENCE_RESISTOR 10 ///< Onboard thermistor reference resistor. -#define ONBOARD_THERMISTOR_BETA_VALUE 3380 ///< Onboard thermistor beta value. -#define ONBOARD_THERMISTOR_REFERENCE_TEMPERATURE 298 ///< Onboard thermistor reference temperature. -#define TWELVE_BIT_RESOLUTION 4096 ///< 12 bit resolution conversion. -#define CELSIUS_TO_KELVIN_CONVERSION 273.15 ///< Celsius to Kelvin temperature conversion. -#define ADC_TEMP_SENSORS_CONVERSION_CONST 272.5 ///< ADC temperature sensors conversion constant. -#define MIN_ALLOWED_TEMPERATURE 10 ///< Thermistors/sensors minimum allowed temperature reading. -#define MAX_ALLOWED_TEMPERATURE 70 ///< Thermistors/sensors maximum allowed temperature reading. +#define THERMISTORS_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Thermistors publish data time interval. +#define THERMISTORS_ADC_READ_INTERVAL ( MS_PER_SECOND / ( 2 * TASK_GENERAL_INTERVAL ) ) ///< Thermistors ADC read time interval. +#define ADC_FPGA_READ_DELAY_COUNT 1 ///< FGPA read delay upon startup. +#define ONBOARD_THERMISTOR_SOURCE_VOLTAGE 3 ///< Onboard thermistor source voltage. +#define ONBOARD_THERMISTOR_REFERENCE_RESISTOR 10 ///< Onboard thermistor reference resistor. +#define ONBOARD_THERMISTOR_BETA_VALUE 3380 ///< Onboard thermistor beta value. +#define ONBOARD_THERMISTOR_REFERENCE_TEMPERATURE 298 ///< Onboard thermistor reference temperature. +#define TWELVE_BIT_RESOLUTION 4096 ///< 12 bit resolution conversion. +#define CELSIUS_TO_KELVIN_CONVERSION 273.15 ///< Celsius to Kelvin temperature conversion. +#define ADC_TEMP_SENSORS_CONVERSION_CONST 272.5 ///< ADC temperature sensors conversion constant. +#define MIN_ALLOWED_TEMPERATURE 0 ///< Thermistors/sensors minimum allowed temperature reading. +#define MAX_ALLOWED_TEMPERATURE 70 ///< Thermistors/sensors maximum allowed temperature reading. +#define MAX_ALLOWED_TEMP_OUT_OF_RANGE_COUNT ( MS_PER_SECOND / ( 4 * TASK_GENERAL_INTERVAL ) ) ///< Thermistors/sensors maximum allowed temperature out of range count. /// Thermistors self test states typedef enum thermistors_Self_Test_States { - THERMISTORS_SELF_TEST_START = 0, ///< Thermistors self test start - THERMISTROS_SELF_TEST_ADC_CHECK, ///< Thermistors self test ADC check - THERMISTORS_SELF_TEST_COMPLETE, ///< Thermistors self test complete - NUM_OF_THERMISTORS_SEsLF_TEST_STATES, ///< Number of thermistors self test states + THERMISTROS_SELF_TEST_CHECK_RANGE = 0, ///< Thermistors self test range check + THERMISTORS_SELF_TEST_COMPLETE, ///< Thermistors self test complete + NUM_OF_THERMISTORS_SELF_TEST_STATES, ///< Number of thermistors self test states } THERMISTORS_SELF_TEST_STATES_T; /// Thermistors exec states @@ -49,23 +49,30 @@ { S32 rawADCRead; ///< Thermistor raw ADC read OVERRIDE_F32_T temperatureValue; ///< Thermistor temperature value + U32 tempOutOfRangeCount; ///< Thermistor temperature out of range counter } THERMISTOR_T; -static SELF_TEST_STATUS_T thermistorsSelfTestReslt = SELF_TEST_STATUS_IN_PROGRESS; ///< Thermistors self test result -static THERMISTORS_SELF_TEST_STATES_T thermistorsSelfTestState = THERMISTORS_SELF_TEST_START; ///< Thermistors self test state -static THERMISTORS_EXEC_STATES_T thermistorsExecState = THERMISTORS_EXEC_STATE_START; ///< Thermistors exec state -static THERMISTOR_T thermistorsStatus[ NUM_OF_THERMISTORS ]; ///< Thermistors array +static SELF_TEST_STATUS_T thermistorsSelfTestReslt = SELF_TEST_STATUS_IN_PROGRESS; ///< Thermistors self test result +static THERMISTORS_SELF_TEST_STATES_T thermistorsSelfTestState = THERMISTROS_SELF_TEST_CHECK_RANGE; ///< Thermistors self test state +static THERMISTORS_EXEC_STATES_T thermistorsExecState = THERMISTORS_EXEC_STATE_START; ///< Thermistors exec state +static THERMISTOR_T thermistorsStatus[ NUM_OF_THERMISTORS ]; ///< Thermistors array static OVERRIDE_U32_T thermistorsPublishInterval = { THERMISTORS_DATA_PUBLISH_INTERVAL, - THERMISTORS_DATA_PUBLISH_INTERVAL, 0, 0 }; ///< Thermistors publish time interval override -static U32 dataPublishCounter; ///< Thermistors data publish timer counter -static U32 adcReadCounter; ///< Thermistors ADC read counter + THERMISTORS_DATA_PUBLISH_INTERVAL, 0, 0 }; ///< Thermistors publish time interval override +static U32 dataPublishCounter; ///< Thermistors data publish timer counter +static U32 adcReadCounter; ///< Thermistors ADC read counter -static const F32 fpgaBoardTempSensorConvCoeff = 503.975 / TWELVE_BIT_RESOLUTION; ///< FPGA board temperature sensor conversion coefficient -static const F32 adcTempSensorsConversionCoeff1 = 1 / 13584; ///< ADC temperature sensors conversion coefficient 1 -static const F32 adcTempSensorsConversionCoeff2 = 0x800000 / 13584; ///< ADC temperature sensors conversion coefficient 2 +static const F32 fpgaBoardTempSensorConvCoeff = 503.975 / TWELVE_BIT_RESOLUTION; ///< FPGA board temperature sensor conversion coefficient +static const F32 adcTempSensorsConversionCoeff1 = 1 / 13584; ///< ADC temperature sensors conversion coefficient 1 +static const F32 adcTempSensorsConversionCoeff2 = 0x800000 / 13584; ///< ADC temperature sensors conversion coefficient 2 +static const F32 onBoardThermistorVoltageConvCoeff = ONBOARD_THERMISTOR_SOURCE_VOLTAGE / + TWELVE_BIT_RESOLUTION; ///< On board thermistor ADC to voltage conversion coefficient +static const F32 onBoardThermistorBetaValueInv = 1 / ONBOARD_THERMISTOR_BETA_VALUE; ///< On board thermistor beta value inverse +static const F32 onBoardThermistorRefTempInv = 1 / ONBOARD_THERMISTOR_REFERENCE_TEMPERATURE; ///< On board thermistor reference temONBOARD_THERMISTOR_REFERENCE_TEMPERATUREperature inverse // ********** private function prototypes ********** +static THERMISTORS_SELF_TEST_STATES_T handleSelfTestRangeCheck( void ); + static THERMISTORS_EXEC_STATES_T handleExecStart( void ); static THERMISTORS_EXEC_STATES_T handleExecGetADCValues( void ); @@ -86,10 +93,18 @@ *************************************************************************/ void initThermistors( void ) { + THERMISTORS_TEMP_SENSORS_T thermistor; + + // Reset the thermistors values for a run thermistorsSelfTestReslt = SELF_TEST_STATUS_IN_PROGRESS; thermistorsExecState = THERMISTORS_EXEC_STATE_START; - thermistorsSelfTestState = THERMISTORS_SELF_TEST_START; + thermistorsSelfTestState = THERMISTROS_SELF_TEST_CHECK_RANGE; dataPublishCounter = 0; + + for ( thermistor = THERMISTOR_ONBOARD_NTC; thermistor < NUM_OF_THERMISTORS; thermistor++ ) + { + thermistorsStatus[ thermistor ].tempOutOfRangeCount = 0; + } } /*********************************************************************//** @@ -103,17 +118,16 @@ { switch ( thermistorsSelfTestState ) { - case THERMISTORS_SELF_TEST_START: + case THERMISTROS_SELF_TEST_CHECK_RANGE: + thermistorsSelfTestState = handleSelfTestRangeCheck(); break; - case THERMISTROS_SELF_TEST_ADC_CHECK: - break; - case THERMISTORS_SELF_TEST_COMPLETE: // Done with POST. Do nothing. break; default: + // Wrong state was called, raise an alarm SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_THERMISTORS_INVALID_SELF_TEST_STATE, thermistorsSelfTestState ); thermistorsSelfTestState = THERMISTORS_SELF_TEST_COMPLETE; break; @@ -142,6 +156,7 @@ break; default: + // Wrong state was called, raise an alarm SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_THERMISTORS_INVALID_EXEC_STATE, thermistorsExecState ); thermistorsExecState = THERMISTORS_EXEC_STATE_GET_ADC_VALUES; break; @@ -186,6 +201,61 @@ /*********************************************************************//** * @brief + * The handleSelfTestRangeCheck function checks whether the thermistors + * are in range upon staring the device. + * @details Inputs: thermistorsStatus, adcReadCounter + * @details Outputs: thermistorsStatus, adcReadCounter + * @return next state of self test + *************************************************************************/ +static THERMISTORS_SELF_TEST_STATES_T handleSelfTestRangeCheck( void ) +{ + THERMISTORS_SELF_TEST_STATES_T state = THERMISTROS_SELF_TEST_CHECK_RANGE; + + // Give a short time for FPGA to boot up and start sending the ADC reads + if ( ++adcReadCounter > ADC_FPGA_READ_DELAY_COUNT ) + { + THERMISTORS_TEMP_SENSORS_T thermistor; + F32 temperature; + + // Assuming self test passed + thermistorsSelfTestReslt = SELF_TEST_STATUS_PASSED; + + // Get all the raw readings in ADC + thermistorsStatus[ THERMISTOR_ONBOARD_NTC ].rawADCRead = getIntADCReading( INT_ADC_BOARD_THERMISTOR ); + thermistorsStatus[ TEMPSENSOR_FPGA_SENSOR ].rawADCRead = getFPGABoardTemp(); + thermistorsStatus[ TEMPSENSOR_LOAD_CELL_A1 ].rawADCRead = getFPGALoadCellsA1B1Temp(); + thermistorsStatus[ TEMPSENSOR_LOAD_CELL_A2 ].rawADCRead = getFPGALoadCellsA2B2Temp(); + thermistorsStatus[ TEMPSENSOR_INTERNAL_THDO_RTD ].rawADCRead = getFPGATHDoInternalTemp(); + thermistorsStatus[ TEMPSENSOR_INTERNAL_TDI_RTD ].rawADCRead = getFPGATDiInternalTemp(); + thermistorsStatus[ TEMPSENSOR_INTERNAL_CONDUCTIVITY ].rawADCRead = getFPGAConductivitySnsrInternalTemp(); + thermistorsStatus[ THERMISTOR_POWER_SUPPLY_1 ].rawADCRead = getIntADCReading( INT_ADC_POWER_SUPPLY_1_THERMISTOR ); + thermistorsStatus[ THERMISTOR_POWER_SUPPLY_2 ].rawADCRead = getIntADCReading( INT_ADC_POWER_SUPPLY_2_THERMISTOR ); + + // Convert the ADC values to temperature + convertADCtoTemperature(); + + for ( thermistor = THERMISTOR_ONBOARD_NTC; thermistor < NUM_OF_THERMISTORS; thermistor++ ) + { + // Get the actual temperature value and not the override value + temperature = thermistorsStatus[ thermistor ].temperatureValue.data; + // If the values are out of range, raise an alarm + if ( temperature < MIN_ALLOWED_TEMPERATURE || temperature >= MAX_ALLOWED_TEMPERATURE ) + { + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_THERMISOTRS_TEMPERATURE_OUT_OF_RANGE, thermistor, temperature ); + // If any thermistor/sensor is not in range, POST has failed + thermistorsSelfTestReslt = SELF_TEST_STATUS_FAILED; + } + } + // Done with POST + state = THERMISTORS_SELF_TEST_COMPLETE; + adcReadCounter = 0; + } + + return state; +} + +/*********************************************************************//** + * @brief * The handleExecStart function handles the start state of the exec state * machine. * @details Inputs: adcReadCounter @@ -222,13 +292,15 @@ if ( ++adcReadCounter >= THERMISTORS_ADC_READ_INTERVAL ) { // Get all the raw readings in ADC - thermistorsStatus[ THERMISTOR_ONBOARD_NTC ].rawADCRead = getIntADCReading( INT_ADC_BOARD_THERMISTOR ); - thermistorsStatus[ TEMPSENSOR_FPGA_SENSOR ].rawADCRead = getFPGABoardTemp(); - thermistorsStatus[ TEMPSENSOR_LOAD_CELL_A1 ].rawADCRead = getFPGALoadCellsA1B1Temp(); - thermistorsStatus[ TEMPSENSOR_LOAD_CELL_A2 ].rawADCRead = getFPGALoadCellsA2B2Temp(); - thermistorsStatus[ TEMPSENSOR_THDO_RTD ].rawADCRead = getFPGATHDoInternalTemp(); - thermistorsStatus[ TEMPSENSOR_TDI_RTD ].rawADCRead = getFPGATDiInternalTemp(); - thermistorsStatus[ TEMPSENSOR_CONDUCTIVITY ].rawADCRead = getFPGAConductivitySnsrInternalTemp(); + thermistorsStatus[ THERMISTOR_ONBOARD_NTC ].rawADCRead = getIntADCReading( INT_ADC_BOARD_THERMISTOR ); + thermistorsStatus[ TEMPSENSOR_FPGA_SENSOR ].rawADCRead = getFPGABoardTemp(); + thermistorsStatus[ TEMPSENSOR_LOAD_CELL_A1 ].rawADCRead = getFPGALoadCellsA1B1Temp(); + thermistorsStatus[ TEMPSENSOR_LOAD_CELL_A2 ].rawADCRead = getFPGALoadCellsA2B2Temp(); + thermistorsStatus[ TEMPSENSOR_INTERNAL_THDO_RTD ].rawADCRead = getFPGATHDoInternalTemp(); + thermistorsStatus[ TEMPSENSOR_INTERNAL_TDI_RTD ].rawADCRead = getFPGATDiInternalTemp(); + thermistorsStatus[ TEMPSENSOR_INTERNAL_CONDUCTIVITY ].rawADCRead = getFPGAConductivitySnsrInternalTemp(); + thermistorsStatus[ THERMISTOR_POWER_SUPPLY_1 ].rawADCRead = getIntADCReading( INT_ADC_POWER_SUPPLY_1_THERMISTOR ); + thermistorsStatus[ THERMISTOR_POWER_SUPPLY_2 ].rawADCRead = getIntADCReading( INT_ADC_POWER_SUPPLY_2_THERMISTOR ); // Zero the counter for the next round of reading adcReadCounter = 0; @@ -263,16 +335,27 @@ // If the thermisotrs and sensors read temperature out of range, raise an alarm if ( temperature < MIN_ALLOWED_TEMPERATURE || temperature >= MAX_ALLOWED_TEMPERATURE ) { - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_THERMISOTRS_TEMPERATURE_OUT_OF_RANGE, thermistor, temperature ); + // If a thermistor/sensor has been out of range consistently, raise an alarm + if ( ++thermistorsStatus[ thermistor ].tempOutOfRangeCount > MAX_ALLOWED_TEMP_OUT_OF_RANGE_COUNT ) + { + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_THERMISOTRS_TEMPERATURE_OUT_OF_RANGE, thermistor, temperature ); + thermistorsStatus[ thermistor ].tempOutOfRangeCount = 0; + } } + // If the next temperature reading is in range but the counter was greater than 0, reset + else if ( thermistorsStatus[ thermistor ].tempOutOfRangeCount > 0 ) + { + thermistorsStatus[ thermistor ].tempOutOfRangeCount = 0; + } } } /*********************************************************************//** * @brief * The convertADCtoTemperature function converts the ADC values of different * thermistors and temperature sensors to temperature value. - * @details Inputs: thermistorsStatus + * @details Inputs: thermistorsStatus, fpgaBoardTempSensorConvCoeff, + * adcTempSensorsConversionCoeff1, adcTempSensorsConversionCoeff2 * @details Outputs: thermistorsStatus * @param thermistor (also covers the temperature sensors) to convert its value * @return none @@ -297,21 +380,26 @@ break; case TEMPSENSOR_FPGA_SENSOR: + // Temperature(C) = ((ADC x 503.975) / 4096) - 273.15 + // The value of 503.975/4096 was done in a const variable to prevent the division all the time temperature = ( rawADC * fpgaBoardTempSensorConvCoeff ) - CELSIUS_TO_KELVIN_CONVERSION; thermistorsStatus[ TEMPSENSOR_FPGA_SENSOR ].temperatureValue.data = temperature; break; // All these sensors have the same conversion procedure case TEMPSENSOR_LOAD_CELL_A1: case TEMPSENSOR_LOAD_CELL_A2: - case TEMPSENSOR_THDO_RTD: - case TEMPSENSOR_TDI_RTD: - case TEMPSENSOR_CONDUCTIVITY: + case TEMPSENSOR_INTERNAL_THDO_RTD: + case TEMPSENSOR_INTERNAL_TDI_RTD: + case TEMPSENSOR_INTERNAL_CONDUCTIVITY: + // Temperature(C) = ((ADC - 0x800000)/13584) - 272.5 + // The values for 1/0x800000 and 0x800000/13584 were done in a const variable to prevent the division all the time temperature = ( ( rawADC * adcTempSensorsConversionCoeff1 ) - adcTempSensorsConversionCoeff2 ) - ADC_TEMP_SENSORS_CONVERSION_CONST; thermistorsStatus[ thermistor ].temperatureValue.data = temperature; break; default: + // Wrong sensor was called, raise an alarm SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_THERMISTOR_SELECTED, thermistor ); break; } @@ -322,20 +410,32 @@ * @brief * The calcualteOnBoardThemristorTemperature function converts the ADC value * of the onboard thermistor into temperature in C - * @details Inputs: none + * @details Inputs: onBoardThermistorVoltageConvCoeff, + * onBoardThermistorBetaValueInv * @details Outputs: none * @param ADC value to be converted into temperature in C * @return calculated temperature in C *************************************************************************/ static F32 calculateOnBoardThemristorTemperature( U32 adcValue ) { - //TODO add comments - F32 thermistorVoltage = ( adcValue * ONBOARD_THERMISTOR_SOURCE_VOLTAGE ) / TWELVE_BIT_RESOLUTION; - F32 thermistorResistor = ( ( ONBOARD_THERMISTOR_REFERENCE_RESISTOR * ONBOARD_THERMISTOR_SOURCE_VOLTAGE ) - + /* + * voltage = ADC x 3 / 2^12 + * voltage = 3 x 10 / ( 10 + R(T) ) + * R(T) = 10 x e^(3380 x (1/T - 1/298)) + * Solve for T which is temperature in Kelvin + */ + + // Voltage = ADC x 3 / 2^12 for 12 bits resolution and a 3V ADC + // The value of 3 / 2^12 has been calculated in a const to prevent the division again + F32 const thermistorVoltage = adcValue * onBoardThermistorVoltageConvCoeff; + // Calculate the thermistor resistor by solving: thermistorVoltage = (3 x 10) / (10 + R(T)) + F32 const thermistorResistor = ( ( ONBOARD_THERMISTOR_REFERENCE_RESISTOR * ONBOARD_THERMISTOR_SOURCE_VOLTAGE ) - ( ONBOARD_THERMISTOR_REFERENCE_RESISTOR * thermistorVoltage ) ) / thermistorVoltage; - F32 InvTemperature = ( logf(thermistorResistor/ONBOARD_THERMISTOR_REFERENCE_RESISTOR) / ONBOARD_THERMISTOR_BETA_VALUE ) + - ( 1 / ONBOARD_THERMISTOR_REFERENCE_TEMPERATURE); - F32 temperature = 1 / InvTemperature; + // 1/T = Ln(thermistorResistor/10)/3380 + 1/298 + F32 const InvTemperature = ( logf( thermistorResistor / ONBOARD_THERMISTOR_REFERENCE_RESISTOR ) * onBoardThermistorBetaValueInv ) + + onBoardThermistorRefTempInv; + // Inverse the value to get the temperature in Kelvin and then convert it to Celsius + F32 const temperature = ( 1 / InvTemperature ) - CELSIUS_TO_KELVIN_CONVERSION; return temperature; } @@ -374,14 +474,16 @@ { THERMISTORS_DATA_T sensorsData; - // Get all the sensors/thermistors values for publication + // Get all the sensors/thermistors temperature values for publication sensorsData.onboardThermistor = getThermistorTemperatureValue( THERMISTOR_ONBOARD_NTC ); - sensorsData.fpgaBoardTempSensor = getFPGABoardTemp(); - sensorsData.loadCellA1TempSensor = getFPGALoadCellsA1B1Temp(); - sensorsData.loadCellA2TempSensor = getFPGALoadCellsA2B2Temp(); - sensorsData.rtdInternalTempSensor = getFPGATHDoInternalTemp(); - sensorsData.rtdTDiInternalTempSensor = getFPGATDiInternalTemp(); - sensorsData.conductivityTempSensor = getFPGAConductivitySnsrInternalTemp(); + sensorsData.fpgaBoardTempSensor = getThermistorTemperatureValue( TEMPSENSOR_FPGA_SENSOR ); + sensorsData.loadCellA1TempSensor = getThermistorTemperatureValue( TEMPSENSOR_LOAD_CELL_A1 ); + sensorsData.loadCellA2TempSensor = getThermistorTemperatureValue( TEMPSENSOR_LOAD_CELL_A2 ); + sensorsData.rtdInternalTempSensor = getThermistorTemperatureValue( TEMPSENSOR_INTERNAL_THDO_RTD ); + sensorsData.rtdTDiInternalTempSensor = getThermistorTemperatureValue( TEMPSENSOR_INTERNAL_TDI_RTD ); + sensorsData.conductivityTempSensor = getThermistorTemperatureValue( TEMPSENSOR_INTERNAL_CONDUCTIVITY ); + sensorsData.powerSupply1Thermistor = getThermistorTemperatureValue( THERMISTOR_POWER_SUPPLY_1 ); + sensorsData.powerSupply2Thermistor = getThermistorTemperatureValue( THERMISTOR_POWER_SUPPLY_2 ); // Broadcast the thermistors data broadcastThermistorsData( &sensorsData ); @@ -495,7 +597,6 @@ } return result; - } /**@}*/ Index: firmware/App/Controllers/Thermistors.h =================================================================== diff -u -r45263215b372cd579e8e16bb8073c287c726c55d -r1f500f8e6159a3fbab85ea68389e918a6df66400 --- firmware/App/Controllers/Thermistors.h (.../Thermistors.h) (revision 45263215b372cd579e8e16bb8073c287c726c55d) +++ firmware/App/Controllers/Thermistors.h (.../Thermistors.h) (revision 1f500f8e6159a3fbab85ea68389e918a6df66400) @@ -19,14 +19,16 @@ /// Enumeration of thermistors typedef enum thermistors_Name { - THERMISTOR_ONBOARD_NTC = 0, ///< Onboard thermistor - TEMPSENSOR_FPGA_SENSOR, ///< FPGA board temperature sensor - TEMPSENSOR_LOAD_CELL_A1, ///< Load cell A1 temperature sensor - TEMPSENSOR_LOAD_CELL_A2, ///< Load cell A2 temperature sensor - TEMPSENSOR_THDO_RTD, ///< THDo RTD temperature sensor - TEMPSENSOR_TDI_RTD, ///< TDi RTD temperature sensor - TEMPSENSOR_CONDUCTIVITY, ///< Conductivity sensor temperature sensor - NUM_OF_THERMISTORS, ///< Number of thermistors + THERMISTOR_ONBOARD_NTC = 0, ///< Onboard thermistor + TEMPSENSOR_FPGA_SENSOR, ///< FPGA board temperature sensor + TEMPSENSOR_LOAD_CELL_A1, ///< Load cell A1 temperature sensor + TEMPSENSOR_LOAD_CELL_A2, ///< Load cell A2 temperature sensor + TEMPSENSOR_INTERNAL_THDO_RTD, ///< THDo RTD internal temperature sensor + TEMPSENSOR_INTERNAL_TDI_RTD, ///< TDi RTD internal temperature sensor + TEMPSENSOR_INTERNAL_CONDUCTIVITY, ///< Conductivity sensor temperature sensor + THERMISTOR_POWER_SUPPLY_1, ///< DG power supply 1 thermistor + THERMISTOR_POWER_SUPPLY_2, ///< DG power supply 2 thermistor + NUM_OF_THERMISTORS, ///< Number of thermistors } THERMISTORS_TEMP_SENSORS_T; /// Thermistors/temperature sensors data publish struct @@ -39,6 +41,8 @@ F32 rtdInternalTempSensor; ///< RTD internal temperature sensor F32 rtdTDiInternalTempSensor; ///< RTD TDi internal temperature sensor F32 conductivityTempSensor; ///< Conductivity temperature sensor + F32 powerSupply1Thermistor; ///< Power supply 1 thermistor + F32 powerSupply2Thermistor; ///< Power supply 2 thermistor } THERMISTORS_DATA_T; // ********** public function prototypes ********** Index: firmware/App/Controllers/UVReactors.h =================================================================== diff -u -r04db56ac0f515f35b7f236d607bfb6f7585f55fb -r1f500f8e6159a3fbab85ea68389e918a6df66400 --- firmware/App/Controllers/UVReactors.h (.../UVReactors.h) (revision 04db56ac0f515f35b7f236d607bfb6f7585f55fb) +++ firmware/App/Controllers/UVReactors.h (.../UVReactors.h) (revision 1f500f8e6159a3fbab85ea68389e918a6df66400) @@ -7,7 +7,8 @@ /** * @defgroup UV Reactors UV Reactors * @brief UV reactors driver module. - * Controls the inlet and outlet UV reactors + * Controls the inlet and outlet of Acuva Strike II-B21 V10K L60 M UV reactors. + * Diality PN 1006797-001 * * @addtogroup UV Reactors * @{ Index: firmware/App/Drivers/InternalADC.c =================================================================== diff -u -r54f45c387430e440ab4607451fc84dea61f273f1 -r1f500f8e6159a3fbab85ea68389e918a6df66400 --- firmware/App/Drivers/InternalADC.c (.../InternalADC.c) (revision 54f45c387430e440ab4607451fc84dea61f273f1) +++ firmware/App/Drivers/InternalADC.c (.../InternalADC.c) (revision 1f500f8e6159a3fbab85ea68389e918a6df66400) @@ -55,8 +55,8 @@ INT_ADC_REF_IN1, // 19 INT_ADC_REF_IN2, // 20 INT_ADC_BOARD_THERMISTOR, // 21 - INT_ADC_NOT_USED, // 22 - INT_ADC_NOT_USED // 23 + INT_ADC_POWER_SUPPLY_1_THERMISTOR, // 22 + INT_ADC_POWER_SUPPLY_2_THERMISTOR // 23 }; // ********** private data ********** Index: firmware/App/Drivers/InternalADC.h =================================================================== diff -u -r54f45c387430e440ab4607451fc84dea61f273f1 -r1f500f8e6159a3fbab85ea68389e918a6df66400 --- firmware/App/Drivers/InternalADC.h (.../InternalADC.h) (revision 54f45c387430e440ab4607451fc84dea61f273f1) +++ firmware/App/Drivers/InternalADC.h (.../InternalADC.h) (revision 1f500f8e6159a3fbab85ea68389e918a6df66400) @@ -58,7 +58,9 @@ INT_ADC_3_3_VOLTS, ///< DG internal ADC DG 3.3 volt supply channel INT_ADC_REFERENCE_VOLTAGE, ///< DG internal ADC reference voltage channel INT_ADC_REF_IN1, ///< DG internal ADC ??? channel TODO - INT_ADC_REF_IN2, ///< DG internal ADC ??? channel TODO + INT_ADC_REF_IN2, ///< DG internal ADC ??? channel TODO + INT_ADC_POWER_SUPPLY_1_THERMISTOR, ///< DG internal ADC DG power supply 1 thermistor + INT_ADC_POWER_SUPPLY_2_THERMISTOR, ///< DG internal ADC DG power supply 2 thermistor NUM_OF_INT_ADC_CHANNELS ///< Number of DG internal ADC channels } INT_ADC_CHANNEL_T; Index: firmware/App/Services/AlarmMgmt.h =================================================================== diff -u -r2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b -r1f500f8e6159a3fbab85ea68389e918a6df66400 --- firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b) +++ firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 1f500f8e6159a3fbab85ea68389e918a6df66400) @@ -152,6 +152,9 @@ SW_FAULT_ID_FAN_INVALID_EXEC_STATE, // 60 SW_FAULT_ID_FAN_INVALID_SELF_TEST_STATE, SW_FAULT_ID_INVALID_FAN_SELECTED, + SW_FAULT_ID_RO_PUMP_INVALID_EXEC_STATE, + SW_FAULT_ID_RO_PUMP_INVALID_FLOW_RATE_SET, + SW_FAULT_ID_DRAIN_PUMP_INVALID_EXEC_STATE, // 65 NUM_OF_SW_FAULT_IDS } SW_FAULT_ID_T; Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r45263215b372cd579e8e16bb8073c287c726c55d -r1f500f8e6159a3fbab85ea68389e918a6df66400 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 45263215b372cd579e8e16bb8073c287c726c55d) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 1f500f8e6159a3fbab85ea68389e918a6df66400) @@ -1505,7 +1505,7 @@ * @details Outputs: none * @return inlet fan 1 pulse value *************************************************************************/ -U16 getFPGAInletFan1Pulse( void ) +U16 getFPGAInletFan1TogglePeriod( void ) { return fpgaSensorReadings.fpgaFan1Pulse; } @@ -1517,7 +1517,7 @@ * @details Outputs: none * @return inlet fan 2 pulse value *************************************************************************/ -U16 getFPGAInletFan2Pulse( void ) +U16 getFPGAInletFan2TogglePeriod( void ) { return fpgaSensorReadings.fpgaFan2Pulse; } @@ -1529,7 +1529,7 @@ * @details Outputs: none * @return inlet fan 3 pulse value *************************************************************************/ -U16 getFPGAInletFan3Pulse( void ) +U16 getFPGAInletFan3TogglePeriod( void ) { return 0; } @@ -1541,7 +1541,7 @@ * @details Outputs: none * @return outlet fan 1 pulse value *************************************************************************/ -U16 getFPGAOutletFan1Pulse( void ) +U16 getFPGAOutletFan1TogglePeriod( void ) { return 0; } @@ -1553,7 +1553,7 @@ * @details Outputs: none * @return outlet fan 2 pulse value *************************************************************************/ -U16 getFPGAOutletFan2Pulse( void ) +U16 getFPGAOutletFan2TogglePeriod( void ) { return 0; } @@ -1565,7 +1565,7 @@ * @details Outputs: none * @return outlet fan 3 pulse value *************************************************************************/ -U16 getFPGAOutletFan3Pulse( void ) +U16 getFPGAOutletFan3TogglePeriod( void ) { return 0; } Index: firmware/App/Services/FPGA.h =================================================================== diff -u -r45263215b372cd579e8e16bb8073c287c726c55d -r1f500f8e6159a3fbab85ea68389e918a6df66400 --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision 45263215b372cd579e8e16bb8073c287c726c55d) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision 1f500f8e6159a3fbab85ea68389e918a6df66400) @@ -100,12 +100,12 @@ void getFPGAAccelMaxes( S16 *xm, S16*ym, S16*zm ); void getFPGAAccelStatus( U16 *cnt, U16 *accelFPGAFaultReg ); -U16 getFPGAInletFan1Pulse( void ); //TODO change these functions' names to inlet1, inlet2 once all 6 fans are implemented -U16 getFPGAInletFan2Pulse( void ); //TODO change these functions' names to inlet1, inlet2 once all 6 fans are implemented -U16 getFPGAInletFan3Pulse( void ); -U16 getFPGAOutletFan1Pulse( void ); -U16 getFPGAOutletFan2Pulse( void ); -U16 getFPGAOutletFan3Pulse( void ); +U16 getFPGAInletFan1TogglePeriod( void ); //TODO change these functions' names to inlet1, inlet2 once all 6 fans are implemented +U16 getFPGAInletFan2TogglePeriod( void ); //TODO change these functions' names to inlet1, inlet2 once all 6 fans are implemented +U16 getFPGAInletFan3TogglePeriod( void ); +U16 getFPGAOutletFan1TogglePeriod( void ); +U16 getFPGAOutletFan2TogglePeriod( void ); +U16 getFPGAOutletFan3TogglePeriod( void ); U32 getFPGABoardTemp( void ); //TODO add the FPGA board temperature sensor U32 getFPGALoadCellsA1B1Temp( void ); Index: firmware/App/Services/MessagePayloads.h =================================================================== diff -u -raa36ab1ed13d099286cedcbd066f7dce11146d13 -r1f500f8e6159a3fbab85ea68389e918a6df66400 --- firmware/App/Services/MessagePayloads.h (.../MessagePayloads.h) (revision aa36ab1ed13d099286cedcbd066f7dce11146d13) +++ firmware/App/Services/MessagePayloads.h (.../MessagePayloads.h) (revision 1f500f8e6159a3fbab85ea68389e918a6df66400) @@ -67,15 +67,6 @@ F32 loadCellB2inGram; ///< Loadcell B2 measurement in gram } LOAD_CELL_DATA_T; -/// Drain pump data struct. -typedef struct -{ - U32 setDrainPumpSpeed; ///< Drain pump speed set target - U32 dacValue; ///< Drain pump DAC value - F32 deltaPressure; ///< Drain pump delta pressure - U32 drainPState; ///< Drain pump state -} DRAIN_PUMP_DATA_T; - /// Pressure data struct. typedef struct { Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r45263215b372cd579e8e16bb8073c287c726c55d -r1f500f8e6159a3fbab85ea68389e918a6df66400 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 45263215b372cd579e8e16bb8073c287c726c55d) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 1f500f8e6159a3fbab85ea68389e918a6df66400) @@ -530,33 +530,25 @@ /*********************************************************************//** * @brief - * The broadcastDrainPumpData function sends out RO pump data. - * @details - * Inputs : none - * Outputs : Drain pump data msg constructed and queued - * @param tgtSpeed target speed for drain pump in RPM - * @param dac set DAC value + * The broadcastDrainPumpData function sends out the drain pump data. + * @details Inputs : none + * @details Outputs : Drain pump data msg constructed and queued + * @param drain pump data structure pointer * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastDrainPumpData( U32 tgtSpeed, U32 dac, F32 deltaP, U32 drainPumpState ) +BOOL broadcastDrainPumpData( DRAIN_PUMP_DATA_T *drainPumpData ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - DRAIN_PUMP_DATA_T payload; // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DRAIN_PUMP_DATA; msg.hdr.payloadLen = sizeof( DRAIN_PUMP_DATA_T ); - payload.setDrainPumpSpeed = tgtSpeed; - payload.dacValue = dac; - payload.deltaPressure = deltaP; - payload.drainPState = drainPumpState; + memcpy( payloadPtr, drainPumpData, sizeof( DRAIN_PUMP_DATA_T ) ); - memcpy( payloadPtr, &payload, sizeof( DRAIN_PUMP_DATA_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); @@ -1185,7 +1177,7 @@ { U32 roPumpPWM; memcpy( &roPumpPWM, message->payload, sizeof(U32) ); - result = setROPumpTargetPWM( roPumpPWM ); + //result = setROPumpTargetPWM( roPumpPWM ); } return result; Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r45263215b372cd579e8e16bb8073c287c726c55d -r1f500f8e6159a3fbab85ea68389e918a6df66400 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 45263215b372cd579e8e16bb8073c287c726c55d) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 1f500f8e6159a3fbab85ea68389e918a6df66400) @@ -17,7 +17,8 @@ #ifndef __SYSTEM_COMM_MESSAGES_H__ #define __SYSTEM_COMM_MESSAGES_H__ - + +#include "DrainPump.h" #include "DGCommon.h" #include "MsgQueues.h" #include "ROPump.h" @@ -65,7 +66,7 @@ BOOL broadcastROPumpData( RO_PUMP_DATA_T *pumpData ); // MSG_ID_DRAIN_PUMP_DATA -BOOL broadcastDrainPumpData( U32 tgtSpeed, U32 dac, F32 deltaP, U32 drainPumpState ); +BOOL broadcastDrainPumpData( DRAIN_PUMP_DATA_T *drainPumpData ); // MSG_ID_DG_PRESSURES_DATA BOOL broadcastPressureSensorsData( F32 measROIn, F32 measROOut, F32 measDrainIn, F32 measDrainOut );