Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r5af49574b5f8e99aa9ea451033213dcd765ea837 -r46c538cc5b7b40ddc8227e2ad1c77bab93716571 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 5af49574b5f8e99aa9ea451033213dcd765ea837) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 46c538cc5b7b40ddc8227e2ad1c77bab93716571) @@ -109,29 +109,9 @@ ///< 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 ) -#ifdef USE_FMD_FLOW_SENSOR /// Measured dialIn flow is filtered w/ moving average. -#define SIZE_OF_ROLLING_AVG ( ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) * DIP_CONTROL_INTERVAL_SEC ) -#else #define SIZE_OF_ROLLING_AVG 10 -#endif -#ifdef USE_FMD_FLOW_SENSOR -/// Dialysate flow sensor signal strength low alarm persistence. -#define FLOW_SIG_STRGTH_ALARM_PERSIST ( 5 * MS_PER_SECOND ) -#define MIN_FLOW_SIG_STRENGTH 0.9 ///< Minimum flow sensor signal strength (90%). - -/// Dialysate flow fast read timeout alarm persistence. -#define DIALYSATE_FLOW_FAST_READ_TO_PERSIST 100 -/// Dialysate flow slow read timeout alarm persistence. -#define DIALYSATE_FLOW_SLOW_READ_TO_PERSIST ( MS_PER_SECOND * 3 ) -/// Blood flow comm error persistence. -#define DIALYSATE_FLOW_COMM_ERROR_PERSIST MS_PER_SECOND - -#define DFM_SENSOR_CONNECTED_STATUS 0x00 ///< Dialysate flow meter connected status. -#define DFM_SENSOR_PARAM_CORRUPT_STATUS 0x07 ///< Dialysate flow meter NVM parameter corrupt status. -#endif - #define PUMP_DIR_ERROR_COUNT_MASK 0x3F ///< Bit mask for pump direction error counter. /// Enumeration of dialysate inlet pump states. @@ -183,17 +163,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 -#ifdef USE_FMD_FLOW_SENSOR -static OVERRIDE_F32_T dialInFlowSignalStrength = { 0.0, 0.0, 0.0, 0 }; ///< Measured dialysate flow signal strength (%) -static U08 lastDialysateFlowFastPacketReadCtr = 0; ///< Previous read counter for the dialysate flow fast packets. -static U08 lastDialysateFlowSlowPacketReadCtr = 0; ///< Previous read counter for the dialysate flow slow packets. -#ifndef DISABLE_PUMP_FLOW_CHECKS -static U08 lastDialysateFlowCommErrorCount = 0; ///< Previous DPi flow sensor comm error count. -#endif -static HD_FLOW_SENSORS_CAL_RECORD_T dialysateFlowCalRecord; ///< Dialysate flow sensor calibration record. -#endif - static U08 lastDialInPumpDirectionCount = 0; ///< Previous pump direction error count reported by FPGA. static U32 dipControlTimerCounter = 0; ///< Determines when to perform control on dialIn flow @@ -238,10 +208,6 @@ static void checkDialInPumpSpeeds( void ); static void checkDialInPumpMCCurrent( void ); static void checkDialInPumpFlowRate( void ); -#ifdef USE_FMD_FLOW_SENSOR -static void checkDialInFlowSensorSignalStrength( void ); -static BOOL processCalibrationData( void ); -#endif /*********************************************************************//** * @brief @@ -273,12 +239,6 @@ MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE, MAX_DIAL_IN_PUMP_PWM_DUTY_CYCLE ); // Initialize persistent alarm for flow sensor signal strength too low -#ifdef USE_FMD_FLOW_SENSOR - initPersistentAlarm( ALARM_ID_DIALYSATE_FLOW_SIGNAL_STRENGTH_TOO_LOW, FLOW_SIG_STRGTH_ALARM_PERSIST, FLOW_SIG_STRGTH_ALARM_PERSIST ); - initPersistentAlarm( ALARM_ID_HD_DP_FLOW_READ_TIMEOUT_ERROR, 0, DIALYSATE_FLOW_FAST_READ_TO_PERSIST ); - initPersistentAlarm( ALARM_ID_HD_DP_FLOW_SLOW_READ_TIMEOUT_ERROR, 0, DIALYSATE_FLOW_SLOW_READ_TO_PERSIST ); - initPersistentAlarm( ALARM_ID_HD_DP_FLOW_SENSOR_ERROR, 0, DIALYSATE_FLOW_COMM_ERROR_PERSIST ); -#endif initPersistentAlarm( ALARM_ID_HD_DIAL_IN_FLOW_OUT_OF_RANGE, 0, DIP_MAX_FLOW_RATE_OUT_OF_RANGE_PERSIST ); initPersistentAlarm( ALARM_ID_HD_DIALYSATE_FLOW_DATA_NOT_RECEIVE, 0, 0 ); } @@ -447,6 +407,7 @@ U08 spReadCtr = getFPGADialysateFlowSlowPacketReadCounter(); U08 flowErrorCtr = getFPGADialysateFlowErrorCounter(); U08 flowStatus = getFPGADialysateFlowMeterStatus(); +<<<<<<< HEAD F32 dipFlow; #ifdef USE_FMD_FLOW_SENSOR F32 dpFlow = getFPGADialysateFlow(); @@ -512,6 +473,8 @@ } } #endif +======= +>>>>>>> 954107454f4c5d4cfbdfaefda5cc1cd15b1e18ac 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; @@ -529,9 +492,6 @@ // Check pump speeds and flow checkDialInPumpSpeeds(); checkDialInPumpFlowRate(); -#ifdef USE_FMD_FLOW_SENSOR - checkDialInFlowSensorSignalStrength(); -#endif // Check for home position, zero/low speed checkDialInPumpRotor(); } @@ -782,56 +742,8 @@ } } -#ifdef USE_FMD_FLOW_SENSOR /*********************************************************************//** * @brief - * The processCalibrationData function gets the calibration data and makes - * sure it is valid by checking the calibration date. The calibration date - * should not be 0. - * @details Inputs: none - * @details Outputs: dialysateFlowCalRecord - * @return TRUE if the calibration record is valid, otherwise FALSE - *************************************************************************/ -static BOOL processCalibrationData( void ) -{ - BOOL status = TRUE; - - // Get the calibration record from NVDataMgmt - HD_FLOW_SENSORS_CAL_RECORD_T calData = getHDFlowSensorsCalibrationRecord(); - - // Check if the calibration data that was received from NVDataMgmt is legitimate - // The calibration date item should not be zero. If the calibration date is 0, - // then the dialysate flow sensors data is not stored in the NV memory or it was corrupted. - if ( 0 == calData.hdFlowSensors[ CAL_DATA_HD_DIALYSATE_FLOW_SENSOR ].calibrationTime ) - { -#ifndef SKIP_CAL_CHECK - activateAlarmNoData( ALARM_ID_HD_DIALYSATE_FLOW_INVALID_CAL_RECORD ); - status = FALSE; -#endif - } - - // The calibration data was valid, update the local copy - dialysateFlowCalRecord.hdFlowSensors[ CAL_DATA_HD_DIALYSATE_FLOW_SENSOR ].fourthOrderCoeff = - calData.hdFlowSensors[ CAL_DATA_HD_DIALYSATE_FLOW_SENSOR ].fourthOrderCoeff; - - dialysateFlowCalRecord.hdFlowSensors[ CAL_DATA_HD_DIALYSATE_FLOW_SENSOR ].thirdOrderCoeff = - calData.hdFlowSensors[ CAL_DATA_HD_DIALYSATE_FLOW_SENSOR ].thirdOrderCoeff; - - dialysateFlowCalRecord.hdFlowSensors[ CAL_DATA_HD_DIALYSATE_FLOW_SENSOR ].secondOrderCoeff = - calData.hdFlowSensors[ CAL_DATA_HD_DIALYSATE_FLOW_SENSOR ].secondOrderCoeff; - - dialysateFlowCalRecord.hdFlowSensors[ CAL_DATA_HD_DIALYSATE_FLOW_SENSOR ].gain = - calData.hdFlowSensors[ CAL_DATA_HD_DIALYSATE_FLOW_SENSOR ].gain; - - dialysateFlowCalRecord.hdFlowSensors[ CAL_DATA_HD_DIALYSATE_FLOW_SENSOR ].offset = - calData.hdFlowSensors[ CAL_DATA_HD_DIALYSATE_FLOW_SENSOR ].offset; - - return status; -} -#endif - -/*********************************************************************//** - * @brief * The getTargetDialInFlowRate function gets the current target dialIn flow * rate. * @details Inputs: targetDialInFlowRate @@ -863,28 +775,6 @@ return result; } -#ifdef USE_FMD_FLOW_SENSOR -/*********************************************************************//** - * @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; -} -#endif - /*********************************************************************//** * @brief * The getMeasuredDialInPumpRotorSpeed function gets the measured dialIn flow @@ -1009,11 +899,7 @@ payload.measMCSpd = getMeasuredDialInPumpMCSpeed(); payload.measMCCurr = getMeasuredDialInPumpMCCurrent(); payload.pwmDC = dialInPumpPWMDutyCyclePctSet * FRACTION_TO_PERCENT_FACTOR; -#ifdef USE_FMD_FLOW_SENSOR - payload.flowSigStrength = getMeasuredDialInFlowSignalStrength() * FRACTION_TO_PERCENT_FACTOR; -#else payload.flowSigStrength = 0.0; -#endif broadcastData( MSG_ID_DIALYSATE_FLOW_DATA, COMM_BUFFER_OUT_CAN_HD_BROADCAST, (U08*)&payload, sizeof( DIALIN_PUMP_STATUS_PAYLOAD_T ) ); dialInFlowDataPublicationTimerCounter = 0; } @@ -1367,35 +1253,6 @@ } } -#ifdef USE_FMD_FLOW_SENSOR -/*********************************************************************//** - * @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 ); - - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_DIALYSATE_FLOW_SIGNAL_STRENGTH_TOO_LOW, outOfRange ) ) - { - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DIALYSATE_FLOW_SIGNAL_STRENGTH_TOO_LOW, sigStrength, MIN_FLOW_SIG_STRENGTH ); - } - } -#endif -} -#endif - /*********************************************************************//** * @brief * The execDialInFlowTest function executes the state machine for the @@ -1406,30 +1263,7 @@ *************************************************************************/ SELF_TEST_STATUS_T execDialInFlowTest( void ) { -#ifdef USE_FMD_FLOW_SENSOR - SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; - U08 const dfmStatus = getFPGADialysateFlowMeterStatus(); - - if ( DFM_SENSOR_PARAM_CORRUPT_STATUS != dfmStatus ) - { - BOOL calStatus = processCalibrationData(); - - if ( TRUE == calStatus ) - { - result = SELF_TEST_STATUS_PASSED; - } - else - { - result = SELF_TEST_STATUS_FAILED; - } - } - else - { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_DIALYSATE_FLOW_STATUS_SELF_TEST_FAILURE, (U32)dfmStatus ); - } -#else SELF_TEST_STATUS_T result = SELF_TEST_STATUS_PASSED; -#endif return result; } @@ -1748,51 +1582,4 @@ return result; } -#ifdef USE_FMD_FLOW_SENSOR -/*********************************************************************//** - * @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; -} -#endif - /**@}*/