Index: firmware/App/Controllers/AirTrap.c =================================================================== diff -u -r1e5bc8dd7ce3ba97104df3d1b12f98d4a4f97234 -r5b25cf850d5e37d46a09895508c524cff9ed9e9f --- firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision 1e5bc8dd7ce3ba97104df3d1b12f98d4a4f97234) +++ firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision 5b25cf850d5e37d46a09895508c524cff9ed9e9f) @@ -50,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 @@ -370,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; } @@ -395,6 +397,7 @@ if ( TRUE == pendingStopAirTrapController ) { pendingStopAirTrapController = FALSE; + result = AIR_TRAP_MANUAL_CONTROL_STATE; } // Skip fill and lower level events when no tubing set is installed @@ -408,23 +411,35 @@ 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; } @@ -448,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; @@ -490,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 @@ -498,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; }