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; +} + /**@}*/