Index: firmware/App/Modes/BloodPrime.c =================================================================== diff -u -re45524455c005d4fa1734efcbaf7ed0499302670 -r764d85698b625d8b8fc1f53d60b6c0f10dad82b8 --- firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision e45524455c005d4fa1734efcbaf7ed0499302670) +++ firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision 764d85698b625d8b8fc1f53d60b6c0f10dad82b8) @@ -37,7 +37,8 @@ // ********** private definitiions *********** #define TARGET_BLOOD_PRIME_VOLUME_ML 300.0 ///< Target blood prime volume to prime the blood side circuit (in mL). -#define MIN_RAMP_TIME_SEC 60 ///< Minimum ramp time for blood prime (in seconds). +#define MAX_BLOOD_PRIME_VOLUME_ERROR_ML 60.0 ///< Maximum error in total additional blood prime volume (20% of total). +#define MIN_RAMP_TIME_SEC 60 ///< Minimum ramp time for blood prime (in seconds). /// Initial flow rate for blood pump when starting blood prime operation. #define BLOOD_PRIME_INIT_BP_FLOW_RATE_ML_MIN 100 @@ -63,7 +64,8 @@ /// Interval (in task intervals) at which to publish blood prime data to CAN bus. static OVERRIDE_U32_T bloodPrimePublishInterval = { BLOOD_PRIME_DATA_PUBLISH_INTERVAL, BLOOD_PRIME_DATA_PUBLISH_INTERVAL, BLOOD_PRIME_DATA_PUBLISH_INTERVAL, 0 }; -static OVERRIDE_F32_T cumulativeBloodPrimeVolume_mL = { 0.0, 0.0, 0.0, 0 }; ///< Total cumulative blood prime volume (in mL). +static OVERRIDE_F32_T cumulativeBloodPrimeVolume_mL = { 0.0, 0.0, 0.0, 0 }; ///< Total cumulative blood prime volume (in mL) from measured blood flow rate. +static F32 expectedBloodPrimeVolume_mL = 0.0; ///< Total cumulative blood prime volume (in mL) expected based on target blood flow rate. // ********** private function prototypes ********** @@ -88,6 +90,7 @@ bloodPrimeRampControlTimerCtr = 0; bloodPrimePublishTimerCtr = BLOOD_PRIME_DATA_PUBLISH_INTERVAL; cumulativeBloodPrimeVolume_mL.data = 0.0; + expectedBloodPrimeVolume_mL = 0.0; resetBloodPrimeFlags(); bloodPrimeRampFlowRate_mL_min = (F32)BLOOD_PRIME_INIT_BP_FLOW_RATE_ML_MIN; @@ -218,6 +221,7 @@ // Update blood prime volume delivered so far cumulativeBloodPrimeVolume_mL.data += ( getMeasuredBloodFlowRate() * BLOOD_PRIME_FLOW_INTEGRATOR ); + expectedBloodPrimeVolume_mL += ( (F32)getTargetBloodFlowRate() * BLOOD_PRIME_FLOW_INTEGRATOR ); // Has blood prime completed? if ( getBloodPrimeVolume() >= TARGET_BLOOD_PRIME_VOLUME_ML ) @@ -229,7 +233,7 @@ } #ifndef DISABLE_PUMP_FLOW_CHECKS // Is blood prime taking too long based on set BP rate? - else if ( TBD ) + else if ( fabs( expectedBloodPrimeVolume_mL - getBloodPrimeVolume() ) > MAX_BLOOD_PRIME_VOLUME_ERROR_ML ) { activateAlarmNoData( ALARM_ID_BLOOD_PRIME_VOLUME_CHECK_FAILURE ); }