Move lpq_len to Temperature class (#10715)
This commit is contained in:
parent
02a79cc030
commit
aff683c3f5
@ -448,10 +448,6 @@ void report_current_position();
|
|||||||
filament_change_load_length[EXTRUDERS];
|
filament_change_load_length[EXTRUDERS];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(PID_EXTRUSION_SCALING)
|
|
||||||
extern int lpq_len;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HAS_POWER_SWITCH
|
#if HAS_POWER_SWITCH
|
||||||
extern bool powersupply_on;
|
extern bool powersupply_on;
|
||||||
#define PSU_PIN_ON() do{ OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); powersupply_on = true; }while(0)
|
#define PSU_PIN_ON() do{ OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); powersupply_on = true; }while(0)
|
||||||
|
@ -696,10 +696,6 @@ static bool send_ok[BUFSIZE];
|
|||||||
bool chdkActive = false;
|
bool chdkActive = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(PID_EXTRUSION_SCALING)
|
|
||||||
int lpq_len = 20;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLED(HOST_KEEPALIVE_FEATURE)
|
#if ENABLED(HOST_KEEPALIVE_FEATURE)
|
||||||
MarlinBusyState busy_state = NOT_BUSY;
|
MarlinBusyState busy_state = NOT_BUSY;
|
||||||
static millis_t next_busy_signal_ms = 0;
|
static millis_t next_busy_signal_ms = 0;
|
||||||
@ -9598,7 +9594,7 @@ inline void gcode_M226() {
|
|||||||
* With PID_EXTRUSION_SCALING:
|
* With PID_EXTRUSION_SCALING:
|
||||||
*
|
*
|
||||||
* C[float] Kc term
|
* C[float] Kc term
|
||||||
* L[float] LPQ length
|
* L[int] LPQ length
|
||||||
*/
|
*/
|
||||||
inline void gcode_M301() {
|
inline void gcode_M301() {
|
||||||
|
|
||||||
@ -9612,8 +9608,9 @@ inline void gcode_M226() {
|
|||||||
if (parser.seen('D')) PID_PARAM(Kd, e) = scalePID_d(parser.value_float());
|
if (parser.seen('D')) PID_PARAM(Kd, e) = scalePID_d(parser.value_float());
|
||||||
#if ENABLED(PID_EXTRUSION_SCALING)
|
#if ENABLED(PID_EXTRUSION_SCALING)
|
||||||
if (parser.seen('C')) PID_PARAM(Kc, e) = parser.value_float();
|
if (parser.seen('C')) PID_PARAM(Kc, e) = parser.value_float();
|
||||||
if (parser.seen('L')) lpq_len = parser.value_float();
|
if (parser.seen('L')) thermalManager.lpq_len = parser.value_float();
|
||||||
NOMORE(lpq_len, LPQ_MAX_LEN);
|
NOMORE(thermalManager.lpq_len, LPQ_MAX_LEN);
|
||||||
|
NOLESS(thermalManager.lpq_len, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
thermalManager.updatePID();
|
thermalManager.updatePID();
|
||||||
|
@ -73,6 +73,10 @@
|
|||||||
#include "fwretract.h"
|
#include "fwretract.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(PID_EXTRUSION_SCALING)
|
||||||
|
#define LPQ_LEN thermalManager.lpq_len
|
||||||
|
#endif
|
||||||
|
|
||||||
#pragma pack(push, 1) // No padding between variables
|
#pragma pack(push, 1) // No padding between variables
|
||||||
|
|
||||||
typedef struct PID { float Kp, Ki, Kd; } PID;
|
typedef struct PID { float Kp, Ki, Kd; } PID;
|
||||||
@ -183,7 +187,7 @@ typedef struct SettingsDataStruct {
|
|||||||
//
|
//
|
||||||
PIDC hotendPID[MAX_EXTRUDERS]; // M301 En PIDC / M303 En U
|
PIDC hotendPID[MAX_EXTRUDERS]; // M301 En PIDC / M303 En U
|
||||||
|
|
||||||
int lpq_len; // M301 L
|
int16_t lpq_len; // M301 L
|
||||||
|
|
||||||
//
|
//
|
||||||
// PIDTEMPBED
|
// PIDTEMPBED
|
||||||
@ -609,9 +613,9 @@ void MarlinSettings::postprocess() {
|
|||||||
_FIELD_TEST(lpq_len);
|
_FIELD_TEST(lpq_len);
|
||||||
|
|
||||||
#if DISABLED(PID_EXTRUSION_SCALING)
|
#if DISABLED(PID_EXTRUSION_SCALING)
|
||||||
int lpq_len = 20;
|
const int16_t LPQ_LEN = 20;
|
||||||
#endif
|
#endif
|
||||||
EEPROM_WRITE(lpq_len);
|
EEPROM_WRITE(LPQ_LEN);
|
||||||
|
|
||||||
#if DISABLED(PIDTEMPBED)
|
#if DISABLED(PIDTEMPBED)
|
||||||
dummy = DUMMY_PID_VALUE;
|
dummy = DUMMY_PID_VALUE;
|
||||||
@ -1213,9 +1217,9 @@ void MarlinSettings::postprocess() {
|
|||||||
_FIELD_TEST(lpq_len);
|
_FIELD_TEST(lpq_len);
|
||||||
|
|
||||||
#if DISABLED(PID_EXTRUSION_SCALING)
|
#if DISABLED(PID_EXTRUSION_SCALING)
|
||||||
int lpq_len;
|
int16_t LPQ_LEN;
|
||||||
#endif
|
#endif
|
||||||
EEPROM_READ(lpq_len);
|
EEPROM_READ(LPQ_LEN);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Heated Bed PID
|
// Heated Bed PID
|
||||||
@ -1808,7 +1812,7 @@ void MarlinSettings::reset() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#if ENABLED(PID_EXTRUSION_SCALING)
|
#if ENABLED(PID_EXTRUSION_SCALING)
|
||||||
lpq_len = 20; // default last-position-queue size
|
thermalManager.lpq_len = 20; // default last-position-queue size
|
||||||
#endif
|
#endif
|
||||||
#endif // PIDTEMP
|
#endif // PIDTEMP
|
||||||
|
|
||||||
@ -2271,7 +2275,7 @@ void MarlinSettings::reset() {
|
|||||||
SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, e)));
|
SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, e)));
|
||||||
#if ENABLED(PID_EXTRUSION_SCALING)
|
#if ENABLED(PID_EXTRUSION_SCALING)
|
||||||
SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, e));
|
SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, e));
|
||||||
if (e == 0) SERIAL_ECHOPAIR(" L", lpq_len);
|
if (e == 0) SERIAL_ECHOPAIR(" L", thermalManager.lpq_len);
|
||||||
#endif
|
#endif
|
||||||
SERIAL_EOL();
|
SERIAL_EOL();
|
||||||
}
|
}
|
||||||
@ -2286,7 +2290,7 @@ void MarlinSettings::reset() {
|
|||||||
SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
|
SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
|
||||||
#if ENABLED(PID_EXTRUSION_SCALING)
|
#if ENABLED(PID_EXTRUSION_SCALING)
|
||||||
SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, 0));
|
SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, 0));
|
||||||
SERIAL_ECHOPAIR(" L", lpq_len);
|
SERIAL_ECHOPAIR(" L", thermalManager.lpq_len);
|
||||||
#endif
|
#endif
|
||||||
SERIAL_EOL();
|
SERIAL_EOL();
|
||||||
}
|
}
|
||||||
|
@ -237,6 +237,10 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS];
|
|||||||
uint8_t Temperature::ADCKey_count = 0;
|
uint8_t Temperature::ADCKey_count = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(PID_EXTRUSION_SCALING)
|
||||||
|
int16_t Temperature::lpq_len; // Initialized in configuration_store
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAS_PID_HEATING
|
#if HAS_PID_HEATING
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -666,14 +670,14 @@ float Temperature::get_pid_output(const int8_t e) {
|
|||||||
#if ENABLED(PID_EXTRUSION_SCALING)
|
#if ENABLED(PID_EXTRUSION_SCALING)
|
||||||
cTerm[HOTEND_INDEX] = 0;
|
cTerm[HOTEND_INDEX] = 0;
|
||||||
if (_HOTEND_TEST) {
|
if (_HOTEND_TEST) {
|
||||||
long e_position = stepper.position(E_AXIS);
|
const long e_position = stepper.position(E_AXIS);
|
||||||
if (e_position > last_e_position) {
|
if (e_position > last_e_position) {
|
||||||
lpq[lpq_ptr] = e_position - last_e_position;
|
lpq[lpq_ptr] = e_position - last_e_position;
|
||||||
last_e_position = e_position;
|
last_e_position = e_position;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
lpq[lpq_ptr] = 0;
|
lpq[lpq_ptr] = 0;
|
||||||
}
|
|
||||||
if (++lpq_ptr >= lpq_len) lpq_ptr = 0;
|
if (++lpq_ptr >= lpq_len) lpq_ptr = 0;
|
||||||
cTerm[HOTEND_INDEX] = (lpq[lpq_ptr] * planner.steps_to_mm[E_AXIS]) * PID_PARAM(Kc, HOTEND_INDEX);
|
cTerm[HOTEND_INDEX] = (lpq[lpq_ptr] * planner.steps_to_mm[E_AXIS]) * PID_PARAM(Kc, HOTEND_INDEX);
|
||||||
pid_output += cTerm[HOTEND_INDEX];
|
pid_output += cTerm[HOTEND_INDEX];
|
||||||
|
@ -304,6 +304,10 @@ class Temperature {
|
|||||||
static uint8_t ADCKey_count;
|
static uint8_t ADCKey_count;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(PID_EXTRUSION_SCALING)
|
||||||
|
static int16_t lpq_len;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instance Methods
|
* Instance Methods
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user