Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -rc67def50892f9a7c2f1f22985b5351465a8f6773 -r1a685471524555a374854c0c9ec8e208e71fe2df --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision c67def50892f9a7c2f1f22985b5351465a8f6773) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 1a685471524555a374854c0c9ec8e208e71fe2df) @@ -21,16 +21,17 @@ #include "gio.h" #include "mibspi.h" +#include "DialInFlow.h" #include "FPGA.h" #include "InternalADC.h" #include "NVDataMgmt.h" #include "OperationModes.h" +#include "PersistentAlarm.h" #include "PIControllers.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" #include "TaskPriority.h" #include "Timers.h" -#include "DialInFlow.h" /** * @addtogroup DialysateInletFlow @@ -39,53 +40,63 @@ // ********** private definitions ********** -#define DIAL_IN_FLOW_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< interval (ms/task time) at which the dialIn flow data is published on the CAN bus +/// interval (ms/task time) at which the dialIn flow data is published on the CAN bus. +#define DIAL_IN_FLOW_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) #define MAX_DIAL_IN_PUMP_PWM_STEP_UP_CHANGE 0.0133 ///< max duty cycle change when ramping up ~ 200 mL/min/s. #define MAX_DIAL_IN_PUMP_PWM_STEP_DN_CHANGE 0.02 ///< max duty cycle change when ramping down ~ 300 mL/min/s. -#define MAX_DIAL_IN_PUMP_PWM_DUTY_CYCLE 0.88 ///< controller will error if PWM duty cycle > 90%, so set max to 88% -#define MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE 0.12 ///< controller will error if PWM duty cycle < 10%, so set min to 12% +#define MAX_DIAL_IN_PUMP_PWM_DUTY_CYCLE 0.88 ///< controller will error if PWM duty cycle > 90%, so set max to 88%. +#define MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE 0.12 ///< controller will error if PWM duty cycle < 10%, so set min to 12%. #define DIP_CONTROL_INTERVAL ( 10000 / TASK_GENERAL_INTERVAL ) ///< interval (ms/task time) at which the dialIn pump is controlled -#define DIP_P_COEFFICIENT 0.00035 ///< P term for dialIn pump control -#define DIP_I_COEFFICIENT 0.00035 ///< I term for dialIn pump control +#define DIP_P_COEFFICIENT 0.00035 ///< P term for dialIn pump control. +#define DIP_I_COEFFICIENT 0.00035 ///< I term for dialIn pump control. #define DIP_HOME_RATE 100 ///< target pump speed (in estimate mL/min) for homing. #define DIP_HOME_TIMEOUT_MS 10000 ///< maximum time allowed for homing to complete (in ms). #define DIP_SPEED_CALC_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< interval (ms/task time) at which the dialysate inlet pump speed is calculated. #define DIP_HALL_EDGE_COUNTS_PER_REV 48 ///< number of hall sensor edge counts per motor revolution. -#define DIP_MAX_FLOW_VS_SPEED_DIFF_ML_MIN 50.0 ///< maximum difference between measured flow and flow implied by measured motor speed. +#define DIP_MAX_FLOW_VS_SPEED_DIFF_RPM 200.0 ///< maximum difference between measured motor speed and speed implied by measured flow. #define DIP_MAX_MOTOR_SPEED_WHILE_OFF_RPM 100.0 ///< maximum motor speed (RPM) while motor is commanded off. #define DIP_MAX_ROTOR_VS_MOTOR_DIFF_RPM 5.0 ///< maximum difference in speed between motor and rotor (in rotor RPM). #define DIP_MAX_MOTOR_SPEED_ERROR_RPM 300.0 ///< maximum difference in speed between measured and commanded RPM. -#define DIP_FLOW_VS_SPEED_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) for flow vs. motor speed error condition. -#define DIP_OFF_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) for motor off error condition. -#define DIP_MOTOR_SPEED_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) motor speed error condition. -#define DIP_ROTOR_SPEED_ERROR_PERSIST ((12 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) rotor speed error condition. +#define DIP_FLOW_VS_SPEED_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) for flow vs. motor speed error condition. +#define DIP_OFF_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) for motor off error condition. +#define DIP_MOTOR_SPEED_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) motor speed error condition. +#define DIP_ROTOR_SPEED_ERROR_PERSIST ((12 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) rotor speed error condition. +#define DIP_DIRECTION_ERROR_PERSIST (250 / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) pump direction error condition. -#define DIP_MAX_CURR_WHEN_STOPPED_MA 150.0 ///< motor controller current should not exceed this when pump should be stopped -#define DIP_MIN_CURR_WHEN_RUNNING_MA 150.0 ///< motor controller current should always exceed this when pump should be running -#define DIP_MAX_CURR_WHEN_RUNNING_MA 2000.0 ///< motor controller current should not exceed this when pump should be running -#define DIP_MAX_CURR_ERROR_DURATION_MS 2000 ///< motor controller current errors persisting beyond this duration will trigger an alarm +#define DIP_MAX_CURR_WHEN_STOPPED_MA 150.0 ///< motor controller current should not exceed this when pump should be stopped. +#define DIP_MIN_CURR_WHEN_RUNNING_MA 150.0 ///< motor controller current should always exceed this when pump should be running. +#define DIP_MAX_CURR_WHEN_RUNNING_MA 2000.0 ///< motor controller current should not exceed this when pump should be running. +#define DIP_MAX_CURR_ERROR_DURATION_MS 2000 ///< motor controller current errors persisting beyond this duration will trigger an alarm. -#define DIP_SPEED_ADC_TO_RPM_FACTOR 1.280938 ///< conversion factor from ADC counts to RPM for dialIn pump motor -#define DIP_CURRENT_ADC_TO_MA_FACTOR 3.002 ///< conversion factor from ADC counts to mA for dialIn pump motor +#define DIP_SPEED_ADC_TO_RPM_FACTOR 1.280938 ///< conversion factor from ADC counts to RPM for dialIn pump motor. +#define DIP_CURRENT_ADC_TO_MA_FACTOR 3.002 ///< conversion factor from ADC counts to mA for dialIn pump motor. -#define DIP_REV_PER_LITER 150.24 ///< rotor revolutions per liter -#define DIP_ML_PER_MIN_TO_PUMP_RPM_FACTOR ( DIP_REV_PER_LITER / ML_PER_LITER ) ///< -#define DIP_GEAR_RATIO 32.0 ///< dialIn pump motor to dialIn pump gear ratio -#define DIP_MOTOR_RPM_TO_PWM_DC_FACTOR 0.00028 ///< ~28 BP motor RPM = 1% PWM duty cycle -#define DIP_PWM_ZERO_OFFSET 0.1 ///< 10% PWM duty cycle = zero speed -#define DIP_PWM_FROM_ML_PER_MIN(rate) ( (rate) * DIP_ML_PER_MIN_TO_PUMP_RPM_FACTOR * DIP_GEAR_RATIO * DIP_MOTOR_RPM_TO_PWM_DC_FACTOR + DIP_PWM_ZERO_OFFSET ) ///< +#define DIP_REV_PER_LITER 150.0 ///< rotor revolutions per liter. +/// Macro converts flow rate to motor RPM. +#define DIP_ML_PER_MIN_TO_PUMP_RPM_FACTOR ( DIP_REV_PER_LITER / ML_PER_LITER ) +#define DIP_GEAR_RATIO 32.0 ///< dialIn pump motor to dialIn pump gear ratio. +#define DIP_MOTOR_RPM_TO_PWM_DC_FACTOR 0.00028 ///< ~28 BP motor RPM = 1% PWM duty cycle. +#define DIP_PWM_ZERO_OFFSET 0.1 ///< 10% PWM duty cycle = zero speed. +/// Macro converts flow rate to estimate PWM needed to achieve it. +#define DIP_PWM_FROM_ML_PER_MIN(rate) ( (rate) * DIP_ML_PER_MIN_TO_PUMP_RPM_FACTOR * DIP_GEAR_RATIO * DIP_MOTOR_RPM_TO_PWM_DC_FACTOR + DIP_PWM_ZERO_OFFSET ) -#define DIAL_IN_PUMP_ADC_FULL_SCALE_V 3.0 ///< BP analog signals are 0-3V (while int. ADC ref V may be different) +#define DIAL_IN_PUMP_ADC_FULL_SCALE_V 3.0 ///< BP analog signals are 0-3V (while int. ADC ref V may be different). #define DIAL_IN_PUMP_ADC_ZERO 1998 ///< Mid-point (zero) for ADC readings. -#define SIGN_FROM_12_BIT_VALUE(v) ( (S16)(v) - (S16)DIAL_IN_PUMP_ADC_ZERO ) ///< Macro converts a 12-bit ADC reading to a signed 16-bit value. - -#define SIZE_OF_ROLLING_AVG ( ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) * 10 ) ///< measured dialIn flow is filtered w/ moving average - +///< Macro converts a 12-bit ADC reading to a signed 16-bit value. +#define SIGN_FROM_12_BIT_VALUE(v) ( (S16)(v) - (S16)DIAL_IN_PUMP_ADC_ZERO ) + +/// measured dialIn flow is filtered w/ moving average. +#define SIZE_OF_ROLLING_AVG ( ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) * 10 ) + +/// dialysate flow sensor signal strength low alarm persistence. +#define FLOW_SIG_STRGTH_ALARM_PERSIST ( ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) * 5 ) +#define MIN_FLOW_SIG_STRENGTH 0.9 ///< Minimum flow sensor signal strength (90%). + /// Enumeration of dialysate inlet pump states. typedef enum DialInPump_States { @@ -140,6 +151,7 @@ static OVERRIDE_F32_T dialInPumpSpeedRPM = { 0.0, 0.0, 0.0, 0 }; ///< measured dialysate inlet pump motor speed static OVERRIDE_F32_T adcDialInPumpMCSpeedRPM = { 0.0, 0.0, 0.0, 0 }; ///< measured dialysate inlet pump motor controller speed static OVERRIDE_F32_T adcDialInPumpMCCurrentmA = { 0.0, 0.0, 0.0, 0 }; ///< measured dialysate inlet pump motor controller current +static OVERRIDE_F32_T dialInFlowSignalStrength = { 0.0, 0.0, 0.0, 0 }; ///< measured dialysate flow signal strength (%) static U32 dipControlTimerCounter = 0; ///< determines when to perform control on dialIn flow @@ -148,13 +160,13 @@ 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. 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. +static U32 errorDialInPumpDirectionPersistTimerCtr = 0; ///< persistence timer counter for pump direction error condition. static F32 flowReadings[ SIZE_OF_ROLLING_AVG ]; ///< holds flow samples for a rolling average static U32 flowReadingsIdx = 0; ///< index for next sample in rolling average array @@ -185,6 +197,7 @@ static void checkDialInPumpSpeeds( void ); static void checkDialInPumpFlowAgainstSpeed( void ); static void checkDialInPumpMCCurrent( void ); +static void checkDialInFlowSensorSignalStrength( void ); static DATA_GET_PROTOTYPE( U32, getPublishDialInFlowDataInterval ); /*********************************************************************//** @@ -208,6 +221,11 @@ initializePIController( PI_CONTROLLER_ID_DIALYSATE_FLOW, MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE, DIP_P_COEFFICIENT, DIP_I_COEFFICIENT, MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE, MAX_DIAL_IN_PUMP_PWM_DUTY_CYCLE ); + + // initialize persistent alarm for flow sensor signal strength too low + initPersistentAlarm( PERSISTENT_ALARM_DIALYSATE_FLOW_SIGNAL_STRENGTH, + ALARM_ID_DIALYSATE_FLOW_SIGNAL_STRENGTH_TOO_LOW, + FALSE, FLOW_SIG_STRGTH_ALARM_PERSIST, FLOW_SIG_STRGTH_ALARM_PERSIST ); } /*********************************************************************//** @@ -341,6 +359,19 @@ return result; } +/*********************************************************************//** + * @brief + * The isDialInPumpRunning function returns whether the dialysate inlet pump + * is currently running or not. + * @details Inputs: isDialInPumpOn + * @details Outputs: none + * @return isDialInPumpOn + *************************************************************************/ +BOOL isDialInPumpRunning( void ) +{ + return isDialInPumpOn; +} + /*********************************************************************//** * @brief * The execDialInFlowMonitor function executes the dialIn flow monitor. @@ -350,20 +381,22 @@ *************************************************************************/ void execDialInFlowMonitor( void ) { + HD_OP_MODE_T opMode = getCurrentOperationMode(); U16 dipRPM = getIntADCReading( INT_ADC_DIAL_IN_PUMP_SPEED ); U16 dipmA = getIntADCReading( INT_ADC_DIAL_IN_PUMP_MOTOR_CURRENT ); F32 dipFlow = ( getFPGADialysateFlow() * dialInFlowCalGain ) + dialInFlowCalOffset; adcDialInPumpMCSpeedRPM.data = (F32)(SIGN_FROM_12_BIT_VALUE(dipRPM)) * DIP_SPEED_ADC_TO_RPM_FACTOR; adcDialInPumpMCCurrentmA.data = (F32)(SIGN_FROM_12_BIT_VALUE(dipmA)) * DIP_CURRENT_ADC_TO_MA_FACTOR; + dialInFlowSignalStrength.data = getFPGADialysateFlowSignalStrength(); filterDialInFlowReadings( dipFlow ); // calculate dialysate inlet pump motor speed/direction from hall sensor count updateDialInPumpSpeedAndDirectionFromHallSensors(); // don't start enforcing checks until out of init/POST mode - if ( getCurrentOperationMode() != MODE_INIT ) + if ( opMode != MODE_INIT ) { // check pump direction checkDialInPumpDirection(); @@ -373,7 +406,9 @@ checkDialInPumpSpeeds(); checkDialInPumpFlowAgainstSpeed(); // check for home position, zero/low speed - checkDialInPumpRotor(); + checkDialInPumpRotor(); + // check flow sensor signal strength + checkDialInFlowSensorSignalStrength(); } // publish dialIn flow data on interval @@ -498,7 +533,7 @@ DIAL_IN_PUMP_STATE_T result = DIAL_IN_PUMP_RAMPING_DOWN_STATE; // have we essentially reached zero speed - if ( dialInPumpPWMDutyCyclePctSet < (MAX_DIAL_IN_PUMP_PWM_STEP_UP_CHANGE + DIP_PWM_ZERO_OFFSET) ) + if ( dialInPumpPWMDutyCyclePctSet < (MAX_DIAL_IN_PUMP_PWM_STEP_DN_CHANGE + DIP_PWM_ZERO_OFFSET) ) { stopDialInPump(); result = DIAL_IN_PUMP_OFF_STATE; @@ -686,7 +721,27 @@ } return result; -} +} + +/*********************************************************************//** + * @brief + * The getMeasuredDialInFlowSignalStrength function gets the measured dialIn flow + * signal strength. + * @details Inputs: dialInFlowSignalStrength + * @details Outputs: none + * @return the current dialIn flow signal strength (in %). + *************************************************************************/ +F32 getMeasuredDialInFlowSignalStrength( void ) +{ + F32 result = dialInFlowSignalStrength.data; + + if ( OVERRIDE_KEY == dialInFlowSignalStrength.override ) + { + result = dialInFlowSignalStrength.ovData; + } + + return result; +} /*********************************************************************//** * @brief @@ -782,14 +837,17 @@ // publish dialIn flow data on interval if ( ++dialInFlowDataPublicationTimerCounter >= getPublishDialInFlowDataInterval() ) { - S32 flowStPt = (S32)getTargetDialInFlowRate(); - F32 measFlow = getMeasuredDialInFlowRate(); - F32 measRotSpd = getMeasuredDialInPumpRotorSpeed(); - F32 measSpd = getMeasuredDialInPumpSpeed(); - F32 measMCSpd = getMeasuredDialInPumpMCSpeed(); - F32 measMCCurr = getMeasuredDialInPumpMCCurrent(); - F32 pumpPWMPctDutyCycle = dialInPumpPWMDutyCyclePctSet * FRACTION_TO_PERCENT_FACTOR; - broadcastDialInFlowData( flowStPt, measFlow, measRotSpd, measSpd, measMCSpd, measMCCurr, pumpPWMPctDutyCycle ); + DIALIN_PUMP_STATUS_PAYLOAD_T payload; + + payload.setPoint = (S32)getTargetDialInFlowRate(); + payload.measFlow = getMeasuredDialInFlowRate(); + payload.measRotorSpd = getMeasuredDialInPumpRotorSpeed(); + payload.measPumpSpd = getMeasuredDialInPumpSpeed(); + payload.measMCSpd = getMeasuredDialInPumpMCSpeed(); + payload.measMCCurr = getMeasuredDialInPumpMCCurrent(); + payload.pwmDC = dialInPumpPWMDutyCyclePctSet * FRACTION_TO_PERCENT_FACTOR; + payload.flowSigStrength = getMeasuredDialInFlowSignalStrength() * FRACTION_TO_PERCENT_FACTOR; + broadcastDialInFlowData( &payload ); dialInFlowDataPublicationTimerCounter = 0; } } @@ -855,13 +913,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; } @@ -908,18 +964,41 @@ *************************************************************************/ static void checkDialInPumpDirection( void ) { - MOTOR_DIR_T dipMCDir; - if ( DIAL_IN_PUMP_CONTROL_TO_TARGET_STATE == dialInPumpState ) { - // check set direction vs. direction from hall sensors or sign of motor controller speed - dipMCDir = ( getMeasuredDialInPumpMCSpeed() >= 0.0 ? MOTOR_DIR_FORWARD : MOTOR_DIR_REVERSE ); - if ( ( dialInPumpDirectionSet != dipMCDir ) || ( dialInPumpDirectionSet != dipMotorDirectionFromHallSensors ) ) + 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 != dipDir ) { + if ( ++errorDialInPumpDirectionPersistTimerCtr >= DIP_DIRECTION_ERROR_PERSIST ) + { #ifndef DISABLE_PUMP_DIRECTION_CHECKS - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DIAL_IN_PUMP_MC_DIRECTION_CHECK, (U32)dialInPumpDirectionSet, (U32)dipMotorDirectionFromHallSensors ) -#endif + 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 + else if ( dialInPumpDirectionSet != dipMCDir ) + { + if ( ++errorDialInPumpDirectionPersistTimerCtr >= DIP_DIRECTION_ERROR_PERSIST ) + { +#ifndef DISABLE_PUMP_DIRECTION_CHECKS + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DIAL_IN_PUMP_MC_DIRECTION_CHECK, (U32)dialInPumpDirectionSet, (U32)dipMCDir ) +#endif + } + } + else + { + errorDialInPumpDirectionPersistTimerCtr = 0; + } + } + else + { + errorDialInPumpDirectionPersistTimerCtr = 0; } } @@ -1025,15 +1104,15 @@ { F32 flow = getMeasuredDialInFlowRate(); F32 speed = getMeasuredDialInPumpSpeed(); - F32 impliedFlow = ( ( speed / DIP_GEAR_RATIO ) / DIP_REV_PER_LITER ) * (F32)ML_PER_LITER; - F32 delta = fabs( flow - impliedFlow ); + F32 impliedSpeed = ( flow / (F32)ML_PER_LITER ) * DIP_REV_PER_LITER * DIP_GEAR_RATIO; + F32 delta = fabs( speed - impliedSpeed ); - if ( delta > DIP_MAX_FLOW_VS_SPEED_DIFF_ML_MIN ) + if ( delta > DIP_MAX_FLOW_VS_SPEED_DIFF_RPM ) { if ( ++errorDialInFlowVsMotorSpeedPersistTimerCtr >= DIP_FLOW_VS_SPEED_PERSIST ) { #ifndef DISABLE_PUMP_FLOW_CHECKS - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DIAL_IN_PUMP_FLOW_VS_MOTOR_SPEED_CHECK, flow, impliedFlow ); + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DIAL_IN_PUMP_FLOW_VS_MOTOR_SPEED_CHECK, flow, speed ); #endif } } @@ -1098,6 +1177,30 @@ dipCurrErrorDurationCtr = 0; } } +} + +/*********************************************************************//** + * @brief + * The checkDialInFlowSensorSignalStrength function checks the measured + * dialysate flow sensor signal strength is sufficient for accurate flow sensing. + * @details Inputs: + * @details Outputs: + * @return none + *************************************************************************/ +static void checkDialInFlowSensorSignalStrength( void ) +{ +#ifndef DISABLE_PUMP_FLOW_CHECKS + HD_OP_MODE_T opMode = getCurrentOperationMode(); + + // check flow sensor signal strength when appropriate TODO - in pre-treatment, must be far enough along for fluid to be in tubing + if ( MODE_TREA == opMode || ( MODE_PRET == opMode && FALSE ) ) + { + F32 sigStrength = getMeasuredDialInFlowSignalStrength(); + BOOL outOfRange = ( sigStrength < MIN_FLOW_SIG_STRENGTH ? TRUE : FALSE ); + + checkPersistentAlarm( PERSISTENT_ALARM_DIALYSATE_FLOW_SIGNAL_STRENGTH, outOfRange, sigStrength ); + } +#endif } /*********************************************************************//** @@ -1529,5 +1632,50 @@ return result; } + +/*********************************************************************//** + * @brief + * The testSetMeasuredDialInFlowSignalStrengthOverride function overrides the measured + * dialysate flow signal strength. + * @details Inputs: none + * @details Outputs: dialInFlowSignalStrength + * @param value override measured dialysate flow signal strength (in %) + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testSetMeasuredDialInFlowSignalStrengthOverride( F32 value ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + dialInFlowSignalStrength.ovData = value / 100.0; + dialInFlowSignalStrength.override = OVERRIDE_KEY; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testResetMeasuredDialInFlowSignalStrengthOverride function resets the override + * of the measured dialysate flow signal strength. + * @details Inputs: none + * @details Outputs: dialInFlowSignalStrength + * @return TRUE if reset successful, FALSE if not + *************************************************************************/ +BOOL testResetMeasuredDialInFlowSignalStrengthOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + dialInFlowSignalStrength.override = OVERRIDE_RESET; + dialInFlowSignalStrength.ovData = dialInFlowSignalStrength.ovInitData; + } + + return result; +} /**@}*/