Index: firmware/App/Controllers/AirTrap.c =================================================================== diff -u -r0349cbffddfc93b2d444451906a515011a83a461 -r7f3bf72c038de385e8a0d743990069c039e13ba0 --- firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision 0349cbffddfc93b2d444451906a515011a83a461) +++ firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision 7f3bf72c038de385e8a0d743990069c039e13ba0) @@ -7,8 +7,8 @@ * * @file AirTrap.c * -* @author (last) Dara Navaei -* @date (last) 19-Dec-2025 +* @author (last) Sameer Kalliadan Poyil +* @date (last) 23-Mar-2026 * * @author (original) Sean Nash * @date (original) 24-Oct-2024 @@ -26,6 +26,7 @@ #include "Pressures.h" #include "Switches.h" #include "TaskGeneral.h" +#include "TestSupport.h" #include "Timers.h" #include "Utilities.h" #include "Valve3Way.h" @@ -49,7 +50,7 @@ /// Air pump on delay after fill adjustment static const U32 AIR_PUMP_ON_DELAY_ADJUST_AFTER_FILL = ( AIR_PUMP_ON_DELAY_TIME_MS - ( 1 * MS_PER_SECOND ) ); -#define AIR_PUMP_MOTOR_FILL_PWM 60.0F ///< Power level setting (PWM) in percentage for H12 air pump to fill (raise level) the air trap. +#define AIR_PUMP_MOTOR_FILL_PWM 24.0F ///< Power level setting (PWM) in percentage for H12 air pump to fill (raise level) the air trap. #define AIR_PUMP_MOTOR_LOWER_PWM 24.0F ///< Power level setting (PWM) in percentage for H12 air pump to lower the level of the air trap. /// ax2 + bx + c, x is long filtered venous pressure, a,b,c is quadratic coefficients @@ -369,8 +370,10 @@ { pendingStartAirTrapController = FALSE; setAirPumpState( AIR_PUMP_STATE_OFF, AIR_PUMP_MOTOR_OFF ); + set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); set3WayValveState( H20_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); + result = AIR_TRAP_CLOSED_STATE; } @@ -394,33 +397,49 @@ if ( TRUE == pendingStopAirTrapController ) { pendingStopAirTrapController = FALSE; + result = AIR_TRAP_MANUAL_CONTROL_STATE; } - + // Skip fill and lower level events when no tubing set is installed + else if ( TRUE == getTestConfigStatus( TEST_CONFIG_TESTING_WITHOUT_TUBING_SET ) ) + { + result = AIR_TRAP_CLOSED_STATE; + } // Lower air trap level if fluid reaches upper level. else if ( AIR_TRAP_LEVEL_FLUID == getLevelSensorState( H16_LEVL ) ) { if ( ( AIR_PUMP_STATE_OFF == getAirPumpState() ) && ( TRUE == didTimeout( airTrapLowerDelayStartTime, AIR_PUMP_ON_DELAY_TIME_MS ) ) ) { - set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_OPEN_STATE ); // open valve H13 to allow air to be pumped into air trap from atmosphere + // open valve H13 to allow air to be pumped into air trap from atmosphere + set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_OPEN_STATE ); + + // get long filtered H14 venous pressure before AP lower event airTrapAirPumpLowerPowerLevel.data = getCalculatedAirPumpDutyCycle(); setAirPumpState( AIR_PUMP_STATE_ON, getAirPumpLowerPowerLevel() ); + airTrapLowerStartTime = getMSTimerCount(); signalInitiatePressureStabilization( USE_SHORT_STABILIZATION_PERIOD ); + SEND_EVENT_WITH_2_U32_DATA( TD_EVENT_AIR_TRAP_LOWER, ON, 0 ); + result = AIR_TRAP_LOWER_LEVEL_STATE; } } - // Raise air trap level once at start of treatment (blood priming) or when air detected at lower level else if ( ( airTrapWasFilledAtStartOfTreatement != TRUE ) || ( AIR_TRAP_LEVEL_AIR == getLevelSensorState( H17_LEVL ) ) ) { + // fill/raise duty cycle is always 24% setAirPumpState( AIR_PUMP_STATE_ON, getAirPumpRaisePowerLevel() ); - set3WayValveState( H20_VALV, VALVE_3WAY_COMMON_TO_OPEN_STATE ); // open valve H20 to allow air to be pumped out of air trap to atmosphere + + // open valve H20 to allow air to be pumped out of air trap to atmosphere + set3WayValveState( H20_VALV, VALVE_3WAY_COMMON_TO_OPEN_STATE ); + airTrapFillStartTime = getMSTimerCount(); + SEND_EVENT_WITH_2_U32_DATA( TD_EVENT_AIR_TRAP_FILL, ON, 0 ); + result = AIR_TRAP_RAISE_LEVEL_STATE; } @@ -444,24 +463,31 @@ if ( TRUE == pendingStopAirTrapController ) { pendingStopAirTrapController = FALSE; + setAirPumpState( AIR_PUMP_STATE_OFF, AIR_PUMP_MOTOR_OFF ); set3WayValveState( H20_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); + result = AIR_TRAP_MANUAL_CONTROL_STATE; } // Transition back to lower level state when air trap fill completed else if ( AIR_TRAP_LEVEL_FLUID == getRawLevelSensorState( H16_LEVL ) ) { airTrapWasFilledAtStartOfTreatement = TRUE; + set3WayValveState( H20_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); - set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_OPEN_STATE ); // open valve H13 to allow air to be pumped into air trap from atmosphere - airTrapAirPumpLowerPowerLevel.data = getCalculatedAirPumpDutyCycle(); - setAirPumpState( AIR_PUMP_STATE_ON, getAirPumpLowerPowerLevel() ); + set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_OPEN_STATE ); + + setAirPumpState( AIR_PUMP_STATE_OFF, AIR_PUMP_MOTOR_OFF ); + // adjust the air trap lower delay start time after fill complete + // simulate that 9 sec is elapsed so that air pump will be turned on after 1 sec by decrementing 9000 mili sec from current time in milli sec airTrapLowerDelayStartTime = u32DiffWithWrap( AIR_PUMP_ON_DELAY_ADJUST_AFTER_FILL, getMSTimerCount() ); airTrapLowerStartTime = getMSTimerCount(); signalInitiatePressureStabilization( USE_SHORT_STABILIZATION_PERIOD ); - SEND_EVENT_WITH_2_U32_DATA( TD_EVENT_AIR_TRAP_LOWER, ON, 0 ); - result = AIR_TRAP_LOWER_LEVEL_STATE; + + SEND_EVENT_WITH_2_U32_DATA( TD_EVENT_AIR_TRAP_FILL, OFF, 0 ); + + result = AIR_TRAP_CLOSED_STATE; } return result; @@ -486,6 +512,7 @@ pendingStopAirTrapController = FALSE; setAirPumpState( AIR_PUMP_STATE_OFF, AIR_PUMP_MOTOR_OFF ); set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); + result = AIR_TRAP_MANUAL_CONTROL_STATE; } // Transition back to closed state when air trap lower level operation completed when air detected at upper level @@ -494,9 +521,12 @@ { setAirPumpState( AIR_PUMP_STATE_OFF, AIR_PUMP_MOTOR_OFF ); set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); + airTrapLowerDelayStartTime = getMSTimerCount(); signalLowVenousPressureCheck(); + SEND_EVENT_WITH_2_U32_DATA( TD_EVENT_AIR_TRAP_LOWER, OFF, 0 ); + result = AIR_TRAP_CLOSED_STATE; }