Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -rf7cecfd05b7fd84735ea35b1fa3782d29a786ee0 -r236e5a9331b60710d1eb45ed3c70e90885fe24f6 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision f7cecfd05b7fd84735ea35b1fa3782d29a786ee0) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 236e5a9331b60710d1eb45ed3c70e90885fe24f6) @@ -106,8 +106,7 @@ #define DIP_GEAR_RATIO 32.0F ///< DialIn pump motor to dialIn pump gear ratio. #define DIP_PWM_ZERO_OFFSET 0.1F ///< 10% PWM duty cycle = zero speed. -/// Macro converts flow rate to estimate PWM needed to achieve it. -//#define DIP_PWM_FROM_ML_PER_MIN(rate) ( ( ( (rate) - 49.121F ) / 684.73F ) + DIP_PWM_ZERO_OFFSET ) +/// Macro converts flow rate to estimate PWM needed to achieve it. #define DIP_PWM_FROM_ML_PER_MIN(rate) ( (rate) * DIP_ML_PER_MIN_TO_PUMP_RPM_FACTOR * DIP_GEAR_RATIO * DIP_MOTOR_RPM_TO_PWM_DC_FACTOR + 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 ) @@ -316,7 +315,6 @@ 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 ) ); dialInPumpPWMDutyCyclePct = ( 0 == flowRate ? DIP_PWM_ZERO_OFFSET : dialysateInPumpPWMFromTargetFlowRate( (F32)flowRate ) ); switch ( dialInPumpState ) @@ -392,7 +390,7 @@ * hall sensor detection. Calculates rotor speed (in RPM). Stops pump if * there is a pending request to home the pump. * @details Inputs: dipRotorRevStartTime, dipStopAtHomePosition - * @details Outputs: dipRotorRevStartTime, dialInPumpRotorSpeedRPM + * @details Outputs: dipRotorRevStartTime, dialInPumpRotorSpeedRPM, dialysateInPumpRotorCounter, dipStopAtHomePosition * @return none *************************************************************************/ void signalDialInPumpRotorHallSensor( void ) @@ -1074,8 +1072,7 @@ flowReadings[ flowReadingsIdx ] = flow; flowReadingsTotal += flow; flowReadingsIdx = INC_WRAP( flowReadingsIdx, 0, SIZE_OF_ROLLING_AVG - 1 ); - flowReadingsCount = INC_CAP( flowReadingsCount, SIZE_OF_ROLLING_AVG ); - //measuredDialInFlowRate.data = (F32)( flowReadingsTotal / (F64)flowReadingsCount ); + flowReadingsCount = INC_CAP( flowReadingsCount, SIZE_OF_ROLLING_AVG ); filteredDialInFlowMeterReading = (F32)( flowReadingsTotal / (F64)flowReadingsCount ); }