Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -raf2cd84d3319b1e298057fe2d329aa7824306507 -rd28280f1054fc9ddf9304a11373dc9ee963425e3 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision af2cd84d3319b1e298057fe2d329aa7824306507) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision d28280f1054fc9ddf9304a11373dc9ee963425e3) @@ -261,10 +261,11 @@ * @details Outputs: targetDialInFlowRate, dialInPumpdirection, dialInPumpPWMDutyCyclePct * @param flowRate new target dialIn flow rate * @param dir new dialIn flow direction - * @param mode new control mode + * @param mode new control mode + * @param pwm PWM duty cycle to set pump controller to (optional for open loop) * @return TRUE if new flow rate & dir are set, FALSE if not *************************************************************************/ -BOOL setDialInPumpTargetFlowRate( U32 flowRate, MOTOR_DIR_T dir, PUMP_CONTROL_MODE_T mode ) +BOOL setDialInPumpTargetFlowRate( U32 flowRate, MOTOR_DIR_T dir, PUMP_CONTROL_MODE_T mode, F32 pwm ) { BOOL result = FALSE; @@ -292,8 +293,15 @@ targetDialInFlowRate = dirFlowRate; dialInPumpDirection = dir; dialInPumpControlMode = mode; - // Set PWM duty cycle target to an estimated initial target to ramp to based on target flow rate - then we will control to flow when ramp completed - dialInPumpPWMDutyCyclePct = ( 0 == flowRate ? DIP_PWM_ZERO_OFFSET : DIP_PWM_FROM_ML_PER_MIN( (F32)flowRate ) ); + // Set PWM duty cycle target to an estimated initial target to ramp to based on target flow rate - then we will control to flow when ramp completed + if ( PUMP_CONTROL_MODE_CLOSED_LOOP == mode || fabs(pwm) < NEARLY_ZERO ) + { + dialInPumpPWMDutyCyclePct = ( 0 == flowRate ? DIP_PWM_ZERO_OFFSET : DIP_PWM_FROM_ML_PER_MIN( (F32)flowRate ) ); + } + else // Dialin command to open loop w/ set PWM duty cycle + { + dialInPumpPWMDutyCyclePct = pwm; + } switch ( dialInPumpState ) { @@ -403,7 +411,7 @@ { dipStopAtHomePosition = TRUE; dipHomeStartTime = getMSTimerCount(); - result = setDialInPumpTargetFlowRate( DIP_HOME_RATE, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + result = setDialInPumpTargetFlowRate( DIP_HOME_RATE, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP, 0.0F ); } return result; @@ -1397,7 +1405,7 @@ } else { - result = setDialInPumpTargetFlowRate( abs(value), dir, (PUMP_CONTROL_MODE_T)ctrlMode ); + result = setDialInPumpTargetFlowRate( abs(value), dir, (PUMP_CONTROL_MODE_T)ctrlMode, 0.0F ); } } } @@ -1644,12 +1652,11 @@ if ( TRUE == isTestingActivated() ) { - targetDialInFlowRate = (S32) DIP_ML_PER_MIN_FROM_PWM( value ); + setDialInPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP, value ); result = TRUE; } return result; } - /**@}*/