Merge pull request #4486 from thinkyhead/rc_pid_add_extrusion_rate_off

PID_EXTRUSION_SCALING, disabled by default
2.0.x
Scott Lahteine 9 years ago committed by GitHub
commit 6eed37aafb

@ -113,8 +113,8 @@
#if ENABLED(PIDTEMP)
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#if ENABLED(PID_ADD_EXTRUSION_RATE)
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif

@ -352,7 +352,7 @@ float code_value_temp_diff();
extern FilamentChangeMenuResponse filament_change_menu_response;
#endif
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
extern int lpq_len;
#endif

@ -531,7 +531,7 @@ static bool send_ok[BUFSIZE];
boolean chdkActive = false;
#endif
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
int lpq_len = 20;
#endif
@ -5671,7 +5671,7 @@ inline void gcode_M226() {
* I[float] Ki term (unscaled)
* D[float] Kd term (unscaled)
*
* With PID_ADD_EXTRUSION_RATE:
* With PID_EXTRUSION_SCALING:
*
* C[float] Kc term
* L[float] LPQ length
@ -5686,7 +5686,7 @@ inline void gcode_M226() {
if (code_seen('P')) PID_PARAM(Kp, e) = code_value_float();
if (code_seen('I')) PID_PARAM(Ki, e) = scalePID_i(code_value_float());
if (code_seen('D')) PID_PARAM(Kd, e) = scalePID_d(code_value_float());
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
if (code_seen('C')) PID_PARAM(Kc, e) = code_value_float();
if (code_seen('L')) lpq_len = code_value_float();
NOMORE(lpq_len, LPQ_MAX_LEN);
@ -5704,7 +5704,7 @@ inline void gcode_M226() {
SERIAL_ECHO(unscalePID_i(PID_PARAM(Ki, e)));
SERIAL_ECHOPGM(" d:");
SERIAL_ECHO(unscalePID_d(PID_PARAM(Kd, e)));
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
SERIAL_ECHOPGM(" c:");
//Kc does not have scaling applied above, or in resetting defaults
SERIAL_ECHO(PID_PARAM(Kc, e));

@ -730,4 +730,6 @@
#error "HOMING_FEEDRATE is deprecated. Set individual rates with HOMING_FEEDRATE_(XY|Z|E) instead."
#elif defined(MANUAL_HOME_POSITIONS)
#error "MANUAL_HOME_POSITIONS is deprecated. Set MANUAL_[XYZ]_HOME_POS as-needed instead."
#elif defined(PID_ADD_EXTRUSION_RATE)
#error "PID_ADD_EXTRUSION_RATE is now PID_EXTRUSION_SCALING and is DISABLED by default. Are you sure you want to use this option? Please update your configuration."
#endif

@ -290,7 +290,7 @@ void Config_StoreSettings() {
EEPROM_WRITE(PID_PARAM(Kp, e));
EEPROM_WRITE(PID_PARAM(Ki, e));
EEPROM_WRITE(PID_PARAM(Kd, e));
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
EEPROM_WRITE(PID_PARAM(Kc, e));
#else
dummy = 1.0f; // 1.0 = default kc
@ -308,7 +308,7 @@ void Config_StoreSettings() {
} // Hotends Loop
#if DISABLED(PID_ADD_EXTRUSION_RATE)
#if DISABLED(PID_EXTRUSION_SCALING)
int lpq_len = 20;
#endif
EEPROM_WRITE(lpq_len);
@ -481,7 +481,7 @@ void Config_RetrieveSettings() {
PID_PARAM(Kp, e) = dummy;
EEPROM_READ(PID_PARAM(Ki, e));
EEPROM_READ(PID_PARAM(Kd, e));
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
EEPROM_READ(PID_PARAM(Kc, e));
#else
EEPROM_READ(dummy);
@ -496,7 +496,7 @@ void Config_RetrieveSettings() {
for (uint8_t q = MAX_EXTRUDERS * 4; q--;) EEPROM_READ(dummy); // Kp, Ki, Kd, Kc
#endif // !PIDTEMP
#if DISABLED(PID_ADD_EXTRUSION_RATE)
#if DISABLED(PID_EXTRUSION_SCALING)
int lpq_len;
#endif
EEPROM_READ(lpq_len);
@ -641,11 +641,11 @@ void Config_ResetDefault() {
PID_PARAM(Kp, e) = DEFAULT_Kp;
PID_PARAM(Ki, e) = scalePID_i(DEFAULT_Ki);
PID_PARAM(Kd, e) = scalePID_d(DEFAULT_Kd);
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
PID_PARAM(Kc, e) = DEFAULT_Kc;
#endif
}
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
lpq_len = 20; // default last-position-queue size
#endif
#endif // PIDTEMP
@ -863,7 +863,7 @@ void Config_PrintSettings(bool forReplay) {
SERIAL_ECHOPAIR(" P", PID_PARAM(Kp, e));
SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, e)));
SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, e)));
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, e));
if (e == 0) SERIAL_ECHOPAIR(" L", lpq_len);
#endif
@ -878,7 +878,7 @@ void Config_PrintSettings(bool forReplay) {
SERIAL_ECHOPAIR(" M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echo values for E0
SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, 0));
SERIAL_ECHOPAIR(" L", lpq_len);
#endif

