Index: firmware/App/Monitors/Temperature.c =================================================================== diff -u -rd748813399d38ef5b71d760e327e368cc82d7a38 -r5d60262836ddc8f80ac98f07f2cfd6707a5b7b79 --- firmware/App/Monitors/Temperature.c (.../Temperature.c) (revision d748813399d38ef5b71d760e327e368cc82d7a38) +++ firmware/App/Monitors/Temperature.c (.../Temperature.c) (revision 5d60262836ddc8f80ac98f07f2cfd6707a5b7b79) @@ -7,8 +7,8 @@ * * @file Temperature.c * -* @author (last) Vinayakam Mani -* @date (last) 11-Feb-2026 +* @author (last) Raghu Kallala +* @date (last) 10-Feb-2026 * * @author (original) Vinayakam Mani * @date (original) 25-Sep-2024 @@ -46,7 +46,7 @@ #define TEMP_SENSORS_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Temperature sensors publish data time interval. #define TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Temperature sensors FPGA error timeout in milliseconds. #define D4_TEMP_MOVING_AVG_NUM_OF_SAMPLES 50 ///< D4 temperature sensor moving average number of samples. -#define D50_TEMP_MOVING_AVG_NUM_OF_SAMPLES 50 ///< D50 temperature sensor moving average number of samples. +#define D50_TEMP_MOVING_AVG_NUM_OF_SAMPLES 25 ///< D50 temperature sensor moving average number of samples ( 250ms filter ). #define D99_TEMP_MOVING_AVG_NUM_OF_SAMPLES 50 ///< D99 temperature sensor moving average number of samples #define DATA_PUBLISH_COUNTER_START_COUNT 30 ///< Data publish counter start count. #define DIAL_TEMP_MOVING_AVG_NUM_OF_SAMPLES 30 ///< Dialysate temperature sensors moving average number of samples. @@ -95,9 +95,8 @@ static F32 d4TempSamplesC[ D4_TEMP_MOVING_AVG_NUM_OF_SAMPLES ]; ///< D4 temperature samples array in C. static U32 d4TempSamplesNextIndex; ///< D4 temperature sample next index number. static U32 d4TempCount; ///< D4 Number of samples in average buffer. -static U32 tempDataCollectionTimeInterval; ///< Temperature data collection time interval in milliseconds. +static U32 tempDataColTimeInterval; ///< Temperature data collection time interval in milliseconds. static U32 d4TempSampleIntervalCounter; ///< D4 temperature sensor sample collection timer counter. -static U32 d50TempSampleIntervalCounter; ///< D50 temperature sensor sample collection timer counter. static F32 d50TempAvgC; ///< D50 temperature average in C. static F32 d50TempRunningSumC; ///< D50 temperature running sum in C. @@ -152,9 +151,8 @@ d99TempSamplesNextIndex = 0; d99TempCount = 0; d4TempSampleIntervalCounter = 0; - d50TempSampleIntervalCounter = 0; d99TempSampleIntervalCounter = 0; - tempDataCollectionTimeInterval = 0; + tempDataColTimeInterval = 0; tempDriftEventCheck = FALSE; dialTempMovingAvgData[ DIAL_TEMP_D28 ].dialTempColHasTimerBeenSet = FALSE; @@ -311,7 +309,7 @@ static void filterTemperatureReadings( void ) { // Moving average sample collection interval varies based on the dialysate flow rate - if ( ++d4TempSampleIntervalCounter >= tempDataCollectionTimeInterval ) + if ( ++d4TempSampleIntervalCounter >= tempDataColTimeInterval ) { // Filter D4 Temperature for AC heater if ( d4TempCount >= D4_TEMP_MOVING_AVG_NUM_OF_SAMPLES ) @@ -328,26 +326,22 @@ d4TempSampleIntervalCounter = 0; } - // Moving average sample collection interval varies based on the dialysate flow rate - if ( ++d50TempSampleIntervalCounter >= tempDataCollectionTimeInterval ) + // Filter D50 Temperature ( 250 ms filter ) for trimmer heater + if ( d50TempCount >= D50_TEMP_MOVING_AVG_NUM_OF_SAMPLES ) { - if ( d50TempCount >= D50_TEMP_MOVING_AVG_NUM_OF_SAMPLES ) - { - d50TempRunningSumC -= d50TempSamplesC[ d50TempSamplesNextIndex ]; - } - - F32 d50Temp = getTemperatureValue( D50_TEMP ); - d50TempSamplesC[ d50TempSamplesNextIndex ] = d50Temp; - d50TempRunningSumC += d50Temp; - d50TempSamplesNextIndex = INC_WRAP( d50TempSamplesNextIndex, 0, D50_TEMP_MOVING_AVG_NUM_OF_SAMPLES - 1 ); - d50TempCount = INC_CAP( d50TempCount, D50_TEMP_MOVING_AVG_NUM_OF_SAMPLES ); - d50TempAvgC = d50TempRunningSumC / (F32)d50TempCount; - d50TempSampleIntervalCounter = 0; + d50TempRunningSumC -= d50TempSamplesC[ d50TempSamplesNextIndex ]; } + F32 d50Temp = getTemperatureValue( D50_TEMP ); + d50TempSamplesC[ d50TempSamplesNextIndex ] = d50Temp; + d50TempRunningSumC += d50Temp; + d50TempSamplesNextIndex = INC_WRAP( d50TempSamplesNextIndex, 0, D50_TEMP_MOVING_AVG_NUM_OF_SAMPLES - 1 ); + d50TempCount = INC_CAP( d50TempCount, D50_TEMP_MOVING_AVG_NUM_OF_SAMPLES ); + d50TempAvgC = d50TempRunningSumC / (F32)d50TempCount; + // Moving average sample collection interval varies based on the dialysate flow rate - if ( ++d99TempSampleIntervalCounter >= tempDataCollectionTimeInterval ) + if ( ++d99TempSampleIntervalCounter >= tempDataColTimeInterval ) { // Filter D99 Temperature for fresh dialysate temperature @@ -498,7 +492,7 @@ U32 sampleInterval = (U32)( ( period / (F32)D4_TEMP_MOVING_AVG_NUM_OF_SAMPLES ) * MS_PER_SECOND ); - tempDataCollectionTimeInterval = (U32) ( sampleInterval / TASK_PRIORITY_INTERVAL ); + tempDataColTimeInterval = (U32) ( sampleInterval / TASK_PRIORITY_INTERVAL ); } /*********************************************************************//**