Independent PID parameters for each extruder

* Variables Kp, Ki, Kd, Kc now arrays of size EXTRUDERS
* M301 gains (optional, default=0) E parameter to define which
extruder's settings to modify. Tested, works with Repetier Host's EEPROM
config window, albeit only reads/updates settings for E0.
* All Kp, Ki, Kd, Kc parameters saved in EEPROM (version now v14), up to
3 extruders supported (same as Marlin in general)
This commit is contained in:
grob6000
2015-01-10 14:46:08 +11:00
parent 6e8e9bb41e
commit 37c7e8300f
4 changed files with 184 additions and 101 deletions

View File

@ -3196,30 +3196,50 @@ Sigma_Exit:
#endif // M300
#ifdef PIDTEMP
case 301: // M301
{
if(code_seen('P')) Kp = code_value();
if(code_seen('I')) Ki = scalePID_i(code_value());
if(code_seen('D')) Kd = scalePID_d(code_value());
case 301: // M301
{
#ifdef PID_ADD_EXTRUSION_RATE
if(code_seen('C')) Kc = code_value();
#endif
// multi-extruder PID patch: M301 updates or prints a single extruder's PID values
// default behaviour (omitting E parameter) is to update for extruder 0 only
int e = 0; // extruder being updated
if (code_seen('E'))
{
e = (int)code_value();
}
if (e < EXTRUDERS) // catch bad input value
{
if (code_seen('P')) Kp[e] = code_value();
if (code_seen('I')) Ki[e] = scalePID_i(code_value());
if (code_seen('D')) Kd[e] = scalePID_d(code_value());
#ifdef PID_ADD_EXTRUSION_RATE
if (code_seen('C')) Kc[e] = code_value();
#endif
updatePID();
SERIAL_PROTOCOL(MSG_OK);
SERIAL_PROTOCOL(" e:"); // specify extruder in serial output
SERIAL_PROTOCOL(e);
SERIAL_PROTOCOL(" p:");
SERIAL_PROTOCOL(Kp[e]);
SERIAL_PROTOCOL(" i:");
SERIAL_PROTOCOL(unscalePID_i(Ki[e]));
SERIAL_PROTOCOL(" d:");
SERIAL_PROTOCOL(unscalePID_d(Kd[e]));
#ifdef PID_ADD_EXTRUSION_RATE
SERIAL_PROTOCOL(" c:");
//Kc does not have scaling applied above, or in resetting defaults
SERIAL_PROTOCOL(Kc[e]);
#endif
SERIAL_PROTOCOLLN("");
}
else
{
SERIAL_ECHO_START;
SERIAL_ECHOLN(MSG_INVALID_EXTRUDER);
}
updatePID();
SERIAL_PROTOCOL(MSG_OK);
SERIAL_PROTOCOL(" p:");
SERIAL_PROTOCOL(Kp);
SERIAL_PROTOCOL(" i:");
SERIAL_PROTOCOL(unscalePID_i(Ki));
SERIAL_PROTOCOL(" d:");
SERIAL_PROTOCOL(unscalePID_d(Kd));
#ifdef PID_ADD_EXTRUSION_RATE
SERIAL_PROTOCOL(" c:");
//Kc does not have scaling applied above, or in resetting defaults
SERIAL_PROTOCOL(Kc);
#endif
SERIAL_PROTOCOLLN("");
}
break;
#endif //PIDTEMP