@ -113,8 +113,8 @@
#if ENABLED(PIDTEMP)
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#if ENABLED(PID_ADD_EXTRUSION_RATE)
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif

@ -113,8 +113,8 @@
#if ENABLED(PIDTEMP)
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#if ENABLED(PID_ADD_EXTRUSION_RATE)
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif

@ -113,8 +113,8 @@
#if ENABLED(PIDTEMP)
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#if ENABLED(PID_ADD_EXTRUSION_RATE)
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif

@ -113,8 +113,8 @@
#if ENABLED(PIDTEMP)
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#if ENABLED(PID_ADD_EXTRUSION_RATE)
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif

@ -119,8 +119,8 @@
#if ENABLED(PIDTEMP)
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#if ENABLED(PID_ADD_EXTRUSION_RATE)
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif

@ -113,8 +113,8 @@
#if ENABLED(PIDTEMP)
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#if ENABLED(PID_ADD_EXTRUSION_RATE)
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif

@ -113,8 +113,8 @@
#if ENABLED(PIDTEMP)
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#if ENABLED(PID_ADD_EXTRUSION_RATE)
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif

@ -113,8 +113,8 @@
#if ENABLED(PIDTEMP)
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#if ENABLED(PID_ADD_EXTRUSION_RATE)
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif

@ -113,8 +113,8 @@
#if ENABLED(PIDTEMP)
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#if ENABLED(PID_ADD_EXTRUSION_RATE)
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif

@ -113,8 +113,8 @@
#if ENABLED(PIDTEMP)
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#if ENABLED(PID_ADD_EXTRUSION_RATE)
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif

@ -113,8 +113,8 @@
#if ENABLED(PIDTEMP)
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#if ENABLED(PID_ADD_EXTRUSION_RATE)
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif

@ -113,8 +113,8 @@
#if ENABLED(PIDTEMP)
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#if ENABLED(PID_ADD_EXTRUSION_RATE)
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif

@ -113,8 +113,8 @@
#if ENABLED(PIDTEMP)
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#if ENABLED(PID_ADD_EXTRUSION_RATE)
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif

@ -118,8 +118,8 @@
#if ENABLED(PIDTEMP)
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#if ENABLED(PID_ADD_EXTRUSION_RATE)
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif

@ -113,8 +113,8 @@
#if ENABLED(PIDTEMP)
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#if ENABLED(PID_ADD_EXTRUSION_RATE)
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif

@ -113,8 +113,8 @@
#if ENABLED(PIDTEMP)
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#if ENABLED(PID_ADD_EXTRUSION_RATE)
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif

@ -113,8 +113,8 @@
#if ENABLED(PIDTEMP)
// this adds an experimental additional term to the heating power, proportional to the extrusion speed.
// if Kc is chosen well, the additional required power due to increased melting should be compensated.
#define PID_ADD_EXTRUSION_RATE
#if ENABLED(PID_ADD_EXTRUSION_RATE)
//#define PID_EXTRUSION_SCALING
#if ENABLED(PID_EXTRUSION_SCALING)
#define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
#define LPQ_MAX_LEN 50
#endif

