Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -r27f3db92495948d4c1192421c1b0c20338c4a034 -r6811f0251b0fa7d27c3e6d5eb16ade2bc88a3204 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 6811f0251b0fa7d27c3e6d5eb16ade2bc88a3204) @@ -36,7 +36,6 @@ #define RESERVOIR_SETTLE_TIME_MS 5000 ///< Time (in ms) allotted for reservoir to settle (after fill, before drain). -#define SIZE_OF_SMALL_LOAD_CELL_AVG 8 ///< Small load cell moving average has 8 samples. #define SIZE_OF_LARGE_LOAD_CELL_AVG 32 ///< Large load cell moving average has 32 samples. /// States of the treatment reservoir management state machine. @@ -78,16 +77,10 @@ /// Measured weight from load cells. static OVERRIDE_F32_T loadCellWeightInGrams[ NUM_OF_LOAD_CELLS ]; -/// Filtered (8 sample) weight of reservoirs. -static F32 smFilteredReservoirWeightInGrams[ NUM_OF_DG_RESERVOIRS ]; /// Filtered (32 sample) weight of reservoirs. static F32 lgFilteredReservoirWeightInGrams[ NUM_OF_DG_RESERVOIRS ]; // Load cell filtering data -/// Holds load cell samples for small load cell moving average. -static F32 smLoadCellReadings[ NUM_OF_DG_RESERVOIRS ][ SIZE_OF_SMALL_LOAD_CELL_AVG ]; -static U32 smLoadCellReadingsIdx = 0; ///< Index for next sample in small load cell rolling average sample array. -static F32 smLoadCellReadingsTotal[ NUM_OF_DG_RESERVOIRS ]; ///< Rolling total - used to calc small load cell moving average. /// Holds load cell samples for large load cell moving average. static F32 lgLoadCellReadings[ NUM_OF_DG_RESERVOIRS ][ SIZE_OF_LARGE_LOAD_CELL_AVG ]; static U32 lgLoadCellReadingsIdx = 0; ///< Index for next sample in large load cell rolling average sample array. @@ -145,12 +138,7 @@ // initialize reservoirs weights for ( i = 0; i < NUM_OF_DG_RESERVOIRS; i++ ) { - smFilteredReservoirWeightInGrams[ i ] = 0.0; lgFilteredReservoirWeightInGrams[ i ] = 0.0; - for ( j = 0; j < SIZE_OF_SMALL_LOAD_CELL_AVG; j++ ) - { - smLoadCellReadings[ i ][ j ] = 0.0; - } for ( j = 0; j < SIZE_OF_LARGE_LOAD_CELL_AVG; j++ ) { lgLoadCellReadings[ i ][ j ] = 0.0; @@ -165,9 +153,6 @@ dgCmdResp[ i ].rejectCode = DG_CMD_REQUEST_REJECT_REASON_NONE; } - smLoadCellReadingsIdx = 0; - smLoadCellReadingsTotal[ DG_RESERVOIR_1 ] = 0.0; - smLoadCellReadingsTotal[ DG_RESERVOIR_2 ] = 0.0; lgLoadCellReadingsIdx = 0; lgLoadCellReadingsTotal[ DG_RESERVOIR_1 ] = 0.0; lgLoadCellReadingsTotal[ DG_RESERVOIR_2 ] = 0.0; @@ -498,27 +483,6 @@ /*********************************************************************//** * @brief - * The getReservoirWeightSmallFilter function gets the load cell weight - * of the given reservoir after small (8 sample) filter applied. - * @details Inputs: lgFilteredReservoirWeightInGrams[] - * @details Outputs: none - * @param resID ID of reservoir to get filtered weight for - * @return the current filtered weight of the given reservoir in grams - *************************************************************************/ -F32 getReservoirWeightSmallFilter( DG_RESERVOIR_ID_T resID ) -{ - F32 result = 0.0; - - if ( resID < NUM_OF_DG_RESERVOIRS ) - { - result = smFilteredReservoirWeightInGrams[ resID ]; - } - - return result; -} - -/*********************************************************************//** - * @brief * The getReservoirWeightLargeFilter function gets the load cell weight * of the given reservoir after large (32 sample) filter applied. * @details Inputs: lgFilteredReservoirWeightInGrams[] @@ -694,16 +658,11 @@ for ( res = DG_RESERVOIR_1; res < NUM_OF_DG_RESERVOIRS; res++ ) { F32 wt = ( res == DG_RESERVOIR_1 ? res1Primary : res2Primary ); - smLoadCellReadingsTotal[ res ] -= smLoadCellReadings[ res ][ smLoadCellReadingsIdx ]; lgLoadCellReadingsTotal[ res ] -= lgLoadCellReadings[ res ][ lgLoadCellReadingsIdx ]; - smLoadCellReadings[ res ][ smLoadCellReadingsIdx ] = wt; lgLoadCellReadings[ res ][ lgLoadCellReadingsIdx ] = wt; - smLoadCellReadingsTotal[ res ] += wt; lgLoadCellReadingsTotal[ res ] += wt; - smFilteredReservoirWeightInGrams[ res ] = smLoadCellReadingsTotal[ res ] / (F32)SIZE_OF_SMALL_LOAD_CELL_AVG; lgFilteredReservoirWeightInGrams[ res ] = lgLoadCellReadingsTotal[ res ] / (F32)SIZE_OF_LARGE_LOAD_CELL_AVG; } - smLoadCellReadingsIdx = INC_WRAP( smLoadCellReadingsIdx, 0, SIZE_OF_SMALL_LOAD_CELL_AVG - 1 ); lgLoadCellReadingsIdx = INC_WRAP( lgLoadCellReadingsIdx, 0, SIZE_OF_LARGE_LOAD_CELL_AVG - 1 ); } Index: firmware/App/Controllers/DGInterface.h =================================================================== diff -u -r27f3db92495948d4c1192421c1b0c20338c4a034 -r6811f0251b0fa7d27c3e6d5eb16ade2bc88a3204 --- firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) +++ firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision 6811f0251b0fa7d27c3e6d5eb16ade2bc88a3204) @@ -132,7 +132,6 @@ F32 getDGROPumpFlowRateMlMin( void ); U32 getDGDrainPumpRPMSetPt( void ); F32 getLoadCellWeightInGrams( LOAD_CELL_ID_T loadCellID ); -F32 getReservoirWeightSmallFilter( DG_RESERVOIR_ID_T resID ); F32 getReservoirWeightLargeFilter( DG_RESERVOIR_ID_T resID ); void setDGOpMode( U32 opMode, U32 subMode ); Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r9798f57bc288270fe058fe098a76088cbb34d50c -r6811f0251b0fa7d27c3e6d5eb16ade2bc88a3204 --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 9798f57bc288270fe058fe098a76088cbb34d50c) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 6811f0251b0fa7d27c3e6d5eb16ade2bc88a3204) @@ -1098,7 +1098,8 @@ static void updateUFVolumes( void ) { DG_RESERVOIR_ID_T activeRes = getDGActiveReservoir(); - F32 latestResVolume = getReservoirWeightSmallFilter( activeRes ); + LOAD_CELL_ID_T lc = ( activeRes == DG_RESERVOIR_1 ? LOAD_CELL_RESERVOIR_1_PRIMARY : LOAD_CELL_RESERVOIR_2_PRIMARY ); + F32 latestResVolume = getLoadCellWeightInGrams( lc ); #ifndef DISABLE_UF_ALARMS F32 deltaVolume = latestResVolume - resFinalVolume[ activeRes ]; Index: firmware/App/Modes/Prime.c =================================================================== diff -u -r0eee20d6e821c444dbfbc7ba98b9dd64e2b08ec8 -r6811f0251b0fa7d27c3e6d5eb16ade2bc88a3204 --- firmware/App/Modes/Prime.c (.../Prime.c) (revision 0eee20d6e821c444dbfbc7ba98b9dd64e2b08ec8) +++ firmware/App/Modes/Prime.c (.../Prime.c) (revision 6811f0251b0fa7d27c3e6d5eb16ade2bc88a3204) @@ -633,7 +633,7 @@ { HD_PRE_TREATMENT_PRIME_STATE_T state = HD_PRIME_DIALYSATE_DIALYZER_STATE; - F32 const loadcellWeight = getReservoirWeightSmallFilter( DG_RESERVOIR_1 ); + F32 const loadcellWeight = getLoadCellWeightInGrams( LOAD_CELL_RESERVOIR_1_PRIMARY ); F32 const weightChange = fabs( 1.0 - ( previousLoadCellReading / loadcellWeight ) ); if ( weightChange < LOAD_CELL_VOLUME_NOISE_TOLERANCE ) @@ -701,7 +701,7 @@ static HD_PRE_TREATMENT_PRIME_STATE_T handlePrimeDialysateBypassState( void ) { HD_PRE_TREATMENT_PRIME_STATE_T state = HD_PRIME_DIALYSATE_BYPASS_STATE; - F32 const loadcellWeight = getReservoirWeightSmallFilter( DG_RESERVOIR_2 ); + F32 const loadcellWeight = getLoadCellWeightInGrams( LOAD_CELL_RESERVOIR_2_PRIMARY ); F32 const weightChange = fabs( 1.0 - ( previousLoadCellReading / loadcellWeight ) ); if ( weightChange < LOAD_CELL_VOLUME_NOISE_TOLERANCE )