Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u -r736cc5b56cc9c784ab1d8fc8687a73d190c35759 -r5d21baeb59273eb0f9fa54d8e4802fa31abbdbab --- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 736cc5b56cc9c784ab1d8fc8687a73d190c35759) +++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 5d21baeb59273eb0f9fa54d8e4802fa31abbdbab) @@ -45,6 +45,8 @@ #define PRES_LIMIT_STABILIZATION_TIME_MS ( 60 * MS_PER_SECOND ) ///< Duration of pressure limit stabilization period (in ms). #define PRES_LIMIT_SHORT_STABILIZE_TIME_MS ( 10 * MS_PER_SECOND ) ///< Duration of pressure limit short stabilization period (in ms). #define PRES_LIMIT_RESTABILIZE_TIME_MS ( 30 * SEC_PER_MIN * MS_PER_SECOND ) ///< Duration of pressure limit re-stabilize period (in ms). +// Pressure Limit minimum stabilization time before short stabilization time activation +static const U32 PRES_LIMIT_MIN_STABILIZATION_TIME_IN_MS = ( PRES_LIMIT_STABILIZATION_TIME_MS - PRES_LIMIT_SHORT_STABILIZE_TIME_MS ) ; #define ARTERIAL_PRESSURE_CONVERSION_OFFSET 0x800000 ///< Arterial pressure conversion coefficient. #define ARTERIAL_PRESSURE_V_BIAS ( 3.0F ) ///< Bias voltage for arterial pressure sensor. @@ -450,15 +452,23 @@ *************************************************************************/ void signalInitiatePressureStabilization( BOOL useShort ) { - useShortStabilizeTime = useShort; - // User update of blood/dialysate flow rate or UF rate or initiates/resets a stabilization period (if we were in stabilization or stable state) if ( PRESSURE_LIMITS_STATE_STABILIZATION == currPresLimitsState ) { - stabilizationStartTimeMs = getMSTimerCount(); + U32 currentTime = getMSTimerCount(); + U32 expiredTime = ( currentTime > stabilizationStartTimeMs ) ? ( currentTime - stabilizationStartTimeMs ) : + ( ( 0xFFFFFFFF - stabilizationStartTimeMs ) + currentTime + 1 ) ; + // if pressure is already stabilized enough, assign the short stabilize time for the recent event ( air pump on). else, + // leave the current/on going stabilization to expire due to long pending stable time to settle down the pressure. + if ( expiredTime > PRES_LIMIT_MIN_STABILIZATION_TIME_IN_MS ) + { + useShortStabilizeTime = useShort; + stabilizationStartTimeMs = getMSTimerCount(); + } } else if ( PRESSURE_LIMITS_STATE_STABLE == currPresLimitsState ) { + useShortStabilizeTime = useShort; currPresLimitsState = PRESSURE_LIMITS_STATE_STABILIZATION; stabilizationStartTimeMs = getMSTimerCount(); }