@ -72,14 +72,14 @@ unsigned char Temperature::soft_pwm_bed;
float Temperature::Kp[HOTENDS] = ARRAY_BY_HOTENDS1(DEFAULT_Kp),
Temperature::Ki[HOTENDS] = ARRAY_BY_HOTENDS1((DEFAULT_Ki) * (PID_dT)),
Temperature::Kd[HOTENDS] = ARRAY_BY_HOTENDS1((DEFAULT_Kd) / (PID_dT));
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
float Temperature::Kc[HOTENDS] = ARRAY_BY_HOTENDS1(DEFAULT_Kc);
#endif
#else
float Temperature::Kp = DEFAULT_Kp,
Temperature::Ki = (DEFAULT_Ki) * (PID_dT),
Temperature::Kd = (DEFAULT_Kd) / (PID_dT);
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
float Temperature::Kc = DEFAULT_Kc;
#endif
#endif
@ -126,7 +126,7 @@ volatile bool Temperature::temp_meas_ready = false;
Temperature::iTerm[HOTENDS],
Temperature::dTerm[HOTENDS];
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
float Temperature::cTerm[HOTENDS];
long Temperature::last_e_position;
long Temperature::lpq[LPQ_MAX_LEN];
@ -444,7 +444,7 @@ Temperature::Temperature() { }
void Temperature::updatePID() {
#if ENABLED(PIDTEMP)
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
last_e_position = 0;
#endif
HOTEND_LOOP() {
@ -560,7 +560,7 @@ float Temperature::get_pid_output(int e) {
pid_output = pTerm[HOTEND_INDEX] + iTerm[HOTEND_INDEX] - dTerm[HOTEND_INDEX];
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
cTerm[HOTEND_INDEX] = 0;
if (_HOTEND_TEST) {
long e_position = stepper.position(E_AXIS);
@ -575,7 +575,7 @@ float Temperature::get_pid_output(int e) {
cTerm[HOTEND_INDEX] = (lpq[lpq_ptr] * planner.steps_to_mm[E_AXIS]) * PID_PARAM(Kc, HOTEND_INDEX);
pid_output += cTerm[HOTEND_INDEX];
}
#endif //PID_ADD_EXTRUSION_RATE
#endif // PID_EXTRUSION_SCALING
if (pid_output > PID_MAX) {
if (pid_error[HOTEND_INDEX] > 0) temp_iState[HOTEND_INDEX] -= pid_error[HOTEND_INDEX]; // conditional un-integration
@ -598,7 +598,7 @@ float Temperature::get_pid_output(int e) {
SERIAL_ECHOPAIR(MSG_PID_DEBUG_PTERM, pTerm[HOTEND_INDEX]);
SERIAL_ECHOPAIR(MSG_PID_DEBUG_ITERM, iTerm[HOTEND_INDEX]);
SERIAL_ECHOPAIR(MSG_PID_DEBUG_DTERM, dTerm[HOTEND_INDEX]);
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
SERIAL_ECHOPAIR(MSG_PID_DEBUG_CTERM, cTerm[HOTEND_INDEX]);
#endif
SERIAL_EOL;
@ -949,7 +949,7 @@ void Temperature::init() {
#if ENABLED(PIDTEMP)
temp_iState_min[e] = 0.0;
temp_iState_max[e] = (PID_INTEGRAL_DRIVE_MAX) / PID_PARAM(Ki, e);
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
last_e_position = 0;
#endif
#endif //PIDTEMP
@ -959,7 +959,7 @@ void Temperature::init() {
#endif //PIDTEMPBED
}
#if ENABLED(PIDTEMP) && ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PIDTEMP) && ENABLED(PID_EXTRUSION_SCALING)
last_e_position = 0;
#endif

@ -31,7 +31,7 @@
#include "planner.h"
#include "thermistortables.h"
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
#include "stepper.h"
#endif
@ -79,7 +79,7 @@ class Temperature {
#if ENABLED(PID_PARAMS_PER_HOTEND) && HOTENDS > 1
static float Kp[HOTENDS], Ki[HOTENDS], Kd[HOTENDS];
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
static float Kc[HOTENDS];
#endif
#define PID_PARAM(param, h) Temperature::param[h]
@ -87,7 +87,7 @@ class Temperature {
#else
static float Kp, Ki, Kd;
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
static float Kc;
#endif
#define PID_PARAM(param, h) Temperature::param
@ -149,7 +149,7 @@ class Temperature {
iTerm[HOTENDS],
dTerm[HOTENDS];
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
static float cTerm[HOTENDS];
static long last_e_position;
static long lpq[LPQ_MAX_LEN];

@ -1684,7 +1684,7 @@ void kill_screen(const char* lcd_msg) {
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)
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#if ENABLED(PID_EXTRUSION_SCALING)
#define _PID_MENU_ITEMS(ELABEL, eindex) \
_PID_BASE_MENU_ITEMS(ELABEL, eindex); \
MENU_ITEM_EDIT(float3, MSG_PID_C ELABEL, &PID_PARAM(Kc, eindex), 1, 9990)

Loading…
Cancel
Save