Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -r1d07de4e970f54f2ae1786ef546cf5567df9ba8e -r10c0ce336dc810a3d75d91cb2e14fc32e0e9f100 --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 1d07de4e970f54f2ae1786ef546cf5567df9ba8e) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 10c0ce336dc810a3d75d91cb2e14fc32e0e9f100) @@ -104,6 +104,8 @@ #define DOP_GEAR_RATIO 32.0F ///< Pump motor to pump gear ratio. #define DOP_PWM_ZERO_OFFSET 0.1F ///< 10% PWM duty cycle = zero speed. #define DOP_100_PCT_PWM_RPM_RANGE 4000.0F ///< 10-90% PWM range yields 0-3,200 RPM range. Full 100% PWM range would yield 4,000 RPM range. +#define DOP_RATE_CORRECTION_SCALAR 0.08F ///< Scalar for estimating DPo rate correction offset based on target Qd. +#define DOP_RATE_CORRECTION_OFFSET 25.0F ///< Offset for estimating DPo rate correction offset based on target Qd. /// 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 ) @@ -280,6 +282,13 @@ { pwmDC = ( 0 == flowRate ? DOP_PWM_ZERO_OFFSET : DOP_PWM_FROM_ML_PER_MIN( (F32)flowRate ) ); } + else + { // if rate correction offset not yet set, set it based on target dialysate flow rate + if ( fabs( dopRateCorrectionOffset ) < NEARLY_ZERO ) + { + dopRateCorrectionOffset = (F32)getTargetDialInFlowRate() * DOP_RATE_CORRECTION_SCALAR + DOP_RATE_CORRECTION_OFFSET; + } + } // Don't interrupt pump control unless rate or mode is changing if ( ( fabs( pwmDC - dialOutPumpPWMDutyCyclePct ) > NEARLY_ZERO ) || ( mode != dialOutPumpControlMode ) ) { @@ -375,6 +384,19 @@ /*********************************************************************//** * @brief + * The resetDialOutRateOffset function resets the dialysate outlet pump + * rate correction offset. Call this function before starting a new treatment. + * @details Inputs: none + * @details Outputs: dopRateCorrectionOffset + * @return none + *************************************************************************/ +void resetDialOutRateOffset( void ) +{ + dopRateCorrectionOffset = 0.0F; +} + +/*********************************************************************//** + * @brief * The setDialOutUFVolumes function sets the ultrafiltration reference and * measured total volumes (in mL). * @details Inputs: none