Index: firmware/App/Controllers/AirPump.c =================================================================== diff -u -r42ce3a1717fa1afc0089666df23e02bf4e31764a -r984bd22d53c604713e6b3a22a536c64a920e9100 --- firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision 42ce3a1717fa1afc0089666df23e02bf4e31764a) +++ firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision 984bd22d53c604713e6b3a22a536c64a920e9100) @@ -21,6 +21,7 @@ #include "AlarmMgmt.h" #include "ModeTreatmentParams.h" #include "OperationModes.h" +#include "PersistentAlarm.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" #include "TaskPriority.h" @@ -36,7 +37,7 @@ #define AIR_PUMP_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) #define DATA_PUBLISH_COUNTER_START_COUNT #define AIR_PUMP_GPIO_PIN 0x04 -#define AIR_PUMP_PERSISTENCE_TIMEOUT ( 10 * MS_PER_SECOND ) +#define AIR_PUMP_OPERATION_TIMEOUT ( 5 * MS_PER_SECOND ) typedef enum AirPumpMotorStates { @@ -72,7 +73,7 @@ { currentAirPumpState = AIR_PUMP_STATE_INIT; currentAirPumpMotorState = AIR_PUMP_MOTOR_OFF; - initPersistentAlarm(ALARM_ID_HD_AIR_PUMP_TIMEOUT, 0, AIR_PUMP_PERSISTENCE_TIMEOUT); + initPersistentAlarm( ALARM_ID_HD_AIR_PUMP_TIMEOUT, 0, AIR_PUMP_OPERATION_TIMEOUT ); } /*********************************************************************//** @@ -163,6 +164,7 @@ if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_AIR_PUMP_TIMEOUT, getAirPumpMotorState() ) ) { SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_AIR_PUMP_TIMEOUT, getAirPumpMotorState() ); + setAirPumpState(AIR_PUMP_STATE_OFF); } publishAirPumpData(); Index: firmware/App/Controllers/AirTrap.c =================================================================== diff -u -rfae5ed2aeb0f330868f37ff37dd49cb29e5476f2 -r984bd22d53c604713e6b3a22a536c64a920e9100 --- firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision fae5ed2aeb0f330868f37ff37dd49cb29e5476f2) +++ firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision 984bd22d53c604713e6b3a22a536c64a920e9100) @@ -34,10 +34,11 @@ // ********** private definitions ********** /// Interval (ms/task time) at which the air trap data is published on the CAN bus. -#define AIR_TRAP_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) +#define AIR_TRAP_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) +#define AIR_PUMP_UPPER_LEVEL_PERSISTENCE ( 2 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) /// Persistence period for illegal level sensors fault. -static const U32 AIR_TRAP_ILLEGAL_LEVELS_PERSISTENCE = ( MS_PER_SECOND * 2 / TASK_PRIORITY_INTERVAL ); -static const U32 AIR_TRAP_UPPER_LEVEL_PERSISTENCE = ( MS_PER_SECOND * 2 / TASK_PRIORITY_INTERVAL ); +static const U32 AIR_TRAP_ILLEGAL_LEVELS_PERSISTENCE = ( MS_PER_SECOND * 2 / TASK_GENERAL_INTERVAL ); +static const U32 AIR_TRAP_UPPER_LEVEL_PERSISTENCE = ( MS_PER_SECOND * 2 / TASK_GENERAL_INTERVAL ); /// Volume (in mL) of venous portion of blood circuit line. TODO - get actual volume from Systems. #define VENOUS_LINE_VOLUME_ML ( 200.0F ) @@ -67,6 +68,7 @@ static U32 fillStartTime = 0; ///< Time stamp for start of air trap fill. +static U32 airPumpUpperlevelctr = 0; static U32 airTrapUpperLevelCtr = 0; ///< Timer count for upper level persistence. static U32 airTrapIllegalLevelSensorsCtr = 0; ///< Timer counter for illegal level sensor fault. @@ -90,6 +92,7 @@ resetAirTrap(); airTrapIllegalLevelSensorsCtr = DATA_PUBLISH_COUNTER_START_COUNT; + airPumpUpperlevelctr = 0; for ( i = 0; i < NUM_OF_AIR_TRAP_LEVEL_SENSORS; i++ ) { @@ -343,13 +346,6 @@ pendingStopAirTrapController = FALSE; result = AIR_TRAP_MANUAL_CONTROL_STATE; } - // Transition to open valve state when air detected at lower level - else if ( AIR_TRAP_LEVEL_AIR == getAirTrapLevel( AIR_TRAP_LEVEL_SENSOR_LOWER ) ) - { - setValveAirTrap( STATE_OPEN ); - fillStartTime = getMSTimerCount(); - result = AIR_TRAP_VALVE_OPEN_STATE; - } //Turn on air pump if fluid reaches upper level. else if ( AIR_TRAP_LEVEL_FLUID == getAirTrapLevel( AIR_TRAP_LEVEL_SENSOR_UPPER ) ) { @@ -361,10 +357,46 @@ { setAirPumpState( AIR_PUMP_STATE_ON ); } + else + { + airPumpUpperlevelctr--; + } #ifndef _RELEASE_ } #endif } + + else if ( ( AIR_TRAP_LEVEL_AIR == getAirTrapLevel( AIR_TRAP_LEVEL_SENSOR_UPPER ) ) ) + { + +#ifndef _RELEASE_ + if ( SW_CONFIG_DISABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_AIR_PUMP ) ) + { +#endif + if ( AIR_PUMP_STATE_ON == getAirPumpState() ) + { + airPumpUpperlevelctr++; + // Turn air pump off once we detect air at upper level and exceed persistence + // But first, open the air valve. + if ( airPumpUpperlevelctr >= AIR_PUMP_UPPER_LEVEL_PERSISTENCE ) + { + setValveAirTrap( STATE_OPEN ); + result = AIR_TRAP_VALVE_OPEN_STATE; + } + } +#ifndef _RELEASE_ + } +#endif + } + + // Transition to open valve state when air detected at lower level + else if ( AIR_TRAP_LEVEL_AIR == getAirTrapLevel( AIR_TRAP_LEVEL_SENSOR_LOWER ) ) + { + setValveAirTrap( STATE_OPEN ); + fillStartTime = getMSTimerCount(); + result = AIR_TRAP_VALVE_OPEN_STATE; + } + return result; } @@ -386,7 +418,23 @@ pendingStopAirTrapController = FALSE; result = AIR_TRAP_MANUAL_CONTROL_STATE; } - // Transition to closed valve state when fluid detected at upper level + // Turn air pump off once we detect air at upper level. + else if ( AIR_TRAP_LEVEL_AIR == getAirTrapLevel( AIR_TRAP_LEVEL_SENSOR_UPPER ) ) + { +#ifndef _RELEASE_ + if ( SW_CONFIG_DISABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_AIR_PUMP ) ) + { +#endif + if ( AIR_PUMP_STATE_ON == getAirPumpState() ) + { + setAirPumpState( AIR_PUMP_STATE_OFF ); + airPumpUpperlevelctr = 0; + } +#ifndef _RELEASE_ + } +#endif + } + // Transition to closed valve state when fluid detected at lower level else if ( AIR_TRAP_LEVEL_FLUID == getAirTrapLevel( AIR_TRAP_LEVEL_SENSOR_LOWER ) ) { setValveAirTrap( STATE_CLOSED ); @@ -407,7 +455,6 @@ } #endif } - return result; } Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u -raa7b1f5f68aae23c1c52b32658fcb625c29accfb -r984bd22d53c604713e6b3a22a536c64a920e9100 --- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision aa7b1f5f68aae23c1c52b32658fcb625c29accfb) +++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 984bd22d53c604713e6b3a22a536c64a920e9100) @@ -15,7 +15,8 @@ * ***************************************************************************/ -#include "PresOccl.h" +#include "PresOccl.h" +#include "AirPump.h" #include "AlarmMgmt.h" #include "FPGA.h" #include "ModeTreatmentParams.h" @@ -50,6 +51,7 @@ #define VENOUS_PRESSURE_MIN_PSI ( -30.0F ) ///< Minimum of scale for venous pressure sensor reading (in PSI). #define VENOUS_PRESSURE_MAX_PSI ( 30.0F ) ///< Maximum of scale for venous pressure sensor reading (in PSI). #define MIN_VENOUS_PRESSURE_FOR_RAMP_MMHG ( 0.0F ) ///< Minimum venous pressure during blood pump ramp up (in mmHg). +#define VENOUS_OFFSET_WITH_AIRPUMP_MMHG ( 150.0F ) ///< Value to increase venous pressure high limit alarm when air pump is operating. #define ARTERIAL_PRESSURE_OFFSET ( 1638 ) ///< Offset for 14-bit arterial pressure sensor reading. #define ARTERIAL_PRESSURE_SCALE ( 14745 - VENOUS_PRESSURE_OFFSET ) ///< Scale for arterial pressure sensor. @@ -563,6 +565,11 @@ venHighLimit = (F32)getS32TreatmentParamUpperRangeLimit( TREATMENT_PARAM_VEN_PRESSURE_HIGH_LIMIT ); } + if ( AIR_PUMP_STATE_ON == getAirPumpState() ) + { + venHighLimit = (F32)getS32TreatmentParamUpperRangeLimit( TREATMENT_PARAM_VEN_PRESSURE_HIGH_LIMIT ) + VENOUS_OFFSET_WITH_AIRPUMP_MMHG; + } + // Cannot monitor for low venous pressure while venting air trap if ( getValveAirTrapStatus() != STATE_OPEN ) {