Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -r8b73263b38f449dacc0795c67a7cf6240cb79026 -rbb63d313f1edeb2fa72f992cedab03b13cdf644a --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 8b73263b38f449dacc0795c67a7cf6240cb79026) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision bb63d313f1edeb2fa72f992cedab03b13cdf644a) @@ -113,6 +113,8 @@ #define BP_PWM_FROM_ML_PER_MIN(rate) ( (rate) * BP_ML_PER_MIN_TO_PUMP_RPM_FACTOR * BP_GEAR_RATIO * BP_MOTOR_RPM_TO_PWM_DC_FACTOR + BP_PWM_ZERO_OFFSET ) /// Conversion from PWM duty cycle % to commanded pump motor speed. #define BP_PWM_TO_MOTOR_SPEED_RPM(pwm) ( ((pwm) - BP_PWM_ZERO_OFFSET) * 4000.0F ) +/// Conversion macro from mL/min to estimated PWM duty cycle %. +#define BP_ML_PER_MIN_FROM_PWM(pwm) ( ( pwm / ( BP_ML_PER_MIN_TO_PUMP_RPM_FACTOR * BP_GEAR_RATIO * BP_MOTOR_RPM_TO_PWM_DC_FACTOR) ) - BP_PWM_ZERO_OFFSET ) /// Measured blood flow is filtered w/ moving average. #define SIZE_OF_ROLLING_AVG ( ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) * 1 ) Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r9051b47d2d0e9f112d4ebc310a5572844b7528f4 -rbb63d313f1edeb2fa72f992cedab03b13cdf644a --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 9051b47d2d0e9f112d4ebc310a5572844b7528f4) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision bb63d313f1edeb2fa72f992cedab03b13cdf644a) @@ -111,6 +111,9 @@ //#define DIP_PWM_FROM_ML_PER_MIN(rate) ( (rate) * DIP_ML_PER_MIN_TO_PUMP_RPM_FACTOR * DIP_GEAR_RATIO * DIP_MOTOR_RPM_TO_PWM_DC_FACTOR + DIP_PWM_ZERO_OFFSET ) /// Conversion from PWM duty cycle % to commanded pump motor speed. #define DIP_PWM_TO_MOTOR_SPEED_RPM(pwm) ( ((pwm) - DIP_PWM_ZERO_OFFSET) * 4000.0F ) +// Macro converts PWM to estimate flow rate needed to achieve it. +#define DIP_ML_PER_MIN_FROM_PWM(pwm) ( (( pwm + DIP_PWM_ZERO_OFFSET) * 684.73 ) + 49.121 ) + /// Measured dialIn flow is filtered w/ moving average. #define SIZE_OF_ROLLING_AVG 10 @@ -1625,6 +1628,30 @@ } return result; -} +} + +/*********************************************************************//** + * @brief + * The testSetDialInPumpTargetDutyCycle function resets the override of the + * measured dialIn pump motor current. + * @details Inputs: none + * @details Outputs: adcDialInPumpMCCurrentmA + * @return TRUE if reset successful, FALSE if not + *************************************************************************/ +BOOL testSetDialInPumpTargetDutyCycle( F32 value ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + targetDialInFlowRate = (S32) DIP_ML_PER_MIN_FROM_PWM( value ); + result = TRUE; + } + + return result; +} + + + /**@}*/