Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -rf9b8b75c3686be892799b5446b955fd36ab49fa3 -r8377b4e6ed494cbfc5dfc2bd9ad3c89b85b333cd --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision f9b8b75c3686be892799b5446b955fd36ab49fa3) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 8377b4e6ed494cbfc5dfc2bd9ad3c89b85b333cd) @@ -55,7 +55,7 @@ #define DOP_HOME_RATE 50 ///< target pump speed (in estimate mL/min) for homing. #define DOP_HOME_TIMEOUT_MS 10000 ///< maximum time allowed for homing to complete (in ms). #define DOP_SPEED_CALC_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< interval (ms/task time) at which the dialysate outlet pump speed is calculated. -#define DOP_HALL_EDGE_COUNTS_PER_REV 6 ///< number of hall sensor edge counts per motor revolution. +#define DOP_HALL_EDGE_COUNTS_PER_REV 48 ///< number of hall sensor edge counts per motor revolution. #define DOP_MAX_CURR_WHEN_STOPPED_MA 150.0 ///< Motor controller current should not exceed this when pump should be stopped. #define DOP_MIN_CURR_WHEN_RUNNING_MA 150.0 ///< Motor controller current should always exceed this when pump should be running. @@ -65,7 +65,7 @@ #define DOP_SPEED_ADC_TO_RPM_FACTOR 1.280938 ///< Conversion factor from ADC counts to RPM for dialysate outlet pump motor. #define DOP_CURRENT_ADC_TO_MA_FACTOR 3.002 ///< Conversion factor from ADC counts to mA for dialysate outlet pump motor. #define DOP_ADC_FULL_SCALE_V 3.0 ///< DPo analog signals are 0-3V (while int. ADC ref V may be different). -#define DOP_ADC_ZERO ( (F32)( INT_ADC_ZERO ) * ( DOP_ADC_FULL_SCALE_V / INT_ADC_REF_V ) ) ///< Mid-point (zero) for ADC readings. +#define DOP_ADC_ZERO 1998 ///< Mid-point (zero) for ADC readings. #define SIGN_FROM_12_BIT_VALUE(v) ( (S16)(v) - (S16)DOP_ADC_ZERO ) ///< Macro converts a 12-bit ADC reading to a signed 16-bit value. @@ -165,6 +165,8 @@ static void updateDialOutPumpSpeedAndDirectionFromHallSensors( void ); static void checkDialOutPumpRotor( void ); static void checkDialOutPumpDirection( void ); +static void checkDialOutPumpSpeeds( void ); +static void checkDialOutPumpFlowAgainstSpeed( void ); static void checkDialOutPumpMCCurrent( void ); static DATA_GET_PROTOTYPE( U32, getPublishDialOutDataInterval ); @@ -181,6 +183,8 @@ { U32 i; + dopLastMotorHallSensorCount = getFPGADialOutPumpHallSensorCount(); + stopDialOutPump(); setDialOutPumpDirection( MOTOR_DIR_FORWARD ); @@ -403,6 +407,10 @@ // calculate dialysate outlet pump motor speed/direction from hall sensor count updateDialOutPumpSpeedAndDirectionFromHallSensors(); + // check pump speeds and flow + checkDialOutPumpSpeeds(); + checkDialOutPumpFlowAgainstSpeed(); + // check for home position, zero/low speed checkDialOutPumpRotor(); @@ -798,15 +806,25 @@ if ( DIAL_OUT_PUMP_CONTROL_TO_TARGET_STATE == dialOutPumpState ) { - // check set direction vs. direction from sign of motor controller speed + // check set direction vs. direction from hall sensors or sign of motor controller speed dopMCDir = ( getMeasuredDialOutPumpMCSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); - if ( dialOutPumpDirectionSet != dopMCDir ) + if ( ( dialOutPumpDirectionSet != dopMCDir ) || ( dialOutPumpDirectionSet != dopMotorDirectionFromHallSensors ) ) { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DIAL_OUT_PUMP_MC_DIRECTION_CHECK, (U32)dialOutPumpDirectionSet, (U32)dopMCDir ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DIAL_OUT_PUMP_MC_DIRECTION_CHECK, (U32)dialOutPumpDirectionSet, (U32)dopMotorDirectionFromHallSensors ) } } } +static void checkDialOutPumpSpeeds( void ) +{ + +} + +static void checkDialOutPumpFlowAgainstSpeed( void ) +{ + +} + /************************************************************************* * @brief * The checkDialOutPumpMCCurrent function checks the measured MC current vs. \n