Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -rbd594d51a6487960035f36d516c801de1b4aaff9 -r1ffe793b3a3557a408b0f5d30539e8f0f499e559 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision bd594d51a6487960035f36d516c801de1b4aaff9) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 1ffe793b3a3557a408b0f5d30539e8f0f499e559) @@ -164,7 +164,6 @@ static U16 bpLastMotorHallSensorCount = 0; ///< last hall sensor count for the blood pump motor static U32 bloodPumpMotorEdgeCount = 0; ///< running counter for blood pump motor revolutions -static MOTOR_DIR_T bpMotorDirectionFromHallSensors = MOTOR_DIR_FORWARD; ///< pump direction according to hall sensor count static U32 bpMotorSpeedCalcTimerCtr = 0; ///< counter determines interval for calculating blood pump motor speed from hall sensor count. static U32 errorBloodFlowVsMotorSpeedPersistTimerCtr = 0; ///< persistence timer counter for flow vs. motor speed error condition. @@ -967,7 +966,7 @@ * a 1 second interval. * @details * Inputs : bpLastMotorHallSensorCount, bpMotorSpeedCalcTimerCtr, current count from FPGA - * Outputs : bpMotorDirectionFromHallSensors, bloodPumpSpeedRPM + * Outputs : bloodPumpSpeedRPM * @return none *************************************************************************/ static void updateBloodPumpSpeedAndDirectionFromHallSensors( void ) @@ -982,13 +981,11 @@ // determine blood pump speed/direction from delta hall sensor count since last interval if ( incDelta < decDelta ) { - bpMotorDirectionFromHallSensors = MOTOR_DIR_FORWARD; delta = incDelta; bloodPumpSpeedRPM.data = ( (F32)delta / (F32)BP_HALL_EDGE_COUNTS_PER_REV ) * (F32)SEC_PER_MIN; } else { - bpMotorDirectionFromHallSensors = MOTOR_DIR_REVERSE; delta = decDelta; bloodPumpSpeedRPM.data = ( (F32)delta / (F32)BP_HALL_EDGE_COUNTS_PER_REV ) * (F32)SEC_PER_MIN * -1.0; } @@ -1046,17 +1043,18 @@ *************************************************************************/ static void checkBloodPumpDirection( void ) { - MOTOR_DIR_T bpMCDir; - if ( BLOOD_PUMP_CONTROL_TO_TARGET_STATE == bloodPumpState ) { + MOTOR_DIR_T bpMCDir, bpDir; + bpMCDir = ( getMeasuredBloodPumpMCSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); + bpDir = ( getMeasuredBloodPumpSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); // check set direction vs. direction from hall sensors - if ( bloodPumpDirectionSet != bpMotorDirectionFromHallSensors ) + if ( bloodPumpDirectionSet != bpDir ) { #ifndef DISABLE_PUMP_DIRECTION_CHECKS - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_BLOOD_PUMP_MC_DIRECTION_CHECK, (U32)bloodPumpDirectionSet, (U32)bpMotorDirectionFromHallSensors ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_BLOOD_PUMP_MC_DIRECTION_CHECK, (U32)bloodPumpDirectionSet, (U32)bpDir ) #endif } // check set direction vs. direction from sign of motor controller speed