Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r46b163d19c65e8c21db7b0247bbb1af0dba1ece5 -r15919f0c12c0047d3b6331c1f97cdad1dafb3f1b --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 46b163d19c65e8c21db7b0247bbb1af0dba1ece5) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 15919f0c12c0047d3b6331c1f97cdad1dafb3f1b) @@ -77,8 +77,8 @@ 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); -/// Persist time (task intervals) rotor speed error condition. -static const U32 DIP_ROTOR_SPEED_ERROR_PERSIST = ((12 * 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; /// Persist time (task intervals) pump direction error condition. static const U32 DIP_DIRECTION_ERROR_PERSIST = (250 / TASK_PRIORITY_INTERVAL); /// Persist time (task intervals) dialysate flow rate out of range error condition. @@ -880,6 +880,28 @@ return result; } +/*********************************************************************//** + * @brief + * The getPumpRotorErrorPersistTime function calculates the Rotor error persist time. + * @details Inputs: none + * @details Outputs: none + * @param mtr_rpm, RPM of the motor. + * 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 = 0xFFFFFFF; + + if ( mtr_rpm > 0 ) + { + /// 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 ); + } + + return err_persist_time; +} + /*********************************************************************//** * @brief * The publishDialInFlowData function publishes dialIn flow data at the set @@ -1130,7 +1152,7 @@ F32 cmdMotorSpeed = DIP_PWM_TO_MOTOR_SPEED_RPM( dialInPumpPWMDutyCyclePctSet ); F32 deltaMotorSpeed = fabs( measMotorSpeed - cmdMotorSpeed ); F32 deltaMCMotorSpeed = fabs( measMCMotorSpeed - cmdMotorSpeed ); - F32 measRotorSpeed = getMeasuredDialInPumpRotorSpeed(); + F32 measRotorSpeed = fabs( getMeasuredDialInPumpRotorSpeed() ); F32 measMotorSpeedInRotorRPM = measMotorSpeed / DIP_GEAR_RATIO; F32 deltaRotorSpeed = fabs( measRotorSpeed - measMotorSpeedInRotorRPM ); @@ -1155,7 +1177,7 @@ // Check measured rotor speed vs. measured motor speed while controlling to target if ( deltaRotorSpeed > DIP_MAX_ROTOR_VS_MOTOR_DIFF_RPM ) { - if ( ++errorDialInRotorSpeedPersistTimerCtr >= DIP_ROTOR_SPEED_ERROR_PERSIST ) + if ( ++errorDialInRotorSpeedPersistTimerCtr >= ( getPumpRotorErrorPersistTime( measMotorSpeed, DIP_GEAR_RATIO ) / TASK_PRIORITY_INTERVAL ) ) { #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_PUMP_SPEED_CHECKS ) != SW_CONFIG_ENABLE_VALUE )