Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -rac56e4e0486aedb65cfce74a6d0724281ca6fb7f -r569787ec23f8738c3bc5d1b760a5b22dd0753e45 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision ac56e4e0486aedb65cfce74a6d0724281ca6fb7f) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 569787ec23f8738c3bc5d1b760a5b22dd0753e45) @@ -285,7 +285,8 @@ * The setDialInPumpTargetFlowRate function sets a new target flow rate and * pump direction. * @details Inputs: isDialInPumpOn, dialInPumpDirectionSet - * @details Outputs: targetDialInFlowRate, dialInPumpdirection, dialInPumpPWMDutyCyclePct + * @details Outputs: targetDialInFlowRate, dialInPumpdirection, + * dialInPumpPWMDutyCyclePct, isTestPWMSet * @param flowRate new target dialIn flow rate * @param dir new dialIn flow direction * @param mode new control mode @@ -304,7 +305,7 @@ if ( ( dirFlowRate != targetDialInFlowRate ) || ( mode != dialInPumpControlMode ) ) { BOOL isFlowRateInRange = ( flowRate <= MAX_DIAL_IN_FLOW_RATE ? TRUE : FALSE ); - + isTestPWMSet = FALSE; #ifndef _RELEASE_ if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_PUMPS_FLOW_LIMITS ) ) { @@ -1512,21 +1513,23 @@ { MOTOR_DIR_T dir = MOTOR_DIR_FORWARD; BOOL result = FALSE; + F32 pwmFabs = fabs(pwm); - if ( NEARLY_ZERO < pwm ) + if ( pwm < 0 ) { dir = MOTOR_DIR_REVERSE; } + // Direction change while pump is running is not allowed if ( ( FALSE == isDialInPumpOn ) || ( 0 == dialInPumpPWMDutyCyclePct ) || ( dir == dialInPumpDirectionSet ) ) { // Don't interrupt pump control unless rate is changing - if ( ( pwm != dialInPumpPWMDutyCyclePct ) ) + if ( ( pwmFabs != dialInPumpPWMDutyCyclePct ) ) { resetDialInFlowMovingAverage(); dialInPumpDirection = dir; dialInPumpControlMode = PUMP_CONTROL_MODE_OPEN_LOOP; - dialInPumpPWMDutyCyclePct = RANGE( dialInPumpPWMDutyCyclePct, MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE, MAX_DIAL_IN_PUMP_PWM_DUTY_CYCLE ); + dialInPumpPWMDutyCyclePct = RANGE( pwmFabs, MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE, MAX_DIAL_IN_PUMP_PWM_DUTY_CYCLE ); switch ( dialInPumpState ) { @@ -1915,9 +1918,7 @@ isTestPWMSet = TRUE; } - - setDialInPumpWithPWM( pwmPct ); - result = TRUE; + result = setDialInPumpWithPWM( pwmPct ); } }