Index: firmware/App/Controllers/AirPump.c =================================================================== diff -u -rf2e5da3b659f99aaa0eec9174a472529cf11b95a -r2075fb989d74d881f2e73c19052aa32fa9d760a6 --- firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision f2e5da3b659f99aaa0eec9174a472529cf11b95a) +++ firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision 2075fb989d74d881f2e73c19052aa32fa9d760a6) @@ -45,7 +45,8 @@ // ********** private data ********** static AIR_PUMP_STATE_T currentAirPumpState; ///< Current air pump control state. -static F32 currentAirPumpPowerLevel; ///< Current air pump power level setting. +static U16 currentAirPumpRPM; ///< Current air pump RPM. +static F32 currentAirPumpPowerLevel; ///< Current air pump power level setting in % duty cycle (0..100%). static U32 airPumpDataPublicationTimerCounter; ///< Air pump data broadcast timer counter. static OVERRIDE_U32_T airPumpDataPublishInterval; ///< Air pump data broadcast interval (in ms). Index: firmware/App/Controllers/AirPump.h =================================================================== diff -u -rf2e5da3b659f99aaa0eec9174a472529cf11b95a -r2075fb989d74d881f2e73c19052aa32fa9d760a6 --- firmware/App/Controllers/AirPump.h (.../AirPump.h) (revision f2e5da3b659f99aaa0eec9174a472529cf11b95a) +++ firmware/App/Controllers/AirPump.h (.../AirPump.h) (revision 2075fb989d74d881f2e73c19052aa32fa9d760a6) @@ -38,7 +38,8 @@ typedef struct { U32 h12State; ///< Air pump state status - F32 h12Power; ///< Air pump power level setting + F32 h12Power; ///< Air pump power level setting in duty cycle percentage + U32 h12Rpm; ///< Air pump speed in RPM. } AIR_PUMP_PAYLOAD_T; #pragma pack(pop) Index: firmware/App/Controllers/AirTrap.c =================================================================== diff -u -rf2e5da3b659f99aaa0eec9174a472529cf11b95a -r2075fb989d74d881f2e73c19052aa32fa9d760a6 --- firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision f2e5da3b659f99aaa0eec9174a472529cf11b95a) +++ firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision 2075fb989d74d881f2e73c19052aa32fa9d760a6) @@ -51,12 +51,11 @@ /// 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 58.8f ///< Power level setting (PWM) in percentage for H12 air pump to fill (raise level) the air trap. -#define AIR_PUMP_MOTOR_LOWER_PWM 23.5f ///< Power level setting (PWM) in percentage for H12 air pump to lower the level of the air trap. +#define AIR_PUMP_MOTOR_FILL_PWM 58.8F ///< Power level setting (PWM) in percentage for H12 air pump to fill (raise level) the air trap. +#define AIR_PUMP_MOTOR_LOWER_PWM 23.5F ///< Power level setting (PWM) in percentage for H12 air pump to lower the level of the air trap. #define AIR_PUMP_MOTOR_MIN_PWM_OVERRIDE 60 ///< Air pump motor minimum PWM to override. #define AIR_PUMP_MOTOR_MAX_PWM_OVERRIDE 250 ///< Air pump motor maximum PWM to override. #define AIR_PUMP_MOTOR_MAX_PWM 255 ///< Air pump motor maximum PWM. -#define AIR_PUMP_MOTOR_PWM_HUNDRED_PCT 100.0f ///< Percentage calculation constant /// from air pump manufacturer's data for pump current draw based on pump speed and venous pressure mmHg, /// the currently set air pump duty cycle (raw PWM) = 0.0005x^2 + 0.2313x + 63.667, where x is H14 venous pressure in mmHg before air pump lower event #define QUADRATIC_COEFFICIENT 0.005F ///< X2 quadratic coefficient @@ -347,7 +346,7 @@ F32 h14Pressure = getFilteredVenousPressure(); // the currently set P12 duty cycle (raw PWM) must be 0.0005x^2 + 0.2313x + 63.667, where x = H14 venous pressure in mmHg before air pump lower event F32 dutyCycle = ( ( QUADRATIC_COEFFICIENT * ( h14Pressure * h14Pressure ) ) - ( LINEAR_COEFFICIENT * ( h14Pressure ) ) ) + CONSTANT_TERM; - dutyCycle = ( dutyCycle / AIR_PUMP_MOTOR_MAX_PWM ) * AIR_PUMP_MOTOR_PWM_HUNDRED_PCT; + dutyCycle = ( dutyCycle / AIR_PUMP_MOTOR_MAX_PWM ) * FRACTION_TO_PERCENT_FACTOR; return dutyCycle; } Index: firmware/App/Drivers/GLXferPump.c =================================================================== diff -u -rf2e5da3b659f99aaa0eec9174a472529cf11b95a -r2075fb989d74d881f2e73c19052aa32fa9d760a6 --- firmware/App/Drivers/GLXferPump.c (.../GLXferPump.c) (revision f2e5da3b659f99aaa0eec9174a472529cf11b95a) +++ firmware/App/Drivers/GLXferPump.c (.../GLXferPump.c) (revision 2075fb989d74d881f2e73c19052aa32fa9d760a6) @@ -29,16 +29,17 @@ // ********** private definitions ********** #define AIR_PUMP_PWM_TIME 20 ///< Time (in 10ns increments) per PWM register count for the air pump = 20 kHz. -#define AIR_PUMP_MAX_PWM 255.0f ///< Air pump maximum PWM. -#define AIR_PUMP_PWM_PCT 100.0f ///< Air pump pwm percentage +#define AIR_PUMP_MAX_PWM 255 ///< Air pump maximum PWM. +#define AIR_PUMP_DUTY_CYCLE_MIN 0.0F ///< Air pump minimum duty cycle in percentage +#define AIR_PUMP_DUTY_CYCLE_MAX 100.0F ///< Air pump maximum duty cycle in percentage // ********** private data ********** static F32 currentAirPumpMotorPowerLevel; ///< Current air pump motor state: 0=off, 1..255=power level. // ********** private function prototypes ********** -static U08 PercentageToScalar(F32 percentage); +static U08 convertPercentageToScalar( F32 percentage ); /*********************************************************************//** * @brief @@ -48,7 +49,7 @@ * @details \b Outputs: currentAirPumpMotorPowerLevel * @return none *************************************************************************/ -void initGasLiqXferPumpDriver(void) +void initGasLiqXferPumpDriver( void ) { currentAirPumpMotorPowerLevel = AIR_PUMP_MOTOR_OFF; setH12AirPumpMotorPowerLevel( currentAirPumpMotorPowerLevel ); @@ -58,7 +59,7 @@ /*********************************************************************//** * @brief * The setAirPumpMotorPower function sets the air pump motor to the given - * power level. + * power level in duty cycle percentage (0..100%). * @details \b Message \b Sent: MSG_ID_TD_EVENT if changing air pump power level. * @details \b Inputs: none * @details \b Outputs: currentAirPumpMotorPowerLevel @@ -67,11 +68,12 @@ *************************************************************************/ void setAirPumpMotorPower( F32 power ) { + U08 scalarPower = convertPercentageToScalar( power ); // if state is changing, set the air pump to the given on/off state and send event if ( power != currentAirPumpMotorPowerLevel ) { - SEND_EVENT_WITH_2_F32_DATA(TD_EVENT_AIR_PUMP_ON_OFF, currentAirPumpMotorPowerLevel, power ); - setH12AirPumpMotorPowerLevel( PercentageToScalar( power ) ); + SEND_EVENT_WITH_2_F32_DATA( TD_EVENT_AIR_PUMP_ON_OFF, currentAirPumpMotorPowerLevel, power ); + setH12AirPumpMotorPowerLevel( scalarPower ); currentAirPumpMotorPowerLevel = power; } } @@ -98,19 +100,14 @@ * @param percentage Power level for air pump (0...2=off, 3-100.0 for ON). * @return U08 8-bit PWM value (0-255) *************************************************************************/ -static U08 PercentageToScalar(F32 percentage) { +static U08 convertPercentageToScalar( F32 percentage ) +{ + F32 power; // Clamp input to 0-100% - if ( percentage < 0.0f ) - { - percentage = 0.0f; - } - if ( percentage > AIR_PUMP_PWM_PCT ) - { - percentage = AIR_PUMP_PWM_PCT; - } + power = RANGE( percentage, AIR_PUMP_DUTY_CYCLE_MIN, AIR_PUMP_DUTY_CYCLE_MAX ); - // Calculate 0-255 value (255 * percent / 100) - return (U08)( ( ( percentage * AIR_PUMP_MAX_PWM ) / AIR_PUMP_PWM_PCT ) ); + // Calculate 0-255 value (255 * power / 100) + return (U08)( ( ( power * AIR_PUMP_MAX_PWM ) / FRACTION_TO_PERCENT_FACTOR ) ); } Index: firmware/App/TDCommon.h =================================================================== diff -u -rf7cdfaa44243c6950069052828d404962f660c57 -r2075fb989d74d881f2e73c19052aa32fa9d760a6 --- firmware/App/TDCommon.h (.../TDCommon.h) (revision f7cdfaa44243c6950069052828d404962f660c57) +++ firmware/App/TDCommon.h (.../TDCommon.h) (revision 2075fb989d74d881f2e73c19052aa32fa9d760a6) @@ -25,7 +25,7 @@ #define TD_VERSION_MAJOR 0 #define TD_VERSION_MINOR 0 #define TD_VERSION_MICRO 0 -#define TD_VERSION_BUILD 27 +#define TD_VERSION_BUILD 44 // ********** development build switches **********