Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -rbd8d1a18ca5d9dd52c1082f74c19b90ca925af92 -rd5c37b914ce0ba48310f564c9844d03e836679df --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision bd8d1a18ca5d9dd52c1082f74c19b90ca925af92) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision d5c37b914ce0ba48310f564c9844d03e836679df) @@ -82,8 +82,8 @@ #define SYRINGE_PUMP_PRIME_VOLUME_ML 0.353 ///< Target syringe prime volume (in mL). #define SYRINGE_PUMP_MAX_VOL_ERROR_ML 0.1 ///< Maximum Heparin volume error (in mL). #define SYRINGE_PUMP_MAX_RATE_ERROR_ML_HR 0.1 ///< Maximum Heparin delivery rate error (in mL/hr). -#define TEN_PCT_OVER_ALLOWANCE 1.1 ///< Allow ten percent over target before alarming on over travel. -#define FIVE_PCT_OVER_ALLOWANCE 1.05 ///< Allow five percent over target before alarming on over travel. +#define TEN_PCT_OVER_ALLOWANCE 1.1 ///< Allow 10 percent over target before alarming on over travel. +#define FIVE_PCT_OVER_ALLOWANCE 1.05 ///< Allow 5 percent over target before alarming on over travel. /// Expected position of empty in relation to home postion. #define SYRINGE_PUMP_EMPTY_POS ( SYRINGE_ENCODER_COUNTS_PER_ML * 11.0 ) @@ -183,7 +183,8 @@ static S32 syringePumpVolumeStartPosition; ///< Start position for the current volume calculation. static S32 syringePumpHomePositionOffset; ///< FPGA reported position when at home postion. static S32 syringePumpPosition1SecAgo; ///< Position recorded at last 1 Hz speed check. -static MOTOR_DIR_T syringePumpMeasuredDirection; ///< Measured direction of syringe pump. +static MOTOR_DIR_T syringePumpControllerMeasuredDirection; ///< Measured direction of syringe pump per controller. +static MOTOR_DIR_T syringePumpEncoderMeasuredDirection; ///< Measured direction of syringe pump per encoder position relative to previous. static BOOL syringePumpRetractRequested; ///< Flag indicates a retract operation is requested. static BOOL syringePumpSeekRequested; ///< Flag indicates a plunger seek operation is requested. @@ -252,7 +253,8 @@ syringePumpVolumeStartPosition = 0; syringePumpHomePositionOffset = 0; syringePumpPosition1SecAgo = 0; - syringePumpMeasuredDirection = MOTOR_DIR_FORWARD; + syringePumpControllerMeasuredDirection = MOTOR_DIR_FORWARD; + syringePumpEncoderMeasuredDirection = MOTOR_DIR_FORWARD; syringePumpDataPublicationTimerCounter = 0; syringePumpSelfTestTimerCount = 0; @@ -815,7 +817,9 @@ // Calculate measured rate (mL/hr) calcMeasRate(); // Get measured direction - syringePumpMeasuredDirection = ( ( encStatus & SYRINGE_PUMP_ENCODER_DIRECTION_BIT ) != 0 ? MOTOR_DIR_REVERSE : MOTOR_DIR_FORWARD ); + syringePumpControllerMeasuredDirection = ( ( encStatus & SYRINGE_PUMP_ENCODER_DIRECTION_BIT ) != 0 ? MOTOR_DIR_REVERSE : MOTOR_DIR_FORWARD ); + // TODO - calc direction from encoder pos relative to last + // syringePumpEncoderMeasuredDirection = TBD; if ( syringePumpDACVrefWriteInProgress != TRUE ) { @@ -1025,11 +1029,15 @@ syringePumpPrimeCompleted = FALSE; result = SYRINGE_PUMP_OFF_STATE; } - else if ( syringePumpMeasuredDirection != MOTOR_DIR_REVERSE ) + else if ( syringePumpControllerMeasuredDirection != MOTOR_DIR_REVERSE ) { // TODO - alarm w/ some persistence } - // TODO - if position know from prior retract, ensure we don't go lower than -TBD position + else if ( syringePumpEncoderMeasuredDirection != MOTOR_DIR_REVERSE ) + { + // TODO - alarm w/ some persistence + } + // TODO - if position known from prior retract, ensure we don't go lower than -TBD position return result; } Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -rbd8d1a18ca5d9dd52c1082f74c19b90ca925af92 -rd5c37b914ce0ba48310f564c9844d03e836679df --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision bd8d1a18ca5d9dd52c1082f74c19b90ca925af92) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision d5c37b914ce0ba48310f564c9844d03e836679df) @@ -429,7 +429,7 @@ * volume collected so far for current treatment. * @details Inputs: measUFVolume, measUFVolumeFromPriorReservoirs * @details Outputs: none - * @return currentUFState + * @return measUFVolume *************************************************************************/ F32 getUltrafiltrationVolumeCollected( void ) { @@ -444,7 +444,7 @@ * reference volume. * @details Inputs: measUFVolume, measUFVolumeFromPriorReservoirs * @details Outputs: none - * @return currentUFState + * @return refUFVolume *************************************************************************/ F32 getUltrafiltrationReferenceVolume( void ) { @@ -496,8 +496,6 @@ // Send response w/ reason code if rejected sendUFPauseResumeResponse( result, rejectReason, currentUFState ); - // Send state data immediately for UI update - broadcastTreatmentTimeAndState(); return result; } @@ -524,7 +522,7 @@ setDialOutPumpTargetRate( setDialysateFlowRate + FLOAT_TO_INT_WITH_ROUND( setUFRate ), MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); // Restart UF time accumulation for reference volume calculation lastUFTimeStamp = getMSTimerCount(); - // Go to UF paused state + // Go to UF running state currentUFState = UF_RUNNING_STATE; } else @@ -731,17 +729,6 @@ salineBolusStartRequested = FALSE; } } - // Handle auto-resume after saline bolus - else if ( TRUE == salineBolusAutoResumeUF ) - { - salineBolusAutoResumeUF = FALSE; - // Set outlet pump to dialysate rate + set UF rate - setDialOutPumpTargetRate( setDialysateFlowRate + FLOAT_TO_INT_WITH_ROUND( setUFRate ), MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); - // Restart UF time accumulation for reference volume calculation - lastUFTimeStamp = getMSTimerCount(); - // Resume UF - result = UF_RUNNING_STATE; - } return result; } @@ -962,6 +949,7 @@ // Resume UF if appropriate if ( TRUE == salineBolusAutoResumeUF ) { + salineBolusAutoResumeUF = FALSE; currentUFState = UF_RUNNING_STATE; } // Resume dialysis