Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r0a4dcd288d4347b85baaa0b07da568b6add5eac7 -re87ab4599bd69d195dfb4fc0ffb301df2350dceb --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 0a4dcd288d4347b85baaa0b07da568b6add5eac7) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision e87ab4599bd69d195dfb4fc0ffb301df2350dceb) @@ -67,14 +67,13 @@ #define DIP_MAX_FLOW_RATE 1320.0F ///< Maximum measured BP flow rate allowed. #define DIP_MIN_FLOW_RATE -1320.0F ///< Minimum measured BP flow rate allowed. -#define DIP_MAX_FLOW_VS_SPEED_DIFF_RPM 350.0F ///< Maximum difference between measured motor speed and speed implied by measured flow. #define DIP_MAX_MOTOR_SPEED_WHILE_OFF_RPM 100.0F ///< Maximum motor speed (RPM) while motor is commanded off. #define DIP_MAX_ROTOR_VS_MOTOR_DIFF_RPM 2.0F ///< Maximum difference in speed between motor and rotor (in rotor RPM). #define DIP_MAX_MOTOR_SPEED_ERROR_RPM 300.0F ///< Maximum difference in speed between measured and commanded RPM. #define DIP_MAX_MOTOR_SPEED_VS_TRGT_DIFF_PCT 0.15F ///< Maximum motor speed vs target difference in percent. -/// Persist time (task intervals) for flow vs. motor speed error condition. -static const U32 DIP_FLOW_VS_SPEED_PERSIST = ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); +/// Persist time (task intervals) for unexpected flow check failure condition. +static const U32 DIP_UNEXP_FLOW_CHK_PERSIST = ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); /// Persist time (task intervals) for motor off error condition. static const U32 DIP_OFF_ERROR_PERSIST = ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); /// Persist time (task intervals) motor speed error condition. @@ -179,7 +178,6 @@ static MOTOR_DIR_T dialInPumpDirectionSet = MOTOR_DIR_FORWARD; ///< Currently set dialysate flow direction static PUMP_CONTROL_MODE_T dialInPumpControlMode = PUMP_CONTROL_MODE_CLOSED_LOOP; ///< Requested dialIn pump control mode. static PUMP_CONTROL_MODE_T dialInPumpControlModeSet = PUMP_CONTROL_MODE_CLOSED_LOOP; ///< Currently set dialIn pump control mode. -static BOOL isTestPWMSet = FALSE; ///< Using PWM to set the rate instead of target flow. /// Interval (in ms) at which to publish dialIn flow data to CAN bus static OVERRIDE_U32_T dialInFlowDataPublishInterval = { DIAL_IN_FLOW_DATA_PUB_INTERVAL, DIAL_IN_FLOW_DATA_PUB_INTERVAL, DIAL_IN_FLOW_DATA_PUB_INTERVAL, 0 }; @@ -203,7 +201,6 @@ static U32 dipMotorSpeedCalcIdx = 0; ///< Index into 1 second buffer of motor speed hall sensor counts 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. static U32 errorDialInMotorOffPersistTimerCtr = 0; ///< Persistence timer counter for motor off check error condition. static U32 errorDialInMotorSpeedPersistTimerCtr = 0; ///< Persistence timer counter for motor speed error condition. static U32 errorDialInRotorSpeedPersistTimerCtr = 0; ///< Persistence timer counter for rotor speed error condition. @@ -256,7 +253,6 @@ U32 i; dialInFlowDataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; - isTestPWMSet = FALSE; signalDialInPumpHardStop(); setDialInPumpDirection( MOTOR_DIR_FORWARD ); @@ -279,7 +275,7 @@ // Initialize persistent alarm for flow sensor signal strength too low initPersistentAlarm( ALARM_ID_HD_DIAL_IN_FLOW_OUT_OF_RANGE, 0, DIP_MAX_FLOW_RATE_OUT_OF_RANGE_PERSIST ); - initPersistentAlarm( ALARM_ID_HD_DIAL_IN_FLOW_CHECK_FAILURE, DIP_FLOW_VS_SPEED_PERSIST, DIP_FLOW_VS_SPEED_PERSIST ); + initPersistentAlarm( ALARM_ID_HD_DIAL_IN_FLOW_CHECK_FAILURE, DIP_UNEXP_FLOW_CHK_PERSIST, DIP_UNEXP_FLOW_CHK_PERSIST ); initTimeWindowedCount( TIME_WINDOWED_COUNT_DIP_COMMUTATION_ERROR, DIP_COMMUTATION_ERROR_MAX_CNT, DIP_COMMUTATION_ERROR_TIME_WIN_MS ); } @@ -288,8 +284,7 @@ * The setDialInPumpTargetFlowRate function sets a new target flow rate and * pump direction. * @details Inputs: isDialInPumpOn, dialInPumpDirectionSet - * @details Outputs: targetDialInFlowRate, dialInPumpdirection, - * dialInPumpPWMDutyCyclePct, isTestPWMSet + * @details Outputs: targetDialInFlowRate, dialInPumpdirection, dialInPumpPWMDutyCyclePct * @param flowRate new target dialIn flow rate * @param dir new dialIn flow direction * @param mode new control mode @@ -309,7 +304,6 @@ { BOOL isFlowRateInRange = ( flowRate <= MAX_DIAL_IN_FLOW_RATE ? TRUE : FALSE ); - isTestPWMSet = FALSE; #ifndef _RELEASE_ if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_PUMPS_FLOW_LIMITS ) ) { @@ -606,8 +600,7 @@ DIAL_IN_PUMP_STATE_T result = DIAL_IN_PUMP_OFF_STATE; // If we have been given a flow rate, setup ramp up and transition to ramp up state - if ( ( targetDialInFlowRate != 0 ) || - ( TRUE == isTestPWMSet ) ) + if ( targetDialInFlowRate != 0 ) { // Set initial PWM duty cycle dialInPumpPWMDutyCyclePctSet = DIP_PWM_ZERO_OFFSET + MAX_DIAL_IN_PUMP_PWM_STEP_UP_CHANGE; @@ -626,17 +619,18 @@ * @brief * The handleDialInPumpRampingUpState function handles the ramp up state * of the dialIn pump controller state machine. - * @details Inputs: dialInPumpPWMDutyCyclePctSet - * @details Outputs: dialInPumpPWMDutyCyclePctSet + * @details Inputs: dialInPumpPWMDutyCyclePctSet, dialInPumpPWMDutyCyclePct, + * targetDialInFlowRate + * @details Outputs: dialInPumpPWMDutyCyclePctSet, dipControlTimerCounter, + * dialInPumpControlModeSet * @return next state *************************************************************************/ static DIAL_IN_PUMP_STATE_T handleDialInPumpRampingUpState( void ) { DIAL_IN_PUMP_STATE_T result = DIAL_IN_PUMP_RAMPING_UP_STATE; // Have we been asked to stop the dialIn pump? - if ( ( 0 == targetDialInFlowRate ) && - ( FALSE == isTestPWMSet ) ) + if ( 0 == targetDialInFlowRate ) { // Start ramp down to stop dialInPumpPWMDutyCyclePctSet -= MAX_DIAL_IN_PUMP_PWM_STEP_DN_CHANGE; @@ -669,7 +663,8 @@ * The handleDialInPumpRampingDownState function handles the ramp down state * of the dialIn pump controller state machine. * @details Inputs: dialInPumpPWMDutyCyclePctSet - * @details Outputs: dialInPumpPWMDutyCyclePctSet + * @details Outputs: dialInPumpPWMDutyCyclePctSet, dialInPumpControlModeSet, + * dipControlTimerCounter * @return next state *************************************************************************/ static DIAL_IN_PUMP_STATE_T handleDialInPumpRampingDownState( void ) @@ -1408,36 +1403,6 @@ } } - // Check only performed while in treatment mode and while we are in control to target state - if ( ( MODE_TREA == getCurrentOperationMode() ) && ( DIAL_IN_PUMP_CONTROL_TO_TARGET_STATE == dialInPumpState ) ) - { - F32 flow = (F32)targetDialInFlowRate; - F32 speed = getMeasuredDialInPumpSpeed(); - F32 impliedSpeed = dialysateInPumpRPMFromTargetFlowRate( flow ); - F32 delta = fabs( speed - impliedSpeed ); - - if ( delta > DIP_MAX_FLOW_VS_SPEED_DIFF_RPM ) - { - if ( ++errorDialInFlowVsMotorSpeedPersistTimerCtr >= DIP_FLOW_VS_SPEED_PERSIST ) - { -#ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_PUMP_FLOW_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) -#endif - { - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DIAL_IN_PUMP_FLOW_VS_MOTOR_SPEED_CHECK, flow, speed ); - } - } - } - else - { - errorDialInFlowVsMotorSpeedPersistTimerCtr = 0; - } - } - else - { - errorDialInFlowVsMotorSpeedPersistTimerCtr = 0; - } - // Check DG Dialysate flow rate /* TODO: Temporarily comment this out. Will restore it when know better how to handle this alarm. if ( ( TRUE == isDialInPumpRunning() ) && ( dialInPumpControlMode != PUMP_CONTROL_MODE_OPEN_LOOP ) ) @@ -1586,16 +1551,6 @@ dialInPumpPWMDutyCyclePct = RANGE( pwmFabs, MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE, MAX_DIAL_IN_PUMP_PWM_DUTY_CYCLE ); targetDialInFlowRate = DIP_ML_PER_MIN_FROM_PWM( pwmFabs ); - // clear test flag if we are turning off the pump. - if ( pwmFabs <= MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE ) - { - isTestPWMSet = FALSE; - } - else - { - isTestPWMSet = TRUE; - } - switch ( dialInPumpState ) { case DIAL_IN_PUMP_RAMPING_UP_STATE: // See if we need to reverse direction of ramp