Index: firmware/App/Services/StateServices/TubeSetInstall.c =================================================================== diff -u -r05e43e76b6ea947bf51326c43aae77582ad70943 -r5fb66a19c7ed117e6da6f6b28e85ec76abefd4be --- firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision 05e43e76b6ea947bf51326c43aae77582ad70943) +++ firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision 5fb66a19c7ed117e6da6f6b28e85ec76abefd4be) @@ -36,17 +36,15 @@ ///< BP timeout interval (ms/task time) #define BLOOD_PUMP_TIMEOUT_INTERVAL ( ( 10 * MS_PER_SECOND ) / TASK_GENERAL_INTERVAL ) -//< Blood pump flow rate (mL/min) for Auto-Load operation -#define AUTO_LOAD_BLOOD_FLOW_RATE_ML_MIN 100U +///< Blood pump flow rate (mL/min) for Auto-Load operation +#define AUTO_LOAD_BLOOD_FLOW_RATE_ML_MIN 100U -/// Blood pump torque threshold (mN.m) above which a tube-set jam is declared -#define BP_TORQUE_LIMIT_MNM 9999.0F // TODO: Replace with lab characterized value - // ********** private data ********** static BOOL confirmTubesetPlaced; ///< Flag indicating user has confirmed tubeset is placed static U32 bloodPumpTimerCounter; ///< Blood Pump timer counter static BOOL bpLastHome; ///< Flag for Blood Pump last home (for rising-edge) +static U32 bpLeftHomeTimerCounter; ///< Timer Counter to measure how long BP has been away from home static TUBE_SET_INSTALL_STATE_T currentInstallState; ///< Current Tubing Set Install sub-state @@ -68,10 +66,11 @@ **************************************************************************/ void initTubeSetInstall( void ) { - currentInstallState = TUBE_SET_INSTALL_STATE_AWAIT_TUBE_SET_CONFIRMATION; - confirmTubesetPlaced = FALSE; - bloodPumpTimerCounter = 0; - bpLastHome = TRUE; + currentInstallState = TUBE_SET_INSTALL_STATE_AWAIT_TUBE_SET_CONFIRMATION; + confirmTubesetPlaced = FALSE; + bloodPumpTimerCounter = 0; + bpLastHome = TRUE; + bpLeftHomeTimerCounter = 0; } /*********************************************************************//** @@ -181,26 +180,34 @@ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_AUTO_LOAD_EJECT_BP_TIMEOUT, isPeristalticPumpHome(), bloodPumpTimerCounter ); } // Torque jam check. If measured torque exceeds the limit, the tubing set is likely jammed in the rotor. - else if ( bpTorque > BP_TORQUE_LIMIT_MNM ) + else if ( ( ( FALSE == bpLastHome ) && ( ++bpLeftHomeTimerCounter >= BLOOD_PUMP_TIMEOUT_INTERVAL ) ) || + ( bpTorque > AUTO_LOAD_EJECT_BP_TORQUE_LIMIT ) ) { signalBloodPumpHardStop(); SET_ALARM_WITH_1_F32_DATA( ALARM_ID_TD_AUTO_LOAD_EJECT_HIGH_BP_TORQUE, bpTorque ); setBloodPumpTargetFlowRate( AUTO_LOAD_BLOOD_FLOW_RATE_ML_MIN, MOTOR_DIR_REVERSE, PUMP_CONTROL_MODE_OPEN_LOOP ); - bloodPumpTimerCounter = 0; - state = TUBE_SET_INSTALL_STATE_AUTO_LOAD_BACK_OFF; + bloodPumpTimerCounter = 0; + bpLeftHomeTimerCounter = 0; + state = TUBE_SET_INSTALL_STATE_AUTO_LOAD_BACK_OFF; } // BP home position check (rising edge: motor must leave home and return) else if ( ( TRUE == bpCurrentHome ) && ( FALSE == bpLastHome ) ) { signalBloodPumpHardStop(); - bloodPumpTimerCounter = 0; - state = TUBE_SET_INSTALL_STATE_COMPLETE; + bloodPumpTimerCounter = 0; + bpLeftHomeTimerCounter = 0; + state = TUBE_SET_INSTALL_STATE_COMPLETE; } else { // No action required } + if ( TRUE == bpCurrentHome ) + { + bpLeftHomeTimerCounter = 0; + } + bpLastHome = bpCurrentHome; return state;