Index: firmware/App/Modes/BloodPrime.c =================================================================== diff -u -r6b870cd0699bb3ee22b93981d51373a6c2d56162 -rdb22e9d530c5c9d62b02e6dcc72ed96fb67c165a --- firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision 6b870cd0699bb3ee22b93981d51373a6c2d56162) +++ firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision db22e9d530c5c9d62b02e6dcc72ed96fb67c165a) @@ -23,6 +23,7 @@ #include "ModeTreatment.h" #include "ModeTreatmentParams.h" #include "OperationModes.h" +#include "SyringePump.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" #include "Utilities.h" @@ -66,7 +67,7 @@ static U32 bloodPrimePublishTimerCtr; ///< Timer counter for determining interval for blood prime status to be published. static F32 cumulativeBloodPrimeVolume_mL; ///< Total cumulative blood prime volume (in mL). -static U32 bloodPrimeMotorCount; ///< The cumulative sum of BP motor encoder counts used for independent blood prime volume check. +static S32 bloodPrimeMotorCount; ///< The cumulative sum of BP motor encoder counts used for independent blood prime volume check. static U32 bloodPrimeLastMotorCount; ///< The last BP motor encoder count read for independent blood prime volume check. static F32 bloodPrimeVolumeDelivered_Safety; ///< The cumulative independent blood prime volume (in mL) calculated so far. @@ -150,7 +151,8 @@ // Ensure dialysate outlet and Heparin pumps are stopped signalDialOutPumpHardStop(); - // TODO - stop Heparin pump + stopSyringePump(); + // start blood and dialysate inlet pumps setBloodPumpTargetFlowRate( BLOOD_PRIME_INIT_BP_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialInPumpTargetFlowRate( DIALYSATE_FLOW_RATE_FOR_RECIRC, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); @@ -203,14 +205,11 @@ static BLOOD_PRIME_STATE_T handleBloodPrimeRampState( void ) { BLOOD_PRIME_STATE_T result = BLOOD_PRIME_RAMP_STATE; - U32 bldPumpMotorCount = getBloodPumpMotorCount(); - U32 bldPumpMotorDelta = u32DiffWithWrap( bloodPrimeLastMotorCount, bldPumpMotorCount ); // update blood prime volume delivered so far cumulativeBloodPrimeVolume_mL += ( getMeasuredBloodFlowRate() * BLOOD_PRIME_FLOW_INTEGRATOR ); // update independent calculated safety volume delivered so far - bloodPrimeMotorCount += bldPumpMotorDelta; - bloodPrimeLastMotorCount = bldPumpMotorCount; + 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 // Has blood prime completed?