Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -r1354685cce00d343e29be2c098fd9fdb857374ae -r4d0c621f5994e1de8bf7d3337678f7835292ce73 --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 1354685cce00d343e29be2c098fd9fdb857374ae) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 4d0c621f5994e1de8bf7d3337678f7835292ce73) @@ -8,14 +8,15 @@ * @file SyringePump.c * * @author (last) Sean Nash -* @date (last) 03-Jun-2023 +* @date (last) 16-Aug-2023 * * @author (original) Sean Nash * @date (original) 04-Mar-2021 * ***************************************************************************/ -#include +#include // Used for fabs() functions + #include "AlarmMgmt.h" #include "FPGA.h" #include "ModeTreatmentParams.h" @@ -69,7 +70,8 @@ #define SYRINGE_PUMP_DIR_ALARM_PERSISTENCE 3000 ///< Alarm persistence period (in ms) for syringe pump direction check alarms. #define SYRINGE_PUMP_OFF_ALARM_PERSISTENCE 1000 ///< Alarm persistence period (in ms) for syringe pump off check alarms. #define SYRINGE_PUMP_OFF_ERROR_MAX_CNT 10 ///< Maximum number of syringe pump not stopped errors within time window before alarm triggered. Do not exceed MAX_TIME_WINDOWED_COUNT. -#define SYRINGE_PUMP_OFF_ERROR_TIME_WIN_MS (1 * MS_PER_SECOND) ///< Time window for Syringe Pump not stopped error. +#define SYRINGE_PUMP_OFF_ERROR_TIME_WIN_MS ( 1 * MS_PER_SECOND ) ///< Time window for Syringe Pump not stopped error. +#define SYRINGE_PUMP_PRIMING_TIMEOUT_MS ( 5 * MS_PER_SECOND ) ///< Timeout for syringe pump prime operation. #define STEPS_TO_MICROSTEPS( s ) ( (s) * 32.0F ) ///< Macro conversion from steps to microsteps. #define MICROSTEPS_TO_STEPS( m ) ( (m) / 32.0F ) ///< Macro conversion from microsteps to steps. @@ -235,6 +237,7 @@ static BOOL syringeVolumeAdequate; ///< Flag indicates whether Heparin volume is sufficient to complete treatment. static BOOL syringePumpPrimeCompleted; ///< Flag indicates prime operation was completed. static BOOL syringePumpPreLoadCompleted; ///< Flag indicates preload operation was completed. +static U32 syringePumpStateStartTime; ///< Time current syringe pump state started. static BOOL syringePumpDACVrefWriteInProgress; ///< Flag indicates DAC Vref write is in progress. static F32 syringePumpDACVref; ///< DAC Vref setting for force sensor. @@ -314,6 +317,7 @@ syringePumpSpeedCalcTimerCounter = 0; syringePumpRampTimerCtr = 0; syringePumpSafetyVolumeDelivered = 0.0; + syringePumpStateStartTime = getMSTimerCount(); syringePumpPositionKnown = FALSE; syringePumpPlungerFound = FALSE; @@ -1362,6 +1366,7 @@ // If we are starting an active pump state, set direction and calculate target toggle time to achieve desired rate if ( ( result != SYRINGE_PUMP_OFF_STATE ) && ( result != SYRINGE_PUMP_CONFIG_FORCE_SENSOR_STATE ) ) { + syringePumpStateStartTime = getMSTimerCount(); if ( SYRINGE_PUMP_RETRACT_STATE == result ) { // Set fpga direction to reverse @@ -1578,7 +1583,7 @@ * @brief * The handleSyringePumpPrimeState function handles the prime state * of the syringe pump control state machine. - * @details Inputs: syringePumpVolumeDelivered.data + * @details Inputs: syringePumpVolumeDelivered, syringePumpStateStartTime * @details Outputs: Syringe pump ramped up to prime rate, alarm conditions checked * @return next state *************************************************************************/ @@ -1600,6 +1605,13 @@ syringePumpVolumeStartPosition = syringePumpPosition.data; } + // Check for timeout + if ( TRUE == didTimeout( syringePumpStateStartTime, SYRINGE_PUMP_PRIMING_TIMEOUT_MS ) ) + { + stopPump = TRUE; + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_SYRINGE_PUMP_OCCLUSION, (F32)SYRINGE_PUMP_PRIMING_TIMEOUT_MS, 0.0F ) + } + // Check for stall stopPump = checkForStall( stopPump ); @@ -1875,6 +1887,10 @@ SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_SYRINGE_PUMP_OCCLUSION, forceAtEndOfSeek, currentForceV ) result = TRUE; } + else + { + clearAlarmCondition( ALARM_ID_HD_SYRINGE_PUMP_OCCLUSION ); + } } // Check with persistence during continuous state