Index: firmware/App/Controllers/Fans.c =================================================================== diff -u -rdaf8d5b60c753becab80cbaf164aac0e49d533a2 -r2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b --- firmware/App/Controllers/Fans.c (.../Fans.c) (revision daf8d5b60c753becab80cbaf164aac0e49d533a2) +++ firmware/App/Controllers/Fans.c (.../Fans.c) (revision 2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b) @@ -1,48 +1,415 @@ -/* - * Fans.c - * - * Created on: Aug 6, 2020 - * Author: fw - */ #include "Fans.h" +#include "TaskGeneral.h" +#include "Thermistors.h" +#include "SystemCommMessages.h" +#include "FPGA.h" -//TODO Do we need exec fans? -//TODO Do we need a wrapper for pwm as input? -//TODO What to have in init fans? +/** + * @addtogroup Fans + * @{ + */ +// ********** private definitions ********** + +#define FANS_MIN_PWM_PERCENT 0.1 ///< Fans min PWM. +#define FANS_MAX_PWM_PERCENT 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 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 self test states +typedef enum fans_Self_Test +{ + FANS_SELF_TEST_START = 0, ///< Fans self test start 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_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 +} 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 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 + +/// 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 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 void setInletFansPWM( F32 pwm ); +static void setOutletFansPWM( F32 pwm ); +static F32 getMaximumTemperature( void ); +static void getFansRPM( void ); +static U32 getPublishFansDataInterval( void ); +static void publishFansData( void ); + +/*********************************************************************//** + * @brief + * The initFans function initializes the fans module. + * @details Inputs: fansExecState, fansSelfTestReslt, fansSelfTestState, + * fansStatus, fansControlCounter, fansPublishCounter + * @details Outputs: fansExecState, fansSelfTestReslt, fansSelfTestState, + * fansStatus, fansControlCounter, fansPublishCounter + * @return none + *************************************************************************/ void initFans( void ) { - //TODO fill up + // Initialize the variables + fansExecState = FANS_EXEC_STATE_START; + fansSelfTestReslt = SELF_TEST_STATUS_IN_PROGRESS; + fansSelfTestState = FANS_SELF_TEST_START; + fansControlCounter = 0; + fansPublishCounter = 0; } +/*********************************************************************//** + * @brief + * The execFansSelfTest function executes the fans self test. + * @details Inputs: FILL UP + * @details Outputs: FILL UP + * @return Status of self test + *************************************************************************/ SELF_TEST_STATUS_T execFansSelfTest( void ) { } +/*********************************************************************//** + * @brief + * The execFans function executes the execFans exec states. + * @details Inputs: fansExecState + * @details Outputs: fansExecState + * @return none + *************************************************************************/ void execFans( void ) { - // Possibly the PI controller for the board temperature + switch ( fansExecState ) + { + case FANS_EXEC_STATE_START: + fansExecState = handleFansExecStateStart(); + break; + + case FANS_EXEC_STATE_RUN: + fansExecState = handleFansExecStateRun(); + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_FAN_INVALID_EXEC_STATE, fansExecState ); + fansExecState = FANS_EXEC_STATE_RUN; + break; + } + + publishFansData(); } -BOOL startFan1( F32 pwmPercent ) +/*********************************************************************//** + * @brief + * The getFanRPM function returns the RPM a the selected fan. + * @details Inputs: fansStatus + * @details Outputs: none + * @param selected fan to read its RPM + * @return RPM of the selected fan + *************************************************************************/ +F32 getFanRPM( FANS_NAMES_T fan ) { - F32 pwm = pwmPercent / 100; + F32 rpm = 0.0; + // Check if the called fan is in range + if ( fan < NUM_OF_FANS_NAMES ) + { + rpm = fansStatus.rpm[ fan ]; + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_FAN_SELECTED, fan ); + } + + return rpm; +} + +/*********************************************************************//** + * @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 ) +{ + FANS_EXEC_STATES_T state = FANS_EXEC_STATE_START; + + // TODO do we need to wait for POST or something? + + // Start the fans with minimum PWM + setInletFansPWM( FANS_MIN_PWM_PERCENT ); + setOutletFansPWM( FANS_MIN_PWM_PERCENT ); + state = FANS_EXEC_STATE_RUN; + + return state; +} + +/*********************************************************************//** + * @brief + * The handleFansExecStateRun function handles the run state of the + * fans exec state machine. + * @details Inputs: fansStatus, fansControlCounter + * @details Outputs: fansStatus, fansControlCounter + * @return the next state of the exec state machine + *************************************************************************/ +static FANS_EXEC_STATES_T handleFansExecStateRun( void ) +{ + FANS_EXEC_STATES_T state = FANS_EXEC_STATE_RUN; + + // Check if it is time to check for the control + if( ++fansControlCounter > FANS_CONTROL_INTERVAL ) + { + // 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; + + // If the fans calculated PWM is greater than the previous calculated PWM, we are ramping up + // otherwise, we are ramping down + if ( pwm >= fansStatus.calculatedPWM ) + { + // 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 ) + { + fansStatus.targetPWM = FANS_MAX_ALLOWED_RAMP_UP_PWM_CHANGE; + } + else + { + fansStatus.targetPWM = pwm; + } + } + 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; + } + + // Update the struct + fansStatus.calculatedPWM = pwm; + + // Set the PWM to inlet and outlet fans + setInletFansPWM( fansStatus.targetPWM ); + setOutletFansPWM( fansStatus.targetPWM ); + + // Reset the counter + fansControlCounter = 0; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The setInletFansPWM function sets the inlet fans PWM. + * @details Inputs: none + * @details Outputs: none + * @param PWM that will be set + * @return none + *************************************************************************/ +static void setInletFansPWM( F32 pwm ) +{ etpwmSetCmpA( etpwmREG6, (U32)( (S32)( ( pwm * (F32)(etpwmREG6->TBPRD) ) + FLOAT_TO_INT_ROUNDUP_OFFSET ) ) ); } -BOOL startFan2( F32 pwmPercent ) +/*********************************************************************//** + * @brief + * The setOutletFansPWM function sets the outlet fans PWM. + * @details Inputs: none + * @details Outputs: none + * @param PWM that will be set + * @return none + ************************************************************************/ +static void setOutletFansPWM( F32 pwm ) { + etpwmSetCmpB( etpwmREG6, (U32)( (S32)( ( pwm * (F32)(etpwmREG6->TBPRD) ) + FLOAT_TO_INT_ROUNDUP_OFFSET ) ) ); +} +/*********************************************************************//** + * @brief + * The getMaximumTemperature function runs through the thermistors driver + * and finds the maximum temperature. + * @details Inputs: none + * @details Outputs: none + * @return maximum temperature of the thermistors and sensors + ************************************************************************/ +static F32 getMaximumTemperature( void ) +{ + F32 temperature; + THERMISTORS_TEMP_SENSORS_T thermistor; + + F32 maxTemperature = 0; + + // Loop through the sensors and thermistors + for ( thermistor = THERMISTOR_ONBOARD_NTC; thermistor < NUM_OF_THERMISTORS; thermistor++ ) + { + // Get the value + temperature = getThermistorTemperatureValue( thermistor ); + + // If the latest temperature read is greater than the max temperature, + // set the maximum temperature there + if ( temperature > maxTemperature ) + { + maxTemperature = temperature; + } + } + + return maxTemperature; } -void stopFan1( void ) +/*********************************************************************//** + * @brief + * The getFansRPM function runs through the list of the fans to get the + * FPGA pulse from them and converts them to RPM. + * @details Inputs: fansStatus, toggle2RPMCoefficient + * @details Outputs: fansStatus + * @return none + ************************************************************************/ +static void getFansRPM( void ) { + FANS_NAMES_T fan; + U32 RPM; + // 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 = getFPGAFan1Pulse(); //TODO is this the right place? + break; + + case FAN_INLET_2: + //TODO fill up + break; + + case FAN_INLET_3: + //TODO fill up + break; + + case FAN_OUTLET_1: + RPM = getFPGAFan2Pulse(); //TODO is this the right place? + break; + + case FAN_OUTLET_2: + //TODO fill up + break; + + case FAN_OUTLET_3: + //TODO fill up + break; + + default: + // Invalid fan has been selected, raise an alarm + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_FAN_SELECTED, fan ); + break; + } + + // 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 ) + { + fansStatus.rpm[ fan ] = 0; + } + else + { + fansStatus.rpm[ fan ] = RPM * toggle2RPMCoefficient; + } + } } -void stopFan2( void ) + +/*********************************************************************//** + * @brief + * The getPublishFansDataInterval function gets the fans data publish interval. + * @details Inputs: fansPublishInterval + * @details Outputs: none + * @return data publish time interval in counts + *************************************************************************/ +static U32 getPublishFansDataInterval( void ) { + U32 result = fansPublishInterval.data; + if ( OVERRIDE_KEY == fansPublishInterval.override ) + { + result = fansPublishInterval.ovData; + } + + return result; } + +/*********************************************************************//** + * @brief + * The publishFansData function publishes the fans data at the specified + * time interval. + * @details Inputs: dataPublishCounter + * @details Outputs: dataPublishCounter + * @return none + *************************************************************************/ +static void publishFansData( void ) +{ + if ( ++fansPublishCounter > getPublishFansDataInterval() ) + { + FANS_DATA_T fansData; + + fansData.fansCalculatedPWM = fansStatus.calculatedPWM * 100; + fansData.fansTargetPWM = fansStatus.targetPWM * 100; + //TODO fill up the speeds + + broadcastFansData( &fansData ); + + fansPublishCounter = 0; + } +} + +/************************************************************************* +* TEST SUPPORT FUNCTIONS +*************************************************************************/ + +BOOL testSetFanPublishIntervalOverride( U32 value ) +{ + +} +BOOL testResetFanPublishIntervalOverride( void ) +{ + +} + + Index: firmware/App/Controllers/Fans.h =================================================================== diff -u -r04db56ac0f515f35b7f236d607bfb6f7585f55fb -r2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b --- firmware/App/Controllers/Fans.h (.../Fans.h) (revision 04db56ac0f515f35b7f236d607bfb6f7585f55fb) +++ firmware/App/Controllers/Fans.h (.../Fans.h) (revision 2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b) @@ -1,39 +1,54 @@ -/* - * Fans.h - * - * Created on: Aug 6, 2020 - * Author: fw - */ -#ifndef APP_CONTROLLERS_FANS_H_ -#define APP_CONTROLLERS_FANS_H_ +#ifndef _FANS_H_ +#define _FANS_H_ #include "etpwm.h" #include "Common.h" /** * @defgroup Fans Fans - * @brief Fans monitor/controller module. Controls and monitors the DG fans. + * @brief Fans monitor/controller module. Controls and monitors the DG fans. * * @addtogroup Fans * @{ */ +/// Fans names +typedef enum fans_Name +{ + FAN_INLET_1 = 0, ///< Fan inlet 1 + FAN_INLET_2, ///< Fan inlet 2 + FAN_INLET_3, ///< Fan inlet 3 + FAN_OUTLET_1, ///< Fan outlet 1 + FAN_OUTLET_2, ///< Fan outlet 2 + FAN_OUTLET_3, ///< Fan outlet 3 + NUM_OF_FANS_NAMES ///< Number of fans names +} FANS_NAMES_T; + +/// Fans data publish +typedef struct +{ + F32 fansCalculatedPWM; ///< Fans calculated PWM + F32 fansTargetPWM; ///< Fans target PWM + F32 fanInlet1RPM; ///< Fan inlet 1 RPM + F32 fanInlet2RPM; ///< Fan inlet 2 RPM + F32 fanInlet3RPM; ///< Fan inlet 3 RPM + F32 fanOutlet1RPM; ///< Fan outlet 1 RPM + F32 fanOutlet2RPM; ///< Fan outlet 2 RPM + F32 fanOutlet3RPM; ///< Fan outlet 3 RPM +} FANS_DATA_T; + void initFans( void ); SELF_TEST_STATUS_T execFansSelfTest( void ); void execFans( void ); -// TODO override for fans1 and 2 with PWM -// TODO override baord temp +F32 getFanRPM( FANS_NAMES_T fan ); -// TODO remove -BOOL startFan1( F32 pwmPercent ); -BOOL startFan2( F32 pwmPercent ); +BOOL testSetFanPublishIntervalOverride( U32 value ); +BOOL testResetFanPublishIntervalOverride( void ); -void stopFan1( void ); -void stopFan2( void ); -// TODO Remove +/**@}*/ #endif Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r1538c71d0c6b97469d599befce15f068d9acf5d4 -r2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 1538c71d0c6b97469d599befce15f068d9acf5d4) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b) @@ -263,14 +263,16 @@ if ( roFlowRate < MAX_RO_FLOWRATE_LPM && roFlowRate >= MIN_RO_FLOWRATE_LPM ) { + tgtROPumpPressure = 0.0; + targetROPumpPressure.data = 0.0; targetROPumpFlowRate.data = roFlowRate; roPumpControlMode = PUMP_CONTROL_MODE_CLOSED_LOOP; roPumpPWMDutyCyclePct = ROP_FLOW_TO_PWM_DC( roFlowRate ); -#ifdef EMC_TEST_BUILD +/*#ifdef EMC_TEST_BUILD roPumpPWMDutyCyclePct = 1.0; #else roPumpPWMDutyCyclePct = ROP_FLOW_TO_PWM_DC( roFlowRate ); -#endif +#endif*/ } else // requested pressure out of range { @@ -432,17 +434,16 @@ #endif #endif - // If there is a flow, transition to P controller to get - // the corresponding pressure of that flow + // If there is a flow, transition to P controller to get the corresponding pressure of that flow if ( getTargetROPumpFlowRate() > 0 && roPumpControlMode == PUMP_CONTROL_MODE_CLOSED_LOOP ) { roPumpControlModeSet = roPumpControlMode; - // set initial PWM duty cycle + // Set initial PWM duty cycle roPumpPWMDutyCyclePctSet = roPumpPWMDutyCyclePct; setROPumpControlSignalPWM( roPumpPWMDutyCyclePctSet ); - // reset controller + // Reset controller resetPIController( I_CONTROLLER_ID_RO_PUMP_RAMP_UP, roPumpPWMDutyCyclePctSet ); - // set pump to on + // Set pump to on isROPumpOn = TRUE; result = RO_PUMP_RAMP_UP_STATE; } @@ -459,8 +460,8 @@ /*********************************************************************//** * @brief - * The handleROPumpRampUpState function handles the ro pump ramp up state \n - * of the ro pump controller state machine. + * The handleROPumpRampUpState function handles the RO pump ramp up state \n + * of the RO pump controller state machine. * @details * Inputs: roControlTimerCounter, roPumpPWMDutyCyclePctSet * Outputs: roControlTimerCounter, roPumpPWMDutyCyclePctSet @@ -474,7 +475,6 @@ if ( ++roControlTimerCounter >= ROP_CONTROL_INTERVAL ) { F32 targetFlowRate = getTargetROPumpFlowRate(); - F32 actualFlowRate = (F32)getMeasuredROFlowRate(); if ( fabs( actualFlowRate - targetFlowRate ) > ROP_FLOW_TARGET_TOLERANCE ) @@ -533,7 +533,7 @@ tgtROPumpPressure = avgPressure; // set initial PWM duty cycle - roPumpPWMDutyCyclePctSet = roPumpPWMDutyCyclePct; + //roPumpPWMDutyCyclePctSet = roPumpPWMDutyCyclePct; setROPumpControlSignalPWM( roPumpPWMDutyCyclePctSet ); // reset controller resetPIController( PI_CONTROLLER_ID_RO_PUMP, roPumpPWMDutyCyclePctSet ); Index: firmware/App/Controllers/Thermistors.c =================================================================== diff -u -r04db56ac0f515f35b7f236d607bfb6f7585f55fb -r2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b --- firmware/App/Controllers/Thermistors.c (.../Thermistors.c) (revision 04db56ac0f515f35b7f236d607bfb6f7585f55fb) +++ firmware/App/Controllers/Thermistors.c (.../Thermistors.c) (revision 2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b) @@ -16,12 +16,12 @@ #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 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. /// Thermistors self test states typedef enum thermistors_Self_Test_States @@ -53,7 +53,6 @@ static THERMISTORS_EXEC_STATES_T thermistorsExecState = THERMISTORS_EXEC_STATE_START; ///< Thermistors exec state static THERMISTOR_T thermistorsStatus[ NUM_OF_THERMISTORS ]; ///< Thermistors array -static F32 tempValuesForPublication[ NUM_OF_THERMISTORS ]; ///< Thermistors data publication array static OVERRIDE_U32_T thermistorsPublishInterval = { THERMISTORS_DATA_PUBLISH_INTERVAL, THERMISTORS_DATA_PUBLISH_INTERVAL, 0, 0 }; ///< Thermistors publish time interval override Index: firmware/App/Modes/ModeHeatDisinfect.c =================================================================== diff -u -r1538c71d0c6b97469d599befce15f068d9acf5d4 -r2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b --- firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 1538c71d0c6b97469d599befce15f068d9acf5d4) +++ firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b) @@ -643,7 +643,7 @@ setValveState( VRD, VALVE_STATE_R2_C_TO_NO ); setValveState( VRI, VALVE_STATE_R1_C_TO_NO ); setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); - setROPumpTargetFlowRate( 0.3 ); //RO_PUMP_TARGET_FLOW_RATE_LPM + setROPumpTargetFlowRate( 0.65 ); //RO_PUMP_TARGET_FLOW_RATE_LPM stateTimer = getMSTimerCount(); // For evac recirc path. TODO later, it should be controlled using // the composite pump Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r6e62d12f80c5412bb584f61cbcd2dbb2c4def833 -r2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 6e62d12f80c5412bb584f61cbcd2dbb2c4def833) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b) @@ -237,7 +237,7 @@ BOOL result = FALSE; // If DG is in standby mode and the standby mode is in Idle state, request DG heat disinfection - if ( DG_MODE_STAN == getCurrentOperationMode() && DG_STANDBY_MODE_STATE_IDLE == standbyState ) + //if ( DG_MODE_STAN == getCurrentOperationMode() && DG_STANDBY_MODE_STATE_IDLE == standbyState ) { requestNewOperationMode( DG_MODE_HEAT ); Index: firmware/App/Services/AlarmMgmt.h =================================================================== diff -u -r04db56ac0f515f35b7f236d607bfb6f7585f55fb -r2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b --- firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 04db56ac0f515f35b7f236d607bfb6f7585f55fb) +++ firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b) @@ -149,6 +149,9 @@ SW_FAULT_ID_THERMISTORS_INVALID_EXEC_STATE, SW_FAULT_ID_THERMISTORS_INVALID_SELF_TEST_STATE, SW_FAULT_ID_INVALID_THERMISTOR_SELECTED, + SW_FAULT_ID_FAN_INVALID_EXEC_STATE, // 60 + SW_FAULT_ID_FAN_INVALID_SELF_TEST_STATE, + SW_FAULT_ID_INVALID_FAN_SELECTED, NUM_OF_SW_FAULT_IDS } SW_FAULT_ID_T; Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rc1ef106ed0f97dc998230c6e154aa2362aa476d8 -r2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision c1ef106ed0f97dc998230c6e154aa2362aa476d8) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b) @@ -156,6 +156,8 @@ U08 fpgaReserved1; ///< Reg 375. Reserved U16 fpgaValveStates; ///< Reg 376. Valves states + U16 fpgaFan1Pulse; ///< Reg 378. Fan 1 pulse + U16 fpgaFan2Pulse; ///< Reg 380. Fan 2 pulse } DG_FPGA_SENSORS_T; typedef struct @@ -1496,4 +1498,28 @@ return fpgaSensorReadings.fpgaCPo; } +/*********************************************************************//** + * @brief + * The getFPGAFan1Pulse function gets fan 1 pulse value. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return fan 1 pulse value + *************************************************************************/ +U16 getFPGAFan1Pulse( void ) +{ + return fpgaSensorReadings.fpgaFan1Pulse; +} + +/*********************************************************************//** + * @brief + * The getFPGAFan2Pulse function gets fan 2 pulse value. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return fan 2 pulse value + *************************************************************************/ +U16 getFPGAFan2Pulse( void ) +{ + return fpgaSensorReadings.fpgaFan2Pulse; +} + /**@}*/ Index: firmware/App/Services/FPGA.h =================================================================== diff -u -r54f45c387430e440ab4607451fc84dea61f273f1 -r2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision 54f45c387430e440ab4607451fc84dea61f273f1) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision 2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b) @@ -100,6 +100,9 @@ void getFPGAAccelMaxes( S16 *xm, S16*ym, S16*zm ); void getFPGAAccelStatus( U16 *cnt, U16 *accelFPGAFaultReg ); +U16 getFPGAFan1Pulse( void ); +U16 getFPGAFan2Pulse( void ); + /**@}*/ #endif Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r04db56ac0f515f35b7f236d607bfb6f7585f55fb -r2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 04db56ac0f515f35b7f236d607bfb6f7585f55fb) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b) @@ -736,10 +736,9 @@ /*********************************************************************//** * @brief - * The broadcastUVReactorsData function sends out UV reactors data. - * @details - * Inputs : none - * Outputs : UV reactors data msg constructed and queued + * The broadcastUVReactorsData function sends out the UV reactors data. + * @details Inputs: none + * @details Outputs: UV reactors data msg constructed and queued * @param UV reactors msg constructed and queued * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -764,10 +763,10 @@ /*********************************************************************//** * @brief - * The broadcastThermistorsData function sends out thermistors data. + * The broadcastThermistorsData function sends out the thermistors data. * @details - * Inputs : none - * Outputs : thermistors data msg constructed and queued + * @details Inputs: none + * @details Outputs: thermistors data msg constructed and queued * @param UV reactors msg constructed and queued * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -789,6 +788,33 @@ return result; } + +/*********************************************************************//** + * @brief + * The broadcastFansData function sends out the fans data. + * @details Inputs: none + * @details Outputs: fans data msg constructed and queued + * @param fans msg constructed and queued + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastFansData( FANS_DATA_T *fansData ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_FANS_DATA; + msg.hdr.payloadLen = sizeof( FANS_DATA_T ); + + memcpy( payloadPtr, fansData, sizeof( FANS_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 ); + + return result; +} // *********************************************************************** // **************** Message Handling Helper Functions ******************** Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r04db56ac0f515f35b7f236d607bfb6f7585f55fb -r2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 04db56ac0f515f35b7f236d607bfb6f7585f55fb) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b) @@ -22,7 +22,8 @@ #include "MsgQueues.h" #include "ROPump.h" #include "UVReactors.h" -#include "Thermistors.h" +#include "Thermistors.h" +#include "Fans.h" /** * @defgroup SystemCommMessages SystemCommMessages @@ -123,9 +124,12 @@ // MSG_ID_DG_UV_REACTORS_DATA BOOL broadcastUVReactorsData( UV_REACTORS_DATA_T *uvReactorsData ); -//MSG_ID_DG_THERMISTORS_DATA -BOOL broadcastThermistorsData( THERMISTORS_DATA_T *thermistorsData ); +// MSG_ID_DG_THERMISTORS_DATA +BOOL broadcastThermistorsData( THERMISTORS_DATA_T *thermistorsData ); +// MSG_ID_DG_FANS_DATA +BOOL broadcastFansData( FANS_DATA_T * fansData ); + // *********** public test support message functions ********** #ifdef DEBUG_ENABLED Index: firmware/source/sys_main.c =================================================================== diff -u -raa36ab1ed13d099286cedcbd066f7dce11146d13 -r2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b --- firmware/source/sys_main.c (.../sys_main.c) (revision aa36ab1ed13d099286cedcbd066f7dce11146d13) +++ firmware/source/sys_main.c (.../sys_main.c) (revision 2f2d0ccadd8a09037eb3d0dd144549b2c8c8129b) @@ -68,6 +68,7 @@ #include "ConductivitySensors.h" #include "CPLD.h" #include "DrainPump.h" +#include "Fans.h" #include "FPGA.h" #include "Heaters.h" #include "InternalADC.h" @@ -83,7 +84,9 @@ #include "SystemComm.h" #include "TaskBG.h" #include "TemperatureSensors.h" +#include "Thermistors.h" #include "Timers.h" +#include "UVReactors.h" #include "Valves.h" #include "WatchdogMgmt.h" @@ -185,6 +188,9 @@ initSystemComm(); initReservoirs(); initOperationModes(); + initUVReactors(); + initFans(); + initThermistors(); } /*************************************************************************