Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -r27f3db92495948d4c1192421c1b0c20338c4a034 -r70d33c50c8c3fd987f39eaa1f3b294860d569830 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 70d33c50c8c3fd987f39eaa1f3b294860d569830) @@ -63,7 +63,6 @@ #define BP_SPEED_CALC_INTERVAL ( 40 / TASK_PRIORITY_INTERVAL ) /// Number of hall sensor counts kept in buffer to hold last 1 second of count data. #define BP_SPEED_CALC_BUFFER_LEN ( 1000 / BP_SPEED_CALC_INTERVAL / TASK_PRIORITY_INTERVAL ) -#define BP_HALL_EDGE_COUNTS_PER_REV 48 ///< Number of hall sensor edge counts per motor revolution. #define BP_MAX_ROTOR_SPEED_RPM 100.0 ///< Maximum rotor speed allowed for blood pump. #define BP_MAX_FLOW_VS_SPEED_DIFF_RPM 200.0 ///< Maximum difference between measured speed and speed implied by measured flow. @@ -389,7 +388,7 @@ *************************************************************************/ U32 getBloodPumpMotorCount( void ) { - return bloodPumpMotorEdgeCount / BP_HALL_EDGE_COUNTS_PER_REV; + return bloodPumpMotorEdgeCount; } /*********************************************************************//** Index: firmware/App/Controllers/BloodFlow.h =================================================================== diff -u -r933a18d740285e70be9d00696ed0f5a5381bc8e4 -r70d33c50c8c3fd987f39eaa1f3b294860d569830 --- firmware/App/Controllers/BloodFlow.h (.../BloodFlow.h) (revision 933a18d740285e70be9d00696ed0f5a5381bc8e4) +++ firmware/App/Controllers/BloodFlow.h (.../BloodFlow.h) (revision 70d33c50c8c3fd987f39eaa1f3b294860d569830) @@ -36,6 +36,7 @@ #define SALINE_BOLUS_FLOW_RATE 150 ///< Saline bolus flow rate (in mL/min). #define VOLUME_PER_BP_MOTOR_REV_ML 0.2 ///< Theoretical volume (mL) of blood/saline volume per motor revolution. +#define BP_HALL_EDGE_COUNTS_PER_REV 48 ///< Number of hall sensor edge counts per motor revolution. /// Payload record structure for a blood pump data message. typedef struct Index: firmware/App/Modes/BloodPrime.c =================================================================== diff -u -r6b870cd0699bb3ee22b93981d51373a6c2d56162 -r70d33c50c8c3fd987f39eaa1f3b294860d569830 --- firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision 6b870cd0699bb3ee22b93981d51373a6c2d56162) +++ firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision 70d33c50c8c3fd987f39eaa1f3b294860d569830) @@ -203,14 +203,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 = u32DiffWithWrap( 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? Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r606c80dafe7c1de63b99d775e032a0cc28922a49 -r70d33c50c8c3fd987f39eaa1f3b294860d569830 --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 606c80dafe7c1de63b99d775e032a0cc28922a49) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 70d33c50c8c3fd987f39eaa1f3b294860d569830) @@ -730,10 +730,10 @@ // Calculate UF volumes and provide to dialysate outlet pump controller updateUFVolumes(); - // If we have reached target UF volume, UF is complete + // If we have reached target UF volume, UF is complete - set UF rate to zero for remainder of treatment if ( refUFVolume >= maxUFVolumeML ) { - result = UF_COMPLETED_STATE; + setUFRate = 0.0; } // Handle saline bolus start request from user else if ( TRUE == salineBolusStartRequested ) @@ -903,15 +903,12 @@ F32 bolusTargetVolume = (F32)getTreatmentParameterU32( TREATMENT_PARAM_SALINE_BOLUS_VOLUME ); F32 bldFlowRate = getMeasuredBloodFlowRate(); // TODO - should I use raw flow instead of filtered here??? F32 volSinceLastUpdateMl = bldFlowRate * timeSinceLastVolumeUpdateMin; - U32 bldPumpMotorCount = getBloodPumpMotorCount(); - U32 bldPumpMotorDelta = u32DiffWithWrap( bolusSalineLastMotorCount, bldPumpMotorCount ); // Update saline bolus volumes bolusSalineLastVolumeTimeStamp = getMSTimerCount(); bolusSalineVolumeDelivered += volSinceLastUpdateMl; totalSalineVolumeDelivered += volSinceLastUpdateMl; - bolusSalineMotorCount += bldPumpMotorDelta; - bolusSalineLastMotorCount = bldPumpMotorCount; + bolusSalineMotorCount = u32DiffWithWrap( bolusSalineLastMotorCount, getBloodPumpMotorCount() ) / BP_HALL_EDGE_COUNTS_PER_REV; bolusSalineVolumeDelivered_Safety = ( (F32)bolusSalineMotorCount * VOLUME_PER_BP_MOTOR_REV_ML ); // TODO - include upstream pressure compensation to this calc #ifndef DISABLE_SALINE_BOLUS_CHECKS Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -r38f6b0b6ff1608eb1fd046e91add7fd2c65de4b1 -r70d33c50c8c3fd987f39eaa1f3b294860d569830 --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 38f6b0b6ff1608eb1fd046e91add7fd2c65de4b1) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 70d33c50c8c3fd987f39eaa1f3b294860d569830) @@ -137,6 +137,11 @@ postState = handlePOSTStatus( testStatus ); break; + case POST_STATE_VALVES: + testStatus = execValvesSelfTest(); + postState = handlePOSTStatus( testStatus ); + break; + case POST_STATE_ACCELEROMETER: #ifndef DISABLE_ACCELS testStatus = execAccelTest(); @@ -146,11 +151,6 @@ postState = handlePOSTStatus( testStatus ); break; - case POST_STATE_VALVES: - testStatus = execValvesSelfTest(); - postState = handlePOSTStatus( testStatus ); - break; - case POST_STATE_ALARM_LAMP: testStatus = execAlarmLampTest(); postState = handlePOSTStatus( testStatus ); Index: firmware/App/Modes/Rinseback.c =================================================================== diff -u -rebfb8019ba74b6c614051d1bfd13ee186c9138fd -r70d33c50c8c3fd987f39eaa1f3b294860d569830 --- firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision ebfb8019ba74b6c614051d1bfd13ee186c9138fd) +++ firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision 70d33c50c8c3fd987f39eaa1f3b294860d569830) @@ -338,17 +338,14 @@ static RINSEBACK_STATE_T handleRinsebackRunState( void ) { RINSEBACK_STATE_T result = RINSEBACK_RUN_STATE; - U32 bldPumpMotorCount = getBloodPumpMotorCount(); - U32 bldPumpMotorDelta = u32DiffWithWrap( rinsebackLastMotorCount, bldPumpMotorCount ); // Reset rinseback t/o rinsebackTimerCtr = 0; // Update rinseback volume delivered so far cumulativeRinsebackVolume_mL += ( getMeasuredBloodFlowRate() * RINSEBACK_FLOW_INTEGRATOR ); // update independent calculated safety volume delivered so far - rinsebackMotorCount += bldPumpMotorDelta; - rinsebackLastMotorCount = bldPumpMotorCount; + rinsebackMotorCount = u32DiffWithWrap( rinsebackLastMotorCount, getBloodPumpMotorCount() ) / BP_HALL_EDGE_COUNTS_PER_REV; rinsebackVolumeDelivered_Safety = ( (F32)rinsebackMotorCount * VOLUME_PER_BP_MOTOR_REV_ML ); // TODO - include upstream pressure compensation to this calc // Has user requested to end rinseback?