Index: firmware/App/Monitors/Pressures.c =================================================================== diff -u -reef41b7363d82763095a1317f1757f360f0d9ec1 -r8e5105d7e059711084c0d30041cde756d995d62f --- firmware/App/Monitors/Pressures.c (.../Pressures.c) (revision eef41b7363d82763095a1317f1757f360f0d9ec1) +++ firmware/App/Monitors/Pressures.c (.../Pressures.c) (revision 8e5105d7e059711084c0d30041cde756d995d62f) @@ -101,10 +101,12 @@ #define SIZE_OF_LONG_ART_ROLLING_AVG ( ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) * 10 ) /// Measured arterial pressure is filtered w/ 1 second moving average for inline pressure. #define SIZE_OF_SHORT_ART_ROLLING_AVG ( ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) * 1 ) -/// Measured arterial pressure is filtered w/ 10 second moving average for pressure compensation of flow. +/// Measured venous pressure is filtered w/ 10 second moving average for pressure compensation of flow. #define SIZE_OF_LONG_VEN_ROLLING_AVG ( ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) * 10 ) /// Measured venous pressure is filtered w/ 1 second moving average for inline pressure and unfiltered for occlusion detection. #define SIZE_OF_SHORT_VEN_ROLLING_AVG ( ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) * 1 ) +/// Measured trans-membrane pressure is filtered w/ 10 second moving average for pressure compensation of flow. +#define SIZE_OF_LONG_TMP_ROLLING_AVG ( ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) * 10 ) #define DATA_PUBLISH_COUNTER_START_COUNT 5 ///< Data publish counter start count. @@ -161,6 +163,7 @@ static F32 longFilteredVenousPressure; ///< Measured venous pressure after long (10 s) filter (in mmHg). static OVERRIDE_F32_T shortFilteredVenousPressure; ///< Measured venous pressure after short (1 s) filter (in mmHg). static OVERRIDE_F32_T tmpPressure; ///< Calculated trans-membrane pressure (in mmHg). +static F32 longFilteredTmpPressure; ///< Measured trans-membrane pressure after long (10 s) filter (in mmHg). static STABILIZATION_PERIODS_T pressureStabilizeTime; ///< Pressure stabilization time based on system events such as airpump, treatment param changes etc., static BOOL resetFillExemptPeriod; ///< Flag to reset the exempt period after defined time expire. static BOOL lowVenousPressureExemptCheck; ///< low venous pressure exempt check flag based on the air trap valve status @@ -191,6 +194,11 @@ static U32 venPressureReadingsShortCount; ///< Number of samples in flow rolling average buffer. static BARO_MOVING_AVG_DATA_T baroMovingAvg; ///< Barometric sensor moving average. +static F32 tmpPressureReadingsLong[ SIZE_OF_LONG_TMP_ROLLING_AVG ]; ///< Holds flow samples for long trans-membrane pressure rolling average. +static U32 tmpPressureReadingsLongIdx; ///< Index for next sample in rolling average array. +static F32 tmpPressureReadingsLongTotal; ///< Rolling total - used to calc average. +static U32 tmpPressureReadingsLongCount; ///< Number of samples in flow rolling average buffer. + static PRESSURE_SELF_TEST_STATE_T pressurePostState; ///< Pressure self test post state. //static HD_PRESSURE_SENSORS_CAL_RECORD_T pressureSensorsCalRecord; ///< Pressure sensors calibration record. @@ -286,6 +294,10 @@ venPressureReadingsShortTotal = 0.0F; venPressureReadingsShortCount = 0; + tmpPressureReadingsLongIdx = 0; + tmpPressureReadingsLongTotal = 0.0F; + tmpPressureReadingsLongCount = 0; + baroMovingAvg.baroAvgPSI.data = 0.0F; baroMovingAvg.baroAvgPSI.ovData = 0.0F; baroMovingAvg.baroAvgPSI.ovInitData = 0.0F; @@ -584,6 +596,7 @@ // Get latest dialysate pressure so we can calculate TMP tmpPressure.data = getFilteredVenousPressure() - ( getDialysatePressure() * PSI_TO_MMHG ); + tmpPressure.data = getF32OverrideValue( &tmpPressure ); // Handle pressure limits state machine execPressureLimits(); @@ -977,6 +990,19 @@ /*********************************************************************//** * @brief + * The getLongFilteredTMPPressure function gets the current long filtered + * trans-membrane pressure. + * @details \b Inputs: longFilteredTmpPressure + * @details \b Outputs: none + * @return the current long filtered trans-membrane pressure (in mmHg). + *************************************************************************/ +F32 getLongFilteredTMPPressure( void ) +{ + return longFilteredTmpPressure; +} + +/*********************************************************************//** + * @brief * The getBaroPressurePSI function gets the averaged barometric pressure in psi. * @details \b Inputs: baroMovingAvg.baroAvgPS * @details \b Outputs: none @@ -1045,6 +1071,18 @@ venPressureReadingsShortIdx = INC_WRAP( venPressureReadingsShortIdx, 0, SIZE_OF_SHORT_VEN_ROLLING_AVG - 1 ); venPressureReadingsShortCount = INC_CAP( artPressureReadingsShortCount, SIZE_OF_SHORT_VEN_ROLLING_AVG ); shortFilteredVenousPressure.data = venPressureReadingsShortTotal / (F32)venPressureReadingsShortCount; + + // Long filter for trans-membrane pressure + if ( tmpPressureReadingsLongCount >= SIZE_OF_LONG_VEN_ROLLING_AVG ) + { + tmpPressureReadingsLongTotal -= tmpPressureReadingsLong[ tmpPressureReadingsLongIdx ]; + } + tmpPressureReadingsLong[ tmpPressureReadingsLongIdx ] = tmpPressure.data; + tmpPressureReadingsLongTotal += tmpPressure.data; + tmpPressureReadingsLongIdx = INC_WRAP( tmpPressureReadingsLongIdx, 0, SIZE_OF_LONG_TMP_ROLLING_AVG - 1 ); + tmpPressureReadingsLongCount = INC_CAP( tmpPressureReadingsLongCount, SIZE_OF_LONG_TMP_ROLLING_AVG ); + longFilteredTmpPressure = tmpPressureReadingsLongTotal / (F32)tmpPressureReadingsLongCount; + } /*********************************************************************//** Index: firmware/App/Monitors/Pressures.h =================================================================== diff -u -reef41b7363d82763095a1317f1757f360f0d9ec1 -r8e5105d7e059711084c0d30041cde756d995d62f --- firmware/App/Monitors/Pressures.h (.../Pressures.h) (revision eef41b7363d82763095a1317f1757f360f0d9ec1) +++ firmware/App/Monitors/Pressures.h (.../Pressures.h) (revision 8e5105d7e059711084c0d30041cde756d995d62f) @@ -92,6 +92,7 @@ F32 getFilteredVenousPressure( void ); F32 getLongFilteredVenousPressure( void ); F32 getTMPPressure( void ); +F32 getLongFilteredTMPPressure( void ); F32 getBaroPressurePSI( void ); BOOL testPressuresDataPublishIntervalOverride( MESSAGE_T *message );