Index: firmware/App/Modes/BloodPrime.c =================================================================== diff -u -r9f2e4e5933d2e418b75f91e3db5df69c71878d43 -rea0047d0cb48b899475cf519e7e4997d96f5e538 --- firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision 9f2e4e5933d2e418b75f91e3db5df69c71878d43) +++ firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision ea0047d0cb48b899475cf519e7e4997d96f5e538) @@ -206,9 +206,9 @@ { BLOOD_PRIME_STATE_T result = BLOOD_PRIME_RAMP_STATE; - // update blood prime volume delivered so far + // Update blood prime volume delivered so far cumulativeBloodPrimeVolume_mL += ( getMeasuredBloodFlowRate() * BLOOD_PRIME_FLOW_INTEGRATOR ); - // update independent calculated safety volume delivered so far + // Update independent calculated safety volume delivered so far bloodPrimeMotorCount = u32BiDiffWithWrap( bloodPrimeLastMotorCount, getBloodPumpMotorCount() ) / BP_HALL_EDGE_COUNTS_PER_REV; bloodPrimeVolumeDelivered_Safety = ( (F32)bloodPrimeMotorCount * VOLUME_PER_BP_MOTOR_REV_ML ); // TODO - include upstream pressure compensation to this calc @@ -240,9 +240,14 @@ // ramp blood pump on ramp interval if ( ++bloodPrimeRampControlTimerCtr >= BLOOD_PRIME_RAMPING_INTERVAL ) { - bloodPrimeRampControlTimerCtr = 0; // TODO - stop ramping when reach set rate for BP - bloodPrimeRampFlowRate_mL_min += bloodPrimeRampStep_mL; - setBloodPumpTargetFlowRate( (U32)bloodPrimeRampFlowRate_mL_min, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + U32 setBPRate = getTreatmentParameterU32( TREATMENT_PARAM_BLOOD_FLOW ); + + bloodPrimeRampControlTimerCtr = 0; + if ( bloodPrimeRampFlowRate_mL_min < (F32)setBPRate ) + { + bloodPrimeRampFlowRate_mL_min += bloodPrimeRampStep_mL; + setBloodPumpTargetFlowRate( (U32)bloodPrimeRampFlowRate_mL_min, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + } } }