Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -r7a622a5d2d75aec9662faa2c279b4dbb66ba07bb -rdb6f405ef30befc5acc2c8d70665fd04b1c3cfe6 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 7a622a5d2d75aec9662faa2c279b4dbb66ba07bb) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision db6f405ef30befc5acc2c8d70665fd04b1c3cfe6) @@ -95,7 +95,13 @@ #define BP_MAX_CURR_WHEN_RUNNING_MA 2000.0 ///< Motor controller current should not exceed this when pump should be running. #define BP_MAX_CURR_ERROR_DURATION_MS 2000 ///< Motor controller current errors persisting beyond this duration will trigger an alarm. -#define BP_SPEED_ADC_TO_RPM_FACTOR 1.751752 ///< Conversion factor from ADC counts to RPM for blood pump motor. +#define BLOODPUMP_ADC_FULL_SCALE_V 3.0 ///< BP analog signals are 0-3V (while int. ADC ref may be different). +#define BLOODPUMP_ADC_ZERO 1998 ///< Blood pump ADC channel zero offset. + +/// Macro converts 12 bit ADC value to signed 16-bit value. +#define SIGN_FROM_12_BIT_VALUE(v) ( (S16)(v) - (S16)BLOODPUMP_ADC_ZERO ) + +#define BP_SPEED_ADC_TO_RPM_FACTOR 1.601601 ///< Conversion factor from ADC counts to RPM for blood pump motor (3200 RPM/1998 counts). #define BP_MOTOR_RPM_TO_PWM_DC_FACTOR 0.000238 ///< ~42 BP motor RPM = 1% PWM duty cycle. #define BP_CURRENT_ADC_TO_MA_FACTOR 3.002 ///< Conversion factor from ADC counts to mA for blood pump motor. @@ -110,11 +116,6 @@ /// Conversion from PWM duty cycle % to commanded pump motor speed. #define BP_PWM_TO_MOTOR_SPEED_RPM(pwm) ( ((pwm) - BP_PWM_ZERO_OFFSET) * 4000.0 ) -#define BLOODPUMP_ADC_FULL_SCALE_V 3.0 ///< BP analog signals are 0-3V (while int. ADC ref may be different). -#define BLOODPUMP_ADC_ZERO 1998 ///< Blood pump ADC channel zero offset. -/// Macro converts 12 bit ADC value to signed 16-bit value. -#define SIGN_FROM_12_BIT_VALUE(v) ( (S16)(v) - (S16)BLOODPUMP_ADC_ZERO ) - /// Measured blood flow is filtered w/ moving average. #define SIZE_OF_ROLLING_AVG ( ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) * 1 )