Index: firmware/App/Controllers/AirTrap.c =================================================================== diff -u -rcc2aeed2bef39ae4e5d3b2f9b887bdc902b0d414 -r79a1bc916aaa25b696385e9b292bf6262bab6113 --- firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision cc2aeed2bef39ae4e5d3b2f9b887bdc902b0d414) +++ firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision 79a1bc916aaa25b696385e9b292bf6262bab6113) @@ -49,6 +49,9 @@ /// 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 ///< 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. + /// Defined states for the air trap controller state machine. typedef enum AirTrap_States { @@ -67,6 +70,9 @@ static U32 airTrapDataPublicationTimerCounter; ///< Used to schedule air trap data publication to CAN bus. static OVERRIDE_U32_T airTrapDataPublishInterval; ///< Interval (in ms) at which to publish air trap data to CAN bus. +static OVERRIDE_U32_T airTrapAirPumpRaisePowerLevel; ///< Air pump power level to use when raising the air trap blood level. +static OVERRIDE_U32_T airTrapAirPumpLowerPowerLevel; ///< Air pump power level to use when lowering the air trap blood level. + static BOOL pendingStartAirTrapController; ///< Flag indicates an air trap controller start request is pending. static BOOL pendingStopAirTrapController; ///< Flag indicates an air trap controller stop request is pending. @@ -84,6 +90,8 @@ static AIR_TRAP_STATE_T handleAirTrapClosedState( void ); static AIR_TRAP_STATE_T handleAirTrapRaiseLevelState( void ); static AIR_TRAP_STATE_T handleAirTrapLowerlevelState( void ); +static U08 getAirPumpRaisePowerLevel( void ); +static U08 getAirPumpLowerPowerLevel( void ); static void publishAirTrapData( void ); /*********************************************************************//** @@ -101,11 +109,19 @@ // Initialize controller variables resetAirTrap(); - airTrapDataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; - airTrapDataPublishInterval.data = AIR_TRAP_DATA_PUB_INTERVAL; - airTrapDataPublishInterval.ovData = AIR_TRAP_DATA_PUB_INTERVAL; - airTrapDataPublishInterval.ovInitData = AIR_TRAP_DATA_PUB_INTERVAL; - airTrapDataPublishInterval.override = OVERRIDE_RESET; + airTrapDataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; + airTrapDataPublishInterval.data = AIR_TRAP_DATA_PUB_INTERVAL; + airTrapDataPublishInterval.ovData = AIR_TRAP_DATA_PUB_INTERVAL; + airTrapDataPublishInterval.ovInitData = AIR_TRAP_DATA_PUB_INTERVAL; + airTrapDataPublishInterval.override = OVERRIDE_RESET; + airTrapAirPumpRaisePowerLevel.data = AIR_PUMP_MOTOR_FILL_PWM; + airTrapAirPumpRaisePowerLevel.ovData = AIR_PUMP_MOTOR_FILL_PWM; + airTrapAirPumpRaisePowerLevel.ovInitData = AIR_PUMP_MOTOR_FILL_PWM; + airTrapAirPumpRaisePowerLevel.override = OVERRIDE_RESET; + airTrapAirPumpLowerPowerLevel.data = AIR_PUMP_MOTOR_LOWER_PWM; + airTrapAirPumpLowerPowerLevel.ovData = AIR_PUMP_MOTOR_LOWER_PWM; + airTrapAirPumpLowerPowerLevel.ovInitData = AIR_PUMP_MOTOR_LOWER_PWM; + airTrapAirPumpLowerPowerLevel.override = OVERRIDE_RESET; airTrapFillStartTime = 0; airTrapLowerDelayStartTime = 0; airTrapLowerStartTime = 0; @@ -350,7 +366,7 @@ ( 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, AIR_PUMP_MOTOR_LOWER_PWM ); + 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 ); @@ -362,7 +378,7 @@ else if ( ( airTrapWasFilledAtStartOfTreatement != TRUE ) || ( AIR_TRAP_LEVEL_AIR == getLevelSensorState( H17_LEVL ) ) ) { - setAirPumpState( AIR_PUMP_STATE_ON, AIR_PUMP_MOTOR_FILL_PWM ); + 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 airTrapFillStartTime = getMSTimerCount(); SEND_EVENT_WITH_2_U32_DATA( TD_EVENT_AIR_TRAP_FILL, ON, 0 ); @@ -399,7 +415,7 @@ 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 - setAirPumpState( AIR_PUMP_STATE_ON, AIR_PUMP_MOTOR_LOWER_PWM ); + 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 ); @@ -456,6 +472,36 @@ /*********************************************************************//** * @brief + * The getAirPumpRaisePowerLevel function gets the air pump power level to + * use for raising the blood level in the air trap. + * @details \b Inputs: airTrapAirPumpRaisePowerLevel + * @details \b Outputs: none + * @return air pump power level for raising air trap blood level + *************************************************************************/ +static U08 getAirPumpRaisePowerLevel( void ) +{ + U08 result = getU08OverrideValue( &airTrapAirPumpRaisePowerLevel ); + + return result; +} + +/*********************************************************************//** + * @brief + * The getAirPumpLowerPowerLevel function gets the air pump power level to + * use for lowering the blood level in the air trap. + * @details \b Inputs: airTrapAirPumpLowerPowerLevel + * @details \b Outputs: none + * @return air pump power level for lowering air trap blood level + *************************************************************************/ +static U08 getAirPumpLowerPowerLevel( void ) +{ + U08 result = getU08OverrideValue( &airTrapAirPumpLowerPowerLevel ); + + return result; +} + +/*********************************************************************//** + * @brief * The publishAirTrapData function constructs and sends the air trap data * broadcast message. * @details \b Message \b Sent: MSG_ID_TD_AIR_TRAP_DATA to publish air trap data @@ -538,5 +584,39 @@ return result; } +/*********************************************************************//** + * @brief + * The testAirPumpPowerRaiseOverride function overrides the air pump power + * level used to raise the air trap level. + * @details \b Inputs: none + * @details \b Outputs: airTrapAirPumpRaisePowerLevel + * @param message Override message from Dialin which includes the power level + * to override the air pump to when raising air trap level. + * @return TRUE if override request is successful, FALSE if not + *************************************************************************/ +BOOL testAirPumpPowerRaiseOverride( MESSAGE_T *message ) +{ + BOOL result = u32Override( message, &airTrapAirPumpRaisePowerLevel, AIR_PUMP_MOTOR_OFF, AIR_PUMP_MOTOR_MAX_PWM ); + + return result; +} + +/*********************************************************************//** + * @brief + * The testAirPumpPowerLowerOverride function overrides the air pump power + * level used to lower the air trap level. + * @details \b Inputs: none + * @details \b Outputs: airTrapAirPumpLowerPowerLevel + * @param message Override message from Dialin which includes the power level + * to override the air pump to when lowering air trap level. + * @return TRUE if override request is successful, FALSE if not + *************************************************************************/ +BOOL testAirPumpPowerLowerOverride( MESSAGE_T *message ) +{ + BOOL result = u32Override( message, &airTrapAirPumpLowerPowerLevel, AIR_PUMP_MOTOR_OFF, AIR_PUMP_MOTOR_MAX_PWM ); + + return result; +} + /**@}*/ Index: firmware/App/Controllers/AirTrap.h =================================================================== diff -u -r07c1dbf3b8227766cb584352d9ea86e230270260 -r79a1bc916aaa25b696385e9b292bf6262bab6113 --- firmware/App/Controllers/AirTrap.h (.../AirTrap.h) (revision 07c1dbf3b8227766cb584352d9ea86e230270260) +++ firmware/App/Controllers/AirTrap.h (.../AirTrap.h) (revision 79a1bc916aaa25b696385e9b292bf6262bab6113) @@ -61,6 +61,8 @@ BOOL testAirTrapDataPublishIntervalOverride( MESSAGE_T *message ); BOOL testSetAirTrapControl( MESSAGE_T *message ); +BOOL testAirPumpPowerRaiseOverride( MESSAGE_T *message ); +BOOL testAirPumpPowerLowerOverride( MESSAGE_T *message ); /**@}*/ Index: firmware/App/Drivers/GLXferPump.h =================================================================== diff -u -r5aa32ae453d98f64b6d49d2fef3683557473136e -r79a1bc916aaa25b696385e9b292bf6262bab6113 --- firmware/App/Drivers/GLXferPump.h (.../GLXferPump.h) (revision 5aa32ae453d98f64b6d49d2fef3683557473136e) +++ firmware/App/Drivers/GLXferPump.h (.../GLXferPump.h) (revision 79a1bc916aaa25b696385e9b292bf6262bab6113) @@ -35,8 +35,6 @@ #define AIR_PUMP_MOTOR_OFF 0 ///< Power level setting (PWM) for H12 air pump to turn pump off. #define AIR_PUMP_MOTOR_MAX_PWM 250 ///< Power level setting (PWM) maximum for H12 air pump. -#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. // ********** public function prototypes ********** Index: firmware/App/Modes/StateTxPaused.c =================================================================== diff -u -r9a8e1fc597eb4f681527e691fb6cb24e550d8b92 -r79a1bc916aaa25b696385e9b292bf6262bab6113 --- firmware/App/Modes/StateTxPaused.c (.../StateTxPaused.c) (revision 9a8e1fc597eb4f681527e691fb6cb24e550d8b92) +++ firmware/App/Modes/StateTxPaused.c (.../StateTxPaused.c) (revision 79a1bc916aaa25b696385e9b292bf6262bab6113) @@ -15,7 +15,7 @@ * ***************************************************************************/ -#include "AirPump.h" +#include "AirTrap.h" #include "BloodFlow.h" #include "Buttons.h" #include "Common.h" @@ -402,7 +402,7 @@ setBloodPumpTargetFlowRate( targetBloodFlowMLPM, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setValvePosition( H1_VALV, VALVE_POSITION_C_CLOSE ); setValvePosition( H19_VALV, VALVE_POSITION_C_CLOSE ); - setAirPumpState( AIR_PUMP_STATE_OFF, 0 ); + startAirTrapControl(); set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); set3WayValveState( H20_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); cmdBypassDialyzer( TRUE ); @@ -419,7 +419,7 @@ signalBloodPumpHardStop(); setValvePosition( H1_VALV, VALVE_POSITION_C_CLOSE ); setValvePosition( H19_VALV, VALVE_POSITION_C_CLOSE ); - setAirPumpState( AIR_PUMP_STATE_OFF, 0 ); + endAirTrapControl(); set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); set3WayValveState( H20_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); cmdBypassDialyzer( TRUE ); @@ -436,7 +436,7 @@ setBloodPumpTargetFlowRate( targetBloodFlowMLPM, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setValvePosition( H1_VALV, VALVE_POSITION_B_OPEN ); setValvePosition( H19_VALV, VALVE_POSITION_B_OPEN ); - setAirPumpState( AIR_PUMP_STATE_ON, AIR_PUMP_MOTOR_LOWER_PWM ); // TODO is the PWM Correct? + startAirTrapControl(); set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_OPEN_STATE ); set3WayValveState( H20_VALV, VALVE_3WAY_COMMON_TO_OPEN_STATE ); cmdBypassDialyzer( TRUE ); @@ -450,7 +450,7 @@ signalBloodPumpHardStop(); setValvePosition( H1_VALV, VALVE_POSITION_C_CLOSE ); setValvePosition( H19_VALV, VALVE_POSITION_C_CLOSE ); - setAirPumpState( AIR_PUMP_STATE_OFF, 0 ); + endAirTrapControl(); set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); set3WayValveState( H20_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); cmdBypassDialyzer( TRUE ); Index: firmware/App/Services/Messaging.c =================================================================== diff -u -rc06a32218bad65414ccda5d41293e5349e46d241 -r79a1bc916aaa25b696385e9b292bf6262bab6113 --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision c06a32218bad65414ccda5d41293e5349e46d241) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision 79a1bc916aaa25b696385e9b292bf6262bab6113) @@ -167,7 +167,9 @@ { MSG_ID_TD_BLOOD_FLOW_WEAR_B_TERM_OVERRIDE_REQUEST, &testBPFlowWearBTermOverride }, { MSG_ID_TD_SET_TEST_CONFIGURATION, &testSetTestConfiguration }, { MSG_ID_TD_GET_TEST_CONFIGURATION, &testGetTestConfiguration }, - { MSG_ID_TD_RESET_ALL_TEST_CONFIGURATIONS, &testResetAllTestConfigurations } + { MSG_ID_TD_RESET_ALL_TEST_CONFIGURATIONS, &testResetAllTestConfigurations }, + { MSG_ID_TD_AIR_PUMP_POWER_RAISE_OVERRIDE_REQUEST, &testAirPumpPowerRaiseOverride }, + { MSG_ID_TD_AIR_PUMP_POWER_LOWER_OVERRIDE_REQUEST, &testAirPumpPowerLowerOverride }, }; #define NUM_OF_FUNCTION_HANDLERS (sizeof(MSG_FUNCTION_HANDLER_LOOKUP) / sizeof(MSG_HANDLER_LOOKUP_T))