Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -r8a0735916a4006faaf0651d685131916517c4f33 -r5af49574b5f8e99aa9ea451033213dcd765ea837 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 8a0735916a4006faaf0651d685131916517c4f33) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 5af49574b5f8e99aa9ea451033213dcd765ea837) @@ -91,6 +91,7 @@ // DG Dialysate flow rate static F32 dgDialysateFlowRateMlMin = 0.0; ///< Latest dialysate flow rate reported by the DG. +static BOOL dgDialysateFlowDataFreshFlag = FALSE; ///< Flag to signal the execDialInFlowMonitor() to process fresh flow rate data // Reservoir data static DG_RESERVOIR_ID_T dgActiveReservoir = DG_RESERVOIR_2; ///< Latest active reservoir reported by the DG. @@ -127,7 +128,7 @@ dgTrimmerTempSet = 0.0; dgActiveReservoirSet = DG_RESERVOIR_2; dgReservoirFillVolumeTargetSet = 0; - dgReservoirDrainVolumeTargetSet = 0; + dgReservoirDrainVolumeTargetSet = 0; // initialize load cell weights for ( i = 0; i < NUM_OF_LOAD_CELLS; i++ ) @@ -430,6 +431,19 @@ return result; } + +/*********************************************************************//** + * @brief + * The getDialysateFlowDataFreshFlag function returns a flag to indicate + * if the dialysate flow rate data reported by the DG is fresh or stale data. + * @details Inputs: dgDialysateFlowDataFreshFlag + * @details Outputs: none + * @return T/F flag to indicate fresh/stale status of dialysate flow data. + *************************************************************************/ +BOOL getDialysateFlowDataFreshFlag( void ) +{ + return dgDialysateFlowDataFreshFlag; +} /*********************************************************************//** * @brief @@ -605,18 +619,32 @@ /*********************************************************************//** * @brief - * The setDialysateFlowData function sets the latest dialysate flow data - * reported by the DG. + * The setDialysateFlowData function sets the latest dialysate flow rate + * and its freshness status. The dialysate flow data is reported by the DG. * @details Inputs: none * @details Outputs: dgDialysateFlowRateMlMin - * @param flowRate latest dialysate flow rate (LPM) reported by DG + * @param flowRate latest dialysate flow rate (mL/min) reported by DG * @return none *************************************************************************/ void setDialysateFlowData( F32 flowRate ) { dgDialysateFlowRateMlMin = flowRate; - filterDialInFlowReadings( flowRate * (F32)ML_PER_LITER ); + setDialysateFlowDataFreshFlag( TRUE ); // sets freshness status } + +/*********************************************************************//** + * @brief + * The setDialysateFlowDataFreshFlag function sets the dialysate flow + * data freshness flag. + * @details Inputs: none + * @details Outputs: dgDialysateFlowDataFreshFlag + * @param flowRateFreshFlag to set + * @return none + *************************************************************************/ +void setDialysateFlowDataFreshFlag( BOOL flowRateFreshFlag ) +{ + dgDialysateFlowDataFreshFlag = flowRateFreshFlag; +} /*********************************************************************//** * @brief Index: firmware/App/Controllers/DGInterface.h =================================================================== diff -u -rd39ef6232e746a4f2d425135208602670fae60bd -r5af49574b5f8e99aa9ea451033213dcd765ea837 --- firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision d39ef6232e746a4f2d425135208602670fae60bd) +++ firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision 5af49574b5f8e99aa9ea451033213dcd765ea837) @@ -119,6 +119,7 @@ DG_RESERVOIR_ID_T getDGActiveReservoir( void ); DG_RESERVOIR_ID_T getDGInactiveReservoir( void ); BOOL hasDGCompletedReservoirSwitch( void ); +BOOL getDialysateFlowDataFreshFlag( void ); F32 getDGDialysateFlowRateMlMin( void ); F32 getLoadCellWeight( LOAD_CELL_ID_T loadCellID ); F32 getReservoirWeight( DG_RESERVOIR_ID_T resID ); @@ -131,6 +132,7 @@ void setDGDialysateTemperatures( F32 primaryHtrTemp, F32 trimmerHtrTemp ); void setDGReservoirsData( DG_RESERVOIR_ID_T resID, U32 fillVol, U32 drainVol ); void setDialysateFlowData( F32 flowRate ); +void setDialysateFlowDataFreshFlag( BOOL flowRateFreshFlag ); void setNewLoadCellReadings( F32 res1Primary, F32 res1Backup, F32 res2Primary, F32 res2Backup ); void setDGDisinfectsStates( DG_DISINFECT_UI_STATES_T states ); Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r8a0735916a4006faaf0651d685131916517c4f33 -r5af49574b5f8e99aa9ea451033213dcd765ea837 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 8a0735916a4006faaf0651d685131916517c4f33) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 5af49574b5f8e99aa9ea451033213dcd765ea837) @@ -29,7 +29,8 @@ #include "PersistentAlarm.h" #include "PIControllers.h" #include "SafetyShutdown.h" -#include "SystemCommMessages.h" +#include "SystemCommMessages.h" +#include "SystemComm.h" #include "TaskGeneral.h" #include "TaskPriority.h" #include "Timers.h" @@ -82,6 +83,8 @@ static const U32 DIP_DIRECTION_ERROR_PERSIST = (250 / TASK_PRIORITY_INTERVAL); /// Persist time (task intervals) dialysate flow rate out of range error condition. static const U32 DIP_MAX_FLOW_RATE_OUT_OF_RANGE_PERSIST = ((1 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); +/// Time threshold to trigger an alarm if Dialysate flow data has not arrived within 3 seconds +static const U32 DIP_DIALYSATE_FLOW_DATA_ALARM_THRESHOLD = ((3 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL); #define DIP_MAX_CURR_WHEN_STOPPED_MA 150.0 ///< Motor controller current should not exceed this when pump should be stopped. #define DIP_MAX_CURR_WHEN_RUNNING_MA 2000.0 ///< Motor controller current should not exceed this when pump should be running. @@ -172,7 +175,8 @@ static PUMP_CONTROL_MODE_T dialInPumpControlModeSet = PUMP_CONTROL_MODE_CLOSED_LOOP;///< Currently set dialIn pump control mode. /// 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 }; +static OVERRIDE_U32_T dialInFlowDataPublishInterval = { DIAL_IN_FLOW_DATA_PUB_INTERVAL, DIAL_IN_FLOW_DATA_PUB_INTERVAL, DIAL_IN_FLOW_DATA_PUB_INTERVAL, 0 }; +static U32 dialysateFlowDataFreshStatusCounter = 0; ///< Counter use to trigger alarm if no fresh dialysate flow data is received static S32 targetDialInFlowRate = 0; ///< Requested dialIn flow rate static OVERRIDE_F32_T measuredDialInFlowRate = { 0.0, 0.0, 0.0, 0 }; ///< Measured dialysate inlet flow rate static OVERRIDE_F32_T dialInPumpRotorSpeedRPM = { 0.0, 0.0, 0.0, 0 }; ///< Measured dialysate inlet pump rotor speed @@ -226,7 +230,8 @@ static void releaseDialInPumpStop( void ); static void setDialInPumpDirection( MOTOR_DIR_T dir ); static void publishDialInFlowData( void ); -static void resetDialInFlowMovingAverage( void ); +static void resetDialInFlowMovingAverage( void ); +static void filterDialInFlowReadings( F32 flow ); static void updateDialInPumpSpeedAndDirectionFromHallSensors( void ); static void checkDialInPumpRotor( void ); static void checkDialInPumpDirection( void ); @@ -275,6 +280,7 @@ 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 ); } /*********************************************************************//** @@ -486,12 +492,30 @@ lastDialysateFlowSlowPacketReadCtr = spReadCtr; dialInFlowSignalStrength.data = getFPGADialysateFlowSignalStrength(); - filterDialInFlowReadings( dipFlow ); +#else + if ( TRUE == getDialysateFlowDataFreshFlag() ) + { + dialysateFlowDataFreshStatusCounter = 0; // reset counter + dipFlow = getDGDialysateFlowRateMlMin() * (F32)ML_PER_LITER; + filterDialInFlowReadings( dipFlow ); // process the fresh dialysate flow data + setDialysateFlowDataFreshFlag( FALSE ); + } + else + { // dialysate flow data is a stale data + if ( ++dialysateFlowDataFreshStatusCounter > DIP_DIALYSATE_FLOW_DATA_ALARM_THRESHOLD ) + { + filterDialInFlowReadings( 0.0 ); + if ( TRUE == isDGCommunicating() ) + { + activateAlarmNoData( ALARM_ID_HD_DIALYSATE_FLOW_DATA_NOT_RECEIVE ); + } + } + } #endif 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; - + // Calculate dialysate inlet pump motor speed/direction from hall sensor count updateDialInPumpSpeedAndDirectionFromHallSensors(); Index: firmware/App/Controllers/DialInFlow.h =================================================================== diff -u -r8a0735916a4006faaf0651d685131916517c4f33 -r5af49574b5f8e99aa9ea451033213dcd765ea837 --- firmware/App/Controllers/DialInFlow.h (.../DialInFlow.h) (revision 8a0735916a4006faaf0651d685131916517c4f33) +++ firmware/App/Controllers/DialInFlow.h (.../DialInFlow.h) (revision 5af49574b5f8e99aa9ea451033213dcd765ea837) @@ -56,8 +56,7 @@ BOOL setDialInPumpTargetFlowRate( U32 flowRate, MOTOR_DIR_T dir, PUMP_CONTROL_MODE_T mode ); void signalDialInPumpHardStop( void ); -void signalDialInPumpRotorHallSensor( void ); -void filterDialInFlowReadings( F32 flow ); +void signalDialInPumpRotorHallSensor( void ); BOOL homeDialInPump( void ); BOOL isDialInPumpRunning( void );