Browse Source

in fullauto mode run pumps as a last step to really empty the lines as far as possible.

Thomas Buck 1 year ago
parent
commit
a0f699d41d
3 changed files with 53 additions and 18 deletions
  1. 14
    13
      include/Statemachine.h
  2. 1
    0
      include/config.h
  3. 38
    5
      src/Statemachine.cpp

+ 14
- 13
include/Statemachine.h View File

52
         fillnwater_kickstart_run,
52
         fillnwater_kickstart_run,
53
         fillnwater_plant_run,
53
         fillnwater_plant_run,
54
 
54
 
55
-        fullauto_fert, // d i a
56
-        fullauto_plant, // d i a
57
-        fullauto_stirr_run, // d i a
58
-        fullauto_fert_run, // d i a
59
-        fullauto_tank_run, // d i a
60
-        fullauto_kickstart_run, // d i a
61
-        fullauto_plant_run, // d i a
62
-        fullauto_plant_overrun, // d i a
63
-        fullauto_tank_purge_run, // d i a
64
-        fullauto_kickstart_purge_run, // d i a
65
-        fullauto_plant_purge_run, // d i a
66
-        fullauto_plant_purge_overrun, // d i a
67
-        fullauto_done, // d i a
55
+        fullauto_fert,
56
+        fullauto_plant,
57
+        fullauto_stirr_run,
58
+        fullauto_fert_run,
59
+        fullauto_tank_run,
60
+        fullauto_kickstart_run,
61
+        fullauto_plant_run,
62
+        fullauto_plant_overrun,
63
+        fullauto_tank_purge_run,
64
+        fullauto_kickstart_purge_run,
65
+        fullauto_plant_purge_run,
66
+        fullauto_plant_purge_overrun,
67
+        fullauto_plant_purge_over_pump_run,
68
+        fullauto_done,
68
 
69
 
69
         automation_mode,
70
         automation_mode,
70
         
71
         

+ 1
- 0
include/config.h View File

40
 #define OVERRUN_RUNTIME 75
40
 #define OVERRUN_RUNTIME 75
41
 #define PURGE_FILL_RUNTIME 20
41
 #define PURGE_FILL_RUNTIME 20
42
 #define FULLAUTO_MIN_PLANT_COUNT 2
42
 #define FULLAUTO_MIN_PLANT_COUNT 2
43
+#define FULLAUTO_END_PUMP_TIME 30
43
 
44
 
44
 // Sketch version
45
 // Sketch version
45
 #define FIRMWARE_VERSION "0.6"
46
 #define FIRMWARE_VERSION "0.6"

+ 38
- 5
src/Statemachine.cpp View File

112
     stringify(fullauto_kickstart_purge_run),
112
     stringify(fullauto_kickstart_purge_run),
113
     stringify(fullauto_plant_purge_run),
113
     stringify(fullauto_plant_purge_run),
114
     stringify(fullauto_plant_purge_overrun),
114
     stringify(fullauto_plant_purge_overrun),
115
+    stringify(fullauto_plant_purge_over_pump_run),
115
     stringify(fullauto_done),
116
     stringify(fullauto_done),
116
 
117
 
117
     stringify(automation_mode),
118
     stringify(automation_mode),
535
             || (state == fullauto_plant_run)
536
             || (state == fullauto_plant_run)
536
             || (state == fullauto_plant_overrun)
537
             || (state == fullauto_plant_overrun)
537
             || (state == fullauto_plant_purge_run)
538
             || (state == fullauto_plant_purge_run)
