Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -r0eee20d6e821c444dbfbc7ba98b9dd64e2b08ec8 -rdb22e9d530c5c9d62b02e6dcc72ed96fb67c165a --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 0eee20d6e821c444dbfbc7ba98b9dd64e2b08ec8) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision db22e9d530c5c9d62b02e6dcc72ed96fb67c165a) @@ -180,6 +180,9 @@ static BOOL syringePumpContinuousRequested; ///< Flag indicates start or resume of a Heparin continuous delivery operation is requested. static BOOL syringePumpDACVrefSetRequested; ///< Flag indicates request to set DAC Vref for force sensor. +static BOOL syringePumpPlungerFound; ///< Flag indicates plunger was found. +static BOOL syringePumpPrimeCompleted; ///< Flag indicates prime operation was completed. + static BOOL syringePumpDACVrefWriteInProgress; ///< Flag indicates DAC Vref write is in progress. static F32 syringePumpDACVref; ///< DAC Vref setting for force sensor. @@ -241,6 +244,9 @@ syringePumpSpeedCalcTimerCounter = 0; syringePumpRampTimerCtr = 0; + syringePumpPlungerFound = FALSE; + syringePumpPrimeCompleted = FALSE; + lastSyringePumpADCReadCtr = 0; // Reset request flags @@ -603,6 +609,32 @@ /*********************************************************************//** * @brief + * The isSyringePlungerFound function determines whether the syringe pump + * plunger seek operation was completed. + * @details Inputs: syringePumpPlungerFound + * @details Outputs: none + * @return TRUE if syringe plunger was found, FALSE if not. + *************************************************************************/ +BOOL isSyringePlungerFound( void ) +{ + return syringePumpPlungerFound; +} + +/*********************************************************************//** + * @brief + * The isSyringePumpPrimed function determines whether the syringe pump + * prime operation was completed. + * @details Inputs: syringePumpPrimeCompleted + * @details Outputs: none + * @return TRUE if syringe pump prime is completed, FALSE if not. + *************************************************************************/ +BOOL isSyringePumpPrimed( void ) +{ + return syringePumpPrimeCompleted;; +} + +/*********************************************************************//** + * @brief * The execSyringePumpMonitor function executes the syringe pump monitor. * @details Inputs: FPGA syringe pump readings * @details Outputs: Alarm(s) may be triggered @@ -809,6 +841,8 @@ syringePumpPosition.data = 0; syringePumpVolumeStartPosition = 0; syringePumpVolumeDelivered.data = 0.0; + syringePumpPlungerFound = FALSE; + syringePumpPrimeCompleted = FALSE; result = SYRINGE_PUMP_OFF_STATE; } // Stop retract if syringe is detected (should not have a syringe loaded during retract) @@ -839,8 +873,9 @@ rampSyringePump(); // Is plunger contact detected? - if ( ( syringePumpRampTimerCtr > 800 ) || ( getSyringePumpForceV() >= SYRINGE_FORCE_PLUNGER_THRESHOLD_V ) ) + if ( getSyringePumpForceV() >= SYRINGE_FORCE_PLUNGER_THRESHOLD_V ) { + syringePumpPlungerFound = TRUE; syringePumpVolumeDelivered.data = 0.0; syringePumpVolumeStartPosition = syringePumpPosition.data; syringePumpSetRate = SYRINGE_PUMP_PRIME_RATE; @@ -886,6 +921,7 @@ if ( getSyringePumpVolumeDelivered() >= SYRINGE_PUMP_PRIME_VOLUME_ML ) { stopPump = TRUE; + syringePumpPrimeCompleted = TRUE; syringePumpVolumeDelivered.data = 0.0; syringePumpVolumeStartPosition = syringePumpPosition.data; } Index: firmware/App/Controllers/SyringePump.h =================================================================== diff -u -rf25fbefbf6baa354b26dcbe17787821124b56c82 -rdb22e9d530c5c9d62b02e6dcc72ed96fb67c165a --- firmware/App/Controllers/SyringePump.h (.../SyringePump.h) (revision f25fbefbf6baa354b26dcbe17787821124b56c82) +++ firmware/App/Controllers/SyringePump.h (.../SyringePump.h) (revision db22e9d530c5c9d62b02e6dcc72ed96fb67c165a) @@ -78,6 +78,8 @@ BOOL isSyringeDetected( void ); BOOL isSyringePumpHome( void ); BOOL isSyringePumpStopped( void ); +BOOL isSyringePlungerFound( void ); +BOOL isSyringePumpPrimed( void ); F32 getSyringePumpVolumeDelivered( void ); SELF_TEST_STATUS_T execSyringePumpTest( void ); Index: firmware/App/HDCommon.h =================================================================== diff -u -r0eee20d6e821c444dbfbc7ba98b9dd64e2b08ec8 -rdb22e9d530c5c9d62b02e6dcc72ed96fb67c165a --- firmware/App/HDCommon.h (.../HDCommon.h) (revision 0eee20d6e821c444dbfbc7ba98b9dd64e2b08ec8) +++ firmware/App/HDCommon.h (.../HDCommon.h) (revision db22e9d530c5c9d62b02e6dcc72ed96fb67c165a) @@ -48,7 +48,6 @@ #define DISABLE_PUMP_FLOW_CHECKS 1 // Do not error on HD pump flow checks #define DISABLE_PUMP_SPEED_CHECKS 1 // Do not error on HD pump speed checks #define DISABLE_PUMP_DIRECTION_CHECKS 1 // Do not error on HD pump direction checks -// #define DISABLE_SALINE_BOLUS_CHECKS 1 // Do not error on HD saline bolus checks #define DISABLE_SYRINGE_PUMP 1 // Disable syringe pump functionality #define DISABLE_PRESSURE_CHECKS 1 // Do not error on HD pressure checks // #define DISABLE_UF_ALARMS 1 // Do not error on HD ultrafiltration checks Index: firmware/App/Modes/BloodPrime.c =================================================================== diff -u -rac6532c81f2a6d4ad1c67420c22d59f6aeeaae13 -rdb22e9d530c5c9d62b02e6dcc72ed96fb67c165a --- firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision ac6532c81f2a6d4ad1c67420c22d59f6aeeaae13) +++ firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision db22e9d530c5c9d62b02e6dcc72ed96fb67c165a) @@ -67,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. @@ -209,7 +209,7 @@ // update blood prime volume delivered so far cumulativeBloodPrimeVolume_mL += ( getMeasuredBloodFlowRate() * BLOOD_PRIME_FLOW_INTEGRATOR ); // update independent calculated safety volume delivered so far - bloodPrimeMotorCount = u32DiffWithWrap( bloodPrimeLastMotorCount, getBloodPumpMotorCount() ) / BP_HALL_EDGE_COUNTS_PER_REV; + 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? Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r88ee6f3dce69a3dadb012bb8a39c3fd167ba0afd -rdb22e9d530c5c9d62b02e6dcc72ed96fb67c165a --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 88ee6f3dce69a3dadb012bb8a39c3fd167ba0afd) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision db22e9d530c5c9d62b02e6dcc72ed96fb67c165a) @@ -887,15 +887,13 @@ bolusSalineMotorCount = u32BiDiffWithWrap( 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 (from PBA). -#ifndef DISABLE_SALINE_BOLUS_CHECKS - // TODO - check for empty saline bag - if ( 0 ) + // Check for empty saline bag + if ( TRUE == isSalineBagEmpty() ) { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_EMPTY_SALINE_BAG, 0.0 ); // TODO - give data supporting empty bag detection + activateAlarmNoData( ALARM_ID_EMPTY_SALINE_BAG ); errorFound = TRUE; result = SALINE_BOLUS_STATE_IDLE; } -#endif // Determine if we have reached maximum saline delivery volume if ( ( totalSalineVolumeDelivered >= (F32)MAX_SALINE_VOLUME_DELIVERED ) ) @@ -910,7 +908,7 @@ // If safety thinks we have under-delivered the bolus, throw a fault if ( bolusSalineVolumeDelivered_Safety < ( bolusTargetVolume * MIN_SALINE_BOLUS_VOLUME_PCT ) ) { -#ifndef DISABLE_SALINE_BOLUS_CHECKS +#ifndef DISABLE_PUMP_FLOW_CHECKS SET_ALARM_WITH_2_F32_DATA( ALARM_ID_SALINE_BOLUS_VOLUME_CHECK_FAILURE, bolusTargetVolume, bolusSalineVolumeDelivered_Safety ); errorFound = TRUE; #endif @@ -926,7 +924,7 @@ // Determine if safety thinks we have over-delivered the bolus else if ( bolusSalineVolumeDelivered_Safety > ( bolusTargetVolume * MAX_SALINE_BOLUS_VOLUME_PCT ) ) { -#ifndef DISABLE_SALINE_BOLUS_CHECKS +#ifndef DISABLE_PUMP_FLOW_CHECKS SET_ALARM_WITH_2_F32_DATA( ALARM_ID_SALINE_BOLUS_VOLUME_CHECK_FAILURE, bolusTargetVolume, bolusSalineVolumeDelivered_Safety ); errorFound = TRUE; result = SALINE_BOLUS_STATE_IDLE; Index: firmware/App/Modes/Rinseback.c =================================================================== diff -u -rac6532c81f2a6d4ad1c67420c22d59f6aeeaae13 -rdb22e9d530c5c9d62b02e6dcc72ed96fb67c165a --- firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision ac6532c81f2a6d4ad1c67420c22d59f6aeeaae13) +++ firmware/App/Modes/Rinseback.c (.../Rinseback.c) (revision db22e9d530c5c9d62b02e6dcc72ed96fb67c165a) @@ -66,7 +66,7 @@ static F32 cumulativeRinsebackVolume_mL; ///< Total cumulative rinseback volume (in mL). static F32 targetRinsebackVolumePlusAdditional_mL; ///< Target rinseback volume w/ additional volume(s) added (in mL). static F32 additionalRinsebackVolume_mL; ///< Total volume (in mL) delivered so far for additional volume request. -static U32 rinsebackMotorCount; ///< The cumulative sum of BP motor encoder counts used for independent rinseback volume check. +static S32 rinsebackMotorCount; ///< The cumulative sum of BP motor encoder counts used for independent rinseback volume check. static U32 rinsebackLastMotorCount; ///< The last BP motor encoder count read for independent rinseback volume check. static F32 rinsebackVolumeDelivered_Safety; ///< The cumulative independent rinseback volume (in mL) calculated so far. static U32 rinsebackAdditionalTimerCtr; ///< Timer counter for duration of an additional rinseback delivery. @@ -345,7 +345,7 @@ // Update rinseback volume delivered so far cumulativeRinsebackVolume_mL += ( getMeasuredBloodFlowRate() * RINSEBACK_FLOW_INTEGRATOR ); // update independent calculated safety volume delivered so far - rinsebackMotorCount = u32DiffWithWrap( rinsebackLastMotorCount, getBloodPumpMotorCount() ) / BP_HALL_EDGE_COUNTS_PER_REV; + rinsebackMotorCount = u32BiDiffWithWrap( 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? @@ -371,7 +371,7 @@ // Check for empty saline bag if ( TRUE == isSalineBagEmpty() ) { - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_EMPTY_SALINE_BAG, 0.0 ); // TODO - give data supporting empty bag detection + activateAlarmNoData( ALARM_ID_EMPTY_SALINE_BAG ); setupForRinsebackStopOrPause(); result = RINSEBACK_PAUSED_STATE; }