|
@@ -322,17 +322,17 @@ unsigned char Temperature::soft_pwm[HOTENDS];
|
322
|
322
|
SERIAL_PROTOCOLPAIR(MSG_T_MIN, min);
|
323
|
323
|
SERIAL_PROTOCOLPAIR(MSG_T_MAX, max);
|
324
|
324
|
if (cycles > 2) {
|
325
|
|
- Ku = (4.0 * d) / (3.14159265 * (max - min) * 0.5);
|
|
325
|
+ Ku = (4.0 * d) / (M_PI * (max - min) * 0.5);
|
326
|
326
|
Tu = ((float)(t_low + t_high) * 0.001);
|
327
|
327
|
SERIAL_PROTOCOLPAIR(MSG_KU, Ku);
|
328
|
328
|
SERIAL_PROTOCOLPAIR(MSG_TU, Tu);
|
329
|
329
|
workKp = 0.6 * Ku;
|
330
|
330
|
workKi = 2 * workKp / Tu;
|
331
|
331
|
workKd = workKp * Tu * 0.125;
|
332
|
|
- SERIAL_PROTOCOLLNPGM(MSG_CLASSIC_PID);
|
|
332
|
+ SERIAL_PROTOCOLLNPGM("\n" MSG_CLASSIC_PID);
|
333
|
333
|
SERIAL_PROTOCOLPAIR(MSG_KP, workKp);
|
334
|
334
|
SERIAL_PROTOCOLPAIR(MSG_KI, workKi);
|
335
|
|
- SERIAL_PROTOCOLPAIR(MSG_KD, workKd);
|
|
335
|
+ SERIAL_PROTOCOLLNPAIR(MSG_KD, workKd);
|
336
|
336
|
/**
|
337
|
337
|
workKp = 0.33*Ku;
|
338
|
338
|
workKi = workKp/Tu;
|
|
@@ -390,40 +390,38 @@ unsigned char Temperature::soft_pwm[HOTENDS];
|
390
|
390
|
|
391
|
391
|
#if HAS_PID_FOR_BOTH
|
392
|
392
|
const char* estring = hotend < 0 ? "bed" : "";
|
393
|
|
- SERIAL_PROTOCOLPAIR("#define DEFAULT_", estring); SERIAL_PROTOCOLPAIR("Kp ", workKp);
|
394
|
|
- SERIAL_PROTOCOLPAIR("#define DEFAULT_", estring); SERIAL_PROTOCOLPAIR("Ki ", workKi);
|
395
|
|
- SERIAL_PROTOCOLPAIR("#define DEFAULT_", estring); SERIAL_PROTOCOLPAIR("Kd ", workKd);
|
|
393
|
+ SERIAL_PROTOCOLPAIR("#define DEFAULT_", estring); SERIAL_PROTOCOLPAIR("Kp ", workKp); SERIAL_EOL;
|
|
394
|
+ SERIAL_PROTOCOLPAIR("#define DEFAULT_", estring); SERIAL_PROTOCOLPAIR("Ki ", workKi); SERIAL_EOL;
|
|
395
|
+ SERIAL_PROTOCOLPAIR("#define DEFAULT_", estring); SERIAL_PROTOCOLPAIR("Kd ", workKd); SERIAL_EOL;
|
396
|
396
|
#elif ENABLED(PIDTEMP)
|
397
|
|
- SERIAL_PROTOCOLPAIR("#define DEFAULT_Kp ", workKp);
|
398
|
|
- SERIAL_PROTOCOLPAIR("#define DEFAULT_Ki ", workKi);
|
399
|
|
- SERIAL_PROTOCOLPAIR("#define DEFAULT_Kd ", workKd);
|
|
397
|
+ SERIAL_PROTOCOLPAIR("#define DEFAULT_Kp ", workKp); SERIAL_EOL;
|
|
398
|
+ SERIAL_PROTOCOLPAIR("#define DEFAULT_Ki ", workKi); SERIAL_EOL;
|
|
399
|
+ SERIAL_PROTOCOLPAIR("#define DEFAULT_Kd ", workKd); SERIAL_EOL;
|
400
|
400
|
#else
|
401
|
|
- SERIAL_PROTOCOLPAIR("#define DEFAULT_bedKp ", workKp);
|
402
|
|
- SERIAL_PROTOCOLPAIR("#define DEFAULT_bedKi ", workKi);
|
403
|
|
- SERIAL_PROTOCOLPAIR("#define DEFAULT_bedKd ", workKd);
|
|
401
|
+ SERIAL_PROTOCOLPAIR("#define DEFAULT_bedKp ", workKp); SERIAL_EOL;
|
|
402
|
+ SERIAL_PROTOCOLPAIR("#define DEFAULT_bedKi ", workKi); SERIAL_EOL;
|
|
403
|
+ SERIAL_PROTOCOLPAIR("#define DEFAULT_bedKd ", workKd); SERIAL_EOL;
|
404
|
404
|
#endif
|
405
|
405
|
|
406
|
|
- #define _SET_BED_PID() \
|
|
406
|
+ #define _SET_BED_PID() do { \
|
407
|
407
|
bedKp = workKp; \
|
408
|
408
|
bedKi = scalePID_i(workKi); \
|
409
|
409
|
bedKd = scalePID_d(workKd); \
|
410
|
|
- updatePID()
|
|
410
|
+ updatePID(); } while(0)
|
411
|
411
|
|
412
|
|
- #define _SET_EXTRUDER_PID() \
|
|
412
|
+ #define _SET_EXTRUDER_PID() do { \
|
413
|
413
|
PID_PARAM(Kp, hotend) = workKp; \
|
414
|
414
|
PID_PARAM(Ki, hotend) = scalePID_i(workKi); \
|
415
|
415
|
PID_PARAM(Kd, hotend) = scalePID_d(workKd); \
|
416
|
|
- updatePID()
|
|
416
|
+ updatePID(); } while(0)
|
417
|
417
|
|
418
|
418
|
// Use the result? (As with "M303 U1")
|
419
|
419
|
if (set_result) {
|
420
|
420
|
#if HAS_PID_FOR_BOTH
|
421
|
|
- if (hotend < 0) {
|
|
421
|
+ if (hotend < 0)
|
422
|
422
|
_SET_BED_PID();
|
423
|
|
- }
|
424
|
|
- else {
|
|
423
|
+ else
|
425
|
424
|
_SET_EXTRUDER_PID();
|
426
|
|
- }
|
427
|
425
|
#elif ENABLED(PIDTEMP)
|
428
|
426
|
_SET_EXTRUDER_PID();
|
429
|
427
|
#else
|