Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r4b208641ed0c22d13211e6343ffaec9778560cc5 -r92708a5ab23026f5c9afce66bfa542c84141011a --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 4b208641ed0c22d13211e6343ffaec9778560cc5) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 92708a5ab23026f5c9afce66bfa542c84141011a) @@ -17,6 +17,7 @@ #include // for memcpy() +#include "DrainPump.h" #include "Heaters.h" #include "LoadCell.h" #include "MessageSupport.h" @@ -47,7 +48,8 @@ #define MIN_DRAIN_INLET_PSI_EMPTY -3.0 ///< Minimum drain inlet pressure (in PSI) to indicate reservoir is empty while drain pump on. #define RESERVOIR_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< interval (ms/task time) at which the reservoir data is published on the CAN bus. #define MAX_REDUNDANT_LOAD_CELL_DIFF 50.0 ///< Maximum difference in redundant load cells when determining if fill completed. -#define DRAIN_THRESHOLD_ML 1.0 ///< Drain threshold in milliliters. +// 2400 rpm is ~ 2400 mL/min and it results 1 mL of flow change. +#define DRAIN_THRESHOLD_ML(rpm) ( (F32)rpm / 2400.0 ) ///< Drain threshold in milliliters. #define DATA_PUBLISH_COUNTER_START_COUNT 5 ///< Data publish counter start count. // ********** private data ********** @@ -681,16 +683,15 @@ // ready to consider this the end of the reservoir flow // If the wait for drain to steady has elapsed and the drain pump inlet pressure sensor is indicating and increased vacuum, // signal the drain is complete - if ( ( drainFlowML <= DRAIN_THRESHOLD_ML ) && ( 0 == reservoirWeightUnchangeStartTime[ reservoirId ] ) ) + if ( ( drainFlowML <= DRAIN_THRESHOLD_ML( getDrainPumpTargetRPM() ) ) && ( 0 == reservoirWeightUnchangeStartTime[ reservoirId ] ) ) { reservoirWeightUnchangeStartTime[ reservoirId ] = getMSTimerCount(); } - else if ( drainFlowML > DRAIN_THRESHOLD_ML ) + else if ( drainFlowML > DRAIN_THRESHOLD_ML( getDrainPumpTargetRPM() ) ) { reservoirWeightUnchangeStartTime[ reservoirId ] = 0; } - // TODO make a #define if the extra 1000 ms worked - else if ( ( TRUE == didTimeout( reservoirWeightUnchangeStartTime[ reservoirId ], timeout + 1000 ) && + else if ( ( TRUE == didTimeout( reservoirWeightUnchangeStartTime[ reservoirId ], timeout ) && ( getMeasuredDGPressure( PRESSURE_SENSOR_DRAIN_PUMP_INLET ) > MIN_DRAIN_INLET_PSI_EMPTY ) ) ) { result = TRUE;