Index: firmware/App/Controllers/Fans.c =================================================================== diff -u -r4b208641ed0c22d13211e6343ffaec9778560cc5 -r321e3603df2611c653e4bd330f640ab35822fd6d --- firmware/App/Controllers/Fans.c (.../Fans.c) (revision 4b208641ed0c22d13211e6343ffaec9778560cc5) +++ firmware/App/Controllers/Fans.c (.../Fans.c) (revision 321e3603df2611c653e4bd330f640ab35822fd6d) @@ -128,15 +128,15 @@ rpmAlarmStartTimeOffset.ovData = 0; rpmAlarmStartTimeOffset.ovInitData = 0; rpmAlarmStartTimeOffset.override = OVERRIDE_RESET; + fansStatus.dutyCycle.data = 0.0; + fansStatus.dutyCycle.ovData = 0.0; + fansStatus.dutyCycle.ovInitData = 0.0; + fansStatus.dutyCycle.override = OVERRIDE_RESET; + fansStatus.targetRPM = 0.0; // Initialize the fans for ( fan = FAN_INLET_1; fan < NUM_OF_FANS_NAMES; fan++ ) { - fansStatus.dutyCycle.data = 0.0; - fansStatus.dutyCycle.ovData = 0.0; - fansStatus.dutyCycle.ovInitData = 0.0; - fansStatus.dutyCycle.override = OVERRIDE_RESET; - fansStatus.targetRPM = 0.0; fansStatus.rpm[ fan ].data = 0.0; fansStatus.rpm[ fan ].ovData = 0.0; fansStatus.rpm[ fan ].ovInitData = 0.0; Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -r9c3d402fd9ac55c4dc7116de8a61cc02c18b44bc -r321e3603df2611c653e4bd330f640ab35822fd6d --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 9c3d402fd9ac55c4dc7116de8a61cc02c18b44bc) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 321e3603df2611c653e4bd330f640ab35822fd6d) @@ -320,6 +320,7 @@ } else { + // Raise the alarm SET_ALARM_WITH_1_F32_DATA( ALARM_ID_DG_LOAD_CELLS_TARE_WEIGHT_OUT_OF_RANGE, weight ) } } Index: firmware/App/Modes/ModeHeatDisinfect.c =================================================================== diff -u -r9490539a39d2bfd8d40558f3c05b09b48f041e6c -r321e3603df2611c653e4bd330f640ab35822fd6d --- firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 9490539a39d2bfd8d40558f3c05b09b48f041e6c) +++ firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 321e3603df2611c653e4bd330f640ab35822fd6d) @@ -609,9 +609,8 @@ if ( TRUE == didTimeout( stateTimer, FLUSH_DRAIN_WAIT_TIME_MS ) ) { // If the inlet temperature and conductivity are in range, move onto the next state - if (TRUE) - //if ( ( getTemperatureValue( TEMPSENSORS_INLET_PRIMARY_HEATER ) > MIN_INLET_TEMPERATURE_C ) && - // ( getConductivityValue( CONDUCTIVITYSENSORS_CPI_SENSOR ) <= MAX_INLET_CONDUCTIVITY_US_PER_CM ) ) + if ( ( getTemperatureValue( TEMPSENSORS_INLET_PRIMARY_HEATER ) > MIN_INLET_TEMPERATURE_C ) && + ( getConductivityValue( CONDUCTIVITYSENSORS_CPI_SENSOR ) <= MAX_INLET_CONDUCTIVITY_US_PER_CM ) ) { setValveState( VPD, VALVE_STATE_OPEN_C_TO_NC ); setROPumpTargetFlowRateLPM( RO_PUMP_TARGET_FLUSH_FILL_FLOW_RATE_LPM, MAX_RO_PUMP_FLUSH_FILL_PRESSURE_PSI ); @@ -628,10 +627,9 @@ // Couldn't get a good water sample after a couple of trials and the disinfect cycle failed else { - // DEBUG_DENALI - //alarmDetectedPendingTrigger = ALARM_ID_DG_HEAT_DISINFECT_INLET_COND_AND_TEMP_OUT; - //prevHeatDisinfectState = state; - //state = DG_HEAT_DISINFECT_STATE_CANCEL_BASIC_PATH; + alarmDetectedPendingTrigger = ALARM_ID_DG_HEAT_DISINFECT_INLET_COND_AND_TEMP_OUT; + prevHeatDisinfectState = state; + state = DG_HEAT_DISINFECT_STATE_CANCEL_BASIC_PATH; } } Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r4d1a8ff389678d2f9a0bde6effba32d8c4ac5fb1 -r321e3603df2611c653e4bd330f640ab35822fd6d --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 4d1a8ff389678d2f9a0bde6effba32d8c4ac5fb1) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 321e3603df2611c653e4bd330f640ab35822fd6d) @@ -157,12 +157,6 @@ data.tempLastFill = getLastFillTemperature(); data.timereservoirFill = heatersTempCalc.timeReservoirFillMS; - // TODO remove - data.previousDrainFlow = reservoirPreviousStatus[ DG_RESERVOIR_1 ].previousDrainFlowML; - data.previousLoadCell = reservoirPreviousStatus[ DG_RESERVOIR_1 ].previousReservoirWeightG; - data.drainTime = reservoirWeightUnchangeStartTime[ DG_RESERVOIR_1 ]; - // TODO remove - broadcastData( MSG_ID_DG_RESERVOIRS_DATA, COMM_BUFFER_OUT_CAN_DG_BROADCAST, (U08*)&data, sizeof( RESERVOIR_DATA_T ) ); dataPublishCounter = 0; } @@ -686,12 +680,22 @@ F32 loadcellWeightML = getLoadCellSmallFilteredWeight( associatedLoadCell[ reservoirId ] ); U32 drainPumpFeedbackRPM = getDrainPumpMeasuredRPM(); + // Check if the drain pump is running, the drain pump usually starts with delay so it might take several + // milliseconds to see the RPM feedback is greater than 0. If the feedback is not greater than 0, checking + // for drain is not needed if ( drainPumpFeedbackRPM > 0 ) { + // Calculate the drain threshold that is needed for the target RPM. For instance, RPM = 500 / 2400 as reference = 0.20833 + // so the difference in between the current and previous load cell values must be less than this value to be considered + // as reaching towards the bottom of the reservoir. Otherwise, the drain pump must be easily able to drain more fluid + // than the threshold every 50 ms. F32 drainThresholdML = ( (F32)getDrainPumpTargetRPM() ) / MAX_DRAIN_RPM_MLP; + // Calculate the flow reservoirPreviousStatus[ reservoirId ].previousDrainFlowML = reservoirPreviousStatus[ reservoirId ].previousReservoirWeightG - loadcellWeightML; + // If the previous load cell is greater than the current load cell, it means the reservoir is draining and + // update the previous load cell value if ( reservoirPreviousStatus[ reservoirId ].previousReservoirWeightG > loadcellWeightML ) { reservoirPreviousStatus[ reservoirId ].previousReservoirWeightG = loadcellWeightML; Index: firmware/App/Services/Reservoirs.h =================================================================== diff -u -r5f538f79c346c041661d039e92b4fa1f77c3e1ac -r321e3603df2611c653e4bd330f640ab35822fd6d --- firmware/App/Services/Reservoirs.h (.../Reservoirs.h) (revision 5f538f79c346c041661d039e92b4fa1f77c3e1ac) +++ firmware/App/Services/Reservoirs.h (.../Reservoirs.h) (revision 321e3603df2611c653e4bd330f640ab35822fd6d) @@ -85,12 +85,6 @@ F32 tempAvgFill; ///< Average fill temperature F32 tempLastFill; ///< Last fill temperature F32 timereservoirFill; ///< Reservoir fill time in milliseconds - - // TODO for testing only - F32 previousDrainFlow; - F32 previousLoadCell; - U32 drainTime; - // TODO for testing only } RESERVOIR_DATA_T; // ********** public function prototypes **********