Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r15919f0c12c0047d3b6331c1f97cdad1dafb3f1b -re190a7eb5fb36d4a0c42e9db709571db3037d39d --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 15919f0c12c0047d3b6331c1f97cdad1dafb3f1b) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision e190a7eb5fb36d4a0c42e9db709571db3037d39d) @@ -110,6 +110,9 @@ #define DIP_PWM_FROM_ML_PER_MIN(rate) ( ( ( (rate) - 49.121F ) / 684.73F ) + DIP_PWM_ZERO_OFFSET ) /// Conversion from PWM duty cycle % to commanded pump motor speed. PWM range is 10% to 90%. RPM range is 0 to 3200. 3200 / 0.8 = 4000. #define DIP_PWM_TO_MOTOR_SPEED_RPM(pwm) ( ((pwm) - DIP_PWM_ZERO_OFFSET) * 4000.0F ) +// Macro converts PWM to estimate flow rate needed to achieve it. +#define DIP_ML_PER_MIN_FROM_PWM(pwm) ( (( pwm - DIP_PWM_ZERO_OFFSET) * 684.73 ) + 49.121 ) + /// Measured dialIn flow is filtered w/ moving average. #define SIZE_OF_ROLLING_AVG 10 @@ -261,10 +264,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) { BOOL result = FALSE; @@ -292,7 +296,7 @@ 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 + // 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 ) ); switch ( dialInPumpState ) @@ -1660,6 +1664,27 @@ } 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 testSetDialInPumpTargetDutyCycle( F32 value ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + setDialInPumpTargetFlowRate( (U32)DIP_ML_PER_MIN_FROM_PWM(value), MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + result = TRUE; + } + + return result; +} + /**@}*/