Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -r933a18d740285e70be9d00696ed0f5a5381bc8e4 -rb01542f8e4ef5a29e9b08fc0d465478de516bf02 --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 933a18d740285e70be9d00696ed0f5a5381bc8e4) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision b01542f8e4ef5a29e9b08fc0d465478de516bf02) @@ -153,7 +153,7 @@ static BOOL dopStopAtHomePosition = FALSE; ///< stop dialysate outlet pump at next home position static U32 dopHomeStartTime = 0; ///< when did dialysate outlet pump home command begin? (in ms) -static U16 dopLastMotorHallSensorCounts[ DOP_SPEED_CALC_BUFFER__LEN ]; ///< last hall sensor count for the blood pump motor +static U16 dopLastMotorHallSensorCounts[ DOP_SPEED_CALC_BUFFER__LEN ]; ///< last hall sensor count for the dialysate outlet pump motor static U32 dopMotorSpeedCalcIdx = 0; ///< index into 1 second buffer of motor speed hall sensor counts static U32 dopMotorSpeedCalcTimerCtr = 0; ///< counter determines interval for calculating dialysate outlet pump motor speed from hall sensor count. @@ -615,20 +615,22 @@ { F32 refVol = getTotalTargetDialOutUFVolumeInMl(); F32 totVol = getTotalMeasuredUFVolumeInMl(); - F32 newPWM; - F32 deltaPWM; + F32 newPWMDutyCyclePct; + F32 deltaPWMDutyCyclePct; // get new PWM from PI controller - newPWM = runPIController( PI_CONTROLLER_ID_ULTRAFILTRATION, refVol, totVol ); + newPWMDutyCyclePct = runPIController( PI_CONTROLLER_ID_ULTRAFILTRATION, refVol, totVol ); // limit PWM change to max - deltaPWM = newPWM - dialOutPumpPWMDutyCyclePctSet; - if ( fabs( deltaPWM ) > MAX_DIAL_OUT_PUMP_PWM_STEP_UP_CHANGE ) + deltaPWMDutyCyclePct = newPWMDutyCyclePct - dialOutPumpPWMDutyCyclePctSet; + if ( fabs( deltaPWMDutyCyclePct ) > MAX_DIAL_OUT_PUMP_PWM_STEP_UP_CHANGE ) { - newPWM = ( deltaPWM < 0.0 ? dialOutPumpPWMDutyCyclePctSet - MAX_DIAL_OUT_PUMP_PWM_STEP_UP_CHANGE : dialOutPumpPWMDutyCyclePctSet + MAX_DIAL_OUT_PUMP_PWM_STEP_UP_CHANGE ); + newPWMDutyCyclePct = ( deltaPWMDutyCyclePct < 0.0 ? \ + dialOutPumpPWMDutyCyclePctSet - MAX_DIAL_OUT_PUMP_PWM_STEP_UP_CHANGE : \ + dialOutPumpPWMDutyCyclePctSet + MAX_DIAL_OUT_PUMP_PWM_STEP_UP_CHANGE ); } // set new PWM - dialOutPumpPWMDutyCyclePctSet = newPWM; - setDialOutPumpControlSignalPWM( newPWM ); + dialOutPumpPWMDutyCyclePctSet = newPWMDutyCyclePct; + setDialOutPumpControlSignalPWM( newPWMDutyCyclePct ); } dopControlTimerCounter = 0; } @@ -925,7 +927,6 @@ { errorDialOutRotorSpeedPersistTimerCtr = 0; } - } else { @@ -991,6 +992,7 @@ * GET SUPPORT FUNCTIONS *************************************************************************/ + /*********************************************************************//** * @brief * The getPublishDialOutFlowDataInterval function gets the dialysate out flow