Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -rd4bc221d9817b488c2dcd00868386d7036a5c9a1 -rb20421d84b9049977c04f4752f4fc5697425f25c --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision d4bc221d9817b488c2dcd00868386d7036a5c9a1) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision b20421d84b9049977c04f4752f4fc5697425f25c) @@ -109,7 +109,7 @@ /// Conversion from PWM duty cycle % to commanded pump motor speed. #define DOP_PWM_TO_MOTOR_SPEED_RPM(pwm) ( ( ( pwm ) - DOP_PWM_ZERO_OFFSET) * 4000.0F ) /// Macro converts a PWM to an estimated flow rate. -#define DOP_ML_PER_MIN_FROM_PWM(pwm) ( ( ( pwm - DOP_PWM_ZERO_OFFSET - 0.0972 ) / 0.0009 ) ) +#define DOP_ML_PER_MIN_FROM_PWM(pwm) ( ( ( pwm - DOP_PWM_ZERO_OFFSET ) - 0.0972 ) / 0.0009 ) #define PUMP_DIR_ERROR_COUNT_MASK 0x3F ///< Bit mask for pump direction error counter. #define DOP_MIN_DIR_CHECK_SPEED_RPM 10.0F ///< Minimum motor speed before we check pump direction. @@ -295,7 +295,7 @@ dialOutPumpDirection = dir; dialOutPumpControlMode = 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 - dialOutPumpPWMDutyCyclePct = pwmDC; + dialOutPumpPWMDutyCyclePct = DOP_PWM_FROM_ML_PER_MIN(pwmDC); switch ( dialOutPumpState ) { @@ -1656,10 +1656,16 @@ BOOL testSetDialOutPumpTargetDutyCycle( F32 value ) { BOOL result = FALSE; + F32 targetPWM = DOP_ML_PER_MIN_FROM_PWM(value) ; if ( TRUE == isTestingActivated() ) { - setDialOutPumpTargetRate( (S32)DOP_ML_PER_MIN_FROM_PWM( value ), MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + // currently conversion can create negative values with values <= 10%. + if ( targetPWM < 0 ) + { + targetPWM = 0; + } + setDialOutPumpTargetRate( (U32)targetPWM, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); result = TRUE; }