Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r3d409ee7130063937dce719281bb072c87023d3f -r0afd6b2cf9e986d314f37fb9bf34ca4fba077266 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 3d409ee7130063937dce719281bb072c87023d3f) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 0afd6b2cf9e986d314f37fb9bf34ca4fba077266) @@ -79,8 +79,9 @@ static const U32 DIP_OFF_ERROR_PERSIST = ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); /// Persist time (task intervals) motor speed error condition. static const U32 DIP_MOTOR_SPEED_ERROR_PERSIST = ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); -/// Rotor speed persist time test needs a minimum number of rotations. -static const U32 DIP_ROTOR_ERROR_PERSIST_ROTATION_MIN = 3; +/// Rotor speed persist time test needs a minimum number of rotations or time. +static const U32 DIP_ROTOR_ERROR_PERSIST_ROTATION_MIN = 10; +static const U32 DIP_ROTOR_ERROR_PERSIST_TIME_MIN = (10 * MS_PER_SECOND); /// Persist time (task intervals) pump direction error condition. static const U32 DIP_DIRECTION_ERROR_PERSIST = (250 / TASK_PRIORITY_INTERVAL); /// Time threshold to trigger an alarm if Dialysate flow data has not arrived within 3 seconds @@ -1069,15 +1070,17 @@ U32 getPumpRotorErrorPersistTime( F32 mtr_rpm, F32 gear_ratio ) { U32 err_persist_time = HEX_32_BIT_FULL_SCALE; // 49 days - U32 temporaryPersistentTimeout = 10 * MS_PER_SECOND; + F32 absMotRPM = fabs( mtr_rpm ); - if ( mtr_rpm > 0 ) + if ( absMotRPM > NEARLY_ZERO ) { /// Calculate persist time for rotor speed error condition. - err_persist_time = ( ( DIP_ROTOR_ERROR_PERSIST_ROTATION_MIN / ( mtr_rpm / gear_ratio / SEC_PER_MIN ) ) * MS_PER_SECOND ); + err_persist_time = ( ( (F32)DIP_ROTOR_ERROR_PERSIST_ROTATION_MIN / ( absMotRPM / gear_ratio / (F32)SEC_PER_MIN ) ) * (F32)MS_PER_SECOND ); + // Choose bigger value of MinTime or calculated persist time + err_persist_time = MAX(DIP_ROTOR_ERROR_PERSIST_TIME_MIN, err_persist_time); } - return err_persist_time + temporaryPersistentTimeout; + return err_persist_time; } /*********************************************************************//**