Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -r5e77f78c5dee9dfb441bd5d2053f7f4ac50dc619 -r29e57b5232f605a871c62580e16a7db297aae992 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 5e77f78c5dee9dfb441bd5d2053f7f4ac50dc619) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 29e57b5232f605a871c62580e16a7db297aae992) @@ -55,8 +55,10 @@ #define BP_HOME_RATE 100 ///< target pump speed (in estimate mL/min) for homing. #define BP_HOME_TIMEOUT_MS 10000 ///< maximum time allowed for homing to complete (in ms). -#define BP_SPEED_CALC_INTERVAL ( 40 / TASK_PRIORITY_INTERVAL ) ///< interval (ms/task time) at which the blood pump speed is calculated. -#define BP_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 BP_SPEED_CALC_INTERVAL ( 40 / TASK_PRIORITY_INTERVAL ) +/// number of hall sensor counts kept in buffer to hold last 1 second of count data. +#define BP_SPEED_CALC_BUFFER__LEN ( 1000 / BP_SPEED_CALC_INTERVAL / TASK_PRIORITY_INTERVAL ) #define BP_HALL_EDGE_COUNTS_PER_REV 48 ///< number of hall sensor edge counts per motor revolution. #define BP_MAX_ROTOR_SPEED_RPM 100.0 ///< maximum rotor speed allowed for blood pump. @@ -905,7 +907,9 @@ { U16 bpMotorHallSensorCount = getFPGABloodPumpHallSensorCount(); U32 nextIdx = INC_WRAP( bpMotorSpeedCalcIdx, 0, BP_SPEED_CALC_BUFFER__LEN - 1 ); - U16 incDelta = ( bpMotorHallSensorCount >= bpLastMotorHallSensorCounts[ nextIdx ] ? bpMotorHallSensorCount - bpLastMotorHallSensorCounts[ nextIdx ] : ( HEX_64_K - bpLastMotorHallSensorCounts[ nextIdx ] ) + bpMotorHallSensorCount ); + U16 incDelta = ( bpMotorHallSensorCount >= bpLastMotorHallSensorCounts[ bpMotorSpeedCalcIdx ] ? \ + bpMotorHallSensorCount - bpLastMotorHallSensorCounts[ bpMotorSpeedCalcIdx ] : \ + ( HEX_64_K - bpLastMotorHallSensorCounts[ bpMotorSpeedCalcIdx ] ) + bpMotorHallSensorCount ); U16 decDelta = HEX_64_K - incDelta; U16 delta; Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r5e77f78c5dee9dfb441bd5d2053f7f4ac50dc619 -r29e57b5232f605a871c62580e16a7db297aae992 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 5e77f78c5dee9dfb441bd5d2053f7f4ac50dc619) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 29e57b5232f605a871c62580e16a7db297aae992) @@ -52,8 +52,10 @@ #define DIP_HOME_RATE 100 ///< target pump speed (in estimate mL/min) for homing. #define DIP_HOME_TIMEOUT_MS 10000 ///< maximum time allowed for homing to complete (in ms). -#define DIP_SPEED_CALC_INTERVAL ( 40 / TASK_PRIORITY_INTERVAL ) ///< interval (ms/task time) at which the dialysate inlet pump speed is calculated. -#define DIP_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 DIP_SPEED_CALC_INTERVAL ( 40 / TASK_PRIORITY_INTERVAL ) +/// number of hall sensor counts kept in buffer to hold last 1 second of count data. +#define DIP_SPEED_CALC_BUFFER__LEN ( 1000 / DIP_SPEED_CALC_INTERVAL / TASK_PRIORITY_INTERVAL ) #define DIP_HALL_EDGE_COUNTS_PER_REV 48 ///< number of hall sensor edge counts per motor revolution. #define DIP_MAX_FLOW_VS_SPEED_DIFF_ML_MIN 50.0 ///< maximum difference between measured flow and flow implied by measured motor speed. @@ -884,7 +886,9 @@ { U16 dipMotorHallSensorCount = getFPGADialInPumpHallSensorCount(); U32 nextIdx = INC_WRAP( dipMotorSpeedCalcIdx, 0, DIP_SPEED_CALC_BUFFER__LEN - 1 ); - U16 incDelta = ( dipMotorHallSensorCount >= dipLastMotorHallSensorCounts[ nextIdx ] ? dipMotorHallSensorCount - dipLastMotorHallSensorCounts[ nextIdx ] : ( HEX_64_K - dipLastMotorHallSensorCounts[ nextIdx ] ) + dipMotorHallSensorCount ); + U16 incDelta = ( dipMotorHallSensorCount >= dipLastMotorHallSensorCounts[ dipMotorSpeedCalcIdx ] ? \ + dipMotorHallSensorCount - dipLastMotorHallSensorCounts[ dipMotorSpeedCalcIdx ] : \ + ( HEX_64_K - dipLastMotorHallSensorCounts[ dipMotorSpeedCalcIdx ] ) + dipMotorHallSensorCount ); U16 decDelta = HEX_64_K - incDelta; U16 delta; 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; Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -r5e77f78c5dee9dfb441bd5d2053f7f4ac50dc619 -r29e57b5232f605a871c62580e16a7db297aae992 --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 5e77f78c5dee9dfb441bd5d2053f7f4ac50dc619) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 29e57b5232f605a871c62580e16a7db297aae992) @@ -18,7 +18,8 @@ #include "mibspi.h" #include "AlarmLamp.h" -#include "OperationModes.h" +#include "OperationModes.h" +#include "SafetyShutdown.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" #include "Timers.h" @@ -1048,6 +1049,8 @@ result = TRUE; } } + // in case any previously active alarms had pulled safety shutdown, release safety + testResetSafetyShutdownOverride(); return result; }