Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -rac6fc5b74e15c8925e4579c847ddfca8e1e361ad -r59a959e90acca96b44158dcd65706e83069dc859 --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision ac6fc5b74e15c8925e4579c847ddfca8e1e361ad) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 59a959e90acca96b44158dcd65706e83069dc859) @@ -105,7 +105,7 @@ /// Macro converts a flow rate to an estimated PWM duty cycle %. #define DOP_PWM_FROM_ML_PER_MIN(rate) ( ( ( rate ) * 0.0009F ) + 0.0972F + DOP_PWM_ZERO_OFFSET ) /// 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 ) +#define DOP_PWM_TO_MOTOR_SPEED_RPM(pwm,dir) ( ( ( ( pwm ) - DOP_PWM_ZERO_OFFSET) * 4000.0F ) * ( dir == MOTOR_DIR_FORWARD ? 1 : -1 ) ) /// Macro converts a PWM to an estimated flow rate. #define DOP_ML_PER_MIN_FROM_PWM(pwm) ( ( ( pwm - DOP_PWM_ZERO_OFFSET ) - 0.0972F ) / 0.0009F ) @@ -1016,7 +1016,7 @@ static void checkDialOutPumpSpeeds( void ) { F32 measMotorSpeed = getMeasuredDialOutPumpSpeed(); - F32 measMCMotorSpeed = fabs( getMeasuredDialOutPumpMCSpeed() ); + F32 measMCMotorSpeed = getMeasuredDialOutPumpMCSpeed(); // Check for pump running while commanded off if ( dialOutPumpPWMDutyCyclePctSet <= DOP_PWM_ZERO_OFFSET ) @@ -1046,11 +1046,11 @@ if ( DIAL_OUT_PUMP_CONTROL_TO_TARGET_STATE == dialOutPumpState ) { - F32 cmdMotorSpeed = DOP_PWM_TO_MOTOR_SPEED_RPM( dialOutPumpPWMDutyCyclePctSet ); + F32 cmdMotorSpeed = DOP_PWM_TO_MOTOR_SPEED_RPM( dialOutPumpPWMDutyCyclePctSet, dialOutPumpDirectionSet ); F32 deltaMotorSpeed = fabs( measMotorSpeed - cmdMotorSpeed ); F32 deltaMCMotorSpeed = fabs( measMCMotorSpeed - cmdMotorSpeed ); F32 measRotorSpeed = fabs( getMeasuredDialOutPumpRotorSpeed() ); - F32 measMotorSpeedInRotorRPM = measMotorSpeed / DOP_GEAR_RATIO; + F32 measMotorSpeedInRotorRPM = fabs( measMotorSpeed / DOP_GEAR_RATIO ); F32 deltaRotorSpeed = fabs( measRotorSpeed - measMotorSpeedInRotorRPM ); // Check measured motor speed vs. commanded motor speed while controlling to target