Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -rfba69244d94307e50fefaa1e88bcbb979584461e -rbeeb805ec212b64d188d2ce242c21cb8fb7a9d21 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision fba69244d94307e50fefaa1e88bcbb979584461e) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision beeb805ec212b64d188d2ce242c21cb8fb7a9d21) @@ -53,7 +53,6 @@ #define MAX_DIAL_IN_PUMP_PWM_STEP_DN_CHANGE 0.016F ///< Max duty cycle change when ramping down. #define MAX_DIAL_IN_PUMP_PWM_DUTY_CYCLE 0.90F ///< Controller will error if PWM duty cycle > 90%, so set max to 90%. #define MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE 0.10F ///< Controller will error if PWM duty cycle < 10%, so set min to 10%. -#define MIN_DG_DIAL_FLOW_RATE 10.0F ///< Minimum DG Dialysate Flow Rate (mL/Min) #define DIP_CONTROL_INTERVAL_SEC 4 ///< Dialysate inlet pump control interval (in seconds). /// Interval (ms/task time) at which the dialIn pump is controlled. Index: firmware/App/Controllers/DialInFlow.h =================================================================== diff -u -rfba69244d94307e50fefaa1e88bcbb979584461e -rbeeb805ec212b64d188d2ce242c21cb8fb7a9d21 --- firmware/App/Controllers/DialInFlow.h (.../DialInFlow.h) (revision fba69244d94307e50fefaa1e88bcbb979584461e) +++ firmware/App/Controllers/DialInFlow.h (.../DialInFlow.h) (revision beeb805ec212b64d188d2ce242c21cb8fb7a9d21) @@ -14,27 +14,28 @@ * @date (original) 16-Dec-2019 * ***************************************************************************/ - -#ifndef __DIALYSATE_IN_FLOW_H__ -#define __DIALYSATE_IN_FLOW_H__ - -#include "HDCommon.h" - -/** - * @defgroup DialysateInletFlow DialysateInletFlow - * @brief Dialysate Inlet Pump & Dialysate Flow controller/monitor module. - * Monitors the dialysate flow rate and controls the dialysate inlet pump. - * - * @addtogroup DialysateInletFlow - * @{ - */ - -// ********** public definitions ********** - -#define MAX_DIAL_IN_FLOW_RATE 600 ///< Maximum dialysate inlet flow rate (in mL/min). -#define MIN_DIAL_IN_FLOW_RATE 100 ///< Minimum dialysate inlet flow rate (in mL/min). + +#ifndef __DIALYSATE_IN_FLOW_H__ +#define __DIALYSATE_IN_FLOW_H__ + +#include "HDCommon.h" + +/** + * @defgroup DialysateInletFlow DialysateInletFlow + * @brief Dialysate Inlet Pump & Dialysate Flow controller/monitor module. + * Monitors the dialysate flow rate and controls the dialysate inlet pump. + * + * @addtogroup DialysateInletFlow + * @{ + */ + +// ********** public definitions ********** + +#define MAX_DIAL_IN_FLOW_RATE 600 ///< Maximum dialysate inlet flow rate (in mL/min). +#define MIN_DIAL_IN_FLOW_RATE 100 ///< Minimum dialysate inlet flow rate (in mL/min). #define DIALYSATE_FLOW_RATE_FOR_RECIRC 250 ///< Dialysate recirculation flow rate (in mL/min). - +#define MIN_DG_DIAL_FLOW_RATE 10.0F ///< Minimum DG Dialysate Flow Rate (mL/Min) + /// Payload record structure for a dialysate inlet pump data message. typedef struct { @@ -50,50 +51,50 @@ U32 rotorHall; ///< Rotor hall in counts. } DIALIN_PUMP_STATUS_PAYLOAD_T; -// ********** public function prototypes ********** - -void initDialInFlow( void ); -void execDialInFlowMonitor( void ); -void execDialInFlowController( void ); - -BOOL setDialInPumpTargetFlowRate( U32 flowRate, MOTOR_DIR_T dir, PUMP_CONTROL_MODE_T mode ); +// ********** public function prototypes ********** + +void initDialInFlow( void ); +void execDialInFlowMonitor( void ); +void execDialInFlowController( void ); + +BOOL setDialInPumpTargetFlowRate( U32 flowRate, MOTOR_DIR_T dir, PUMP_CONTROL_MODE_T mode ); BOOL setDialInPumpTargetRPM( U32 rpm, MOTOR_DIR_T dir ); -void signalDialInPumpHardStop( void ); +void signalDialInPumpHardStop( void ); void signalDialInPumpRotorHallSensor( void ); -BOOL homeDialInPump( void ); +BOOL homeDialInPump( void ); BOOL isDialInPumpRunning( void ); BOOL isDialInPumpRampComplete( void ); void resetDialInPumpRotorCount( void ); - -SELF_TEST_STATUS_T execDialInFlowTest( void ); - -S32 getTargetDialInFlowRate( void ); + +SELF_TEST_STATUS_T execDialInFlowTest( void ); + +S32 getTargetDialInFlowRate( void ); F32 getMeasuredDialInFlowRate( void ); -F32 getMeasuredDialInPumpRotorSpeed( void ); -F32 getMeasuredDialInPumpSpeed( void ); -F32 getMeasuredDialInPumpMCSpeed( void ); +F32 getMeasuredDialInPumpRotorSpeed( void ); +F32 getMeasuredDialInPumpSpeed( void ); +F32 getMeasuredDialInPumpMCSpeed( void ); F32 getMeasuredDialInPumpMCCurrent( void ); F32 getDialInPumpPWMDutyCyclePct( BOOL init ); U32 getDialInPumpRotorCount( void ); U32 getPumpRotorErrorPersistTime( F32 mtr_speed, F32 gear_ratio ); - -BOOL testSetDialInFlowDataPublishIntervalOverride( U32 value ); -BOOL testResetDialInFlowDataPublishIntervalOverride( void ); -BOOL testSetTargetDialInFlowRateOverride( S32 value, U32 ctrlMode ); -BOOL testSetMeasuredDialInFlowRateOverride( F32 value ); -BOOL testResetMeasuredDialInFlowRateOverride( void ); -BOOL testSetMeasuredDialInPumpRotorSpeedOverride( F32 value ); -BOOL testResetMeasuredDialInPumpRotorSpeedOverride( void ); -BOOL testSetMeasuredDialInPumpSpeedOverride( F32 value ); -BOOL testResetMeasuredDialInPumpSpeedOverride( void ); -BOOL testSetMeasuredDialInPumpMCSpeedOverride( F32 value ); -BOOL testResetMeasuredDialInPumpMCSpeedOverride( void ); -BOOL testSetMeasuredDialInPumpMCCurrentOverride( F32 value ); + +BOOL testSetDialInFlowDataPublishIntervalOverride( U32 value ); +BOOL testResetDialInFlowDataPublishIntervalOverride( void ); +BOOL testSetTargetDialInFlowRateOverride( S32 value, U32 ctrlMode ); +BOOL testSetMeasuredDialInFlowRateOverride( F32 value ); +BOOL testResetMeasuredDialInFlowRateOverride( void ); +BOOL testSetMeasuredDialInPumpRotorSpeedOverride( F32 value ); +BOOL testResetMeasuredDialInPumpRotorSpeedOverride( void ); +BOOL testSetMeasuredDialInPumpSpeedOverride( F32 value ); +BOOL testResetMeasuredDialInPumpSpeedOverride( void ); +BOOL testSetMeasuredDialInPumpMCSpeedOverride( F32 value ); +BOOL testResetMeasuredDialInPumpMCSpeedOverride( void ); +BOOL testSetMeasuredDialInPumpMCCurrentOverride( F32 value ); BOOL testResetMeasuredDialInPumpMCCurrentOverride( void ); BOOL testSetDialInPumpTargetDutyCycle( F32 value ); BOOL testSetDialysateInPumpRotorCountOverride( U32 value ); -BOOL testResetDialysateInPumpRotorCountOverride( void ); - -/**@}*/ - -#endif +BOOL testResetDialysateInPumpRotorCountOverride( void ); + +/**@}*/ + +#endif Index: firmware/App/Modes/Prime.c =================================================================== diff -u -rfba69244d94307e50fefaa1e88bcbb979584461e -rbeeb805ec212b64d188d2ce242c21cb8fb7a9d21 --- firmware/App/Modes/Prime.c (.../Prime.c) (revision fba69244d94307e50fefaa1e88bcbb979584461e) +++ firmware/App/Modes/Prime.c (.../Prime.c) (revision beeb805ec212b64d188d2ce242c21cb8fb7a9d21) @@ -65,6 +65,7 @@ #define STEADY_VOLUME_DIALYSATE_PRIME_HISTERESIS_ML 0.3F ///< mL of histeresis for the steady state check that determines when bypass line is primed. #define STEADY_VOLUME_BYPASS_PRIME_HISTERESIS_ML 0.3F ///< mL of histeresis for the steady state check that determines when bypass line is primed. #define PRESSURE_OFFSET_DIALYSATE_PRIME_MMHG 50.0F ///< +/- offset from start pressure that defines a range to keep PBo in during dialysate dialyzer prime state. +#define MIN_VENOUS_PRESSURE_DIALSYATE_LINE_OCCLUSION_MMHG -15.0F ///< Minimum measured venous pressure indicates possible clamping/occlusion during dialysate priming. #define DPO_RATE_STEP_PER_SEC_DIALYSATE_PRIME_ML_MIN 1 ///< DPo rate step to maintain pressure during dialysate dialyzer prime state. #define VENOUS_PRESSURE_BUBBLE_CLEAR_MAX_MMHG ( 200.0F ) ///< Maximum venous pressure reading (in mmHg) for bubble clear. @@ -143,6 +144,7 @@ static F32 minimumReservoirVolume; ///< Minimum reservoir volume in mL. static U32 steadyVolumeCount; ///< Use to keep track the number of dVolume/dt < Threshold static BOOL bubbleClearEnded; ///< Bubble clear ended boolean signal. +static BOOL primeDialysateOcclusionDetected; ///< flag used when dialysate occlusion alarm set // ********** private function prototypes ********** @@ -181,6 +183,7 @@ primePauseStartTime = 0; primeStatusBroadcastTimerCounter = 0; bubbleClearEnded = FALSE; + primeDialysateOcclusionDetected = FALSE; } /*********************************************************************//** @@ -818,6 +821,8 @@ if ( TRUE == didTimeout( steadyVolumeSamplingStartTime, LOAD_CELL_STEADY_VOLUME_SAMPLING_TIME ) ) { F32 venPres = getFilteredVenousPressure(); + F32 measuredDialInFlow = getDGRawDialysateFlowRateLMin() * ML_PER_LITER; + BOOL lowFlow = ( measuredDialInFlow < MIN_DG_DIAL_FLOW_RATE ? TRUE : FALSE ); if ( venPres > ( primeDialysateDialyzerStartVenPres + PRESSURE_OFFSET_DIALYSATE_PRIME_MMHG ) ) { @@ -829,6 +834,20 @@ primeDialysateDialyzerDPoRate -= DPO_RATE_STEP_PER_SEC_DIALYSATE_PRIME_ML_MIN; setDialOutPumpTargetRate( primeDialysateDialyzerDPoRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); } + + // if dialysate line is clamped for some reasons, raise an alarm based on the measured venous pressure and raw flow rate. + if ( ( venPres <= MIN_VENOUS_PRESSURE_DIALSYATE_LINE_OCCLUSION_MMHG ) && ( TRUE == lowFlow ) ) + { + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_PRIME_DIALYSATE_LINE_OCCLUSION, venPres, measuredDialInFlow ); + primeDialysateOcclusionDetected = TRUE; + } + else if ( TRUE == primeDialysateOcclusionDetected ) + { + // after clearance of occlusion, start the blood side priming due to any air bubbles collected prior. + state = HD_PRIME_SALINE_SETUP_STATE; + primeDialysateOcclusionDetected = FALSE; + } + steadyVolumeSamplingStartTime = getMSTimerCount(); }