Index: firmware/App/Services/StateServices/TubeSetAutoEject.c =================================================================== diff -u -r05e43e76b6ea947bf51326c43aae77582ad70943 -r5fb66a19c7ed117e6da6f6b28e85ec76abefd4be --- firmware/App/Services/StateServices/TubeSetAutoEject.c (.../TubeSetAutoEject.c) (revision 05e43e76b6ea947bf51326c43aae77582ad70943) +++ firmware/App/Services/StateServices/TubeSetAutoEject.c (.../TubeSetAutoEject.c) (revision 5fb66a19c7ed117e6da6f6b28e85ec76abefd4be) @@ -38,14 +38,12 @@ ///< Blood pump flow rate (mL/min) for the ejecting operation #define AUTO_EJECT_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 autoEjectReqReceived; ///< Flag indicating that user confirmed to eject tubeset static U32 autoEjectTimerCounter; ///< Timer counter shared across all auto-eject states 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_AUTO_EJECT_STATE_T currentAutoEjectState; ///< Current Tube Set Auto Eject state @@ -69,10 +67,11 @@ **************************************************************************/ void initTubeSetAutoEject( void ) { - currentAutoEjectState = TUBE_SET_AUTO_EJECT_STATE_AWAIT_CONFIRMATION; - autoEjectReqReceived = FALSE; - autoEjectTimerCounter = 0; - bpLastHome = TRUE; + currentAutoEjectState = TUBE_SET_AUTO_EJECT_STATE_AWAIT_CONFIRMATION; + autoEjectReqReceived = FALSE; + autoEjectTimerCounter = 0; + bpLastHome = TRUE; + bpLeftHomeTimerCounter = 0; } /*********************************************************************//** @@ -236,27 +235,35 @@ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_AUTO_LOAD_EJECT_BP_TIMEOUT, isPeristalticPumpHome(), autoEjectTimerCounter ); } // 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 >= AUTO_EJECT_OPERATION_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 ); retractEjector(); - autoEjectTimerCounter = 0; - state = TUBE_SET_AUTO_EJECT_STATE_RETRACTING_EJECTOR; + autoEjectTimerCounter = 0; + bpLeftHomeTimerCounter = 0; + state = TUBE_SET_AUTO_EJECT_STATE_RETRACTING_EJECTOR; } // BP home position check (rising edge: motor must leave home and return) else if ( ( TRUE == bpCurrentHome ) && ( FALSE == bpLastHome ) ) { signalBloodPumpHardStop(); retractEjector(); - autoEjectTimerCounter = 0; - state = TUBE_SET_AUTO_EJECT_STATE_RETRACTING_EJECTOR; + autoEjectTimerCounter = 0; + bpLeftHomeTimerCounter = 0; + state = TUBE_SET_AUTO_EJECT_STATE_RETRACTING_EJECTOR; } else { // No action required } + if ( TRUE == bpCurrentHome ) + { + bpLeftHomeTimerCounter = 0; + } + bpLastHome = bpCurrentHome; return state;