|
@@ -131,6 +131,11 @@ float Planner::previous_speed[NUM_AXIS],
|
131
|
131
|
long Planner::axis_segment_time[2][3] = { {MAX_FREQ_TIME + 1, 0, 0}, {MAX_FREQ_TIME + 1, 0, 0} };
|
132
|
132
|
#endif
|
133
|
133
|
|
|
134
|
+#if ENABLED(LIN_ADVANCE)
|
|
135
|
+ float Planner::extruder_advance_k = LIN_ADVANCE_K;
|
|
136
|
+ float Planner::position_float[NUM_AXIS] = { 0 };
|
|
137
|
+#endif
|
|
138
|
+
|
134
|
139
|
/**
|
135
|
140
|
* Class and Instance Methods
|
136
|
141
|
*/
|
|
@@ -140,6 +145,9 @@ Planner::Planner() { init(); }
|
140
|
145
|
void Planner::init() {
|
141
|
146
|
block_buffer_head = block_buffer_tail = 0;
|
142
|
147
|
ZERO(position);
|
|
148
|
+ #if ENABLED(LIN_ADVANCE)
|
|
149
|
+ ZERO(position_float);
|
|
150
|
+ #endif
|
143
|
151
|
ZERO(previous_speed);
|
144
|
152
|
previous_nominal_speed = 0.0;
|
145
|
153
|
#if ABL_PLANAR
|
|
@@ -604,6 +612,14 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
604
|
612
|
lround(c * axis_steps_per_mm[Z_AXIS]),
|
605
|
613
|
lround(e * axis_steps_per_mm[E_AXIS])
|
606
|
614
|
};
|
|
615
|
+
|
|
616
|
+ #if ENABLED(LIN_ADVANCE)
|
|
617
|
+ float target_float[XYZE] = {a, b, c, e};
|
|
618
|
+ float de_float = target_float[E_AXIS] - position_float[E_AXIS];
|
|
619
|
+ float mm_D_float = sqrt(sq(target_float[X_AXIS] - position_float[X_AXIS]) + sq(target_float[Y_AXIS] - position_float[Y_AXIS]));
|
|
620
|
+
|
|
621
|
+ memcpy(position_float, target_float, sizeof(position_float));
|
|
622
|
+ #endif
|
607
|
623
|
|
608
|
624
|
long da = target[X_AXIS] - position[X_AXIS],
|
609
|
625
|
db = target[Y_AXIS] - position[Y_AXIS],
|
|
@@ -1232,12 +1248,12 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
|
1232
|
1248
|
// This leads to an enormous number of advance steps due to a huge e_acceleration.
|
1233
|
1249
|
// The math is correct, but you don't want a retract move done with advance!
|
1234
|
1250
|
// So this situation is filtered out here.
|
1235
|
|
- if (!esteps || (!block->steps[X_AXIS] && !block->steps[Y_AXIS]) || stepper.get_advance_k() == 0 || (uint32_t)esteps == block->step_event_count) {
|
|
1251
|
+ if (!esteps || (!block->steps[X_AXIS] && !block->steps[Y_AXIS]) || extruder_advance_k == 0.0 || (uint32_t)esteps == block->step_event_count) {
|
1236
|
1252
|
block->use_advance_lead = false;
|
1237
|
1253
|
}
|
1238
|
1254
|
else {
|
1239
|
1255
|
block->use_advance_lead = true;
|
1240
|
|
- block->e_speed_multiplier8 = (esteps << 8) / block->step_event_count;
|
|
1256
|
+ block->abs_adv_steps_multiplier8 = lround(extruder_advance_k * (de_float / mm_D_float) * block->nominal_speed / (float)block->nominal_rate * axis_steps_per_mm[Z_AXIS] * 256.0);
|
1241
|
1257
|
}
|
1242
|
1258
|
|
1243
|
1259
|
#elif ENABLED(ADVANCE)
|
|
@@ -1354,3 +1370,14 @@ void Planner::refresh_positioning() {
|
1354
|
1370
|
}
|
1355
|
1371
|
|
1356
|
1372
|
#endif
|
|
1373
|
+
|
|
1374
|
+#if ENABLED(LIN_ADVANCE)
|
|
1375
|
+
|
|
1376
|
+ void Planner::advance_M905(const float &k) {
|
|
1377
|
+ if (k >= 0.0) extruder_advance_k = k;
|
|
1378
|
+ SERIAL_ECHO_START;
|
|
1379
|
+ SERIAL_ECHOPAIR("Advance factor: ", extruder_advance_k);
|
|
1380
|
+ SERIAL_EOL;
|
|
1381
|
+ }
|
|
1382
|
+
|
|
1383
|
+#endif
|