Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -r5e77f78c5dee9dfb441bd5d2053f7f4ac50dc619 -r29e57b5232f605a871c62580e16a7db297aae992 --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 5e77f78c5dee9dfb441bd5d2053f7f4ac50dc619) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 29e57b5232f605a871c62580e16a7db297aae992) @@ -55,8 +55,10 @@ #define DOP_HOME_RATE 100 ///< target pump speed (in estimate mL/min) for homing. #define DOP_HOME_TIMEOUT_MS 10000 ///< maximum time allowed for homing to complete (in ms). -#define DOP_SPEED_CALC_INTERVAL ( 40 / TASK_PRIORITY_INTERVAL ) ///< interval (ms/task time) at which the dialysate outlet pump speed is calculated. -#define DOP_SPEED_CALC_BUFFER__LEN 25 ///< number of hall sensor counts kept in buffer to hold last 1 second of count data. +/// interval (ms/task time) at which the blood pump speed is calculated (every 40 ms). +#define DOP_SPEED_CALC_INTERVAL ( 40 / TASK_PRIORITY_INTERVAL ) +/// number of hall sensor counts kept in buffer to hold last 1 second of count data. +#define DOP_SPEED_CALC_BUFFER__LEN ( 1000 / DOP_SPEED_CALC_INTERVAL / TASK_PRIORITY_INTERVAL ) #define DOP_HALL_EDGE_COUNTS_PER_REV 48 ///< number of hall sensor edge counts per motor revolution. #define DOP_MAX_MOTOR_SPEED_WHILE_OFF_RPM 100.0 ///< maximum motor speed (RPM) while motor is commanded off. @@ -750,7 +752,9 @@ { U16 dopMotorHallSensorCount = getFPGADialOutPumpHallSensorCount(); U32 nextIdx = INC_WRAP( dopMotorSpeedCalcIdx, 0, DOP_SPEED_CALC_BUFFER__LEN - 1 ); - U16 incDelta = ( dopMotorHallSensorCount >= dopLastMotorHallSensorCounts[ nextIdx ] ? dopMotorHallSensorCount - dopLastMotorHallSensorCounts[ nextIdx ] : ( HEX_64_K - dopLastMotorHallSensorCounts[ nextIdx ] ) + dopMotorHallSensorCount ); + U16 incDelta = ( dopMotorHallSensorCount >= dopLastMotorHallSensorCounts[ dopMotorSpeedCalcIdx ] ? \ + dopMotorHallSensorCount - dopLastMotorHallSensorCounts[ dopMotorSpeedCalcIdx ] : \ + ( HEX_64_K - dopLastMotorHallSensorCounts[ dopMotorSpeedCalcIdx ] ) + dopMotorHallSensorCount ); U16 decDelta = HEX_64_K - incDelta; U16 delta;