Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -r6eb873c4bc96fb22e85ac23aeee1c37e5366d731 -r1ffe793b3a3557a408b0f5d30539e8f0f499e559 --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 6eb873c4bc96fb22e85ac23aeee1c37e5366d731) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 1ffe793b3a3557a408b0f5d30539e8f0f499e559) @@ -147,7 +147,6 @@ static U32 dopHomeStartTime = 0; ///< when did dialysate outlet pump home command begin? (in ms) static U16 dopLastMotorHallSensorCount = 0; ///< last hall sensor count for the dialysate outlet pump motor -static MOTOR_DIR_T dopMotorDirectionFromHallSensors = MOTOR_DIR_FORWARD; ///< pump direction according to hall sensor count static U32 dopMotorSpeedCalcTimerCtr = 0; ///< counter determines interval for calculating dialysate outlet pump motor speed from hall sensor count. static U32 errorDialOutMotorOffPersistTimerCtr = 0; ///< persistence timer counter for motor off check error condition. @@ -757,7 +756,7 @@ * a 1 second interval. * @details * Inputs : dopLastMotorHallSensorCount, dopMotorSpeedCalcTimerCtr, current count from FPGA - * Outputs : dopMotorDirectionFromHallSensors, dialOutPumpSpeedRPM + * Outputs : dialOutPumpSpeedRPM * @return none *************************************************************************/ static void updateDialOutPumpSpeedAndDirectionFromHallSensors( void ) @@ -772,13 +771,11 @@ // determine dialysate outlet pump speed/direction from delta hall sensor count since last interval if ( incDelta < decDelta ) { - dopMotorDirectionFromHallSensors = MOTOR_DIR_FORWARD; delta = incDelta; dialOutPumpSpeedRPM.data = ( (F32)delta / (F32)DOP_HALL_EDGE_COUNTS_PER_REV ) * (F32)SEC_PER_MIN; } else { - dopMotorDirectionFromHallSensors = MOTOR_DIR_REVERSE; delta = decDelta; dialOutPumpSpeedRPM.data = ( (F32)delta / (F32)DOP_HALL_EDGE_COUNTS_PER_REV ) * (F32)SEC_PER_MIN * -1.0; } @@ -827,17 +824,18 @@ *************************************************************************/ static void checkDialOutPumpDirection( void ) { - MOTOR_DIR_T dopMCDir; - if ( DIAL_OUT_PUMP_CONTROL_TO_TARGET_STATE == dialOutPumpState ) { + MOTOR_DIR_T dopMCDir, dopDir; + dopMCDir = ( getMeasuredDialOutPumpMCSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); + dopDir = ( getMeasuredDialOutPumpSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); // check set direction vs. direction from hall sensors - if ( dialOutPumpDirectionSet != dopMotorDirectionFromHallSensors ) + if ( dialOutPumpDirectionSet != dopDir ) { #ifndef DISABLE_PUMP_DIRECTION_CHECKS - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DIAL_OUT_PUMP_MC_DIRECTION_CHECK, (U32)dialOutPumpDirectionSet, (U32)dopMotorDirectionFromHallSensors ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DIAL_OUT_PUMP_MC_DIRECTION_CHECK, (U32)dialOutPumpDirectionSet, (U32)dopDir ) #endif } // check set direction vs. direction from sign of motor controller speed