Index: firmware/App/Modes/Prime.c =================================================================== diff -u -r2d354e7ca9b55c5bb4fe679c8dd43fcbafd53d42 -r24237b8f12f5bb4c9cfa8c51b3b1a92d2d692631 --- firmware/App/Modes/Prime.c (.../Prime.c) (revision 2d354e7ca9b55c5bb4fe679c8dd43fcbafd53d42) +++ firmware/App/Modes/Prime.c (.../Prime.c) (revision 24237b8f12f5bb4c9cfa8c51b3b1a92d2d692631) @@ -55,6 +55,9 @@ #define PRIME_SALINE_DIALYZER_TIME_LIMIT ( 300 * MS_PER_SECOND ) ///< Five minutes time limit for priming saline dialyzer path. #define CIRC_BUF_SIZE 10 ///< Size of the circular buffer. Note: the size is not 2^N where N = 1, 2 , 3, 4, 5 ... #define MAX_BUF_INDEX ( CIRC_BUF_SIZE - 1 ) ///< Use to calculate write index of the circular buffer. +#define PRIME_DIALYZER_BYPASS_EXPECTED_VOLUME 1000.0 ///< Prime dialysate dialyzer bypass state expected steady state volume in mL. +#define PRIME_DIALYZER_EXPECTED_VOLUME 1200.0 ///< Prime dialysate dialyzer state expected steady state volume in mL. +#define PRIME_EXPECTED_VOLUME_TOLERANCE 50.0 ///< Prime expected steady state volume tolerance in mL. /// States of the treatment reservoir management state machine. typedef enum PrimeReservoirMgmt_States @@ -651,10 +654,12 @@ F32 const currentLoadCellValue = getLoadCellWeight( LOAD_CELL_RESERVOIR_1_PRIMARY ); F32 const previousLoadCellValue = loadcellReadings[ iteration % CIRC_BUF_SIZE ]; F32 const loadcellDelta = fabs( currentLoadCellValue - previousLoadCellValue ); // delta of the current (now) and the previous (10 seconds ago) - loadcellReadings[ ( iteration + MAX_BUF_INDEX ) % CIRC_BUF_SIZE ] = currentLoadCellValue; // see Circular Buffer.xlsx in X:\Engineering\Denali\06- Software Design\Story\HD\HD Pre-Treatment Prime Update - iteration++; // iteration will not roll over in 136 years at one second increment + loadcellReadings[ ( iteration + MAX_BUF_INDEX ) % CIRC_BUF_SIZE ] = currentLoadCellValue; + iteration++; - if ( loadcellDelta < LOAD_CELL_VOLUME_NOISE_TOLERANCE ) // TODO: also check for the expected reservoir volume here + if ( ( loadcellDelta < LOAD_CELL_VOLUME_NOISE_TOLERANCE ) && + ( currentLoadCellValue < ( PRIME_DIALYZER_BYPASS_EXPECTED_VOLUME + PRIME_EXPECTED_VOLUME_TOLERANCE ) ) && // check the steady state volume of R1 + ( currentLoadCellValue > ( PRIME_DIALYZER_BYPASS_EXPECTED_VOLUME - PRIME_EXPECTED_VOLUME_TOLERANCE ) ) ) { #ifdef RUN_BLOOD_CIRCUIT_PRIME_AGAIN if ( TRUE == runBloodCircuitPrimeAgain ) @@ -757,7 +762,9 @@ loadcellReadings[ ( iteration + MAX_BUF_INDEX ) % CIRC_BUF_SIZE ] = currentLoadCellValue; iteration++; - if ( loadcellDelta < LOAD_CELL_VOLUME_NOISE_TOLERANCE ) // TODO: also check for the expected reservoir volume here + if ( ( loadcellDelta < LOAD_CELL_VOLUME_NOISE_TOLERANCE ) && + ( currentLoadCellValue < ( PRIME_DIALYZER_EXPECTED_VOLUME + PRIME_EXPECTED_VOLUME_TOLERANCE ) ) && // check the steady state volume of R2 + ( currentLoadCellValue > ( PRIME_DIALYZER_EXPECTED_VOLUME - PRIME_EXPECTED_VOLUME_TOLERANCE ) ) ) { signalDialOutPumpHardStop(); transitionToWetSelfTests();