Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -r4ddf1777acc4298a9ed034e56b66916256d22c18 -r1d4d52365189e2cc83b97d28761bc2d4f0128859 --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 4ddf1777acc4298a9ed034e56b66916256d22c18) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 1d4d52365189e2cc83b97d28761bc2d4f0128859) @@ -7,8 +7,8 @@ * * @file SyringePump.c * -* @author (last) Michael Garthwaite -* @date (last) 09-Feb-2023 +* @author (last) Sean Nash +* @date (last) 07-Mar-2023 * * @author (original) Sean Nash * @date (original) 04-Mar-2021 @@ -92,8 +92,8 @@ #define MIN_SYRINGE_PUMP_RATE_FOR_DIR_ALARM 0.5F ///< Minimum measured rate (in mL/hr) required before enforcing direction alarm. /// Expected position of empty in relation to home position. -#define SYRINGE_PUMP_EMPTY_POS ( SYRINGE_ENCODER_COUNTS_PER_ML * 10.84F ) -/// Margin of error for empty position determination. +#define SYRINGE_PUMP_EMPTY_POS ( SYRINGE_ENCODER_COUNTS_PER_ML * 11.0F ) +/// Over-travel (past empty) allowance for alarm. #define SYRINGE_PUMP_EMPTY_POS_MARGIN ( SYRINGE_ENCODER_COUNTS_PER_ML * 0.5F ) /// Minimum retract position. #define SYRINGE_PUMP_RETRACT_POS_MIN ( SYRINGE_ENCODER_COUNTS_PER_ML * -0.5F ) @@ -1410,6 +1410,7 @@ syringePumpPlungerFound = FALSE; syringeVolumeAdequate = FALSE; syringePumpPrimeCompleted = FALSE; + syringePumpPreLoadCompleted = FALSE; syringePumpVolumeRequired = 0.0F; // Clear insufficient volume alarm condition in case we're retracting to allow user to resolve alarm clearAlarmCondition( ALARM_ID_HD_SYRINGE_PUMP_NOT_ENOUGH_HEPARIN_ALARM ); @@ -1421,8 +1422,10 @@ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SYRINGE_PUMP_OVER_TRAVEL_ERROR, (U32)getSyringePumpPosition(), (U32)SYRINGE_PUMP_RETRACT_STATE ); } + // Check for stall stopPump = checkForStall( stopPump ); + // Check direction stopPump = checkDirection( stopPump, MOTOR_DIR_REVERSE ); // If anything found that would require stopping the pump, stop pump and go to off state @@ -1460,17 +1463,8 @@ syringePumpVolumeRequired = txVolumeReq; txVolumeReq = txVolumeReq + SYRINGE_PUMP_PRELOAD_MARGIN_VOLUME_ML; - // Is syringe loaded? - if ( TRUE == isSyringeDetected() ) - { - activateAlarmNoData( ALARM_ID_HD_SYRINGE_DETECTED ); - stopPump = TRUE; - } - else - { - // Handle ramp up - rampSyringePump(); - } + // Handle ramp up + rampSyringePump(); // Is plunger Heparin volume position detected? or volume requiring full syringe. if ( ( syringeVol <= txVolumeReq ) || ( SYRINGE_PUMP_PRELOAD_MAX_VOLUME_ML < txVolumeReq ) ) @@ -1482,6 +1476,9 @@ syringePumpPreLoadCompleted = TRUE; } + // Check for stall + stopPump = checkForStall( stopPump ); + // Check max position > empty + 0.5 mL stopPump = checkMaxTravel( stopPump, SYRINGE_PUMP_EMPTY_POS + SYRINGE_PUMP_EMPTY_POS_MARGIN ); @@ -1547,6 +1544,9 @@ } } + // Check for stall + stopPump = checkForStall( stopPump ); + // Has syringe been removed? stopPump = checkSyringeRemoved( stopPump ); @@ -1815,7 +1815,7 @@ S32 pos = getSyringePumpPosition(); // If near empty position, assume syringe is empty - if ( fabs( pos - SYRINGE_PUMP_EMPTY_POS ) < SYRINGE_PUMP_EMPTY_POS_MARGIN ) + if ( pos >= SYRINGE_PUMP_EMPTY_POS ) { heparinDeliveryState = HEPARIN_STATE_EMPTY; SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_SYRINGE_PUMP_SYRINGE_EMPTY, (F32)pos, force ) @@ -1888,20 +1888,11 @@ BOOL result = stopPump; S32 pos = getSyringePumpPosition(); - if ( pos > ( SYRINGE_PUMP_EMPTY_POS - SYRINGE_PUMP_EMPTY_POS_MARGIN ) ) + if ( pos >= maxPos ) { result = TRUE; - heparinDeliveryState = HEPARIN_STATE_EMPTY; - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_SYRINGE_PUMP_SYRINGE_EMPTY, (F32)pos, getSyringePumpForceV() ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SYRINGE_PUMP_OVER_TRAVEL_ERROR, (U32)pos, (U32)syringePumpState ); } - else if ( pos > maxPos ) - { - result = TRUE; - if ( syringePumpState != SYRINGE_PUMP_PRIME_STATE ) - { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SYRINGE_PUMP_OVER_TRAVEL_ERROR, (U32)pos, (U32)syringePumpState ); - } - } return result; }