Index: firmware/App/Services/StateServices/TubeSetInstall.c =================================================================== diff -u -r253979e460b82c6d038e0a566f3be8c6df0a28c9 -racc8c3eb9d40711058bd214251d7554ab50b3836 --- firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision 253979e460b82c6d038e0a566f3be8c6df0a28c9) +++ firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision acc8c3eb9d40711058bd214251d7554ab50b3836) @@ -46,6 +46,7 @@ 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 TUBE_SET_INSTALL_STATE_T currentInstallState; ///< Current Tubing Set Install sub-state @@ -70,6 +71,7 @@ currentInstallState = TUBE_SET_INSTALL_STATE_AWAIT_TUBE_SET_CONFIRMATION; confirmTubesetPlaced = FALSE; bloodPumpTimerCounter = 0; + bpLastHome = TRUE; } /*********************************************************************//** @@ -151,7 +153,8 @@ if ( FALSE == isAlarmActive( ALARM_ID_TD_CARTRIDGE_DOOR_OPENED ) ) { setBloodPumpTargetFlowRate( AUTO_LOAD_BLOOD_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); - state = TUBE_SET_INSTALL_STATE_AUTO_LOAD; + bpLastHome = TRUE; + state = TUBE_SET_INSTALL_STATE_AUTO_LOAD; } return state; @@ -170,6 +173,7 @@ { TUBE_SET_INSTALL_STATE_T state = TUBE_SET_INSTALL_STATE_AUTO_LOAD; F32 bpTorque = getMeasuredBloodPumpTorque(); + BOOL bpCurrentHome = isPeristalticPumpHome(); // Timeout check if ( ++bloodPumpTimerCounter >= BLOOD_PUMP_TIMEOUT_INTERVAL ) @@ -186,8 +190,8 @@ bloodPumpTimerCounter = 0; state = TUBE_SET_INSTALL_STATE_AUTO_LOAD_BACK_OFF; } - // BP home position check - else if ( TRUE == isPeristalticPumpHome() ) + // BP home position check (rising edge: motor must leave home and return) + else if ( ( TRUE == bpCurrentHome ) && ( FALSE == bpLastHome ) ) { signalBloodPumpHardStop(); bloodPumpTimerCounter = 0; @@ -198,6 +202,8 @@ // No action required } + bpLastHome = bpCurrentHome; + return state; } @@ -213,7 +219,7 @@ { TUBE_SET_INSTALL_STATE_T state = TUBE_SET_INSTALL_STATE_AUTO_LOAD_BACK_OFF; - if ( bloodPumpTimerCounter >= BLOOD_PUMP_TIMEOUT_INTERVAL ) + if ( ++bloodPumpTimerCounter >= BLOOD_PUMP_TIMEOUT_INTERVAL ) { signalBloodPumpHardStop(); SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_AUTO_LOAD_EJECT_BP_TIMEOUT, isPeristalticPumpHome(), bloodPumpTimerCounter );