Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -r15919f0c12c0047d3b6331c1f97cdad1dafb3f1b -re190a7eb5fb36d4a0c42e9db709571db3037d39d --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 15919f0c12c0047d3b6331c1f97cdad1dafb3f1b) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision e190a7eb5fb36d4a0c42e9db709571db3037d39d) @@ -103,9 +103,11 @@ #define DOP_PWM_ZERO_OFFSET 0.1F ///< 10% PWM duty cycle = zero speed. /// Macro converts a flow rate to an estimated PWM duty cycle %. -#define DOP_PWM_FROM_ML_PER_MIN(rate) ( ( (rate) * 0.0009 ) + 0.0972 + DOP_PWM_ZERO_OFFSET ) +#define DOP_PWM_FROM_ML_PER_MIN(rate) ( ( ( rate ) * 0.0009 ) + 0.0972 + 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) ( ( ( 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 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. @@ -291,7 +293,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 ) { @@ -1641,4 +1643,32 @@ return result; } +/*********************************************************************//** + * @brief + * The testSetDialInPumpTargetDutyCycle function resets the override of the + * measured dialIn pump motor current. + * @details Inputs: none + * @details Outputs: adcDialInPumpMCCurrentmA + * @return TRUE if reset successful, FALSE if not + *************************************************************************/ +BOOL testSetDialOutPumpTargetDutyCycle( F32 value ) +{ + BOOL result = FALSE; + F32 targetPWM = DOP_ML_PER_MIN_FROM_PWM(value) ; + + if ( TRUE == isTestingActivated() ) + { + // 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; + } + + return result; +} + + /**@}*/