Browse Source

Merge pull request #1796 from thinkyhead/pidbed_temp_eeprom

Add PIDTEMPBED to EEPROM
Scott Lahteine 9 years ago
parent
commit
c747becec1
2 changed files with 76 additions and 32 deletions
  1. 75
    31
      Marlin/ConfigurationStore.cpp
  2. 1
    1
      Marlin/temperature.h

+ 75
- 31
Marlin/ConfigurationStore.cpp View File

3
  *
3
  *
4
  * Configuration and EEPROM storage
4
  * Configuration and EEPROM storage
5
  *
5
  *
6
- * V16 EEPROM Layout:
6
+ * IMPORTANT:  Whenever there are changes made to the variables stored in EEPROM
7
+ * in the functions below, also increment the version number. This makes sure that
8
+ * the default values are used whenever there is a change to the data, to prevent
9
+ * wrong data being written to the variables.
10
+ *
11
+ * ALSO: Variables in the Store and Retrieve sections must be in the same order.
12
+ *       If a feature is disabled, some data must still be written that, when read,
13
+ *       either sets a Sane Default, or results in No Change to the existing value.
14
+ *
15
+ */
16
+
17
+#define EEPROM_VERSION "V19"
18
+
19
+/**
20
+ * V19 EEPROM Layout:
7
  *
21
  *
8
  *  ver
22
  *  ver
9
  *  axis_steps_per_unit (x4)
23
  *  axis_steps_per_unit (x4)
47
  *  Kp[2], Ki[2], Kd[2], Kc[2]
61
  *  Kp[2], Ki[2], Kd[2], Kc[2]
48
  *  Kp[3], Ki[3], Kd[3], Kc[3]
62
  *  Kp[3], Ki[3], Kd[3], Kc[3]
49
  *
63
  *
64
+ * PIDTEMPBED:
65
+ *  bedKp, bedKi, bedKd
66
+ *
50
  * DOGLCD:
67
  * DOGLCD:
51
  *  lcd_contrast
68
  *  lcd_contrast
52
  *
69
  *
111
 
128
 
112
 #define EEPROM_OFFSET 100
129
 #define EEPROM_OFFSET 100
113
 
130
 
114
-
115
-// IMPORTANT:  Whenever there are changes made to the variables stored in EEPROM
116
-// in the functions below, also increment the version number. This makes sure that
117
-// the default values are used whenever there is a change to the data, to prevent
118
-// wrong data being written to the variables.
119
-// ALSO:  always make sure the variables in the Store and retrieve sections are in the same order.
120
-
121
-#define EEPROM_VERSION "V18"
122
-
123
 #ifdef EEPROM_SETTINGS
131
 #ifdef EEPROM_SETTINGS
124
 
132
 
125
 void Config_StoreSettings()  {
133
 void Config_StoreSettings()  {
194
   EEPROM_WRITE_VAR(i, absPreheatHPBTemp);
202
   EEPROM_WRITE_VAR(i, absPreheatHPBTemp);
195
   EEPROM_WRITE_VAR(i, absPreheatFanSpeed);
203
   EEPROM_WRITE_VAR(i, absPreheatFanSpeed);
196
 
204
 
197
-
198
   for (int e = 0; e < 4; e++) {
205
   for (int e = 0; e < 4; e++) {
199
 
206
 
200
     #ifdef PIDTEMP
207
     #ifdef PIDTEMP
209
           EEPROM_WRITE_VAR(i, dummy);
216
           EEPROM_WRITE_VAR(i, dummy);
210
         #endif
217
         #endif
211
       }
218
       }
212
-      else {
213
-    #else // !PIDTEMP
214
-      {
219
+      else
215
     #endif // !PIDTEMP
220
     #endif // !PIDTEMP
216
-
217
-        dummy = DUMMY_PID_VALUE;
221
+      {
222
+        dummy = DUMMY_PID_VALUE; // When read, will not change the existing value
218
         EEPROM_WRITE_VAR(i, dummy);
223
         EEPROM_WRITE_VAR(i, dummy);
219
         dummy = 0.0f;
224
         dummy = 0.0f;
220
         for (int q = 3; q--;) EEPROM_WRITE_VAR(i, dummy);
225
         for (int q = 3; q--;) EEPROM_WRITE_VAR(i, dummy);
222
 
227
 
223
   } // Extruders Loop
228
   } // Extruders Loop
224
 
229
 
230
+  #ifndef PIDTEMPBED
231
+    float bedKp = DUMMY_PID_VALUE, bedKi = DUMMY_PID_VALUE, bedKd = DUMMY_PID_VALUE;
232
+  #endif
233
+
234
+  EEPROM_WRITE_VAR(i, bedKp);
235
+  EEPROM_WRITE_VAR(i, bedKi);
236
+  EEPROM_WRITE_VAR(i, bedKd);
237
+
225
   #ifndef DOGLCD
238
   #ifndef DOGLCD
226
     int lcd_contrast = 32;
239
     int lcd_contrast = 32;
227
   #endif
240
   #endif
364
 
377
 
365
     #ifdef PIDTEMP
378
     #ifdef PIDTEMP
366
       for (int e = 0; e < 4; e++) { // 4 = max extruders currently supported by Marlin
379
       for (int e = 0; e < 4; e++) { // 4 = max extruders currently supported by Marlin
367
-        EEPROM_READ_VAR(i, dummy);
380
+        EEPROM_READ_VAR(i, dummy); // Kp
368
         if (e < EXTRUDERS && dummy != DUMMY_PID_VALUE) {
381
         if (e < EXTRUDERS && dummy != DUMMY_PID_VALUE) {
369
           // do not need to scale PID values as the values in EEPROM are already scaled
382
           // do not need to scale PID values as the values in EEPROM are already scaled
370
           PID_PARAM(Kp, e) = dummy;
383
           PID_PARAM(Kp, e) = dummy;
385
       for (int q=16; q--;) EEPROM_READ_VAR(i, dummy);  // 4x Kp, Ki, Kd, Kc
398
       for (int q=16; q--;) EEPROM_READ_VAR(i, dummy);  // 4x Kp, Ki, Kd, Kc
386
     #endif // !PIDTEMP
399
     #endif // !PIDTEMP
387
 
400
 
401
+    #ifndef PIDTEMPBED
402
+      float bedKp, bedKi, bedKd;
403
+    #endif
404
+
405
+    EEPROM_READ_VAR(i, dummy); // bedKp
406
+    if (dummy != DUMMY_PID_VALUE) {
407
+      bedKp = dummy;
408
+      EEPROM_READ_VAR(i, bedKi);
409
+      EEPROM_READ_VAR(i, bedKd);
410
+    }
411
+    else {
412
+      for (int q=2; q--;) EEPROM_READ_VAR(i, dummy); // bedKi, bedKd
413
+    }
414
+
388
     #ifndef DOGLCD
415
     #ifndef DOGLCD
389
       int lcd_contrast;
416
       int lcd_contrast;
390
     #endif
417
     #endif
517
     updatePID();
544
     updatePID();
518
   #endif // PIDTEMP
545
   #endif // PIDTEMP
519
 
546
 
547
+  #ifdef PIDTEMPBED
548
+    bedKp = DEFAULT_bedKp;
549
+    bedKi = scalePID_i(DEFAULT_bedKi);
550
+    bedKd = scalePID_d(DEFAULT_bedKd);
551
+  #endif
552
+
520
   #ifdef FWRETRACT
553
   #ifdef FWRETRACT
521
     autoretract_enabled = false;
554
     autoretract_enabled = false;
522
     retract_length = RETRACT_LENGTH;
555
     retract_length = RETRACT_LENGTH;
660
     SERIAL_EOL;  
693
     SERIAL_EOL;  
661
   #endif // DELTA
694
   #endif // DELTA
662
 
695
 
663
-  #ifdef PIDTEMP
696
+  #if defined(PIDTEMP) || defined(PIDTEMPBED)
664
     SERIAL_ECHO_START;
697
     SERIAL_ECHO_START;
665
     if (!forReplay) {
698
     if (!forReplay) {
666
       SERIAL_ECHOLNPGM("PID settings:");
699
       SERIAL_ECHOLNPGM("PID settings:");
667
       SERIAL_ECHO_START;
700
       SERIAL_ECHO_START;
668
     }
701
     }
669
-    SERIAL_ECHOPAIR("   M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echos values for E0
670
-    SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
671
-    SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
672
-    SERIAL_EOL;
673
-  #endif // PIDTEMP
702
+    #if defined(PIDTEMP) && defined(PIDTEMPBED)
703
+      SERIAL_EOL;
704
+    #endif
705
+    #ifdef PIDTEMP
706
+      SERIAL_ECHOPAIR("  M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echos values for E0
707
+      SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
708
+      SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
709
+      SERIAL_EOL;
710
+    #endif
711
+    #ifdef PIDTEMPBED
712
+      SERIAL_ECHOPAIR("  M304 P", bedKp); // for compatibility with hosts, only echos values for E0
713
+      SERIAL_ECHOPAIR(" I", unscalePID_i(bedKi));
714
+      SERIAL_ECHOPAIR(" D", unscalePID_d(bedKd));
715
+      SERIAL_EOL;
716
+    #endif
717
+  #endif
674
 
718
 
675
   #ifdef FWRETRACT
719
   #ifdef FWRETRACT
676
 
720
 
679
       SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
723
       SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
680
       SERIAL_ECHO_START;
724
       SERIAL_ECHO_START;
681
     }
725
     }
682
-    SERIAL_ECHOPAIR("   M207 S", retract_length);
726
+    SERIAL_ECHOPAIR("  M207 S", retract_length);
683
     SERIAL_ECHOPAIR(" F", retract_feedrate*60);
727
     SERIAL_ECHOPAIR(" F", retract_feedrate*60);
684
     SERIAL_ECHOPAIR(" Z", retract_zlift);
728
     SERIAL_ECHOPAIR(" Z", retract_zlift);
685
     SERIAL_EOL;
729
     SERIAL_EOL;
688
       SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)");
732
       SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)");
689
       SERIAL_ECHO_START;
733
       SERIAL_ECHO_START;
690
     }
734
     }
691
-    SERIAL_ECHOPAIR("   M208 S", retract_recover_length);
735
+    SERIAL_ECHOPAIR("  M208 S", retract_recover_length);
692
     SERIAL_ECHOPAIR(" F", retract_recover_feedrate*60);
736
     SERIAL_ECHOPAIR(" F", retract_recover_feedrate*60);
693
     SERIAL_EOL;
737
     SERIAL_EOL;
694
     SERIAL_ECHO_START;
738
     SERIAL_ECHO_START;
696
       SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries");
740
       SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries");
697
       SERIAL_ECHO_START;
741
       SERIAL_ECHO_START;
698
     }
742
     }
699
-    SERIAL_ECHOPAIR("   M209 S", (unsigned long)(autoretract_enabled ? 1 : 0));
743
+    SERIAL_ECHOPAIR("  M209 S", (unsigned long)(autoretract_enabled ? 1 : 0));
700
     SERIAL_EOL;
744
     SERIAL_EOL;
701
 
745
 
702
     #if EXTRUDERS > 1
746
     #if EXTRUDERS > 1
720
       SERIAL_ECHOLNPGM("Filament settings:");
764
       SERIAL_ECHOLNPGM("Filament settings:");
721
       SERIAL_ECHO_START;
765
       SERIAL_ECHO_START;
722
     }
766
     }
723
-    SERIAL_ECHOPAIR("   M200 D", filament_size[0]);
767
+    SERIAL_ECHOPAIR("  M200 D", filament_size[0]);
724
     SERIAL_EOL;
768
     SERIAL_EOL;
725
 
769
 
726
     #if EXTRUDERS > 1
770
     #if EXTRUDERS > 1
727
       SERIAL_ECHO_START;
771
       SERIAL_ECHO_START;
728
-      SERIAL_ECHOPAIR("   M200 T1 D", filament_size[1]);
772
+      SERIAL_ECHOPAIR("  M200 T1 D", filament_size[1]);
729
       SERIAL_EOL;
773
       SERIAL_EOL;
730
       #if EXTRUDERS > 2
774
       #if EXTRUDERS > 2
731
         SERIAL_ECHO_START;
775
         SERIAL_ECHO_START;
732
-        SERIAL_ECHOPAIR("   M200 T2 D", filament_size[2]);
776
+        SERIAL_ECHOPAIR("  M200 T2 D", filament_size[2]);
733
         SERIAL_EOL;
777
         SERIAL_EOL;
734
         #if EXTRUDERS > 3
778
         #if EXTRUDERS > 3
735
           SERIAL_ECHO_START;
779
           SERIAL_ECHO_START;
736
-          SERIAL_ECHOPAIR("   M200 T3 D", filament_size[3]);
780
+          SERIAL_ECHOPAIR("  M200 T3 D", filament_size[3]);
737
           SERIAL_EOL;
781
           SERIAL_EOL;
738
         #endif
782
         #endif
739
       #endif
783
       #endif
752
         SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
796
         SERIAL_ECHOLNPGM("Z-Probe Offset (mm):");
753
         SERIAL_ECHO_START;
797
         SERIAL_ECHO_START;
754
       }
798
       }
755
-      SERIAL_ECHOPAIR("   M", (unsigned long)CUSTOM_M_CODE_SET_Z_PROBE_OFFSET);
799
+      SERIAL_ECHOPAIR("  M", (unsigned long)CUSTOM_M_CODE_SET_Z_PROBE_OFFSET);
756
       SERIAL_ECHOPAIR(" Z", -zprobe_zoffset);
800
       SERIAL_ECHOPAIR(" Z", -zprobe_zoffset);
757
     #else
801
     #else
758
       if (!forReplay) {
802
       if (!forReplay) {

+ 1
- 1
Marlin/temperature.h View File

72
   float unscalePID_d(float d);
72
   float unscalePID_d(float d);
73
 
73
 
74
 #endif
74
 #endif
75
+
75
 #ifdef PIDTEMPBED
76
 #ifdef PIDTEMPBED
76
   extern float bedKp,bedKi,bedKd;
77
   extern float bedKp,bedKi,bedKd;
77
 #endif
78
 #endif
78
   
79
   
79
-  
80
 #ifdef BABYSTEPPING
80
 #ifdef BABYSTEPPING
81
   extern volatile int babystepsTodo[3];
81
   extern volatile int babystepsTodo[3];
82
 #endif
82
 #endif

Loading…
Cancel
Save