Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -re5c6383e93940c2722d3bf73beb1d13a6d3eae6e -r0afd6b2cf9e986d314f37fb9bf34ca4fba077266 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision e5c6383e93940c2722d3bf73beb1d13a6d3eae6e) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 0afd6b2cf9e986d314f37fb9bf34ca4fba077266) @@ -8,7 +8,7 @@ * @file DialInFlow.c * * @author (last) Dara Navaei -* @date (last) 08-May-2023 +* @date (last) 21-May-2023 * * @author (original) Sean * @date (original) 16-Dec-2019 @@ -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 @@ -1063,17 +1064,20 @@ * @details Inputs: none * @details Outputs: none * @param mtr_rpm, RPM of the motor. - * gear_ratio, Gear ratio of motor vs motor + * @param gear_ratio, Gear ratio of motor vs motor * @return Persistent error test time in (ms) *************************************************************************/ U32 getPumpRotorErrorPersistTime( F32 mtr_rpm, F32 gear_ratio ) { U32 err_persist_time = HEX_32_BIT_FULL_SCALE; // 49 days + 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;