538
-            || (state == fullauto_plant_purge_overrun)) {
539
+            || (state == fullauto_plant_purge_overrun)
540
+            || (state == fullauto_plant_purge_over_pump_run)) {
539
         plants.abort();
541
         plants.abort();
540
         stop_time = millis();
542
         stop_time = millis();
541
         switch_to(auto_done);
543
         switch_to(auto_done);
1535
     if ((state == auto_plant_run) || (state == fillnwater_plant_run)
1537
     if ((state == auto_plant_run) || (state == fillnwater_plant_run)
1536
             || (state == fullauto_plant_run) || (state == fullauto_plant_overrun)
1538
             || (state == fullauto_plant_run) || (state == fullauto_plant_overrun)
1537
             || (state == fullauto_plant_purge_run)
1539
             || (state == fullauto_plant_purge_run)
1538
-            || (state == fullauto_plant_purge_overrun)) {
1540
+            || (state == fullauto_plant_purge_overrun)
1541
+            || (state == fullauto_plant_purge_over_pump_run)) {
1539
         unsigned long runtime = millis() - start_time;
1542
         unsigned long runtime = millis() - start_time;
1540
         if ((runtime / 1000UL) >= selected_time) {
1543
         if ((runtime / 1000UL) >= selected_time) {
1541
             if (state == fullauto_plant_run) {
1544
             if (state == fullauto_plant_run) {
1596
             } else if (state == fullauto_plant_purge_overrun) {
1599
             } else if (state == fullauto_plant_purge_overrun) {
1597
                 plants.abort();
1600
                 plants.abort();
1598
                 stop_time = millis();
1601
                 stop_time = millis();
1602
+
1603
+                bool need_kickstart = false;
1604
+                for (int i = 0; i < plants.countPlants(); i++) {
1605
+                    if (selected_plants.isSet(i)) {
1606
+                        if (plants.getKickstart()->getPinNumber(i) >= 0) {
1607
+                            need_kickstart = true;
1608
+                        }
1609
+                    }
1610
+                }
1611
+
1612
+                start_time = millis();
1613
+                selected_time = FULLAUTO_END_PUMP_TIME;
1614
+
1615
+                if (need_kickstart) {
1616
+                    for (int i = 0; i < plants.countPlants(); i++) {
1617
+                        if (selected_plants.isSet(i)) {
1618
+                            plants.startPlant(i, true);
1619
+                        }
1620
+                    }
1621
+
1622
+                    switch_to(fullauto_plant_purge_over_pump_run);
1623
+                } else {
1624
+                    switch_to(fullauto_done);
1625
+                }
1626
+            } else if (state == fullauto_plant_purge_over_pump_run) {
1627
+                plants.abort();
1628
+                stop_time = millis();
1599
                 switch_to(fullauto_done);
1629
                 switch_to(fullauto_done);
1600
             } else {
1630
             } else {
1601
                 plants.abort();
1631
                 plants.abort();
1608
             switch_to(state);
1638
             switch_to(state);
1609
         }
1639
         }
1610
 
1640
 
1611
-        if ((state == fullauto_plant_overrun) || (state == fullauto_plant_purge_overrun)) {
1641
+        if ((state == fullauto_plant_overrun)
1642
+                || (state == fullauto_plant_purge_overrun)
1643
+                || (state == fullauto_plant_purge_over_pump_run)) {
1612
             // overrun should not exit when sensor returns empty
1644
             // overrun should not exit when sensor returns empty
1613
             return;
1645
             return;
1614
         }
1646
         }
1652
                 start_time = millis();
1684
                 start_time = millis();
1653
                 selected_time = OVERRUN_RUNTIME;
1685
                 selected_time = OVERRUN_RUNTIME;
1654
                 switch_to(fullauto_plant_purge_overrun);
1686
                 switch_to(fullauto_plant_purge_overrun);
1655
-
1656
             }
1687
             }
1657
         } else if (wl == Plants::invalid) {
1688
         } else if (wl == Plants::invalid) {
1658
             plants.abort();
1689
             plants.abort();
1878
               b.c_str(),
1909
               b.c_str(),
1879
               "Hit any key to stop!",
1910
               "Hit any key to stop!",
1880
               -1);
1911
               -1);
1881
-    } else if ((s == fullauto_plant_overrun) || (s == fullauto_plant_purge_overrun)) {
1912
+    } else if ((s == fullauto_plant_overrun)
1913
+            || (s == fullauto_plant_purge_overrun)
1914
+            || (s == fullauto_plant_purge_over_pump_run)) {
1882
         unsigned long runtime = millis() - start_time;
1915
         unsigned long runtime = millis() - start_time;
1883
         String a = String(F("Time: ")) + String(runtime / 1000UL) + String(F("s / ")) + String(selected_time) + String('s');
1916
         String a = String(F("Time: ")) + String(runtime / 1000UL) + String(F("s / ")) + String(selected_time) + String('s');
1884
 
1917
 

Loading…
Cancel
Save