Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -rbd594d51a6487960035f36d516c801de1b4aaff9 -r1ffe793b3a3557a408b0f5d30539e8f0f499e559 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision bd594d51a6487960035f36d516c801de1b4aaff9) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 1ffe793b3a3557a408b0f5d30539e8f0f499e559) @@ -159,7 +159,6 @@ static U32 dipHomeStartTime = 0; ///< when did dialysate inlet pump home command begin? (in ms) static U16 dipLastMotorHallSensorCount = 0; ///< last hall sensor count for the dialysate inlet pump motor -static MOTOR_DIR_T dipMotorDirectionFromHallSensors = MOTOR_DIR_FORWARD; ///< pump direction according to hall sensor count static U32 dipMotorSpeedCalcTimerCtr = 0; ///< counter determines interval for calculating dialysate inlet pump motor speed from hall sensor count. static U32 errorDialInFlowVsMotorSpeedPersistTimerCtr = 0; ///< persistence timer counter for flow vs. motor speed error condition. @@ -932,7 +931,7 @@ * a 1 second interval. * @details * Inputs : dipLastMotorHallSensorCount, dipMotorSpeedCalcTimerCtr, current count from FPGA - * Outputs : dipMotorDirectionFromHallSensors, dialInPumpSpeedRPM + * Outputs : dialInPumpSpeedRPM * @return none *************************************************************************/ static void updateDialInPumpSpeedAndDirectionFromHallSensors( void ) @@ -947,13 +946,11 @@ // determine dialysate inlet pump speed/direction from delta hall sensor count since last interval if ( incDelta < decDelta ) { - dipMotorDirectionFromHallSensors = MOTOR_DIR_FORWARD; delta = incDelta; dialInPumpSpeedRPM.data = ( (F32)delta / (F32)DIP_HALL_EDGE_COUNTS_PER_REV ) * (F32)SEC_PER_MIN; } else { - dipMotorDirectionFromHallSensors = MOTOR_DIR_REVERSE; delta = decDelta; dialInPumpSpeedRPM.data = ( (F32)delta / (F32)DIP_HALL_EDGE_COUNTS_PER_REV ) * (F32)SEC_PER_MIN * -1.0; } @@ -1002,17 +999,18 @@ *************************************************************************/ static void checkDialInPumpDirection( void ) { - MOTOR_DIR_T dipMCDir; - if ( DIAL_IN_PUMP_CONTROL_TO_TARGET_STATE == dialInPumpState ) { + MOTOR_DIR_T dipMCDir, dipDir; + dipMCDir = ( getMeasuredDialInPumpMCSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); + dipDir = ( getMeasuredDialInPumpSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); // check set direction vs. direction from hall sensors - if ( dialInPumpDirectionSet != dipMotorDirectionFromHallSensors ) + if ( dialInPumpDirectionSet != dipDir ) { #ifndef DISABLE_PUMP_DIRECTION_CHECKS - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DIAL_IN_PUMP_MC_DIRECTION_CHECK, (U32)dialInPumpDirectionSet, (U32)dipMotorDirectionFromHallSensors ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DIAL_IN_PUMP_MC_DIRECTION_CHECK, (U32)dialInPumpDirectionSet, (U32)dipDir ) #endif } // check set direction vs. direction from sign of motor controller speed