Index: firmware/App/Modes/ModeDrain.c =================================================================== diff -u -r5f538f79c346c041661d039e92b4fa1f77c3e1ac -r4d1a8ff389678d2f9a0bde6effba32d8c4ac5fb1 --- firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 5f538f79c346c041661d039e92b4fa1f77c3e1ac) +++ firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 4d1a8ff389678d2f9a0bde6effba32d8c4ac5fb1) @@ -112,7 +112,7 @@ // set initial actuator states setValveState( VDR, VALVE_STATE_DRAIN_C_TO_NO ); - setDrainPumpTargetRPMDelayed( /*TARGET_DRAIN_PUMP_RPM*/ 500, DELAY_DRAIN_PUMP_MS ); + setDrainPumpTargetRPMDelayed( TARGET_DRAIN_PUMP_RPM, DELAY_DRAIN_PUMP_MS ); // NOTE: The target flow rate should be set prior to setting the start primary heater // because the initial guess in the heaters driver needs the target flow to calculate Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r5f538f79c346c041661d039e92b4fa1f77c3e1ac -r4d1a8ff389678d2f9a0bde6effba32d8c4ac5fb1 --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 5f538f79c346c041661d039e92b4fa1f77c3e1ac) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 4d1a8ff389678d2f9a0bde6effba32d8c4ac5fb1) @@ -683,18 +683,20 @@ { BOOL result = FALSE; - F32 loadcellWeightML = getLoadCellSmallFilteredWeight( associatedLoadCell[ reservoirId ] ); - U32 targetDrainVolML = getU32OverrideValue( &drainVolumeTargetMl ); - F32 drainFlowML = reservoirPreviousStatus[ reservoirId ].previousReservoirWeightG - loadcellWeightML; - F32 drainThresholdML = ( (F32)getDrainPumpTargetRPM() ) / MAX_DRAIN_RPM_MLP; + F32 loadcellWeightML = getLoadCellSmallFilteredWeight( associatedLoadCell[ reservoirId ] ); U32 drainPumpFeedbackRPM = getDrainPumpMeasuredRPM(); - if ( ( reservoirPreviousStatus[ reservoirId ].previousReservoirWeightG > getLoadCellSmallFilteredWeight( associatedLoadCell[ reservoirId ] ) ) && - ( drainPumpFeedbackRPM > 0 ) ) + if ( drainPumpFeedbackRPM > 0 ) { - reservoirPreviousStatus[ reservoirId ].previousReservoirWeightG = getLoadCellSmallFilteredWeight( associatedLoadCell[ reservoirId ] ); - reservoirPreviousStatus[ reservoirId ].previousDrainFlowML = drainFlowML; + F32 drainThresholdML = ( (F32)getDrainPumpTargetRPM() ) / MAX_DRAIN_RPM_MLP; + reservoirPreviousStatus[ reservoirId ].previousDrainFlowML = reservoirPreviousStatus[ reservoirId ].previousReservoirWeightG - loadcellWeightML; + + if ( reservoirPreviousStatus[ reservoirId ].previousReservoirWeightG > loadcellWeightML ) + { + reservoirPreviousStatus[ reservoirId ].previousReservoirWeightG = loadcellWeightML; + } + // If the flow is less than the threshold and the time has not been set, set the timer // If the flow is greater than the threshold and timer has been set, 0 it because the flow is out of range and we are not // ready to consider this the end of the reservoir flow @@ -715,32 +717,6 @@ } } - /*if ( ( drainFlowML < reservoirPreviousStatus[ reservoirId ].previousDrainFlowML ) )//|| ( 0 == reservoirPreviousStatus[ reservoirId ].previousDrainFlowML ) ) - { - // Update the structure with the current weight as the previous - reservoirPreviousStatus[ reservoirId ].previousReservoirWeightG = getLoadCellSmallFilteredWeight( associatedLoadCell[ reservoirId ] ); - reservoirPreviousStatus[ reservoirId ].previousDrainFlowML = drainFlowML; - } - - // If the flow is less than the threshold and the time has not been set, set the timer - // If the flow is greater than the threshold and timer has been set, 0 it because the flow is out of range and we are not - // 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 ( ( reservoirPreviousStatus[ reservoirId ].previousDrainFlowML <= drainThresholdML ) && ( 0 == reservoirWeightUnchangeStartTime[ reservoirId ] ) ) - { - reservoirWeightUnchangeStartTime[ reservoirId ] = getMSTimerCount(); - } - else if ( reservoirPreviousStatus[ reservoirId ].previousDrainFlowML > drainThresholdML ) - { - reservoirWeightUnchangeStartTime[ reservoirId ] = 0; - } - else if ( ( TRUE == didTimeout( reservoirWeightUnchangeStartTime[ reservoirId ], timeout ) && - ( getMeasuredDGPressure( PRESSURE_SENSOR_DRAIN_PUMP_INLET ) > MIN_DRAIN_INLET_PSI_EMPTY ) ) ) - { - result = TRUE; - }*/ - return result; }