Index: firmware/App/Controllers/DrainPump.c =================================================================== diff -u -r1d235091e158221f1fa8b1579140905a13249a54 -rdaf8d5b60c753becab80cbaf164aac0e49d533a2 --- firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision 1d235091e158221f1fa8b1579140905a13249a54) +++ firmware/App/Controllers/DrainPump.c (.../DrainPump.c) (revision daf8d5b60c753becab80cbaf164aac0e49d533a2) @@ -84,19 +84,20 @@ static U32 drainPumpDataPublicationTimerCounter = 0; ///< used to schedule drain pump data publication to CAN bus static U32 drainPumpDAC = 0; ///< initial drain pump DAC value static U32 drainPumpDACSet = 0; ///< currently set drain pump DAC value -static PUMP_CONTROL_MODE_T drainPumpControlMode = NUM_OF_PUMP_CONTROL_MODES; ///< requested drain pump control mode +static PUMP_CONTROL_MODE_T drainPumpControlMode = NUM_OF_PUMP_CONTROL_MODES; ///< requested drain pump control mode +static PUMP_CONTROL_MODE_T drainPumpControlModeSet = PUMP_CONTROL_MODE_CLOSED_LOOP; ///< currently set drain pump control mode static OVERRIDE_U32_T drainPumpDataPublishInterval = { DRAIN_PUMP_DATA_PUB_INTERVAL, DRAIN_PUMP_DATA_PUB_INTERVAL, 0, 0 }; ///< interval (in ms) at which to publish RO flow data to CAN bus static OVERRIDE_U32_T targetDrainPumpSpeed = { 0, 0, 0, 0 }; ///< Target RO pressure (in PSI) -static OVERRIDE_U32_T targetDrainPumpDeltaPressure = { 0, 0, 0, 0 }; ///< Target delta pressure for the drain pump +static OVERRIDE_F32_T targetDrainPumpDeltaPressure = { 0.0, 0.0, 0.0, 0.0 }; ///< Target delta pressure for the drain pump static U32 drainControlTimerCounter = 0; ///< determines when to perform control on drain pump /* These variables are used for POST. POST will be implemented later static DRAIN_PUMP_SELF_TEST_STATE_T drainPumpSelfTestState = DRAIN_PUMP_SELF_TEST_STATE_START; ///< current drain pump self test state -static U32 drainPumpSelfTestTimerCount = 0; ///< timer counter for drain pump self test +static U32 drainPumpSelfTestTimerCount = 0; ///< timer counter for drain pump self test */ // ********** private function prototypes ********** @@ -131,10 +132,10 @@ * The setDrainPumpTargetSpeed function sets a new target speed for the \n * drain pump. * @details - * Inputs : none - * Outputs : targetDrainPumpPressure - * @param rpm : new target drain pump speed (in RPM). - * @return TRUE if new target speed is set, FALSE if not + * Inputs: none + * Outputs: targetDrainPumpPressure + * @param: rpm : new target drain pump speed (in RPM). + * @return: TRUE if new target speed is set, FALSE if not *************************************************************************/ BOOL setDrainPumpTargetSpeed( U32 rpm ) { @@ -157,12 +158,12 @@ * The setDrainPumpTargetDeltaPressure function sets the target delta\n * pressure in between the PRd and PDr sensors * @details - * Inputs : targetDrainPumpDeltaP - * Outputs : targetDrainPumpDeltaP - * @param deltaP : new target drain pump delta pressure - * @return TRUE if new target speed is set, FALSE if not + * Inputs: targetDrainPumpDeltaP + * Outputs: targetDrainPumpDeltaP + * @param: deltaP : new target drain pump delta pressure + * @return: TRUE if new target speed is set, FALSE if not *************************************************************************/ -BOOL setDrainPumpTargetDeltaPressure ( U32 deltaP ) +BOOL setDrainPumpTargetDeltaPressure ( F32 deltaP ) { BOOL result = FALSE; @@ -177,9 +178,9 @@ * @brief * The signalDrainPumpHardStop function stops the Drain pump immediately. * @details - * Inputs : none - * Outputs : Drain pump stopped, set point reset, state changed to off - * @return none + * Inputs: none + * Outputs: Drain pump stopped, set point reset, state changed to off + * @return: none *************************************************************************/ void signalDrainPumpHardStop( void ) { @@ -194,9 +195,9 @@ * @brief * The execDrainPumpMonitor function executes the Drain Pump monitor. * @details - * Inputs : none - * Outputs : none - * @return none + * Inputs: none + * Outputs: none + * @return: none *************************************************************************/ void execDrainPumpMonitor( void ) { @@ -214,9 +215,9 @@ * @brief * The execDrainPumpController function executes the Drain Pump controller. * @details - * Inputs : drainPumpState - * Outputs : drainPumpState - * @return none + * Inputs: drainPumpState + * Outputs: drainPumpState + * @return: none *************************************************************************/ void execDrainPumpController( void ) { @@ -246,9 +247,9 @@ * The handleDrainPumpOffState function handles the drain pump off state \n * of the drain pump controller state machine. * @details - * Inputs : targetDrainPumpSpeed - * Outputs : drainPumpPWMDutyCyclePctSet - * @return next state + * Inputs: targetDrainPumpSpeed + * Outputs: drainPumpPWMDutyCyclePctSet + * @return: next state *************************************************************************/ static DRAIN_PUMP_STATE_T handleDrainPumpOffState( void ) { @@ -262,15 +263,14 @@ setValveState( VPI, VALVE_STATE_OPEN ); setValveState( VRC, VALVE_STATE_DRAIN_C_TO_NO ); setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); - //setDrainPumpTargetSpeed( 1000 ); + setDrainPumpTargetSpeed( 1000 ); } #endif #endif // If the target drain pump speed was not 0 and the control mode // is open loop, set the drain pump to open loop - if ( getTargetDrainPumpSpeed() > 0 && - drainPumpControlMode == PUMP_CONTROL_MODE_OPEN_LOOP ) + if ( getTargetDrainPumpSpeed() > 0 && drainPumpControlMode == PUMP_CONTROL_MODE_OPEN_LOOP ) { // set drain pump enable pin SET_DRAIN_PUMP_ENABLE(); @@ -308,9 +308,9 @@ * The handleDrainPumpControlToTargetState function handles the "control to \n * target" state of the drain pump controller state machine. * @details - * Inputs : none - * Outputs : drainPumpState - * @return next state + * Inputs: none + * Outputs: drainPumpState + * @return: next state *************************************************************************/ static DRAIN_PUMP_STATE_T handleDrainPumpControlToTargetState( void ) { @@ -321,10 +321,10 @@ { F32 inletDrainPressure = getMeasuredDGPressure ( PRESSURE_SENSOR_DRAIN_PUMP_INLET ); F32 outletDrainPressure = getMeasuredDGPressure ( PRESSURE_SENSOR_DRAIN_PUMP_OUTLET ); - F32 pressureDiff = fabs( inletDrainPressure - outletDrainPressure ); + F32 pressureDiff = inletDrainPressure - outletDrainPressure; F32 rpm = runPIController( PI_CONTROLLER_ID_DRAIN_PUMP, targetDrainPumpDeltaPressure.data, pressureDiff ); - drainPumpDAC = (U32)(rpm * DRP_SPEED_RPM_TO_ADC_FACTOR + FLOAT_TO_INT_ROUNDUP_OFFSET); - setFPGADrainPumpSpeed( drainPumpDAC ); + drainPumpDACSet = (U32)(rpm * DRP_SPEED_RPM_TO_ADC_FACTOR + FLOAT_TO_INT_ROUNDUP_OFFSET); + setFPGADrainPumpSpeed( drainPumpDACSet ); drainControlTimerCounter = 0; } @@ -357,9 +357,9 @@ * The handleDrainPumpOpenLoopState function handles the open loop \n * state * @details - * Inputs : none - * Outputs : none - * @return next state + * Inputs: none + * Outputs: none + * @return: next state *************************************************************************/ static DRAIN_PUMP_STATE_T handleDrainPumpOpenLoopState( void ) { @@ -370,9 +370,9 @@ * @brief * The stopDrainPump function sets the Drain pump DAC to zero. * @details - * Inputs : none - * Outputs : DAC zeroed - * @return none + * Inputs: none + * Outputs: DAC zeroed + * @return: none *************************************************************************/ static void stopDrainPump( void ) { @@ -387,9 +387,9 @@ * The getPublishDrainPumpDataInterval function gets the Drain pump data \n * publication interval. * @details - * Inputs : drainPumpDataPublishInterval - * Outputs : none - * @return the current Drain pump data publication interval (in ms). + * Inputs: drainPumpDataPublishInterval + * Outputs: none + * @return: the current Drain pump data publication interval (in ms). *************************************************************************/ U32 getPublishDrainPumpDataInterval( void ) { @@ -408,9 +408,9 @@ * The getTargetDrainPumpSpeed function gets the current target Drain pump \n * speed. * @details - * Inputs : targetDrainPumpSpeed + * Inputs: targetDrainPumpSpeed * Outputs : none - * @return the current target drain pump speed. + * @return: the current target drain pump speed. *************************************************************************/ U32 getTargetDrainPumpSpeed( void ) { @@ -429,9 +429,9 @@ * The publishDrainPumpData function publishes drain pump data at the set \n * interval. * @details - * Inputs : target speed - * Outputs : Drain pump data is published to CAN bus. - * @return none + * Inputs: target speed + * Outputs: Drain pump data is published to CAN bus. + * @return: none *************************************************************************/ static void publishDrainPumpData( void ) { @@ -453,9 +453,9 @@ * The execDrainPumpTest function executes the state machine for the Drain \n * Pump self test. * @details - * Inputs : none - * Outputs : none - * @return the current state of the Drain Pump self test. + * Inputs: none + * Outputs: none + * @return: the current state of the Drain Pump self test. *************************************************************************/ SELF_TEST_STATUS_T execDrainPumpTest( void ) { @@ -478,10 +478,10 @@ * The testSetDrainPumpDataPublishIntervalOverride function overrides the \n * drain pump data publish interval. * @details - * Inputs : none - * Outputs : drainPumpDataPublishInterval - * @param value : override RO pump data publish interval with (in ms) - * @return TRUE if override successful, FALSE if not + * Inputs: none + * Outputs: drainPumpDataPublishInterval + * @param: value : override RO pump data publish interval with (in ms) + * @return: TRUE if override successful, FALSE if not *************************************************************************/ BOOL testSetDrainPumpDataPublishIntervalOverride( U32 value ) { @@ -504,9 +504,9 @@ * The testResetDrainPumpDataPublishIntervalOverride function resets the override \n * of the drain pump data publish interval. * @details - * Inputs : none - * Outputs : drainPumpDataPublishInterval - * @return TRUE if override reset successful, FALSE if not + * Inputs: none + * Outputs: drainPumpDataPublishInterval + * @return: TRUE if override reset successful, FALSE if not *************************************************************************/ BOOL testResetDrainPumpDataPublishIntervalOverride( void ) { @@ -527,10 +527,10 @@ * The testSetTargetDrainPumpSpeedOverride function overrides the target \n * drain pump speed (in RPM). * @details - * Inputs : none - * Outputs : targetDrainPumpSpeed - * @param value : override target drain pump speed (in RPM) - * @return TRUE if override successful, FALSE if not + * Inputs: none + * Outputs: targetDrainPumpSpeed + * @param: value : override target drain pump speed (in RPM) + * @return: TRUE if override successful, FALSE if not *************************************************************************/ BOOL testSetTargetDrainPumpSpeedOverride( U32 value ) { @@ -552,9 +552,9 @@ * The testResetTargetDrainPumpSpeedOverride function resets the override of the \n * target drain pump speed (in RPM). * @details - * Inputs : none - * Outputs : targetDrainPumpSpeed - * @return TRUE if override reset successful, FALSE if not + * Inputs: none + * Outputs: targetDrainPumpSpeed + * @return: TRUE if override reset successful, FALSE if not *************************************************************************/ BOOL testResetTargetDrainPumpSpeedOverride( void ) { @@ -577,12 +577,12 @@ * The testSetTargetDrainPumpDeltaPressureOverride function overrides \n * the target drain pump delta pressure * @details - * Inputs : none - * Outputs : targetDrainPumpDeltaPressure - * @param value : override target drain pump delta pressure - * @return TRUE if override successful, FALSE if not + * Inputs: none + * Outputs: targetDrainPumpDeltaPressure + * @param: value : override target drain pump delta pressure + * @return: TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetTargetDrainPumpDeltaPressureOverride( U32 value ) +BOOL testSetTargetDrainPumpDeltaPressureOverride( F32 value ) { BOOL result = FALSE; @@ -602,9 +602,9 @@ * The testResetTargetDrainPumpDeltaPressureOverride function resets the \n * override of the target drain pump delta pressure * @details - * Inputs : none - * Outputs : targetDrainPumpDeltaPressure - * @return TRUE if override reset successful, FALSE if not + * Inputs: none + * Outputs: targetDrainPumpDeltaPressure + * @return: TRUE if override reset successful, FALSE if not *************************************************************************/ BOOL testResetTargetDrainPumpDeltaPressureOverride( void ) { @@ -621,5 +621,3 @@ return result; } - - Index: firmware/App/Controllers/DrainPump.h =================================================================== diff -u -r1d235091e158221f1fa8b1579140905a13249a54 -rdaf8d5b60c753becab80cbaf164aac0e49d533a2 --- firmware/App/Controllers/DrainPump.h (.../DrainPump.h) (revision 1d235091e158221f1fa8b1579140905a13249a54) +++ firmware/App/Controllers/DrainPump.h (.../DrainPump.h) (revision daf8d5b60c753becab80cbaf164aac0e49d533a2) @@ -41,7 +41,7 @@ BOOL setDrainPumpTargetSpeed( U32 rpm ); -BOOL setDrainPumpTargetDeltaPressure ( U32 deltaP ); +BOOL setDrainPumpTargetDeltaPressure ( F32 deltaP ); void signalDrainPumpHardStop( void ); @@ -55,7 +55,7 @@ BOOL testSetTargetDrainPumpSpeedOverride( U32 value ); BOOL testResetTargetDrainPumpSpeedOverride( void ); -BOOL testSetTargetDrainPumpDeltaPressureOverride( U32 value ); +BOOL testSetTargetDrainPumpDeltaPressureOverride( F32 value ); BOOL testResetTargetDrainPumpDeltaPressureOverride( void ); /**@}*/ Index: firmware/App/Controllers/Fans.c =================================================================== diff -u -rc721aafa9f333b48a57f9e9239b25930a4da116d -rdaf8d5b60c753becab80cbaf164aac0e49d533a2 --- firmware/App/Controllers/Fans.c (.../Fans.c) (revision c721aafa9f333b48a57f9e9239b25930a4da116d) +++ firmware/App/Controllers/Fans.c (.../Fans.c) (revision daf8d5b60c753becab80cbaf164aac0e49d533a2) @@ -23,7 +23,7 @@ void execFans( void ) { - + // Possibly the PI controller for the board temperature } BOOL startFan1( F32 pwmPercent ) Index: firmware/App/Controllers/Fans.h =================================================================== diff -u -rc721aafa9f333b48a57f9e9239b25930a4da116d -rdaf8d5b60c753becab80cbaf164aac0e49d533a2 --- firmware/App/Controllers/Fans.h (.../Fans.h) (revision c721aafa9f333b48a57f9e9239b25930a4da116d) +++ firmware/App/Controllers/Fans.h (.../Fans.h) (revision daf8d5b60c753becab80cbaf164aac0e49d533a2) @@ -25,11 +25,16 @@ void execFans( void ); +// TODO override for fans1 and 2 with PWM +// TODO override baord temp + +// TODO remove BOOL startFan1( F32 pwmPercent ); BOOL startFan2( F32 pwmPercent ); void stopFan1( void ); void stopFan2( void ); +// TODO Remove #endif Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r518fb519933260477ba20118744399f94ac1a632 -rdaf8d5b60c753becab80cbaf164aac0e49d533a2 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 518fb519933260477ba20118744399f94ac1a632) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision daf8d5b60c753becab80cbaf164aac0e49d533a2) @@ -47,35 +47,35 @@ #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_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.01 ///< 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.01 ///< 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_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). +#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 / 1.2)) ///< Initial conversion factor from target flow rate to PWM duty cycle estimate /// Enumeration of RO pump states. typedef enum ROPump_States { RO_PUMP_OFF_STATE = 0, ///< RO pump off state RO_PUMP_RAMP_UP_STATE, ///< RO pump ramp up to target flow rate state - RO_PUMP_VERIFY_FLOW_STATE, ///< RO pump maintain the flow rate for a few seconds state + RO_PUMP_VERIFY_FLOW_STATE, ///< RO pump maintain the flow rate for a set period of time RO_PUMP_CONTROL_TO_TARGET_STATE, ///< RO pump control to target pressure state RO_PUMP_OPEN_LOOP_STATE, ///< RO pump open loop state NUM_OF_RO_PUMP_STATES ///< Number of RO pump states @@ -103,29 +103,30 @@ 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 //TODO remove +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_) +static OVERRIDE_F32_T targetROPumpFlowRate = { 0, 0, 0, 0 }; ///< Target RO flow rate (in LPM) static OVERRIDE_U32_T roPumpDataPublishInterval = { RO_PUMP_DATA_PUB_INTERVAL, RO_PUMP_DATA_PUB_INTERVAL, - 0, 0 }; ///< Interval (in ms) at which to publish RO flow data to CAN bus. -static OVERRIDE_F32_T measuredROFlowRateLPM = { 0.0, 0.0, 0.0, 0 }; ///< measured RO flow rate (in LPM). -static F32 measuredROPumpPressure = 0.0; ///< measured RO pressure (in PSI). // TODO remove + 0, 0 }; ///< Interval (in ms) at which to publish RO flow data to CAN bus +static OVERRIDE_F32_T measuredROFlowRateLPM = { 0.0, 0.0, 0.0, 0 }; ///< measured RO flow rate (in LPM) +static F32 measuredROPumpPressure = 0.0; ///< measured RO pressure (in PSI) // TODO remove static F32 tgtROPumpPressure = 0.0; ///< Target RO control pressure (in PSI) -static S32 measuredFlowReadingsSum = 0; ///< Raw flow reading sums for averaging. -static U32 flowFilterCounter = 0; ///< used to schedule flow filtering. +static S32 measuredFlowReadingsSum = 0; ///< Raw flow reading sums for averaging +static U32 flowFilterCounter = 0; ///< used to schedule flow filtering static U32 flowVerificationCounter = 0; ///< Counter to verify the flow is in range static U32 roControlTimerCounter = 0; ///< determines when to perform control on ro pump -static U32 roPumpOpenLooptargetPWM = 0; ///< Target RO pump open loop PWM +static U32 roPumpOpenLoopTargetPWM = 0; ///< Target RO pump open loop PWM static F32 roPumpFlowRateRunningSum = 0; static F32 roPumpPressureRunningSum = 0; /* The variables used for POST. They are not in use yet, so they are commented out static RO_PUMP_SELF_TEST_STATE_T roPumpSelfTestState = RO_PUMP_SELF_TEST_STATE_START; ///< current ro pump self test state -static U32 roPumpSelfTestTimerCount = 0; ///< timer counter for ro pump self test +static U32 roPumpSelfTestTimerCount = 0; ///< timer counter for ro pump self test */ // ********** private function prototypes ********** @@ -143,8 +144,8 @@ * @brief * The initROPump function initializes the ROPump module. * @details - * Inputs : none - * Outputs : ROPump module initialized. + * Inputs: none + * Outputs: ROPump module initialized. * @return none *************************************************************************/ void initROPump( void ) @@ -166,8 +167,8 @@ * @brief * The setROPumpTargetPWM function sets the PWM that the pump should run * @details - * Inputs : roPumpOpenLooptargetPWM, roPumpControlMode - * Outputs : roPumpOpenLooptargetPWM, roPumpControlMode + * Inputs: roPumpOpenLooptargetPWM, roPumpControlMode + * Outputs: roPumpOpenLooptargetPWM, roPumpControlMode * @param: pwm * @return whether the value was set (TRUE) or not (FALSE) *************************************************************************/ @@ -177,7 +178,8 @@ if ( pwm > 0 ) { - roPumpOpenLooptargetPWM = pwm; + roPumpOpenLoopTargetPWM = pwm; + roPumpPWMDutyCyclePct = ROP_FLOW_TO_PWM_DC( getTargetROPumpFlowRate() ); roPumpControlMode = PUMP_CONTROL_MODE_OPEN_LOOP; result = TRUE; } @@ -189,9 +191,9 @@ * The setROPumpTargetFlowRate function sets a new target flow rate for the \n * RO pump. * @details - * Inputs : none - * Outputs : targetROPumpFlowRate, roPumpPWMDutyCyclePct - * @param roFlowRate : new target RO flow rate + * Inputs: none + * Outputs: targetROPumpFlowRate, roPumpPWMDutyCyclePct + * @param: roFlowRate : new target RO flow rate * @return TRUE if new target flow rate is set, FALSE if not *************************************************************************/ BOOL setROPumpTargetFlowRate( F32 roFlowRate ) @@ -202,7 +204,7 @@ { targetROPumpFlowRate.data = roFlowRate; roPumpControlMode = PUMP_CONTROL_MODE_CLOSED_LOOP; - roPumpPWMDutyCyclePct = roFlowRate; + roPumpPWMDutyCyclePct = ROP_FLOW_TO_PWM_DC( roFlowRate ); #ifdef EMC_TEST_BUILD roPumpPWMDutyCyclePct = 1.0; #else @@ -221,8 +223,8 @@ * @brief * The signalROPumpHardStop function stops the RO pump immediately. * @details - * Inputs : none - * Outputs : RO pump stopped, set point reset, state changed to off + * Inputs: none + * Outputs: RO pump stopped, set point reset, state changed to off * @return none *************************************************************************/ void signalROPumpHardStop( void ) @@ -241,8 +243,8 @@ * @brief * The execROPumpMonitor function executes the RO Pump monitor. * @details - * Inputs : none - * Outputs : measuredROPumpPressure, measuredROFlowRateLPM + * Inputs: none + * Outputs: measuredROPumpPressure, measuredROFlowRateLPM * @return none *************************************************************************/ void execROPumpMonitor( void ) @@ -283,8 +285,8 @@ * @brief * The execROPumpController function executes the RO Pump controller. * @details - * Inputs : roPumpState - * Outputs : roPumpState + * Inputs: roPumpState + * Outputs: roPumpState * @return none *************************************************************************/ void execROPumpController( void ) @@ -322,9 +324,9 @@ * @brief * The isROPumpOn function returns the status of RO pump * @details - * Inputs : none - * Outputs : none - * @param none + * Inputs: none + * Outputs: none + * @param: none * @return isROPumpOn *************************************************************************/ BOOL isReverseOsmosisPumpOn( void ) @@ -337,8 +339,8 @@ * The handleROPumpOffState function handles the ro pump off state \n * of the ro pump controller state machine. * @details - * Inputs : roPumpPWMDutyCyclePctSet, isROPumpOn - * Outputs : roPumpPWMDutyCyclePctSet, isROPumpOn + * Inputs: roPumpPWMDutyCyclePctSet, isROPumpOn + * Outputs: roPumpPWMDutyCyclePctSet, isROPumpOn * @return next state *************************************************************************/ static RO_PUMP_STATE_T handleROPumpOffState( void ) @@ -371,11 +373,11 @@ // 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 ) + if ( getTargetROPumpFlowRate() > 0 && roPumpControlMode == PUMP_CONTROL_MODE_CLOSED_LOOP ) { - // set initial PWM duty cycle - roPumpPWMDutyCyclePctSet = ROP_FLOW_TO_PWM_DC( getTargetROPumpFlowRate() ); + roPumpControlModeSet = roPumpControlMode; + // set initial PWM duty cycle + roPumpPWMDutyCyclePctSet = roPumpPWMDutyCyclePct; setROPumpControlSignalPWM ( roPumpPWMDutyCyclePctSet ); // reset controller resetPIController ( I_CONTROLLER_ID_RO_PUMP_RAMP_UP, roPumpPWMDutyCyclePctSet ); @@ -384,10 +386,9 @@ result = RO_PUMP_RAMP_UP_STATE; } - if ( roPumpOpenLooptargetPWM > 0 && - roPumpControlMode == PUMP_CONTROL_MODE_OPEN_LOOP ) + if ( roPumpOpenLoopTargetPWM > 0 && roPumpControlMode == PUMP_CONTROL_MODE_OPEN_LOOP ) { - setROPumpControlSignalPWM ( roPumpOpenLooptargetPWM ); + setROPumpControlSignalPWM ( roPumpOpenLoopTargetPWM ); isROPumpOn = TRUE; result = RO_PUMP_OPEN_LOOP_STATE; } @@ -400,8 +401,8 @@ * 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 + * Inputs: roControlTimerCounter, roPumpPWMDutyCyclePctSet + * Outputs: roControlTimerCounter, roPumpPWMDutyCyclePctSet * @return next state *************************************************************************/ static RO_PUMP_STATE_T handleROPumpRampUpState( void ) @@ -411,11 +412,7 @@ // control at set interval if ( ++roControlTimerCounter >= ROP_CONTROL_INTERVAL ) { - F32 targetFlowRate = targetROPumpFlowRate.data; - if ( targetROPumpFlowRate.override == OVERRIDE_KEY ) - { - targetFlowRate = targetROPumpFlowRate.ovData; - } + F32 targetFlowRate = getTargetROPumpFlowRate(); F32 actualFlowRate = (F32)getMeasuredROFlowRate(); @@ -441,9 +438,9 @@ * The handleROPumpVerifyFlowState function handles the RO pump verify \n * flow state of the RO pump controller state machine. * @details - * Inputs : flowVerificationCounter, roPumpPWMDutyCyclePctSet, \n + * Inputs: flowVerificationCounter, roPumpPWMDutyCyclePctSet, \n * tgtROPumpPressure, roPumpFlowRateRunningSum, roPumpPressureRunningSum - * Outputs : flowVerificationCounter, roPumpPWMDutyCyclePctSet, \n + * Outputs: flowVerificationCounter, roPumpPWMDutyCyclePctSet, \n * tgtROPumpPressure, roPumpFlowRateRunningSum, roPumpPressureRunningSum * @return next state *************************************************************************/ @@ -462,11 +459,8 @@ F32 avgPressure = roPumpPressureRunningSum / flowVerificationCounter; F32 avgFlowRate = roPumpFlowRateRunningSum / flowVerificationCounter; - F32 targetFlowRate = targetROPumpFlowRate.data; - if ( targetROPumpFlowRate.override == OVERRIDE_KEY ) - { - targetFlowRate = targetROPumpFlowRate.ovData; - } + F32 targetFlowRate = getTargetROPumpFlowRate(); + // Calculate the flow rate deviation from the target flow rate F32 flowRateDeviation = ( targetFlowRate - avgFlowRate ) / targetFlowRate; // Use the flow rate deviation to adjust the average calculated pressure. This @@ -496,8 +490,8 @@ * The handleROPumpControlToTargetState function handles the "control to \n * target" state of the ro pump controller state machine. * @details - * Inputs : roPumpPWMDutyCyclePctSet, roControlTimerCounter - * Outputs : roPumpPWMDutyCyclePctSet, roControlTimerCounter + * Inputs: roPumpPWMDutyCyclePctSet, roControlTimerCounter + * Outputs: roPumpPWMDutyCyclePctSet, roControlTimerCounter * @return next state *************************************************************************/ static RO_PUMP_STATE_T handleROPumpControlToTargetState( void ) @@ -546,8 +540,8 @@ * The handleROPumpOpenLoopState function handles the open loop state \n * of the RO pump controller * @details - * Inputs : roPumpPWMDutyCyclePctSet, roControlTimerCounter - * Outputs : roPumpPWMDutyCyclePctSet, roControlTimerCounter + * Inputs: roPumpPWMDutyCyclePctSet, roControlTimerCounter + * Outputs: roPumpPWMDutyCyclePctSet, roControlTimerCounter * @return next state *************************************************************************/ static RO_PUMP_STATE_T handleROPumpOpenLoopState( void ) @@ -560,9 +554,9 @@ * The setROPumpControlSignalPWM function sets the PWM duty cycle for \n * the RO pump to a given %. * @details - * Inputs : none - * Outputs : PWM duty cycle zeroed - * @param newPWM : new duty cycle % to apply to PWM + * Inputs: none + * Outputs: PWM duty cycle zeroed + * @param: newPWM : new duty cycle % to apply to PWM * @return none *************************************************************************/ static void setROPumpControlSignalPWM( F32 newPWM ) @@ -574,8 +568,8 @@ * @brief * The stopROPump function sets the RO pump PWM to zero. * @details - * Inputs : none - * Outputs : PWM duty cycle zeroed + * Inputs: none + * Outputs: PWM duty cycle zeroed * @return none *************************************************************************/ static void stopROPump( void ) @@ -590,8 +584,8 @@ * The getPublishROPumpDataInterval function gets the RO pump data \n * publication interval. * @details - * Inputs : roPumpDataPublishInterval - * Outputs : none + * Inputs: roPumpDataPublishInterval + * Outputs: none * @return the current RO pump data publication interval (in ms). *************************************************************************/ U32 getPublishROPumpDataInterval( void ) @@ -611,8 +605,8 @@ * The getTargetROPumpFlowRate function gets the current target RO pump \n * flow rate * @details - * Inputs : targetROPumpFlowRate - * Outputs : targetROPumpFlowRate + * Inputs: targetROPumpFlowRate + * Outputs: targetROPumpFlowRate * @return the current target RO flow rate (in LPM). *************************************************************************/ F32 getTargetROPumpFlowRate( void ) @@ -632,8 +626,8 @@ * The getMeasuredROFlowRate function gets the measured RO pump \n * flow rate. * @details - * Inputs : measuredROFlowRateLPM - * Outputs : none + * Inputs: measuredROFlowRateLPM + * Outputs: none * @return the current RO pump flow rate (in LPM). *************************************************************************/ F32 getMeasuredROFlowRate( void ) @@ -653,8 +647,8 @@ * The publishROPumpData function publishes RO pump data at the set \n * interval. * @details - * Inputs : target pressure, measured pressure, measured RO pump speed. - * Outputs : RO pump data is published to CAN bus. + * Inputs: target pressure, measured pressure, measured RO pump speed. + * Outputs: RO pump data is published to CAN bus. * @return none *************************************************************************/ static void publishROPumpData( void ) @@ -673,8 +667,8 @@ * @brief * The execROPumpTest function executes the state machine for the ROPump self test. * @details - * Inputs : none - * Outputs : none + * Inputs: none + * Outputs: none * @return the current state of the ROPump self test. *************************************************************************/ SELF_TEST_STATUS_T execROPumpTest( void ) @@ -699,9 +693,9 @@ * The testSetROPumpDataPublishIntervalOverride function overrides the \n * RO pump data publish interval. * @details - * Inputs : none - * Outputs : roPumpDataPublishInterval - * @param value : override RO pump data publish interval with (in ms) + * Inputs: none + * Outputs: roPumpDataPublishInterval + * @param: value : override RO pump data publish interval with (in ms) * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testSetROPumpDataPublishIntervalOverride( U32 value ) @@ -725,8 +719,8 @@ * The testResetROPumpDataPublishIntervalOverride function resets the override \n * of the RO pump data publish interval. * @details - * Inputs : none - * Outputs : roPumpDataPublishInterval + * Inputs: none + * Outputs: roPumpDataPublishInterval * @return TRUE if override reset successful, FALSE if not *************************************************************************/ BOOL testResetROPumpDataPublishIntervalOverride( void ) @@ -748,9 +742,9 @@ * The testSetTargetROPumpFlowRateOverride function overrides the target \n * RO flow rate. \n * @details - * Inputs : targetROPumpFlowRate - * Outputs : targetROPumpPressure - * @param value : override target RO flow rate (in LPM) + * Inputs: targetROPumpFlowRate + * Outputs: targetROPumpPressure + * @param: value : override target RO flow rate (in LPM) * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testSetTargetROPumpFlowRateOverride( F32 value ) @@ -773,9 +767,9 @@ * The testResetTargetROPumpFlowRateOverride function resets the override of the \n * target RO flow rate. * @details - * Inputs : targetROPumpFlowRate - * Outputs : targetROPumpFlowRate - * @param none + * Inputs: targetROPumpFlowRate + * Outputs: targetROPumpFlowRate + * @param: none * @return TRUE if override reset successful, FALSE if not *************************************************************************/ BOOL testResetTargetROPumpFlowRateOverride( void ) @@ -799,9 +793,9 @@ * The testSetMeasuredROFlowRateOverride function overrides the measured \n * RO flow rate. * @details - * Inputs : none - * Outputs : measuredROFlowRateLPM - * @param value : override measured RO pump motor speed (in LPM) + * Inputs: none + * Outputs: measuredROFlowRateLPM + * @param: value : override measured RO pump motor speed (in LPM) * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testSetMeasuredROFlowRateOverride( F32 value ) @@ -823,9 +817,9 @@ * The testResetMeasuredROFlowRateOverride function resets the override of the \n * measured RO flow rate. * @details - * Inputs : none - * Outputs : measuredROFlowRateLPM - * @param none + * Inputs: none + * Outputs: measuredROFlowRateLPM + * @param: none * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testResetMeasuredROFlowRateOverride( void ) Index: firmware/App/Modes/ModeHeatDisinfect.c =================================================================== diff -u -r74d78e2ac10592448dd5c7b83fccebdc6c65556b -rdaf8d5b60c753becab80cbaf164aac0e49d533a2 --- firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 74d78e2ac10592448dd5c7b83fccebdc6c65556b) +++ firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision daf8d5b60c753becab80cbaf164aac0e49d533a2) @@ -40,10 +40,10 @@ // ********** private definitions ********** #define HEAT_DISINFECT_TIME_INTERVAL_DAYS 2U ///< Heat disinfect time interval in days //TODO change the interval to actual value (was it every 21 days?) -#define HEAT_DISINFECT_TIME_INTERVAL_SECONDS ( HEAT_DISINFECT_TIME_INTERVAL_DAYS * 86400 ) ///< Heat disinfect time interval in seconds +#define HEAT_DISINFECT_TIME_INTERVAL_SECONDS ( HEAT_DISINFECT_TIME_INTERVAL_DAYS * SECONDS_IN_A_DAY ) ///< Heat disinfect time interval in seconds #define HEAT_DISINFECT_TARGET_TEMPERATURE 30U ///< Heat disinfection target temperature //TODO change the target temperature back to 85C -#define MAX_TPO_AND_TDI_SENSORS_DIFFERENCE 1U ///< Maximum allowed temperature difference in between TPi and TPo +#define MAX_TPO_AND_TDI_SENSORS_DIFFERENCE 1U ///< Maximum allowed temperature difference in between TDi and TPo //TODO remove #define MAX_TEMPERATURE_DEVIATION_FROM_TARGET 4U ///< Maximum allowed temperature deviation from target temperature #define HEAT_DISINFECT_RECIRC_PATH_TIME_MINS 1U ///< Recirculation path heat disinfection duration in minutes @@ -84,10 +84,10 @@ static INTERNAL_HEAT_DISINFECT_STATE_T heatDisinfectInternalState = INTERNAL_HEAT_DISINFECT_STATE_OFF; ///< Currently active internal heat disinfect state static DG_HEAT_DISINFECT_STATE_T heatDisinfectState = DG_HEAT_DISINFECT_STATE_START; ///< Currently active heat disinfect state -static U32 heatDisinfectElapsedTime = 0; ///< Overall heat disinfection elapsed time +static U32 heatDisinfectStartTime = 0; ///< Overall heat disinfection elapsed time static U32 stateTimer = 0; ///< Timer of an individual state static U32 drainPumpTargetRPM = 0; ///< Drain pump current target RPM -static U32 heatDisinfectCurrentCycle = 0; ///< Current cycle count of the heat disinfect mode +static U32 heatDisinfectCurrentCycle = 1; ///< Current cycle count of the heat disinfect mode static U32 heatDisinfectPublishCounter = 0; ///< Current publication counter of heat disinfect mode static OVERRIDE_F32_T heatDisinfectRecircDuration = { HEAT_DISINFECT_RECIRC_PATH_TIME_MS, @@ -122,8 +122,8 @@ static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectEvacuateDialysateFillWithWater( void ); static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectHeatWater( void ); static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectRecirculationPath( void ); -static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectReservoir1To2( void ); -static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectReservoir2To1( void ); +static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectR1ToR2( void ); +static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectR2ToR1( void ); static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectDrainPath( void ); static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectFillWithWaterDeprimeReservoirs( void ); @@ -137,23 +137,23 @@ static DATA_GET_PROTOTYPE( U32, getPublishHeatDisinfectDataInterval ); static DATA_GET_PROTOTYPE( F32, getRecirculationDuration ); -static DATA_GET_PROTOTYPE( F32, getRSVR1ToRSVR2Duration ); -static DATA_GET_PROTOTYPE( F32, getRSVR2ToRSVR1Duration ); +static DATA_GET_PROTOTYPE( F32, getR1ToR2Duration ); +static DATA_GET_PROTOTYPE( F32, getR2ToR1Duration ); static DATA_GET_PROTOTYPE( U32, getNoOfCyclesToRun ); /*********************************************************************//** * @brief * The initHeatDisinfectMode function initializes the heat disinfect Mode module. * @details - * Inputs : none - * Outputs : none + * Inputs: none + * Outputs: none * @return none *************************************************************************/ void initHeatDisinfectMode( void ) { - heatDisinfectElapsedTime = 0; + heatDisinfectStartTime = 0; drainPumpTargetRPM = 0; - heatDisinfectCurrentCycle = 0; + heatDisinfectCurrentCycle = 1; heatDisinfectState = DG_HEAT_DISINFECT_STATE_START; } @@ -162,8 +162,8 @@ * The transitionToHeatDisinfectMode function prepares for transition * to heat disinfect mode. * @details - * Inputs : none - * Outputs : none + * Inputs: none + * Outputs: none * @return none *************************************************************************/ void transitionToHeatDisinfectMode( void ) @@ -177,8 +177,8 @@ * The execHeatDisinfectMode function executes the heat disinfect Mode * state machine. * @details - * Inputs : none - * Outputs : none + * Inputs: none + * Outputs: none * @return current state. *************************************************************************/ U32 execHeatDisinfectMode( void ) @@ -202,11 +202,11 @@ break; case DG_HEAT_DISINFECT_STATE_DISINFECT_RESERVOIR_1_TO_2: - heatDisinfectState = handleHeatDisinfectReservoir1To2(); + heatDisinfectState = handleHeatDisinfectR1ToR2(); break; case DG_HEAT_DISINFECT_STATE_DISINFECT_RESERVOIR_2_TO_1: - heatDisinfectState = handleHeatDisinfectReservoir2To1(); + heatDisinfectState = handleHeatDisinfectR2ToR1(); break; case DG_HEAT_DISINFECT_STATE_DISINFECT_DRAIN_PATH: @@ -237,8 +237,8 @@ * The getCurrentHeatDisinfectState function returns the current state of the \n * heat disinfect mode. * @details - * Inputs : heatState - * Outputs : none + * Inputs: heatState + * Outputs: none * @return the current state of heat disinfect mode. *************************************************************************/ DG_HEAT_DISINFECT_STATE_T getCurrentHeatDisinfectState( void ) @@ -250,30 +250,28 @@ * @brief * The startDGHeatDisinfect function starts heat disinfect mode. * @details - * Inputs : none - * Outputs : none - * @return state of run + * Inputs: none + * Outputs: none + * @return: TRUE if the switch was successful *************************************************************************/ BOOL startDGHeatDisinfect( void ) { // TODO: make sure DG is not in the middle of something and it is in standby - initHeatDisinfectMode(); requestNewOperationMode( DG_MODE_HEAT ); - return TRUE; // For now. Check whether it is the right request before switching + return TRUE; // TODO Check whether it is the right request before switching } /*********************************************************************//** * @brief * The stopDGHeatDisinfect function stops heat disinfect mode. * @details - * Inputs : heatDisinfectionState - * Outputs : heatDisinfectionState + * Inputs: heatDisinfectionState + * Outputs: heatDisinfectionState * @return none *************************************************************************/ void stopDGHeatDisinfect( void ) { - //heatDisinfectionState = DG_HEAT_DISINFECT_STATE_COMPLETE; stopActuators(); requestNewOperationMode( DG_MODE_STAN ); } @@ -284,10 +282,10 @@ * @brief * The handleHeatDisinfectStart function handles heat disinfect start state * @details - * Inputs : drainPumpTargetRPM, heatDisinfectInternalState, - * heatDisinfectElapsedTime - * Outputs : drainPumpTargetRPM, heatDisinfectInternalState, - * heatDisinfectElapsedTime + * Inputs: drainPumpTargetRPM, heatDisinfectInternalState, + * heatDisinfectStartTime + * Outputs: drainPumpTargetRPM, heatDisinfectInternalState, + * heatDisinfectStartTime * @return next state *************************************************************************/ static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectStart( void ) @@ -298,7 +296,7 @@ drainPumpTargetRPM = DRAIN_PUMP_EVACUATE_FLUID_TARGET_RPM; heatDisinfectInternalState = INTERNAL_HEAT_DISINFECT_STATE_OFF; - heatDisinfectElapsedTime = getMSTimerCount(); + heatDisinfectStartTime = getMSTimerCount(); return state; } @@ -308,8 +306,8 @@ * The handleHeatDisinfectEvacuateDialysateFillWithWater function handles \n * evacuate dialysate and fill with water state * @details - * Inputs : heatDisinfectInternalState - * Outputs : none + * Inputs: heatDisinfectInternalState + * Outputs: none * @return next state *************************************************************************/ static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectEvacuateDialysateFillWithWater( void ) @@ -352,8 +350,8 @@ * @brief * The handleHeatDisinfectHeatWater function handles heat water state * @details - * Inputs : stateTimer - * Outputs : stateTimer + * Inputs: stateTimer + * Outputs: stateTimer * @return next state *************************************************************************/ static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectHeatWater( void ) @@ -363,7 +361,8 @@ F32 TPi = getTemperatureValue ( TEMPSENSORS_OUTLET_PRIMARY_HEATER_TEMP_SENSOR ); F32 TDi = getTemperatureValue ( TEMPSENSORS_INLET_DIALYSATE_TEMP_SENSOR ); - if ( fabs(TPi - TDi) <= MAX_TPO_AND_TDI_SENSORS_DIFFERENCE ) + if ( fabs(TPi - HEAT_DISINFECT_TARGET_TEMPERATURE) <= MAX_TEMPERATURE_DEVIATION_FROM_TARGET && + fabs(TDi - HEAT_DISINFECT_TARGET_TEMPERATURE) <= MAX_TEMPERATURE_DEVIATION_FROM_TARGET ) { // Set the states to disinfect recirculation path setValveState ( VPI, VALVE_STATE_OPEN ); @@ -389,8 +388,8 @@ * The handleHeatDisinfectRecirculationPath function handles disinfect \n * recirculate path state * @details - * Inputs : stateTimer - * Outputs : stateTimer + * Inputs: stateTimer + * Outputs: stateTimer * @return next state *************************************************************************/ static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectRecirculationPath( void ) @@ -432,11 +431,11 @@ * The handleHeatDisinfectReservoir1To2 function handles disinfect \n * reservoir 1 to reservoir 2 state * @details - * Inputs : stateTimer - * Outputs : stateTimer + * Inputs: stateTimer + * Outputs: stateTimer * @return next state *************************************************************************/ -static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectReservoir1To2( void ) +static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectR1ToR2( void ) { DG_HEAT_DISINFECT_STATE_T state = DG_HEAT_DISINFECT_STATE_DISINFECT_RESERVOIR_1_TO_2; @@ -445,7 +444,7 @@ { state = DG_HEAT_DISINFECT_STATE_HEAT_WATER; } - else if ( didTimeout( stateTimer, getRSVR1ToRSVR2Duration() ) ) + else if ( didTimeout( stateTimer, getR1ToR2Duration() ) ) { // Set the state for reservoir 1 to reservoir 2 setValveState ( VPI, VALVE_STATE_OPEN ); @@ -475,13 +474,13 @@ * The handleHeatDisinfectReservoir2To1 function handles disinfect \n * reservoir 2 to reservoir 1 state * @details - * Inputs : heatDisinfectCurrentCycle, heatDisinfectInternalState, + * Inputs: heatDisinfectCurrentCycle, heatDisinfectInternalState, * drainPumpTargetRPM, stateTimer - * Outputs : heatDisinfectCurrentCycle, heatDisinfectInternalState, + * Outputs: heatDisinfectCurrentCycle, heatDisinfectInternalState, * drainPumpTargetRPM, stateTimer * @return next state *************************************************************************/ -static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectReservoir2To1( void ) +static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectR2ToR1( void ) { DG_HEAT_DISINFECT_STATE_T state = DG_HEAT_DISINFECT_STATE_DISINFECT_RESERVOIR_2_TO_1; @@ -490,7 +489,7 @@ { state = DG_HEAT_DISINFECT_STATE_HEAT_WATER; } - else if ( didTimeout( stateTimer, getRSVR2ToRSVR1Duration() ) ) + else if ( didTimeout( stateTimer, getR2ToR1Duration() ) ) { // Set the state for reservoir 1 to reservoir 2 setValveState ( VPI, VALVE_STATE_OPEN ); @@ -508,7 +507,7 @@ setDrainPumpTargetDeltaPressure( DRAIN_PUMP_TARGET_DELTA_PRESSURE ); setROPumpTargetFlowRate( RO_PUMP_TARGET_FLOW_RATE_LPM ); - if ( ++heatDisinfectCurrentCycle > getNoOfCyclesToRun() ) + if ( ++heatDisinfectCurrentCycle >= getNoOfCyclesToRun() ) { drainPumpTargetRPM = DRAIN_PUMP_DISINFECT_DRAIN_PATH_TARGET_RPM; heatDisinfectInternalState = INTERNAL_HEAT_DISINFECT_STATE_OFF; @@ -541,8 +540,8 @@ * The handleHeatDisinfectDrainPath function handles disinfect drain path \n * state * @details - * Inputs : drainPumpTargetRPM, heatDisinfectInternalState - * Outputs : drainPumpTargetRPM, heatDisinfectInternalState + * Inputs: drainPumpTargetRPM, heatDisinfectInternalState + * Outputs: drainPumpTargetRPM, heatDisinfectInternalState * @return next state *************************************************************************/ static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectDrainPath( void ) @@ -566,8 +565,8 @@ * The handleHeatDisinfectFillWithWaterDeprimeReservoirs function handles \n * fill with water and deprime the reservoirs state * @details - * Inputs : none - * Outputs : none + * Inputs: none + * Outputs: none * @return next state *************************************************************************/ static DG_HEAT_DISINFECT_STATE_T handleHeatDisinfectFillWithWaterDeprimeReservoirs( void ) @@ -590,8 +589,8 @@ * The execHeatDisinfectInternalStates function executes the heat \n * disinfection internal state machine * @details - * Inputs : heatDisinfectInternalState - * Outputs : heatDisinfectInternalState + * Inputs: heatDisinfectInternalState + * Outputs: heatDisinfectInternalState * @return none *************************************************************************/ static void execHeatDisinfectInternalStates( void ) @@ -623,6 +622,7 @@ break; default: + // TODO add sw fault heatDisinfectInternalState = INTERNAL_HEAT_DISINFECT_STATE_COMPLETE; break; } @@ -633,8 +633,8 @@ * The handleHeatDisinfectOffState function handles internal heat disinfec \n * off state * @details - * Inputs : heatDisinfectState, stateTimer - * Outputs : stateTimer + * Inputs: heatDisinfectState, stateTimer + * Outputs: stateTimer * @return next state *************************************************************************/ static INTERNAL_HEAT_DISINFECT_STATE_T handleHeatDisinfectOffState( void ) @@ -645,17 +645,17 @@ if ( heatDisinfectState == DG_HEAT_DISINFECT_STATE_EVACUATE_DIALYSATE_FILL_WITH_WATER ) { // Set the actuators for evacuate recirculation path - setValveState ( VPI, VALVE_STATE_OPEN ); - setValveState ( VBF, VALVE_STATE_OPEN ); - setValveState ( VSP, VALVE_STATE_CLOSED ); - setValveState ( VPD, VALVE_STATE_OPEN_C_TO_NO ); - setValveState ( VPO, VALVE_STATE_NOFILL_C_TO_NO ); - setValveState ( VDR, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState ( VRC, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState ( VRO, VALVE_STATE_R2_C_TO_NO ); - setValveState ( VRD, VALVE_STATE_R1_C_TO_NO ); - setValveState ( VRI, VALVE_STATE_R1_C_TO_NO ); - setValveState ( VRF, VALVE_STATE_R2_C_TO_NO ); + setValveState( VPI, VALVE_STATE_OPEN ); + setValveState( VBF, VALVE_STATE_OPEN ); + setValveState( VSP, VALVE_STATE_CLOSED ); + setValveState( VPD, VALVE_STATE_OPEN_C_TO_NO ); + setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); + setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); + setValveState( VRC, VALVE_STATE_DRAIN_C_TO_NO ); + setValveState( VRO, VALVE_STATE_R2_C_TO_NO ); + setValveState( VRD, VALVE_STATE_R1_C_TO_NO ); + setValveState( VRI, VALVE_STATE_R1_C_TO_NO ); + setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); setROPumpTargetFlowRate( RO_PUMP_TARGET_FLOW_RATE_LPM ); stateTimer = getMSTimerCount(); // For evac recirc path. TODO later, it should be controlled using // the composite pump @@ -677,17 +677,19 @@ // Set the actuators for draining the path signalROPumpHardStop(); signalDrainPumpHardStop(); - setValveState ( VPI, VALVE_STATE_OPEN ); - setValveState ( VBF, VALVE_STATE_OPEN ); - setValveState ( VSP, VALVE_STATE_CLOSED ); - setValveState ( VPD, VALVE_STATE_OPEN_C_TO_NO ); - setValveState ( VPO, VALVE_STATE_NOFILL_C_TO_NO ); - setValveState ( VDR, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState ( VRC, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState ( VRO, VALVE_STATE_R2_C_TO_NC ); - setValveState ( VRD, VALVE_STATE_R1_C_TO_NC ); - setValveState ( VRI, VALVE_STATE_R1_C_TO_NO ); - setValveState ( VRF, VALVE_STATE_R2_C_TO_NO ); + stopPrimaryHeater(); + stopTrimmerHeater(); + setValveState( VPI, VALVE_STATE_OPEN ); + setValveState( VBF, VALVE_STATE_OPEN ); + setValveState( VSP, VALVE_STATE_CLOSED ); + setValveState( VPD, VALVE_STATE_OPEN_C_TO_NO ); + setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); + setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); + setValveState( VRC, VALVE_STATE_DRAIN_C_TO_NO ); + setValveState( VRO, VALVE_STATE_R2_C_TO_NC ); + setValveState( VRD, VALVE_STATE_R1_C_TO_NC ); + setValveState( VRI, VALVE_STATE_R1_C_TO_NO ); + setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); setDrainPumpTargetSpeed( drainPumpTargetRPM ); state = INTERNAL_HEAT_DISINFECT_STATE_EVACUATE_RESERVOIR_1; @@ -701,16 +703,16 @@ * The handleHeatDisinfectFillWithWaterState function handles internal \n * fill with water state * @details - * Inputs : heatDisinfectState, stateTimer - * Outputs : stateTimer + * Inputs: heatDisinfectState, stateTimer + * Outputs: stateTimer * @return next state *************************************************************************/ static INTERNAL_HEAT_DISINFECT_STATE_T handleHeatDisinfectFillWithWaterState( void ) { INTERNAL_HEAT_DISINFECT_STATE_T state = INTERNAL_HEAT_DISINFECT_STATE_FILL_WITH_WATER; - F32 reservoir1Weight = getLoadCellFilteredWeight ( LOAD_CELL_A1 ); - F32 reservoir2Weight = getLoadCellFilteredWeight ( LOAD_CELL_B1 ); + F32 reservoir1Weight = getLoadCellFilteredWeight( LOAD_CELL_A1 ); + F32 reservoir2Weight = getLoadCellFilteredWeight( LOAD_CELL_B1 ); if ( reservoir1Weight >= FULL_RESERVOIRS_WEIGHT_GRAMS && reservoir2Weight >= FULL_RESERVOIRS_WEIGHT_GRAMS ) @@ -722,17 +724,17 @@ } else if ( heatDisinfectState == DG_HEAT_DISINFECT_STATE_FILL_WITH_WATER_DEPRIME_RESERVOIRS ) { - setValveState ( VPI, VALVE_STATE_OPEN ); - setValveState ( VBF, VALVE_STATE_OPEN ); - setValveState ( VSP, VALVE_STATE_CLOSED ); - setValveState ( VPD, VALVE_STATE_OPEN_C_TO_NO ); - setValveState ( VPO, VALVE_STATE_NOFILL_C_TO_NO ); - setValveState ( VDR, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState ( VRC, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState ( VRO, VALVE_STATE_R2_C_TO_NO ); - setValveState ( VRD, VALVE_STATE_R1_C_TO_NO ); - setValveState ( VRI, VALVE_STATE_R1_C_TO_NO ); - setValveState ( VRF, VALVE_STATE_R2_C_TO_NO ); + setValveState( VPI, VALVE_STATE_OPEN ); + setValveState( VBF, VALVE_STATE_OPEN ); + setValveState( VSP, VALVE_STATE_CLOSED ); + setValveState( VPD, VALVE_STATE_OPEN_C_TO_NO ); + setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); + setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); + setValveState( VRC, VALVE_STATE_DRAIN_C_TO_NO ); + setValveState( VRO, VALVE_STATE_R2_C_TO_NO ); + setValveState( VRD, VALVE_STATE_R1_C_TO_NO ); + setValveState( VRI, VALVE_STATE_R1_C_TO_NO ); + setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); setROPumpTargetFlowRate( RO_PUMP_TARGET_FLOW_RATE_LPM ); stateTimer = getMSTimerCount(); @@ -748,8 +750,8 @@ * The handleHeatDisinfectEvacRecircPathState function handles internal \n * evacuate recirculation path state * @details - * Inputs : stateTimer, drainPumpTargetRPM - * Outputs : none + * Inputs: stateTimer, drainPumpTargetRPM + * Outputs: none * @return next state *************************************************************************/ static INTERNAL_HEAT_DISINFECT_STATE_T handleHeatDisinfectEvacRecircPathState( void ) @@ -761,18 +763,18 @@ { // Set the state to evacuate reservoir 1 signalROPumpHardStop(); - setValveState ( VPI, VALVE_STATE_OPEN ); - setValveState ( VBF, VALVE_STATE_OPEN ); - setValveState ( VSP, VALVE_STATE_CLOSED ); - setValveState ( VPD, VALVE_STATE_OPEN_C_TO_NO ); - setValveState ( VPO, VALVE_STATE_NOFILL_C_TO_NO ); - setValveState ( VDR, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState ( VRC, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState ( VRO, VALVE_STATE_R2_C_TO_NO ); - setValveState ( VRD, VALVE_STATE_R1_C_TO_NC ); - setValveState ( VRI, VALVE_STATE_R1_C_TO_NO ); - setValveState ( VRF, VALVE_STATE_R2_C_TO_NO ); - setDrainPumpTargetSpeed ( drainPumpTargetRPM ); + setValveState( VPI, VALVE_STATE_OPEN ); + setValveState( VBF, VALVE_STATE_OPEN ); + setValveState( VSP, VALVE_STATE_CLOSED ); + setValveState( VPD, VALVE_STATE_OPEN_C_TO_NO ); + setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); + setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); + setValveState( VRC, VALVE_STATE_DRAIN_C_TO_NO ); + setValveState( VRO, VALVE_STATE_R2_C_TO_NO ); + setValveState( VRD, VALVE_STATE_R1_C_TO_NC ); + setValveState( VRI, VALVE_STATE_R1_C_TO_NO ); + setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); + setDrainPumpTargetSpeed( drainPumpTargetRPM ); state = INTERNAL_HEAT_DISINFECT_STATE_EVACUATE_RESERVOIR_1; } @@ -785,31 +787,31 @@ * The handleHeatDisifnectEvacReservoir1State function handles internal \n * evacuate reservoir 1 state * @details - * Inputs : none - * Outputs : none + * Inputs: none + * Outputs: none * @return next state *************************************************************************/ static INTERNAL_HEAT_DISINFECT_STATE_T handleHeatDisifnectEvacReservoir1State( void ) { INTERNAL_HEAT_DISINFECT_STATE_T state = INTERNAL_HEAT_DISINFECT_STATE_EVACUATE_RESERVOIR_1; - F32 reservoir1Weight = getLoadCellFilteredWeight ( LOAD_CELL_A1 ); + F32 reservoir1Weight = getLoadCellFilteredWeight( LOAD_CELL_A1 ); if ( reservoir1Weight <= EMPTY_RESERVOIRS_WEIGHT_GRAMS ) { // Set the state to evacuate reservoir 2 - setValveState ( VPI, VALVE_STATE_OPEN ); - setValveState ( VBF, VALVE_STATE_OPEN ); - setValveState ( VSP, VALVE_STATE_CLOSED ); - setValveState ( VPD, VALVE_STATE_OPEN_C_TO_NO ); - setValveState ( VPO, VALVE_STATE_NOFILL_C_TO_NO ); - setValveState ( VDR, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState ( VRC, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState ( VRO, VALVE_STATE_R2_C_TO_NC ); - setValveState ( VRD, VALVE_STATE_R2_C_TO_NO ); - setValveState ( VRI, VALVE_STATE_R2_C_TO_NC ); - setValveState ( VRF, VALVE_STATE_R2_C_TO_NO ); - setDrainPumpTargetSpeed ( drainPumpTargetRPM ); //probably it is not needed TODO test this + setValveState( VPI, VALVE_STATE_OPEN ); + setValveState( VBF, VALVE_STATE_OPEN ); + setValveState( VSP, VALVE_STATE_CLOSED ); + setValveState( VPD, VALVE_STATE_OPEN_C_TO_NO ); + setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); + setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); + setValveState( VRC, VALVE_STATE_DRAIN_C_TO_NO ); + setValveState( VRO, VALVE_STATE_R2_C_TO_NC ); + setValveState( VRD, VALVE_STATE_R2_C_TO_NO ); + setValveState( VRI, VALVE_STATE_R2_C_TO_NC ); + setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); + setDrainPumpTargetSpeed( drainPumpTargetRPM ); //probably it is not needed TODO test this state = INTERNAL_HEAT_DISINFECT_STATE_EVACUATE_RESERVOIR_2; } @@ -822,8 +824,8 @@ * The handleHeatDisinfectEvacReservoir2State function handles internal \n * evacuate reservoir 2 state * @details - * Inputs : heatDisinfectState - * Outputs : none + * Inputs: heatDisinfectState + * Outputs: none * @return next state *************************************************************************/ static INTERNAL_HEAT_DISINFECT_STATE_T handleHeatDisinfectEvacReservoir2State( void ) @@ -854,24 +856,24 @@ * The stopActuators function sets all the actuators in stop and \n * de-energized state * @details - * Inputs : none - * Outputs : none + * Inputs: none + * Outputs: none * @return none *************************************************************************/ static void stopActuators( void ) { // De-energize all the valves - setValveState ( VPI, VALVE_STATE_OPEN ); - setValveState ( VBF, VALVE_STATE_OPEN ); - setValveState ( VSP, VALVE_STATE_CLOSED ); - setValveState ( VPD, VALVE_STATE_OPEN_C_TO_NO ); - setValveState ( VPO, VALVE_STATE_NOFILL_C_TO_NO ); - setValveState ( VDR, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState ( VRC, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState ( VRO, VALVE_STATE_R2_C_TO_NO ); - setValveState ( VRD, VALVE_STATE_R1_C_TO_NC ); - setValveState ( VRI, VALVE_STATE_R1_C_TO_NO ); - setValveState ( VRF, VALVE_STATE_R2_C_TO_NO ); + setValveState( VPI, VALVE_STATE_OPEN ); + setValveState( VBF, VALVE_STATE_OPEN ); + setValveState( VSP, VALVE_STATE_CLOSED ); + setValveState( VPD, VALVE_STATE_OPEN_C_TO_NO ); + setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); + setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); + setValveState( VRC, VALVE_STATE_DRAIN_C_TO_NO ); + setValveState( VRO, VALVE_STATE_R2_C_TO_NO ); + setValveState( VRD, VALVE_STATE_R1_C_TO_NC ); + setValveState( VRI, VALVE_STATE_R1_C_TO_NO ); + setValveState( VRF, VALVE_STATE_R2_C_TO_NO ); //TODO composition pumps signalROPumpHardStop(); @@ -887,21 +889,19 @@ * The isTemperatureInRange function checks whether the water temperature \n * is out of range * @details - * Inputs : heatDisinfectElapsedTime - * Outputs : heatDisinfectElapsedTime + * Inputs: none + * Outputs: none * @return TRUE if the water temperature is still in range *************************************************************************/ static BOOL isTemperatureInRange( void ) { BOOL result = FALSE; - F32 TPi = getTemperatureValue ( TEMPSENSORS_OUTLET_PRIMARY_HEATER_TEMP_SENSOR ); - F32 TDi = getTemperatureValue ( TEMPSENSORS_INLET_DIALYSATE_TEMP_SENSOR ); + F32 TPi = getTemperatureValue( TEMPSENSORS_OUTLET_PRIMARY_HEATER_TEMP_SENSOR ); + F32 TDi = getTemperatureValue( TEMPSENSORS_INLET_DIALYSATE_TEMP_SENSOR ); - if ( fabs( TPi - TDi ) <= MAX_TEMPERATURE_DEVIATION_FROM_TARGET ) + if ( fabs(TPi - HEAT_DISINFECT_TARGET_TEMPERATURE) <= MAX_TEMPERATURE_DEVIATION_FROM_TARGET && + fabs(TDi - HEAT_DISINFECT_TARGET_TEMPERATURE) <= MAX_TEMPERATURE_DEVIATION_FROM_TARGET ) { - // Reset the heat disinfect elapsed time - // It has to start over - heatDisinfectElapsedTime = 0; result = TRUE; } @@ -913,23 +913,23 @@ * The setActuatorsToFillWater function sets the actuators to fill with \n * water mode * @details - * Inputs : none - * Outputs : none + * Inputs: none + * Outputs: none * @return none *************************************************************************/ static void setActuatorsToFillWater( void ) { - setValveState ( VPI, VALVE_STATE_OPEN ); - setValveState ( VBF, VALVE_STATE_OPEN ); - setValveState ( VSP, VALVE_STATE_CLOSED ); - setValveState ( VPD, VALVE_STATE_OPEN_C_TO_NO ); - setValveState ( VPO, VALVE_STATE_FILL_C_TO_NC ); - setValveState ( VDR, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState ( VRC, VALVE_STATE_DRAIN_C_TO_NO ); - setValveState ( VRO, VALVE_STATE_R2_C_TO_NO ); - setValveState ( VRD, VALVE_STATE_R2_C_TO_NO ); - setValveState ( VRI, VALVE_STATE_R2_C_TO_NC ); - setValveState ( VRF, VALVE_STATE_R1_C_TO_NC ); + setValveState( VPI, VALVE_STATE_OPEN ); + setValveState( VBF, VALVE_STATE_OPEN ); + setValveState( VSP, VALVE_STATE_CLOSED ); + setValveState( VPD, VALVE_STATE_OPEN_C_TO_NO ); + setValveState( VPO, VALVE_STATE_FILL_C_TO_NC ); + setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); + setValveState( VRC, VALVE_STATE_DRAIN_C_TO_NO ); + setValveState( VRO, VALVE_STATE_R2_C_TO_NO ); + setValveState( VRD, VALVE_STATE_R2_C_TO_NO ); + setValveState( VRI, VALVE_STATE_R2_C_TO_NC ); + setValveState( VRF, VALVE_STATE_R1_C_TO_NC ); setROPumpTargetFlowRate( RO_PUMP_TARGET_FLOW_RATE_LPM ); } @@ -938,8 +938,8 @@ * The getPublishHeatDisinfectDataInterval function sets the data publish \n * interval * @details - * Inputs : heatDisinfectDataPublishInterval - * Outputs : none + * Inputs: heatDisinfectDataPublishInterval + * Outputs: none * @return result : data publish time interval *************************************************************************/ static U32 getPublishHeatDisinfectDataInterval( void ) @@ -958,16 +958,16 @@ * @brief * The publishHeatDisinfectData function publishes heat disinfect mode * @details - * Inputs : heatDisinfectPublishCounter, heatDisinfectCurrentCycle, - * heatDisinfectInternalState - * Outputs : heatDisinfectPublishCounter + * Inputs: heatDisinfectPublishCounter, heatDisinfectCurrentCycle, + * heatDisinfectInternalState + * Outputs: heatDisinfectPublishCounter * @return none *************************************************************************/ static void publishHeatDisinfectData ( void ) { if ( ++heatDisinfectPublishCounter >= getPublishHeatDisinfectDataInterval() ) { - F32 elapsedtime = calcTimeSince( heatDisinfectElapsedTime ) / MINUTES_TO_MS_CONVERSION; + F32 elapsedtime = calcTimeSince( heatDisinfectStartTime ) / MINUTES_TO_MS_CONVERSION; broadcastHeatDisinfectData( (U32)heatDisinfectInternalState, elapsedtime, heatDisinfectCurrentCycle ); heatDisinfectPublishCounter = 0; } @@ -978,10 +978,10 @@ * The testSetHeatDisinfectDataPublishIntervalOverride function overrides \n * the data publication interval * @details - * Inputs : heatDisinfectDataPublishInterval - * Outputs : heatDisinfectDataPublishInterval - * @param value : The requested value for override - * @return result : TRUE if override was successful + * Inputs: heatDisinfectDataPublishInterval + * Outputs: heatDisinfectDataPublishInterval + * @param: value : The requested value for override + * @return: result : TRUE if override was successful *************************************************************************/ BOOL testSetHeatDisinfectDataPublishIntervalOverride( U32 value ) { @@ -1004,9 +1004,9 @@ * The testResetHeatDisinfectDataPublishIntervalOverride function \n * resets the overridden data publication time interval * @details - * Inputs : heatDisinfectDataPublishInterval - * Outputs : heatDisinfectDataPublishInterval - * @return result : TRUE if reset was successful + * Inputs: heatDisinfectDataPublishInterval + * Outputs: heatDisinfectDataPublishInterval + * @return: result : TRUE if reset was successful *************************************************************************/ BOOL testResetHeatDisinfectDataPublishIntervalOverride( void ) { @@ -1027,20 +1027,20 @@ * The testSetHeatDisinfectRecircDurationOverride function overrides the \n * duration of the recirculation path heat disinfection in minutes * @details - * Inputs : heatDisinfectRecircDuration - * Outputs : heatDisinfectRecircDuration - * @param recircMins : recirculation duration in minutes - * @return result : TRUE if override was successful + * Inputs: heatDisinfectRecircDuration + * Outputs: heatDisinfectRecircDuration + * @param: recircMins : recirculation duration in minutes + * @return: result : TRUE if override was successful *************************************************************************/ BOOL testSetHeatDisinfectRecircDurationOverride( F32 recircMins ) { BOOL result = FALSE; if ( TRUE == isTestingActivated() ) { - heatDisinfectRecircDuration.ovInitData = heatDisinfectRecircDuration.data; - heatDisinfectRecircDuration.ovData = recircMins * MINUTES_TO_MS_CONVERSION; - heatDisinfectRecircDuration.override = OVERRIDE_KEY; + heatDisinfectRecircDuration.ovInitData = heatDisinfectRecircDuration.data; + heatDisinfectRecircDuration.ovData = recircMins * MINUTES_TO_MS_CONVERSION; + heatDisinfectRecircDuration.override = OVERRIDE_KEY; } return result; @@ -1051,9 +1051,9 @@ * The testResetHeatDisinfectRecircDurationOverride function resets the \n * overridden duration of recirculation path heat disinfection * @details - * Inputs : heatDisinfectRecircDuration - * Outputs : heatDisinfectRecircDuration - * @return result : TRUE if reset was successful + * Inputs: heatDisinfectRecircDuration + * Outputs: heatDisinfectRecircDuration + * @return: result : TRUE if reset was successful *************************************************************************/ BOOL testResetHeatDisinfectRecircDurationOverride( void ) { @@ -1062,8 +1062,8 @@ if ( TRUE == isTestingActivated() ) { result = TRUE; - heatDisinfectRecircDuration.ovData = heatDisinfectRecircDuration.ovInitData; - heatDisinfectRecircDuration.override = OVERRIDE_RESET; + heatDisinfectRecircDuration.ovData = heatDisinfectRecircDuration.ovInitData; + heatDisinfectRecircDuration.override = OVERRIDE_RESET; } return result; @@ -1074,10 +1074,10 @@ * The testSetHeatDisinfectR1ToR2DurationOverride function overrides\n * the duration of reservoir 1 to reservoir 2 heat disinfection in minutes * @details - * Inputs : heatDisinfectR1ToR2Duration - * Outputs : heatDisinfectR1ToR2Duration - * @param R1ToR2Mins : reservoir 1 to reservoir 2 duration in minutes - * @return result : TRUE if override was successful + * Inputs: heatDisinfectR1ToR2Duration + * Outputs: heatDisinfectR1ToR2Duration + * @param: R1ToR2Mins : reservoir 1 to reservoir 2 duration in minutes + * @return: result : TRUE if override was successful *************************************************************************/ BOOL testSetHeatDisinfectR1ToR2DurationOverride( F32 R1ToR2Mins ) { @@ -1086,9 +1086,9 @@ if ( TRUE == isTestingActivated() ) { result = TRUE; - heatDisinfectR1ToR2Duration.ovInitData = heatDisinfectR1ToR2Duration.data; - heatDisinfectR1ToR2Duration.ovData = R1ToR2Mins * MINUTES_TO_MS_CONVERSION; - heatDisinfectR1ToR2Duration.override = OVERRIDE_KEY; + heatDisinfectR1ToR2Duration.ovInitData = heatDisinfectR1ToR2Duration.data; + heatDisinfectR1ToR2Duration.ovData = R1ToR2Mins * MINUTES_TO_MS_CONVERSION; + heatDisinfectR1ToR2Duration.override = OVERRIDE_KEY; } return result; @@ -1099,9 +1099,9 @@ * The testResetHeatDisinfectR1ToR2DurationOverride function \n * resets the overridden reservoir 1 to reservoir 2 duration * @details - * Inputs : heatDisinfectR1ToR2Duration - * Outputs : heatDisinfectR1ToR2Duration - * @return result : TRUE if reset was successful + * Inputs: heatDisinfectR1ToR2Duration + * Outputs: heatDisinfectR1ToR2Duration + * @return: result : TRUE if reset was successful *************************************************************************/ BOOL testResetHeatDisinfectR1ToR2DurationOverride( void ) { @@ -1110,8 +1110,8 @@ if ( TRUE == isTestingActivated() ) { result = TRUE; - heatDisinfectR1ToR2Duration.ovData = heatDisinfectR1ToR2Duration.ovInitData; - heatDisinfectR1ToR2Duration.override = OVERRIDE_RESET; + heatDisinfectR1ToR2Duration.ovData = heatDisinfectR1ToR2Duration.ovInitData; + heatDisinfectR1ToR2Duration.override = OVERRIDE_RESET; } return result; @@ -1121,10 +1121,10 @@ * @brief * The testSetHeatDisinfectionR2ToR1DurationOverride function overrides \n * the duration of reservoir 2 to reservoir 1 heat disinfection in minutes - * Inputs : heatDisinfectR2ToR1Duration - * Outputs : heatDisinfectR2ToR1Duration - * @param R2ToR1Mins : reservoir 2 to reservoir 1 duration in minutes - * @return result : TRUE is override was successful + * Inputs: heatDisinfectR2ToR1Duration + * Outputs: heatDisinfectR2ToR1Duration + * @param: R2ToR1Mins : reservoir 2 to reservoir 1 duration in minutes + * @return: result : TRUE is override was successful *************************************************************************/ BOOL testSetHeatDisinfectionR2ToR1DurationOverride( F32 R2ToR1Mins ) { @@ -1133,9 +1133,9 @@ if ( TRUE == isTestingActivated() ) { result = TRUE; - heatDisinfectR2ToR1Duration.ovInitData = heatDisinfectR2ToR1Duration.data; - heatDisinfectR2ToR1Duration.ovData = R2ToR1Mins * MINUTES_TO_MS_CONVERSION; - heatDisinfectR2ToR1Duration.override = OVERRIDE_KEY; + heatDisinfectR2ToR1Duration.ovInitData = heatDisinfectR2ToR1Duration.data; + heatDisinfectR2ToR1Duration.ovData = R2ToR1Mins * MINUTES_TO_MS_CONVERSION; + heatDisinfectR2ToR1Duration.override = OVERRIDE_KEY; } return result; @@ -1157,8 +1157,8 @@ if ( TRUE == isTestingActivated() ) { result = TRUE; - heatDisinfectR2ToR1Duration.ovData = heatDisinfectR2ToR1Duration.ovInitData; - heatDisinfectR2ToR1Duration.override = OVERRIDE_RESET; + heatDisinfectR2ToR1Duration.ovData = heatDisinfectR2ToR1Duration.ovInitData; + heatDisinfectR2ToR1Duration.override = OVERRIDE_RESET; } return result; @@ -1169,10 +1169,10 @@ * The testSetHeatDisinfectNoOfCyclesOverride function overrides the \n * number of cycles to run during heat disinfection * @details - * Inputs : heatDisinfectNoOfCyclesToRun - * Outputs : heatDisinfectNoOfCyclesToRun - * @param cycles : number of cycles to run heat disinfection - * @return result : TRUE if override was successful + * Inputs: heatDisinfectNoOfCyclesToRun + * Outputs: heatDisinfectNoOfCyclesToRun + * @param: cycles : number of cycles to run heat disinfection + * @return: result : TRUE if override was successful *************************************************************************/ BOOL testSetHeatDisinfectNoOfCyclesOverride( U32 cycles ) { @@ -1194,9 +1194,9 @@ * The testResetHeatDisinfectNoOfCyclesOverride function \n * resets the cycles to run heat disinfection * @details - * Inputs : heatDisinfectNoOfCyclesToRun - * Outputs : heatDisinfectNoOfCyclesToRun - * @return result : TRUE if reset was successful + * Inputs: heatDisinfectNoOfCyclesToRun + * Outputs: heatDisinfectNoOfCyclesToRun + * @return: result : TRUE if reset was successful *************************************************************************/ BOOL testResetHeatDisinfectNoOfCyclesOverride( void ) { @@ -1217,9 +1217,9 @@ * The getRecirculationDuration function gets the duration of recirculation \n * path heat disinfection * @details - * Inputs : heatDisinfectRecircDuration - * Outputs : none - * @return result : the duration in minutes + * Inputs: heatDisinfectRecircDuration + * Outputs: none + * @return: result : the duration in minutes *************************************************************************/ static F32 getRecirculationDuration( void ) { @@ -1238,11 +1238,11 @@ * The getRSVR1ToRSVR2Duration function gets the duration of reservoir 1 \n * to reservoir 2 heat disinfection * @details - * Inputs : heatDisinfectR1ToR2Duration - * Outputs : none - * @return result : the duration in minutes + * Inputs: heatDisinfectR1ToR2Duration + * Outputs: none + * @return: result : the duration in minutes *************************************************************************/ -static F32 getRSVR1ToRSVR2Duration( void ) +static F32 getR1ToR2Duration( void ) { F32 result = heatDisinfectR1ToR2Duration.data; @@ -1259,11 +1259,11 @@ * The getRSVR2ToRSVR1Duration function gets the duration of reservoir 2 \n * to reservoir 1 heat disinfection * @details - * Inputs : heatDisinfectR2ToR1Duration - * Outputs : none - * @return result : the duration in minutes + * Inputs: heatDisinfectR2ToR1Duration + * Outputs: none + * @return: result : the duration in minutes *************************************************************************/ -static F32 getRSVR2ToRSVR1Duration() +static F32 getR2ToR1Duration() { F32 result = heatDisinfectR2ToR1Duration.data; @@ -1280,9 +1280,9 @@ * The getNoOfCyclesToRun function gets the number of cycles to run \n * heat disinfection * @details - * Inputs : heatDisinfectNoOfCyclesToRun - * Outputs : none - * @return result : the no of cycles + * Inputs: heatDisinfectNoOfCyclesToRun + * Outputs: none + * @return: result : the no of cycles *************************************************************************/ static U32 getNoOfCyclesToRun() { Index: firmware/App/Services/CommBuffers.c =================================================================== diff -u -r8f5feed92f41a476d5656038bcdfe884e17bd593 -rdaf8d5b60c753becab80cbaf164aac0e49d533a2 --- firmware/App/Services/CommBuffers.c (.../CommBuffers.c) (revision 8f5feed92f41a476d5656038bcdfe884e17bd593) +++ firmware/App/Services/CommBuffers.c (.../CommBuffers.c) (revision daf8d5b60c753becab80cbaf164aac0e49d533a2) @@ -75,7 +75,7 @@ { if ( buffer < NUM_OF_COMM_BUFFERS ) { - S32 d,i; + S32 d, i; // thread protection for queue operations _disable_IRQ(); @@ -122,8 +122,7 @@ U32 currentActiveBufCount; // where to start adding new data to buffer (after existing data) // prevent adding to out-going CAN buffer if DG is only node on CAN bus - if ( ( FALSE == isDGOnlyCANNode() ) || - ( FALSE == isCANBoxForXmit( (CAN_MESSAGE_BOX_T)buffer ) ) ) + if ( ( FALSE == isDGOnlyCANNode() ) || ( FALSE == isCANBoxForXmit( (CAN_MESSAGE_BOX_T)buffer ) ) ) { // thread protection for queue operations _disable_IRQ(); Index: firmware/App/Services/PIControllers.h =================================================================== diff -u -r359cf587f2f935ef9f40a16d17c4105efa653c1d -rdaf8d5b60c753becab80cbaf164aac0e49d533a2 --- firmware/App/Services/PIControllers.h (.../PIControllers.h) (revision 359cf587f2f935ef9f40a16d17c4105efa653c1d) +++ firmware/App/Services/PIControllers.h (.../PIControllers.h) (revision daf8d5b60c753becab80cbaf164aac0e49d533a2) @@ -34,10 +34,10 @@ typedef enum ControllerList { PI_CONTROLLER_ID_RO_PUMP = 0, ///< RO Pump controller. - I_CONTROLLER_ID_RO_PUMP_RAMP_UP, ///< RO Pump controller during ramp up time. - PI_CONTROLLER_ID_DRAIN_PUMP, ///< Drain Pump controller. PI_CONTROLLER_ID_PRIMARY_HEATER, ///< Primary Heater controller. - PI_CONTROLLER_ID_TRIMMER_HEATER, ///< Trimmer Heater controller. + PI_CONTROLLER_ID_TRIMMER_HEATER, ///< Trimmer Heater controller. + I_CONTROLLER_ID_RO_PUMP_RAMP_UP, ///< RO Pump controller during ramp up time. + PI_CONTROLLER_ID_DRAIN_PUMP, ///< Drain Pump controller. NUM_OF_PI_CONTROLLERS_IDS ///< Number of PI controllers. } PI_CONTROLLER_ID_T; Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r44cc25461e4936f7928904640c87a03ef7cf3c16 -rdaf8d5b60c753becab80cbaf164aac0e49d533a2 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 44cc25461e4936f7928904640c87a03ef7cf3c16) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision daf8d5b60c753becab80cbaf164aac0e49d533a2) @@ -118,8 +118,6 @@ static U32 transmitNextUARTPacket( void ); #endif - - static COMM_BUFFER_T findNextHighestPriorityCANPacketToTransmit( void ); static U32 transmitNextCANPacket( void ); Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r44cc25461e4936f7928904640c87a03ef7cf3c16 -rdaf8d5b60c753becab80cbaf164aac0e49d533a2 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 44cc25461e4936f7928904640c87a03ef7cf3c16) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision daf8d5b60c753becab80cbaf164aac0e49d533a2) @@ -51,23 +51,24 @@ typedef struct { - U32 alarmState; // 0 = no alarms, 1 = low priority, 2 = medium priority, 3 = high priority - U32 alarmTop; // ID of top active alarm - U32 escalatesIn; // seconds - U32 silenceExpiresIn; // seconds - U16 alarmsFlags; // bit flags: 1 = true, 0 = false for each bit + U32 alarmState; //< 0 = no alarms, 1 = low priority, 2 = medium priority, 3 = high priority + U32 alarmTop; //< ID of top active alarm + U32 escalatesIn; //< seconds + U32 silenceExpiresIn; //< seconds + U16 alarmsFlags; //< bit flags: 1 = true, 0 = false for each bit } ALARM_COMP_STATUS_PAYLOAD_T; - + +/// DG version data typedef struct { - U08 major; - U08 minor; - U08 micro; - U16 build; - U08 fpgaId; - U08 fpgaMajor; - U08 fpgaMinor; - U08 fpgaLab; + U08 major; ///< Major + U08 minor; ///< Minor + U08 micro; ///< Micro + U16 build; ///< Build number + U08 fpgaId; ///< FPGA ID + U08 fpgaMajor; ///< FPGA major + U08 fpgaMinor; ///< FPGA minor + U08 fpgaLab; ///< FPGA lab } DG_VERSIONS_T; typedef struct @@ -84,21 +85,23 @@ F32 loadCellB1inGram; F32 loadCellB2inGram; } LOAD_CELL_DATA_T; - + +/// RO pump data typedef struct { - F32 roPumpTgtPressure; - F32 measROFlowRate; - F32 roPumpPWM; - U32 roPumpState; + F32 roPumpTgtPressure; ///< RO pump target pressure + F32 measROFlowRate; ///< RO pump measured flow rate + F32 roPumpPWM; ///< RO pump PWM duty cycle + U32 roPumpState; ///< RO pump current state } RO_PUMP_DATA_T; - + +/// Drain pump data typedef struct { - U32 setDrainPumpSpeed; - U32 dacValue; - F32 deltaPressure; - U32 drainPState; + U32 setDrainPumpSpeed; ///< Drain pump set speed + U32 dacValue; ///< Drain pump DAC value + F32 deltaPressure; ///< Drain pump delta pressure + U32 drainPState; ///< Drain pump state } DRAIN_PUMP_DATA_T; typedef struct @@ -115,25 +118,28 @@ U32 fillToVolumeMl; U32 drainToVolumeMl; } RESERVOIR_DATA_T; - + +/// Target temperature of the heaters data typedef struct { - F32 targetPrimaryHeaterTemp; - F32 targetTrimmerHeaterTemp; + F32 targetPrimaryHeaterTemp; ///< Target primary heater temperature + F32 targetTrimmerHeaterTemp; ///< Target trimmer heater temperature } TARGET_TEMPS_PAYLOAD_T; - + +/// Heaters data typedef struct { - U32 mainPrimayHeaterDC; - U32 smallPrimaryHeaterDC; - U32 trimmerHeaterDC; + U32 mainPrimayHeaterDC; ///< Main primary heater duty cycle + U32 smallPrimaryHeaterDC; ///< Small primary heater duty cycle + U32 trimmerHeaterDC; ///< Trimmer heater duty cycle } HEATERS_DATA_T; +/// Heat disinfect data typedef struct { - U32 internalState; - F32 elapsedTimeMins; - U32 currentCycle; + U32 internalState; ///< Internal state of heat disinfect state machine + F32 elapsedTimeMins; ///< Heat disinfect elapsed time in minutes + U32 currentCycle; ///< Current cycle of the heat disinfect } DG_HEAT_DISINFECT_DATA_T; #pragma pack(pop)