Selaa lähdekoodia

Initial implementation of PID Autotune Menu Items

Adds the parameter U to M303. If U1 is included , it will use the
PID-values from the auto-tune.
WPBack 9 vuotta sitten
vanhempi
commit
3b3e8a02b5
5 muutettua tiedostoa jossa 42 lisäystä ja 11 poistoa
  1. 1
    1
      Marlin/Configuration.h
  2. 3
    1
      Marlin/Marlin_main.cpp
  3. 18
    1
      Marlin/temperature.cpp
  4. 1
    1
      Marlin/temperature.h
  5. 19
    7
      Marlin/ultralcd.cpp

+ 1
- 1
Marlin/Configuration.h Näytä tiedosto

@@ -718,7 +718,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
718 718
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
719 719
 //#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu
720 720
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
721
-//#define ULTIPANEL  //the UltiPanel as on Thingiverse
721
+#define ULTIPANEL  //the UltiPanel as on Thingiverse
722 722
 //#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
723 723
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
724 724
 //#define LCD_FEEDBACK_FREQUENCY_HZ 1000         // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click

+ 3
- 1
Marlin/Marlin_main.cpp Näytä tiedosto

@@ -5142,13 +5142,15 @@ inline void gcode_M226() {
5142 5142
 inline void gcode_M303() {
5143 5143
   int e = code_seen('E') ? code_value_short() : 0;
5144 5144
   int c = code_seen('C') ? code_value_short() : 5;
5145
+  bool u = code_seen('U') && code_value_short() == 1;
5146
+  
5145 5147
   float temp = code_seen('S') ? code_value() : (e < 0 ? 70.0 : 150.0);
5146 5148
 
5147 5149
   if (e >=0 && e < EXTRUDERS)
5148 5150
     target_extruder = e;
5149 5151
 
5150 5152
   KEEPALIVE_STATE(NOT_BUSY);
5151
-  PID_autotune(temp, e, c);
5153
+  PID_autotune(temp, e, c, u);
5152 5154
 }
5153 5155
 
5154 5156
 #if ENABLED(SCARA)

+ 18
- 1
Marlin/temperature.cpp Näytä tiedosto

@@ -199,7 +199,7 @@ static void updateTemperaturesFromRawValues();
199 199
 //================================ Functions ================================
200 200
 //===========================================================================
201 201
 
202
-void PID_autotune(float temp, int extruder, int ncycles) {
202
+void PID_autotune(float temp, int extruder, int ncycles, bool set_result) {
203 203
   float input = 0.0;
204 204
   int cycles = 0;
205 205
   bool heating = true;
@@ -346,6 +346,23 @@ void PID_autotune(float temp, int extruder, int ncycles) {
346 346
       SERIAL_PROTOCOLPGM("#define  DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Kp "); SERIAL_PROTOCOLLN(Kp);
347 347
       SERIAL_PROTOCOLPGM("#define  DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Ki "); SERIAL_PROTOCOLLN(Ki);
348 348
       SERIAL_PROTOCOLPGM("#define  DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Kd "); SERIAL_PROTOCOLLN(Kd);
349
+      //Uses the result if set_result is true
350
+      if (set_result) {
351
+        if (extruder < 0) {
352
+          #if ENABLED(PIDTEMPBED)
353
+            bedKp = Kp;
354
+            bedKi = scalePID_i(Ki);
355
+            bedKd = scalePID_d(Kd);
356
+            updatePID();
357
+          #endif
358
+        }
359
+        else {
360
+          PID_PARAM(Kp, extruder) = Kp;
361
+          PID_PARAM(Ki, e) = scalePID_i(Ki);
362
+          PID_PARAM(Kd, e) = scalePID_d(Kd);
363
+          updatePID();
364
+        }
365
+      }
349 366
       return;
350 367
     }
351 368
     lcd_update();

+ 1
- 1
Marlin/temperature.h Näytä tiedosto

@@ -141,7 +141,7 @@ int getHeaterPower(int heater);
141 141
 void disable_all_heaters();
142 142
 void updatePID();
143 143
 
144
-void PID_autotune(float temp, int extruder, int ncycles);
144
+void PID_autotune(float temp, int extruder, int ncycles, bool set_result);
145 145
 
146 146
 void setExtruderAutoFanState(int pin, bool state);
147 147
 void checkExtruderAutoFans();

+ 19
- 7
Marlin/ultralcd.cpp Näytä tiedosto

@@ -1176,11 +1176,11 @@ static void lcd_control_temperature_menu() {
1176 1176
   #endif
1177 1177
 
1178 1178
   //
1179
-  // PID-P, PID-I, PID-D, PID-C
1180
-  // PID-P E1, PID-I E1, PID-D E1, PID-C E1
1181
-  // PID-P E2, PID-I E2, PID-D E2, PID-C E2
1182
-  // PID-P E3, PID-I E3, PID-D E3, PID-C E3
1183
-  // PID-P E4, PID-I E4, PID-D E4, PID-C E4
1179
+  // PID-P, PID-I, PID-D, PID-C, PID Autotune
1180
+  // PID-P E1, PID-I E1, PID-D E1, PID-C E1, PID Autotune E1
1181
+  // PID-P E2, PID-I E2, PID-D E2, PID-C E2, PID Autotune E2
1182
+  // PID-P E3, PID-I E3, PID-D E3, PID-C E3, PID Autotune E3
1183
+  // PID-P E4, PID-I E4, PID-D E4, PID-C E4, PID Autotune E4
1184 1184
   //
1185 1185
   #if ENABLED(PIDTEMP)
1186 1186
 
@@ -1189,8 +1189,20 @@ static void lcd_control_temperature_menu() {
1189 1189
       raw_Kd = unscalePID_d(PID_PARAM(Kd, eindex)); \
1190 1190
       MENU_ITEM_EDIT(float52, MSG_PID_P ELABEL, &PID_PARAM(Kp, eindex), 1, 9990); \
1191 1191
       MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I ELABEL, &raw_Ki, 0.01, 9990, copy_and_scalePID_i_E ## eindex); \
1192
-      MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D ELABEL, &raw_Kd, 1, 9990, copy_and_scalePID_d_E ## eindex)
1193
-
1192
+      MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D ELABEL, &raw_Kd, 1, 9990, copy_and_scalePID_d_E ## eindex); \
1193
+      if (eindex == 0) { \
1194
+        MENU_ITEM(gcode, MSG_PID_AUTOTUNE ELABEL, PSTR("M303 U1")); \
1195
+      } \
1196
+      else if (eindex == 1) { \
1197
+        MENU_ITEM(gcode, MSG_PID_AUTOTUNE ELABEL, PSTR("M303 U1 E1")); \
1198
+      } \
1199
+      else if (eindex == 2) { \
1200
+        MENU_ITEM(gcode, MSG_PID_AUTOTUNE ELABEL, PSTR("M303 U1 E2")); \
1201
+      } \
1202
+      else { \
1203
+        MENU_ITEM(gcode, MSG_PID_AUTOTUNE ELABEL, PSTR("M303 U1 E3")); \
1204
+      }
1205
+      
1194 1206
     #if ENABLED(PID_ADD_EXTRUSION_RATE)
1195 1207
       #define PID_MENU_ITEMS(ELABEL, eindex) \
1196 1208
         _PID_MENU_ITEMS(ELABEL, eindex); \

Loading…
Peruuta
Tallenna