Allow Edit menu to call fn after edit; Fix PID Ki and Kd display in menus; Actually use changed PID and Max Accel values
Add new 'callback' edit-menu types that call a function after the edit is done. Use this to display and edit Ki and Kd correctly (removing the scaling first and reapplying it after). Also use it to reset maximum stepwise acceleration rates, after updating mm/s^2 rates via menus. (Previously, changes did nothing to affect planner unless saved back to EEPROM, and the machine reset). Add calls to updatePID() so that PID loop uses updated values whether set by gcode (it already did this), or by restoring defaults, or loading from EEPROM (it didn't do those last two). Similarly, update the maximum step/s^2 accel rates when the mm/s^2 values are changed - whether by menu edits, restore defaults, or EEPROM read. Refactor the acceleration rate update logic, and the PID scaling logic, into new functions that can be called from wherever, including the callbacks. Add menu items to allow the z jerk and e jerk to be viewed/edited in the Control->Motion menu, as per xy jerk. Conflicts: Marlin/language.h
This commit is contained in:
@@ -363,13 +363,8 @@ void setup()
|
||||
fromsd[i] = false;
|
||||
}
|
||||
|
||||
Config_RetrieveSettings(); // loads data from EEPROM if available
|
||||
|
||||
for(int8_t i=0; i < NUM_AXIS; i++)
|
||||
{
|
||||
axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i];
|
||||
}
|
||||
|
||||
// loads data from EEPROM if available else uses defaults (and resets step acceleration rate)
|
||||
Config_RetrieveSettings();
|
||||
|
||||
tp_init(); // Initialize temperature loop
|
||||
plan_init(); // Initialize planner;
|
||||
@@ -1323,9 +1318,10 @@ void process_commands()
|
||||
if(code_seen(axis_codes[i]))
|
||||
{
|
||||
max_acceleration_units_per_sq_second[i] = code_value();
|
||||
axis_steps_per_sqr_second[i] = code_value() * axis_steps_per_unit[i];
|
||||
}
|
||||
}
|
||||
// steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
|
||||
reset_acceleration_rates();
|
||||
break;
|
||||
#if 0 // Not used for Sprinter/grbl gen6
|
||||
case 202: // M202
|
||||
@@ -1468,22 +1464,25 @@ void process_commands()
|
||||
case 301: // M301
|
||||
{
|
||||
if(code_seen('P')) Kp = code_value();
|
||||
if(code_seen('I')) Ki = code_value()*PID_dT;
|
||||
if(code_seen('D')) Kd = code_value()/PID_dT;
|
||||
if(code_seen('I')) Ki = scalePID_i(code_value());
|
||||
if(code_seen('D')) Kd = scalePID_d(code_value());
|
||||
|
||||
#ifdef PID_ADD_EXTRUSION_RATE
|
||||
if(code_seen('C')) Kc = code_value();
|
||||
#endif
|
||||
|
||||
updatePID();
|
||||
SERIAL_PROTOCOL(MSG_OK);
|
||||
SERIAL_PROTOCOL(" p:");
|
||||
SERIAL_PROTOCOL(Kp);
|
||||
SERIAL_PROTOCOL(" i:");
|
||||
SERIAL_PROTOCOL(Ki/PID_dT);
|
||||
SERIAL_PROTOCOL(unscalePID_i(Ki));
|
||||
SERIAL_PROTOCOL(" d:");
|
||||
SERIAL_PROTOCOL(Kd*PID_dT);
|
||||
SERIAL_PROTOCOL(unscalePID_d(Kd));
|
||||
#ifdef PID_ADD_EXTRUSION_RATE
|
||||
SERIAL_PROTOCOL(" c:");
|
||||
SERIAL_PROTOCOL(Kc*PID_dT);
|
||||
//Kc does not have scaling applied above, or in resetting defaults
|
||||
SERIAL_PROTOCOL(Kc);
|
||||
#endif
|
||||
SERIAL_PROTOCOLLN("");
|
||||
}
|
||||
@@ -1493,16 +1492,18 @@ void process_commands()
|
||||
case 304: // M304
|
||||
{
|
||||
if(code_seen('P')) bedKp = code_value();
|
||||
if(code_seen('I')) bedKi = code_value()*PID_dT;
|
||||
if(code_seen('D')) bedKd = code_value()/PID_dT;
|
||||
if(code_seen('I')) bedKi = scalePID_i(code_value());
|
||||
if(code_seen('D')) bedKd = scalePID_d(code_value());
|
||||
// Scale the Bed PID values by PID_dT
|
||||
scaleBedPID();
|
||||
updatePID();
|
||||
SERIAL_PROTOCOL(MSG_OK);
|
||||
SERIAL_PROTOCOL(" p:");
|
||||
SERIAL_PROTOCOL(bedKp);
|
||||
SERIAL_PROTOCOL(" i:");
|
||||
SERIAL_PROTOCOL(bedKi/PID_dT);
|
||||
SERIAL_PROTOCOL(unscalePID_i(bedKi));
|
||||
SERIAL_PROTOCOL(" d:");
|
||||
SERIAL_PROTOCOL(bedKd*PID_dT);
|
||||
SERIAL_PROTOCOL(unscalePID_d(bedKd));
|
||||
SERIAL_PROTOCOLLN("");
|
||||
}
|
||||
break;
|
||||
|
Reference in New Issue
Block a user