|
88 | 88 | #define GET_PRESSURE_READ_EVERY 50
|
89 | 89 | #define GET_SCALES_READ_EVERY 100
|
90 | 90 | #define REFRESH_SCREEN_EVERY 150 // Screen refresh interval (ms)
|
91 |
| -#define DESCALE_PHASE1_EVERY 500 // short pump pulses during descale |
92 |
| -#define DESCALE_PHASE2_EVERY 5000 // short pause for pulse effficience activation |
93 |
| -#define DESCALE_PHASE3_EVERY 120000 // long pause for scale softening |
| 91 | +#define DESCALE_PHASE1_EVERY 60000 // short pump pulses during descale |
| 92 | +#define DESCALE_PHASE2_EVERY 120000 // long pause for scale softening |
| 93 | +#define DESCALE_PHASE3_EVERY 4000 // short pause for pulse effficience activation |
94 | 94 | #define MAX_SETPOINT_VALUE 110 //Defines the max value of the setpoint
|
95 | 95 | #define EEPROM_RESET 1 //change this value if want to reset to defaults
|
96 | 96 | #define PUMP_RANGE 127
|
@@ -878,58 +878,83 @@ void setBoiler(int val) {
|
878 | 878 |
|
879 | 879 | void deScale() {
|
880 | 880 | static bool blink = true;
|
881 |
| - static long timer = millis(); |
882 |
| - static int currentCycleRead = myNex.readNumber("j0.val"); |
883 |
| - static int lastCycleRead = 10; |
| 881 | + static long timer = 0; |
| 882 | + static int currentCycleRead = 0; |
| 883 | + static int lastCycleRead = 0; |
884 | 884 | static bool descaleFinished = false;
|
885 | 885 | if (brewActive && !descaleFinished) {
|
886 | 886 | if (currentCycleRead < lastCycleRead) { // descale in cycles for 5 times then wait according to the below condition
|
887 | 887 | if (blink == true) { // Logic that switches between modes depending on the $blink value
|
888 |
| - pump.set(15); |
889 |
| - if (millis() - timer > DESCALE_PHASE1_EVERY) { //set dimmer power to max descale value for 10 sec |
890 |
| - if (currentCycleRead >=100) descaleFinished = true; |
| 888 | + pump.set(10); |
| 889 | + if (millis() - timer > DESCALE_PHASE1_EVERY) { // 60 sec |
891 | 890 | blink = false;
|
892 |
| - currentCycleRead = myNex.readNumber("j0.val"); |
| 891 | + currentCycleRead += 2; |
893 | 892 | timer = millis();
|
894 | 893 | }
|
895 | 894 | } else {
|
896 |
| - pump.set(30); |
897 |
| - if (millis() - timer > DESCALE_PHASE2_EVERY) { //set dimmer power to min descale value for 20 sec |
| 895 | + pump.set(0); |
| 896 | + if (millis() - timer > DESCALE_PHASE2_EVERY) { // nothing for 120 sec |
898 | 897 | blink = true;
|
899 |
| - currentCycleRead++; |
900 |
| - if (currentCycleRead<100) myNex.writeNum("j0.val", currentCycleRead); |
| 898 | + currentCycleRead += 4; |
901 | 899 | timer = millis();
|
902 | 900 | }
|
903 | 901 | }
|
904 | 902 | } else {
|
905 |
| - pump.set(0); |
906 |
| - if ((millis() - timer) > DESCALE_PHASE3_EVERY) { //nothing for 5 minutes |
907 |
| - if (currentCycleRead*3 < 100) myNex.writeNum("j0.val", currentCycleRead*3); |
908 |
| - else { |
909 |
| - myNex.writeNum("j0.val", 100); |
910 |
| - descaleFinished = true; |
911 |
| - } |
912 |
| - lastCycleRead = currentCycleRead*3; |
| 903 | + pump.set(30); |
| 904 | + if ((millis() - timer) > DESCALE_PHASE3_EVERY) { //set dimmer power to max descale value for 4 sec |
| 905 | + solenoidBeat(); |
| 906 | + blink = true; |
| 907 | + currentCycleRead += 4; // need an overflow on 3rd cycle (34 -> 68 -> 102) |
| 908 | + lastCycleRead += 33; |
913 | 909 | timer = millis();
|
914 | 910 | }
|
915 | 911 | }
|
916 |
| - } else if (brewActive && descaleFinished == true){ |
| 912 | + |
| 913 | + if (currentCycleRead >= 100) { |
| 914 | + descaleFinished = true; |
| 915 | + } |
| 916 | + |
| 917 | + if (millis() > pageRefreshTimer) { |
| 918 | + if (currentCycleRead < 100) { |
| 919 | + myNex.writeNum("j0.val", currentCycleRead); |
| 920 | + } else { |
| 921 | + myNex.writeNum("j0.val", 100); |
| 922 | + } |
| 923 | + } |
| 924 | + } else if (brewActive && descaleFinished) { |
917 | 925 | pump.set(0);
|
918 | 926 | if ((millis() - timer) > 1000) {
|
919 |
| - brewTimer(false); |
| 927 | + brewTimer(0); |
920 | 928 | myNex.writeStr("t14.txt", "FINISHED!");
|
921 |
| - timer=millis(); |
| 929 | + timer = millis(); |
922 | 930 | }
|
923 | 931 | } else {
|
| 932 | + pump.set(0); |
| 933 | + blink = true; |
924 | 934 | currentCycleRead = 0;
|
925 |
| - lastCycleRead = 10; |
| 935 | + lastCycleRead = 30; |
926 | 936 | descaleFinished = false;
|
927 | 937 | timer = millis();
|
928 | 938 | }
|
929 | 939 | //keeping it at temp
|
930 | 940 | justDoCoffee();
|
931 | 941 | }
|
932 | 942 |
|
| 943 | +void solenoidBeat() { |
| 944 | + pump.set(PUMP_RANGE); |
| 945 | + digitalWrite(valvePin, LOW); |
| 946 | + delay(200); |
| 947 | + digitalWrite(valvePin, HIGH); |
| 948 | + delay(200); |
| 949 | + digitalWrite(valvePin, LOW); |
| 950 | + delay(200); |
| 951 | + digitalWrite(valvePin, HIGH); |
| 952 | + delay(200); |
| 953 | + digitalWrite(valvePin, LOW); |
| 954 | + delay(200); |
| 955 | + digitalWrite(valvePin, HIGH); |
| 956 | + pump.set(0); |
| 957 | +} |
933 | 958 |
|
934 | 959 | //#############################################################################################
|
935 | 960 | //###############################____PRESSURE_CONTROL____######################################
|
|
0 commit comments