Index: firmware/App/Controllers/AirTrap.c =================================================================== diff -u -rbe1f6ba8f58abfe098865c85ebca070eb0dde6ce -r7fa60180faff90527b27843cbf6e4de21c566505 --- firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision be1f6ba8f58abfe098865c85ebca070eb0dde6ce) +++ firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision 7fa60180faff90527b27843cbf6e4de21c566505) @@ -51,6 +51,7 @@ #define AIR_PUMP_MOTOR_FILL_PWM 60 ///< Power level setting (PWM) for H12 air pump to fill (raise level) the air trap. #define AIR_PUMP_MOTOR_LOWER_PWM 250 ///< Power level setting (PWM) for H12 air pump to lower the level of the air trap. +#define AIR_PUMP_MOTOR_MAX_PWM_OVERRIDE 255 ///< Air pump motor maximum PWM to override. /// Defined states for the air trap controller state machine. typedef enum AirTrap_States @@ -362,10 +363,8 @@ // Lower air trap level if fluid reaches upper level. else if ( AIR_TRAP_LEVEL_FLUID == getLevelSensorState( H16_LEVL ) ) { - // TODO un-comment - //if ( ( AIR_PUMP_STATE_OFF == getAirPumpState() ) && - // ( TRUE == didTimeout( airTrapLowerDelayStartTime, AIR_PUMP_ON_DELAY_TIME_MS ) ) ) - if ( AIR_PUMP_STATE_OFF == getAirPumpState() ) + 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 setAirPumpState( AIR_PUMP_STATE_ON, getAirPumpLowerPowerLevel() ); @@ -442,7 +441,7 @@ // Air pump stop time based on the blood flow rate S32 qB = 500; // TODO abs( getTargetBloodFlowRate() ); U32 qBx = ( 0 == qB ? MIN_SET_BLOOD_FLOW_RATE : (U32)qB ); - U32 airPumpStopTime = 10000; //AIR_PUMP_LOWER_OP_TIME_MIN_MS + ( ( qBx - MIN_SET_BLOOD_FLOW_RATE ) / 2 ); + U32 airPumpStopTime = 1000; //AIR_PUMP_LOWER_OP_TIME_MIN_MS + ( ( qBx - MIN_SET_BLOOD_FLOW_RATE ) / 2 ); // Transition to manual valve control state when requested if ( TRUE == pendingStopAirTrapController ) @@ -452,11 +451,9 @@ set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); result = AIR_TRAP_MANUAL_CONTROL_STATE; } - // TODO investigate the timeout // Transition back to closed state when air trap lower level operation completed when air detected at upper level - //else if ( ( TRUE == didTimeout( airTrapLowerStartTime, airPumpStopTime ) ) || - // ( AIR_TRAP_LEVEL_AIR == getRawLevelSensorState( H16_LEVL ) ) ) - else if ( AIR_TRAP_LEVEL_AIR == getRawLevelSensorState( H16_LEVL ) ) + else if ( ( TRUE == didTimeout( airTrapLowerStartTime, airPumpStopTime ) ) || + ( AIR_TRAP_LEVEL_AIR == getRawLevelSensorState( H16_LEVL ) ) ) { setAirPumpState( AIR_PUMP_STATE_OFF, AIR_PUMP_MOTOR_OFF ); set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); @@ -601,7 +598,7 @@ *************************************************************************/ BOOL testAirPumpPowerRaiseOverride( MESSAGE_T *message ) { - BOOL result = u32Override( message, &airTrapAirPumpRaisePowerLevel, AIR_PUMP_MOTOR_OFF, AIR_PUMP_MOTOR_MAX_PWM ); + BOOL result = u32Override( message, &airTrapAirPumpRaisePowerLevel, AIR_PUMP_MOTOR_OFF, AIR_PUMP_MOTOR_MAX_PWM_OVERRIDE ); return result; } @@ -618,7 +615,7 @@ *************************************************************************/ BOOL testAirPumpPowerLowerOverride( MESSAGE_T *message ) { - BOOL result = u32Override( message, &airTrapAirPumpLowerPowerLevel, AIR_PUMP_MOTOR_OFF, AIR_PUMP_MOTOR_MAX_PWM ); + BOOL result = u32Override( message, &airTrapAirPumpLowerPowerLevel, AIR_PUMP_MOTOR_OFF, AIR_PUMP_MOTOR_MAX_PWM_OVERRIDE ); return result; }