Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -rba9341bc691b500d5ec3904fec1eb38279c5fbbd -r71ea7fe082e92a86b737983e3fb51e6f37072560 --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision ba9341bc691b500d5ec3904fec1eb38279c5fbbd) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 71ea7fe082e92a86b737983e3fb51e6f37072560) @@ -340,35 +340,42 @@ * @details \b Outputs: targetROPumpFlowRate, roPumpControlMode, roPumpDutyCyclePctSet, * roControlTimerCounter, isROPumpOn * @param roFlowRate which is target RO flow rate in mL/min + * @param firmwareCall indicates whether the call initiated by firmware + * internally or by dialin * @return TRUE if new target flow rate is set successfully, FALSE if not *************************************************************************/ BOOL setROPumpTargetFlowRateMLPM( U32 roFlowRate, BOOL firmwareCall ) { BOOL result = FALSE; + BOOL skipSet = FALSE; // First of all, the flow rate must be in range if ( ( roFlowRate <= MAX_RO_FLOWRATE_MLPM ) && ( roFlowRate >= MIN_RO_FLOWRATE_MLPM ) ) { if ( firmwareCall == TRUE ) // firmware call { + // set the target flow and pressure to zero if there are no active override if ( ( targetROPumpFlowRate.override == OVERRIDE_RESET ) && ( targetROPumpPressure.override == OVERRIDE_RESET ) && ( roPumpOpenLoopTargetDutyCycle.override == OVERRIDE_RESET ) ) { targetROPumpPressure.data = 0; roPumpOpenLoopTargetDutyCycle.data = 0.0F; } + // skip the firmware set call if any override is active else { result = TRUE; - return result; + skipSet = TRUE; } - } - targetROPumpFlowRate.data = roFlowRate; - // Get the initial guess of the duty cycle - roPumpDutyCyclePctSet = roPumpFlowToPWM( getTargetROPumpFlowRateMLPM() ); - roControlTimerCounter = 0; - isROPumpOn = TRUE; - result = TRUE; + if ( FALSE == skipSet ) + { + targetROPumpFlowRate.data = roFlowRate; + // Get the initial guess of the duty cycle + roPumpDutyCyclePctSet = roPumpFlowToPWM( getTargetROPumpFlowRateMLPM() ); + roControlTimerCounter = 0; + isROPumpOn = TRUE; + result = TRUE; + } } // Requested flow rate is out of range else @@ -387,34 +394,42 @@ * @details \b Outputs: roPumpOpenLoopTargetDutyCycle, targetROPumpFlowRate, isROPumpOn, * roControlTimerCounter, roPumpDutyCyclePctSet, roPumpControlMode, targetROPumpPressure * @param roPressure which is target RO pressure + * @param firmwareCall indicates whether the call initiated by firmware + * internally or by dialin * @return TRUE if new target flow rate is set successfully, FALSE if not *************************************************************************/ BOOL setROPumpTargetPressure( F32 roPressure, BOOL firmwareCall ) { BOOL result = FALSE; + BOOL skipSet = FALSE; // First of all, the pressure must be in range if ( ( roPressure <= MAX_RO_PRESSURE_PSI ) && ( roPressure >= MIN_RO_PRESSURE_PSI ) ) { if ( firmwareCall == TRUE ) // firmware call { + // set the target flow and pressure to zero if there are no active override if ( ( targetROPumpFlowRate.override == OVERRIDE_RESET ) && ( targetROPumpPressure.override == OVERRIDE_RESET ) && ( roPumpOpenLoopTargetDutyCycle.override == OVERRIDE_RESET ) ) { targetROPumpFlowRate.data = 0; roPumpOpenLoopTargetDutyCycle.data = 0.0F; } + // skip the firmware set call if any override is active else { result = TRUE; - return result; + skipSet = TRUE; } } - targetROPumpPressure.data = roPressure; - // Get the initial guess of the duty cycle - roPumpDutyCyclePctSet = roPumpPresToPWM( getTargetROPumpPressure() ); - roControlTimerCounter = 0; - isROPumpOn = TRUE; - result = TRUE; + if ( FALSE == skipSet ) + { + targetROPumpPressure.data = roPressure; + // Get the initial guess of the duty cycle + roPumpDutyCyclePctSet = roPumpPresToPWM( getTargetROPumpPressure() ); + roControlTimerCounter = 0; + isROPumpOn = TRUE; + result = TRUE; + } } // Requested flow rate is out of range else @@ -434,43 +449,50 @@ * @details \b Outputs: roPumpOpenLoopTargetDutyCycle * roPumpControlMode, targetROPumpFlowRate, targetROPumpPressure * @param duty which is the duty cycle + * @param firmwareCall indicates whether the call initiated by firmware + * internally or by dialin * @return none *************************************************************************/ BOOL setROPumpTargetDutyCycle( F32 dutyCycle, BOOL firmwareCall ) { BOOL result = FALSE; + BOOL skipSet = FALSE; if ( ( dutyCycle >= MIN_FLUID_PUMP_DUTY_CYCLE_PCT ) && ( dutyCycle <= MAX_FLUID_PUMP_DUTY_CYCLE_PCT ) ) { if ( firmwareCall == TRUE ) // firmware call { + // set the target flow and pressure to zero if there are no active override if ( ( targetROPumpFlowRate.override == OVERRIDE_RESET ) && ( targetROPumpPressure.override == OVERRIDE_RESET ) && ( roPumpOpenLoopTargetDutyCycle.override == OVERRIDE_RESET ) ) { targetROPumpFlowRate.data = 0; targetROPumpPressure.data = 0.0F; } + // skip the firmware set call if any override is active else { result = TRUE; - return result; + skipSet = TRUE; } } - - // Set the new duty cycle of the pump - roPumpOpenLoopTargetDutyCycle.data = dutyCycle; - result = TRUE; - // stop RO Pump if duty cycle is set to zero - if ( dutyCycle == 0.0F ) + if ( FALSE == skipSet ) { - if ( ( targetROPumpFlowRate.data == 0 ) && ( targetROPumpPressure.data == 0.0F ) ) - { - signalROPumpHardStop(); - } + // Set the new duty cycle of the pump + roPumpOpenLoopTargetDutyCycle.data = dutyCycle; + result = TRUE; + // stop RO Pump if duty cycle is set to zero + if ( dutyCycle == 0.0F ) + { + if ( ( targetROPumpFlowRate.data == 0 ) && ( targetROPumpPressure.data == 0.0F ) ) + { + signalROPumpHardStop(); + } + } + else + { + setFluidPumpPctToPWMDutyCycle( P12_PUMP, getTargetROPumpDutyCyclePCT() ); + } } - else - { - setFluidPumpPctToPWMDutyCycle( P12_PUMP, getTargetROPumpDutyCyclePCT() ); - } } else { @@ -659,6 +681,7 @@ } } + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Drivers/FluidPump.c =================================================================== diff -u -r311c75cc5ac41b4b9ca4983df84e43af910f9be4 -r71ea7fe082e92a86b737983e3fb51e6f37072560 --- firmware/App/Drivers/FluidPump.c (.../FluidPump.c) (revision 311c75cc5ac41b4b9ca4983df84e43af910f9be4) +++ firmware/App/Drivers/FluidPump.c (.../FluidPump.c) (revision 71ea7fe082e92a86b737983e3fb51e6f37072560) @@ -318,6 +318,61 @@ return pwmCnt; } +/*********************************************************************//** + * @brief + * The handleFluidPumpU32Data function checks the OVERRIDE_U32_T and sets + * the current data to 0 and resets the override if it is active. + * @details \b Inputs: None + * @details \b Outputs: None + * @param ovU32 pointer to an unsigned integer override record + * @return none + *************************************************************************/ +void handleFluidPumpU32Data( OVERRIDE_U32_T *ovU32) +{ + if ( ovU32->data > 0 ) + { + if ( ovU32->override != OVERRIDE_RESET ) + { + ovU32->ovData = 0; + ovU32->override = OVERRIDE_RESET; + ovU32->data = 0; + } + else if ( ovU32->ovInitData == 0 ) + { + ovU32->ovInitData = ovU32->data; + ovU32->data = 0; + } + } +} + +/*********************************************************************//** + * @brief + * The handleFluidPumpF32Data function checks the OVERRIDE_F32_T and sets + * the current data to 0 and resets the override if it is active. + * @details \b Inputs: None + * @details \b Outputs: None + * @param ovF32 pointer to an floating point override record + * @return none + *************************************************************************/ +void handleFluidPumpF32Data( OVERRIDE_F32_T *ovF32) +{ + if ( ovF32->data > 0.0F ) + { + if ( ovF32->override != OVERRIDE_RESET ) + { + ovF32->ovData = 0.0F; + ovF32->override = OVERRIDE_RESET; + ovF32->data = 0.0F; + } + else if ( ovF32->ovInitData == 0.0F ) + { + ovF32->ovInitData = ovF32->data; + ovF32->data = 0.0F; + } + } +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Drivers/FluidPump.h =================================================================== diff -u -rd305dff19b8ce0fdd0d0f848a579da3d95bf4e31 -r71ea7fe082e92a86b737983e3fb51e6f37072560 --- firmware/App/Drivers/FluidPump.h (.../FluidPump.h) (revision d305dff19b8ce0fdd0d0f848a579da3d95bf4e31) +++ firmware/App/Drivers/FluidPump.h (.../FluidPump.h) (revision 71ea7fe082e92a86b737983e3fb51e6f37072560) @@ -60,6 +60,8 @@ F32 convertDutyCycleCntToPct( U32 dutyCycleCnt ); U16 convertDutyCyclePctToCnt( F32 dutyCyclePct ); BOOL setFluidPumpPctToPWMDutyCycle( FP_FLUID_PUMP_T pumpID, F32 dutyCyclePct); +void handleFluidPumpU32Data( OVERRIDE_U32_T *ovU32); +void handleFluidPumpF32Data( OVERRIDE_F32_T *ovF32); BOOL testSetFluidPumpPWM( MESSAGE_T *message ); BOOL testFluidPumpPWMOverride( MESSAGE_T *message );