|
@@ -231,7 +231,7 @@ void PID_autotune(float temp, int extruder, int ncycles, bool set_result/*=false
|
231
|
231
|
|
232
|
232
|
long bias, d;
|
233
|
233
|
float Ku, Tu;
|
234
|
|
- float Kp = 0, Ki = 0, Kd = 0;
|
|
234
|
+ float workKp = 0, workKi = 0, workKd = 0;
|
235
|
235
|
float max = 0, min = 10000;
|
236
|
236
|
|
237
|
237
|
#if HAS_AUTO_FAN
|
|
@@ -309,28 +309,28 @@ void PID_autotune(float temp, int extruder, int ncycles, bool set_result/*=false
|
309
|
309
|
Tu = ((float)(t_low + t_high) / 1000.0);
|
310
|
310
|
SERIAL_PROTOCOLPGM(MSG_KU); SERIAL_PROTOCOL(Ku);
|
311
|
311
|
SERIAL_PROTOCOLPGM(MSG_TU); SERIAL_PROTOCOLLN(Tu);
|
312
|
|
- Kp = 0.6 * Ku;
|
313
|
|
- Ki = 2 * Kp / Tu;
|
314
|
|
- Kd = Kp * Tu / 8;
|
|
312
|
+ workKp = 0.6 * Ku;
|
|
313
|
+ workKi = 2 * workKp / Tu;
|
|
314
|
+ workKd = workKp * Tu / 8;
|
315
|
315
|
SERIAL_PROTOCOLLNPGM(MSG_CLASSIC_PID);
|
316
|
|
- SERIAL_PROTOCOLPGM(MSG_KP); SERIAL_PROTOCOLLN(Kp);
|
317
|
|
- SERIAL_PROTOCOLPGM(MSG_KI); SERIAL_PROTOCOLLN(Ki);
|
318
|
|
- SERIAL_PROTOCOLPGM(MSG_KD); SERIAL_PROTOCOLLN(Kd);
|
|
316
|
+ SERIAL_PROTOCOLPGM(MSG_KP); SERIAL_PROTOCOLLN(workKp);
|
|
317
|
+ SERIAL_PROTOCOLPGM(MSG_KI); SERIAL_PROTOCOLLN(workKi);
|
|
318
|
+ SERIAL_PROTOCOLPGM(MSG_KD); SERIAL_PROTOCOLLN(workKd);
|
319
|
319
|
/**
|
320
|
|
- Kp = 0.33*Ku;
|
321
|
|
- Ki = Kp/Tu;
|
322
|
|
- Kd = Kp*Tu/3;
|
|
320
|
+ workKp = 0.33*Ku;
|
|
321
|
+ workKi = workKp/Tu;
|
|
322
|
+ workKd = workKp*Tu/3;
|
323
|
323
|
SERIAL_PROTOCOLLNPGM(" Some overshoot ");
|
324
|
|
- SERIAL_PROTOCOLPGM(" Kp: "); SERIAL_PROTOCOLLN(Kp);
|
325
|
|
- SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLLN(Ki);
|
326
|
|
- SERIAL_PROTOCOLPGM(" Kd: "); SERIAL_PROTOCOLLN(Kd);
|
327
|
|
- Kp = 0.2*Ku;
|
328
|
|
- Ki = 2*Kp/Tu;
|
329
|
|
- Kd = Kp*Tu/3;
|
|
324
|
+ SERIAL_PROTOCOLPGM(" Kp: "); SERIAL_PROTOCOLLN(workKp);
|
|
325
|
+ SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLLN(workKi);
|
|
326
|
+ SERIAL_PROTOCOLPGM(" Kd: "); SERIAL_PROTOCOLLN(workKd);
|
|
327
|
+ workKp = 0.2*Ku;
|
|
328
|
+ workKi = 2*workKp/Tu;
|
|
329
|
+ workKd = workKp*Tu/3;
|
330
|
330
|
SERIAL_PROTOCOLLNPGM(" No overshoot ");
|
331
|
|
- SERIAL_PROTOCOLPGM(" Kp: "); SERIAL_PROTOCOLLN(Kp);
|
332
|
|
- SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLLN(Ki);
|
333
|
|
- SERIAL_PROTOCOLPGM(" Kd: "); SERIAL_PROTOCOLLN(Kd);
|
|
331
|
+ SERIAL_PROTOCOLPGM(" Kp: "); SERIAL_PROTOCOLLN(workKp);
|
|
332
|
+ SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLLN(workKi);
|
|
333
|
+ SERIAL_PROTOCOLPGM(" Kd: "); SERIAL_PROTOCOLLN(workKd);
|
334
|
334
|
*/
|
335
|
335
|
}
|
336
|
336
|
}
|
|
@@ -365,24 +365,24 @@ void PID_autotune(float temp, int extruder, int ncycles, bool set_result/*=false
|
365
|
365
|
if (cycles > ncycles) {
|
366
|
366
|
SERIAL_PROTOCOLLNPGM(MSG_PID_AUTOTUNE_FINISHED);
|
367
|
367
|
const char* estring = extruder < 0 ? "bed" : "";
|
368
|
|
- SERIAL_PROTOCOLPGM("#define DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Kp "); SERIAL_PROTOCOLLN(Kp);
|
369
|
|
- SERIAL_PROTOCOLPGM("#define DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Ki "); SERIAL_PROTOCOLLN(Ki);
|
370
|
|
- SERIAL_PROTOCOLPGM("#define DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Kd "); SERIAL_PROTOCOLLN(Kd);
|
|
368
|
+ SERIAL_PROTOCOLPGM("#define DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Kp "); SERIAL_PROTOCOLLN(workKp);
|
|
369
|
+ SERIAL_PROTOCOLPGM("#define DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Ki "); SERIAL_PROTOCOLLN(workKi);
|
|
370
|
+ SERIAL_PROTOCOLPGM("#define DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Kd "); SERIAL_PROTOCOLLN(workKd);
|
371
|
371
|
|
372
|
372
|
// Use the result? (As with "M303 U1")
|
373
|
373
|
if (set_result) {
|
374
|
374
|
if (extruder < 0) {
|
375
|
375
|
#if ENABLED(PIDTEMPBED)
|
376
|
|
- bedKp = Kp;
|
377
|
|
- bedKi = scalePID_i(Ki);
|
378
|
|
- bedKd = scalePID_d(Kd);
|
|
376
|
+ bedKp = workKp;
|
|
377
|
+ bedKi = scalePID_i(workKi);
|
|
378
|
+ bedKd = scalePID_d(workKd);
|
379
|
379
|
updatePID();
|
380
|
380
|
#endif
|
381
|
381
|
}
|
382
|
382
|
else {
|
383
|
|
- PID_PARAM(Kp, extruder) = Kp;
|
384
|
|
- PID_PARAM(Ki, e) = scalePID_i(Ki);
|
385
|
|
- PID_PARAM(Kd, e) = scalePID_d(Kd);
|
|
383
|
+ PID_PARAM(Kp, extruder) = workKp;
|
|
384
|
+ PID_PARAM(Ki, extruder) = scalePID_i(workKi);
|
|
385
|
+ PID_PARAM(Kd, extruder) = scalePID_d(workKd);
|
386
|
386
|
updatePID();
|
387
|
387
|
}
|
388
|
388
|
}
|
|
@@ -395,7 +395,7 @@ void PID_autotune(float temp, int extruder, int ncycles, bool set_result/*=false
|
395
|
395
|
void updatePID() {
|
396
|
396
|
#if ENABLED(PIDTEMP)
|
397
|
397
|
for (int e = 0; e < EXTRUDERS; e++) {
|
398
|
|
- temp_iState_max[e] = (PID_INTEGRAL_DRIVE_MAX) / PID_PARAM(Ki,e);
|
|
398
|
+ temp_iState_max[e] = (PID_INTEGRAL_DRIVE_MAX) / PID_PARAM(Ki, e);
|
399
|
399
|
#if ENABLED(PID_ADD_EXTRUSION_RATE)
|
400
|
400
|
last_position[e] = 0;
|
401
|
401
|
#endif
|