Index: firmware/App/Modes/ModePostTreat.c =================================================================== diff -u -r253979e460b82c6d038e0a566f3be8c6df0a28c9 -racc8c3eb9d40711058bd214251d7554ab50b3836 --- firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision 253979e460b82c6d038e0a566f3be8c6df0a28c9) +++ firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision acc8c3eb9d40711058bd214251d7554ab50b3836) @@ -18,6 +18,7 @@ #include "Buttons.h" #include "ModePostTreat.h" #include "OperationModes.h" +#include "Switches.h" #include "TubeSetAutoEject.h" /** @@ -62,6 +63,7 @@ { initPostTreatmentMode(); initTubeSetAutoEject(); + doorClosedRequired(TRUE); setPostTreatStateTransition(); return (U32)currentPostTreatmentState; Index: firmware/App/Services/StateServices/TubeSetAutoEject.c =================================================================== diff -u -r253979e460b82c6d038e0a566f3be8c6df0a28c9 -racc8c3eb9d40711058bd214251d7554ab50b3836 --- firmware/App/Services/StateServices/TubeSetAutoEject.c (.../TubeSetAutoEject.c) (revision 253979e460b82c6d038e0a566f3be8c6df0a28c9) +++ firmware/App/Services/StateServices/TubeSetAutoEject.c (.../TubeSetAutoEject.c) (revision acc8c3eb9d40711058bd214251d7554ab50b3836) @@ -20,6 +20,7 @@ #include "Messaging.h" #include "OperationModes.h" #include "PeristalticPump.h" +#include "Switches.h" #include "TaskGeneral.h" #include "TubeSetAutoEject.h" @@ -40,6 +41,7 @@ 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 TUBE_SET_AUTO_EJECT_STATE_T currentAutoEjectState; ///< Current Tube Set Auto Eject state @@ -65,6 +67,7 @@ currentAutoEjectState = TUBE_SET_AUTO_EJECT_STATE_AWAIT_CONFIRMATION; autoEjectReqReceived = FALSE; autoEjectTimerCounter = 0; + bpLastHome = TRUE; } /*********************************************************************//** @@ -152,8 +155,10 @@ signalBloodPumpHardStop(); SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_AUTO_LOAD_EJECT_BP_TIMEOUT, (U32)isPeristalticPumpHome(), autoEjectTimerCounter ); } - else if ( TRUE == isPeristalticPumpHome() ) + else if ( TRUE != isPumpHomeInProgress() ) { + // Door close not required from this point (ejector mechanically pushes the door during eject) + doorClosedRequired(FALSE); extendEjector(); autoEjectTimerCounter = 0; state = TUBE_SET_AUTO_EJECT_STATE_EXTENDING_EJECTOR; @@ -186,6 +191,7 @@ else if ( EJECTOR_STATE_EXTENDED == getEjectorState() ) { setBloodPumpTargetFlowRate( AUTO_EJECT_BLOOD_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + bpLastHome = TRUE; autoEjectTimerCounter = 0; state = TUBE_SET_AUTO_EJECT_STATE_EJECTING; } @@ -210,13 +216,15 @@ static TUBE_SET_AUTO_EJECT_STATE_T handleAutoEjectEjectingState( void ) { TUBE_SET_AUTO_EJECT_STATE_T state = TUBE_SET_AUTO_EJECT_STATE_EJECTING; + BOOL bpCurrentHome = isPeristalticPumpHome(); if ( ++autoEjectTimerCounter >= AUTO_EJECT_OPERATION_TIMEOUT_INTERVAL ) { signalBloodPumpHardStop(); SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_AUTO_LOAD_EJECT_BP_TIMEOUT, isPeristalticPumpHome(), autoEjectTimerCounter ); } - else if ( TRUE == isPeristalticPumpHome() ) + // BP home position check (rising edge: motor must leave home and return) + else if ( ( TRUE == bpCurrentHome ) && ( FALSE == bpLastHome ) ) { signalBloodPumpHardStop(); retractEjector(); @@ -228,6 +236,8 @@ // No action required } + bpLastHome = bpCurrentHome; + return state; } 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 );