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.
This commit is contained in:
parent
da9d4c4caf
commit
3b3e8a02b5
@ -718,7 +718,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
|
|||||||
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||||
//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu
|
//#define REVERSE_MENU_DIRECTION // When enabled CLOCKWISE moves UP in the LCD menu
|
||||||
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
||||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||||
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
||||||
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
||||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||||
|
@ -5142,13 +5142,15 @@ inline void gcode_M226() {
|
|||||||
inline void gcode_M303() {
|
inline void gcode_M303() {
|
||||||
int e = code_seen('E') ? code_value_short() : 0;
|
int e = code_seen('E') ? code_value_short() : 0;
|
||||||
int c = code_seen('C') ? code_value_short() : 5;
|
int c = code_seen('C') ? code_value_short() : 5;
|
||||||
|
bool u = code_seen('U') && code_value_short() == 1;
|
||||||
|
|
||||||
float temp = code_seen('S') ? code_value() : (e < 0 ? 70.0 : 150.0);
|
float temp = code_seen('S') ? code_value() : (e < 0 ? 70.0 : 150.0);
|
||||||
|
|
||||||
if (e >=0 && e < EXTRUDERS)
|
if (e >=0 && e < EXTRUDERS)
|
||||||
target_extruder = e;
|
target_extruder = e;
|
||||||
|
|
||||||
KEEPALIVE_STATE(NOT_BUSY);
|
KEEPALIVE_STATE(NOT_BUSY);
|
||||||
PID_autotune(temp, e, c);
|
PID_autotune(temp, e, c, u);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLED(SCARA)
|
#if ENABLED(SCARA)
|
||||||
|
@ -199,7 +199,7 @@ static void updateTemperaturesFromRawValues();
|
|||||||
//================================ Functions ================================
|
//================================ Functions ================================
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
void PID_autotune(float temp, int extruder, int ncycles) {
|
void PID_autotune(float temp, int extruder, int ncycles, bool set_result) {
|
||||||
float input = 0.0;
|
float input = 0.0;
|
||||||
int cycles = 0;
|
int cycles = 0;
|
||||||
bool heating = true;
|
bool heating = true;
|
||||||
@ -346,6 +346,23 @@ void PID_autotune(float temp, int extruder, int ncycles) {
|
|||||||
SERIAL_PROTOCOLPGM("#define DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Kp "); SERIAL_PROTOCOLLN(Kp);
|
SERIAL_PROTOCOLPGM("#define DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Kp "); SERIAL_PROTOCOLLN(Kp);
|
||||||
SERIAL_PROTOCOLPGM("#define DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Ki "); SERIAL_PROTOCOLLN(Ki);
|
SERIAL_PROTOCOLPGM("#define DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Ki "); SERIAL_PROTOCOLLN(Ki);
|
||||||
SERIAL_PROTOCOLPGM("#define DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Kd "); SERIAL_PROTOCOLLN(Kd);
|
SERIAL_PROTOCOLPGM("#define DEFAULT_"); SERIAL_PROTOCOL(estring); SERIAL_PROTOCOLPGM("Kd "); SERIAL_PROTOCOLLN(Kd);
|
||||||
|
//Uses the result if set_result is true
|
||||||
|
if (set_result) {
|
||||||
|
if (extruder < 0) {
|
||||||
|
#if ENABLED(PIDTEMPBED)
|
||||||
|
bedKp = Kp;
|
||||||
|
bedKi = scalePID_i(Ki);
|
||||||
|
bedKd = scalePID_d(Kd);
|
||||||
|
updatePID();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PID_PARAM(Kp, extruder) = Kp;
|
||||||
|
PID_PARAM(Ki, e) = scalePID_i(Ki);
|
||||||
|
PID_PARAM(Kd, e) = scalePID_d(Kd);
|
||||||
|
updatePID();
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lcd_update();
|
lcd_update();
|
||||||
|
@ -141,7 +141,7 @@ int getHeaterPower(int heater);
|
|||||||
void disable_all_heaters();
|
void disable_all_heaters();
|
||||||
void updatePID();
|
void updatePID();
|
||||||
|
|
||||||
void PID_autotune(float temp, int extruder, int ncycles);
|
void PID_autotune(float temp, int extruder, int ncycles, bool set_result);
|
||||||
|
|
||||||
void setExtruderAutoFanState(int pin, bool state);
|
void setExtruderAutoFanState(int pin, bool state);
|
||||||
void checkExtruderAutoFans();
|
void checkExtruderAutoFans();
|
||||||
|
@ -1176,11 +1176,11 @@ static void lcd_control_temperature_menu() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// PID-P, PID-I, PID-D, PID-C
|
// PID-P, PID-I, PID-D, PID-C, PID Autotune
|
||||||
// PID-P E1, PID-I E1, PID-D E1, PID-C E1
|
// PID-P E1, PID-I E1, PID-D E1, PID-C E1, PID Autotune E1
|
||||||
// PID-P E2, PID-I E2, PID-D E2, PID-C E2
|
// PID-P E2, PID-I E2, PID-D E2, PID-C E2, PID Autotune E2
|
||||||
// PID-P E3, PID-I E3, PID-D E3, PID-C E3
|
// PID-P E3, PID-I E3, PID-D E3, PID-C E3, PID Autotune E3
|
||||||
// PID-P E4, PID-I E4, PID-D E4, PID-C E4
|
// PID-P E4, PID-I E4, PID-D E4, PID-C E4, PID Autotune E4
|
||||||
//
|
//
|
||||||
#if ENABLED(PIDTEMP)
|
#if ENABLED(PIDTEMP)
|
||||||
|
|
||||||
@ -1189,7 +1189,19 @@ static void lcd_control_temperature_menu() {
|
|||||||
raw_Kd = unscalePID_d(PID_PARAM(Kd, eindex)); \
|
raw_Kd = unscalePID_d(PID_PARAM(Kd, eindex)); \
|
||||||
MENU_ITEM_EDIT(float52, MSG_PID_P ELABEL, &PID_PARAM(Kp, eindex), 1, 9990); \
|
MENU_ITEM_EDIT(float52, MSG_PID_P ELABEL, &PID_PARAM(Kp, eindex), 1, 9990); \
|
||||||
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I ELABEL, &raw_Ki, 0.01, 9990, copy_and_scalePID_i_E ## eindex); \
|
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I ELABEL, &raw_Ki, 0.01, 9990, copy_and_scalePID_i_E ## eindex); \
|
||||||
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D ELABEL, &raw_Kd, 1, 9990, copy_and_scalePID_d_E ## eindex)
|
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D ELABEL, &raw_Kd, 1, 9990, copy_and_scalePID_d_E ## eindex); \
|
||||||
|
if (eindex == 0) { \
|
||||||
|
MENU_ITEM(gcode, MSG_PID_AUTOTUNE ELABEL, PSTR("M303 U1")); \
|
||||||
|
} \
|
||||||
|
else if (eindex == 1) { \
|
||||||
|
MENU_ITEM(gcode, MSG_PID_AUTOTUNE ELABEL, PSTR("M303 U1 E1")); \
|
||||||
|
} \
|
||||||
|
else if (eindex == 2) { \
|
||||||
|
MENU_ITEM(gcode, MSG_PID_AUTOTUNE ELABEL, PSTR("M303 U1 E2")); \
|
||||||
|
} \
|
||||||
|
else { \
|
||||||
|
MENU_ITEM(gcode, MSG_PID_AUTOTUNE ELABEL, PSTR("M303 U1 E3")); \
|
||||||
|
}
|
||||||
|
|
||||||
#if ENABLED(PID_ADD_EXTRUSION_RATE)
|
#if ENABLED(PID_ADD_EXTRUSION_RATE)
|
||||||
#define PID_MENU_ITEMS(ELABEL, eindex) \
|
#define PID_MENU_ITEMS(ELABEL, eindex) \
|
||||||
|
Loading…
Reference in New Issue
Block a user