|
@@ -522,7 +522,9 @@ void Planner::check_axes_activity() {
|
522
|
522
|
}
|
523
|
523
|
|
524
|
524
|
#if PLANNER_LEVELING
|
525
|
|
-
|
|
525
|
+ /**
|
|
526
|
+ * lx, ly, lz - logical (cartesian, not delta) positions in mm
|
|
527
|
+ */
|
526
|
528
|
void Planner::apply_leveling(float &lx, float &ly, float &lz) {
|
527
|
529
|
|
528
|
530
|
#if HAS_ABL
|
|
@@ -549,19 +551,7 @@ void Planner::check_axes_activity() {
|
549
|
551
|
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
550
|
552
|
|
551
|
553
|
float tmp[XYZ] = { lx, ly, 0 };
|
552
|
|
-
|
553
|
|
- #if ENABLED(DELTA)
|
554
|
|
-
|
555
|
|
- float offset = bilinear_z_offset(tmp);
|
556
|
|
- lx += offset;
|
557
|
|
- ly += offset;
|
558
|
|
- lz += offset;
|
559
|
|
-
|
560
|
|
- #else
|
561
|
|
-
|
562
|
|
- lz += bilinear_z_offset(tmp);
|
563
|
|
-
|
564
|
|
- #endif
|
|
554
|
+ lz += bilinear_z_offset(tmp);
|
565
|
555
|
|
566
|
556
|
#endif
|
567
|
557
|
}
|
|
@@ -601,15 +591,17 @@ void Planner::check_axes_activity() {
|
601
|
591
|
#endif // PLANNER_LEVELING
|
602
|
592
|
|
603
|
593
|
/**
|
604
|
|
- * Planner::buffer_line
|
|
594
|
+ * Planner::_buffer_line
|
605
|
595
|
*
|
606
|
596
|
* Add a new linear movement to the buffer.
|
607
|
597
|
*
|
608
|
|
- * x,y,z,e - target position in mm
|
609
|
|
- * fr_mm_s - (target) speed of the move
|
610
|
|
- * extruder - target extruder
|
|
598
|
+ * Leveling and kinematics should be applied ahead of calling this.
|
|
599
|
+ *
|
|
600
|
+ * a,b,c,e - target positions in mm or degrees
|
|
601
|
+ * fr_mm_s - (target) speed of the move
|
|
602
|
+ * extruder - target extruder
|
611
|
603
|
*/
|
612
|
|
-void Planner::buffer_line(ARG_X, ARG_Y, ARG_Z, const float &e, float fr_mm_s, const uint8_t extruder) {
|
|
604
|
+void Planner::_buffer_line(const float &a, const float &b, const float &c, const float &e, float fr_mm_s, const uint8_t extruder) {
|
613
|
605
|
// Calculate the buffer head after we push this byte
|
614
|
606
|
int next_buffer_head = next_block_index(block_buffer_head);
|
615
|
607
|
|
|
@@ -617,43 +609,39 @@ void Planner::buffer_line(ARG_X, ARG_Y, ARG_Z, const float &e, float fr_mm_s, co
|
617
|
609
|
// Rest here until there is room in the buffer.
|
618
|
610
|
while (block_buffer_tail == next_buffer_head) idle();
|
619
|
611
|
|
620
|
|
- #if PLANNER_LEVELING
|
621
|
|
- apply_leveling(lx, ly, lz);
|
622
|
|
- #endif
|
623
|
|
-
|
624
|
612
|
// The target position of the tool in absolute steps
|
625
|
613
|
// Calculate target position in absolute steps
|
626
|
614
|
//this should be done after the wait, because otherwise a M92 code within the gcode disrupts this calculation somehow
|
627
|
|
- long target[NUM_AXIS] = {
|
628
|
|
- lround(lx * axis_steps_per_mm[X_AXIS]),
|
629
|
|
- lround(ly * axis_steps_per_mm[Y_AXIS]),
|
630
|
|
- lround(lz * axis_steps_per_mm[Z_AXIS]),
|
|
615
|
+ long target[XYZE] = {
|
|
616
|
+ lround(a * axis_steps_per_mm[X_AXIS]),
|
|
617
|
+ lround(b * axis_steps_per_mm[Y_AXIS]),
|
|
618
|
+ lround(c * axis_steps_per_mm[Z_AXIS]),
|
631
|
619
|
lround(e * axis_steps_per_mm[E_AXIS])
|
632
|
620
|
};
|
633
|
621
|
|
634
|
|
- long dx = target[X_AXIS] - position[X_AXIS],
|
635
|
|
- dy = target[Y_AXIS] - position[Y_AXIS],
|
636
|
|
- dz = target[Z_AXIS] - position[Z_AXIS];
|
|
622
|
+ long da = target[X_AXIS] - position[X_AXIS],
|
|
623
|
+ db = target[Y_AXIS] - position[Y_AXIS],
|
|
624
|
+ dc = target[Z_AXIS] - position[Z_AXIS];
|
637
|
625
|
|
638
|
626
|
/*
|
639
|
627
|
SERIAL_ECHOPAIR(" Planner FR:", fr_mm_s);
|
640
|
628
|
SERIAL_CHAR(' ');
|
641
|
629
|
#if IS_KINEMATIC
|
642
|
|
- SERIAL_ECHOPAIR("A:", lx);
|
643
|
|
- SERIAL_ECHOPAIR(" (", dx);
|
644
|
|
- SERIAL_ECHOPAIR(") B:", ly);
|
|
630
|
+ SERIAL_ECHOPAIR("A:", a);
|
|
631
|
+ SERIAL_ECHOPAIR(" (", da);
|
|
632
|
+ SERIAL_ECHOPAIR(") B:", b);
|
645
|
633
|
#else
|
646
|
|
- SERIAL_ECHOPAIR("X:", lx);
|
647
|
|
- SERIAL_ECHOPAIR(" (", dx);
|
648
|
|
- SERIAL_ECHOPAIR(") Y:", ly);
|
|
634
|
+ SERIAL_ECHOPAIR("X:", a);
|
|
635
|
+ SERIAL_ECHOPAIR(" (", da);
|
|
636
|
+ SERIAL_ECHOPAIR(") Y:", b);
|
649
|
637
|
#endif
|
650
|
|
- SERIAL_ECHOPAIR(" (", dy);
|
|
638
|
+ SERIAL_ECHOPAIR(" (", db);
|
651
|
639
|
#if ENABLED(DELTA)
|
652
|
|
- SERIAL_ECHOPAIR(") C:", lz);
|
|
640
|
+ SERIAL_ECHOPAIR(") C:", c);
|
653
|
641
|
#else
|
654
|
|
- SERIAL_ECHOPAIR(") Z:", lz);
|
|
642
|
+ SERIAL_ECHOPAIR(") Z:", c);
|
655
|
643
|
#endif
|
656
|
|
- SERIAL_ECHOPAIR(" (", dz);
|
|
644
|
+ SERIAL_ECHOPAIR(" (", dc);
|
657
|
645
|
SERIAL_CHAR(')');
|
658
|
646
|
SERIAL_EOL;
|
659
|
647
|
//*/
|
|
@@ -692,24 +680,24 @@ void Planner::buffer_line(ARG_X, ARG_Y, ARG_Z, const float &e, float fr_mm_s, co
|
692
|
680
|
#if ENABLED(COREXY)
|
693
|
681
|
// corexy planning
|
694
|
682
|
// these equations follow the form of the dA and dB equations on http://www.corexy.com/theory.html
|
695
|
|
- block->steps[A_AXIS] = labs(dx + dy);
|
696
|
|
- block->steps[B_AXIS] = labs(dx - dy);
|
697
|
|
- block->steps[Z_AXIS] = labs(dz);
|
|
683
|
+ block->steps[A_AXIS] = labs(da + db);
|
|
684
|
+ block->steps[B_AXIS] = labs(da - db);
|
|
685
|
+ block->steps[Z_AXIS] = labs(dc);
|
698
|
686
|
#elif ENABLED(COREXZ)
|
699
|
687
|
// corexz planning
|
700
|
|
- block->steps[A_AXIS] = labs(dx + dz);
|
701
|
|
- block->steps[Y_AXIS] = labs(dy);
|
702
|
|
- block->steps[C_AXIS] = labs(dx - dz);
|
|
688
|
+ block->steps[A_AXIS] = labs(da + dc);
|
|
689
|
+ block->steps[Y_AXIS] = labs(db);
|
|
690
|
+ block->steps[C_AXIS] = labs(da - dc);
|
703
|
691
|
#elif ENABLED(COREYZ)
|
704
|
692
|
// coreyz planning
|
705
|
|
- block->steps[X_AXIS] = labs(dx);
|
706
|
|
- block->steps[B_AXIS] = labs(dy + dz);
|
707
|
|
- block->steps[C_AXIS] = labs(dy - dz);
|
|
693
|
+ block->steps[X_AXIS] = labs(da);
|
|
694
|
+ block->steps[B_AXIS] = labs(db + dc);
|
|
695
|
+ block->steps[C_AXIS] = labs(db - dc);
|
708
|
696
|
#else
|
709
|
697
|
// default non-h-bot planning
|
710
|
|
- block->steps[X_AXIS] = labs(dx);
|
711
|
|
- block->steps[Y_AXIS] = labs(dy);
|
712
|
|
- block->steps[Z_AXIS] = labs(dz);
|
|
698
|
+ block->steps[X_AXIS] = labs(da);
|
|
699
|
+ block->steps[Y_AXIS] = labs(db);
|
|
700
|
+ block->steps[Z_AXIS] = labs(dc);
|
713
|
701
|
#endif
|
714
|
702
|
|
715
|
703
|
block->steps[E_AXIS] = labs(de) * volumetric_multiplier[extruder] * flow_percentage[extruder] * 0.01 + 0.5;
|
|
@@ -733,33 +721,33 @@ void Planner::buffer_line(ARG_X, ARG_Y, ARG_Z, const float &e, float fr_mm_s, co
|
733
|
721
|
block->e_to_p_pressure = baricuda_e_to_p_pressure;
|
734
|
722
|
#endif
|
735
|
723
|
|
736
|
|
- // Compute direction bits for this block
|
737
|
|
- uint8_t db = 0;
|
|
724
|
+ // Compute direction bit-mask for this block
|
|
725
|
+ uint8_t dm = 0;
|
738
|
726
|
#if ENABLED(COREXY)
|
739
|
|
- if (dx < 0) SBI(db, X_HEAD); // Save the real Extruder (head) direction in X Axis
|
740
|
|
- if (dy < 0) SBI(db, Y_HEAD); // ...and Y
|
741
|
|
- if (dz < 0) SBI(db, Z_AXIS);
|
742
|
|
- if (dx + dy < 0) SBI(db, A_AXIS); // Motor A direction
|
743
|
|
- if (dx - dy < 0) SBI(db, B_AXIS); // Motor B direction
|
|
727
|
+ if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis
|
|
728
|
+ if (db < 0) SBI(dm, Y_HEAD); // ...and Y
|
|
729
|
+ if (dc < 0) SBI(dm, Z_AXIS);
|
|
730
|
+ if (da + db < 0) SBI(dm, A_AXIS); // Motor A direction
|
|
731
|
+ if (da - db < 0) SBI(dm, B_AXIS); // Motor B direction
|
744
|
732
|
#elif ENABLED(COREXZ)
|
745
|
|
- if (dx < 0) SBI(db, X_HEAD); // Save the real Extruder (head) direction in X Axis
|
746
|
|
- if (dy < 0) SBI(db, Y_AXIS);
|
747
|
|
- if (dz < 0) SBI(db, Z_HEAD); // ...and Z
|
748
|
|
- if (dx + dz < 0) SBI(db, A_AXIS); // Motor A direction
|
749
|
|
- if (dx - dz < 0) SBI(db, C_AXIS); // Motor C direction
|
|
733
|
+ if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis
|
|
734
|
+ if (db < 0) SBI(dm, Y_AXIS);
|
|
735
|
+ if (dc < 0) SBI(dm, Z_HEAD); // ...and Z
|
|
736
|
+ if (da + dc < 0) SBI(dm, A_AXIS); // Motor A direction
|
|
737
|
+ if (da - dc < 0) SBI(dm, C_AXIS); // Motor C direction
|
750
|
738
|
#elif ENABLED(COREYZ)
|
751
|
|
- if (dx < 0) SBI(db, X_AXIS);
|
752
|
|
- if (dy < 0) SBI(db, Y_HEAD); // Save the real Extruder (head) direction in Y Axis
|
753
|
|
- if (dz < 0) SBI(db, Z_HEAD); // ...and Z
|
754
|
|
- if (dy + dz < 0) SBI(db, B_AXIS); // Motor B direction
|
755
|
|
- if (dy - dz < 0) SBI(db, C_AXIS); // Motor C direction
|
|
739
|
+ if (da < 0) SBI(dm, X_AXIS);
|
|
740
|
+ if (db < 0) SBI(dm, Y_HEAD); // Save the real Extruder (head) direction in Y Axis
|
|
741
|
+ if (dc < 0) SBI(dm, Z_HEAD); // ...and Z
|
|
742
|
+ if (db + dc < 0) SBI(dm, B_AXIS); // Motor B direction
|
|
743
|
+ if (db - dc < 0) SBI(dm, C_AXIS); // Motor C direction
|
756
|
744
|
#else
|
757
|
|
- if (dx < 0) SBI(db, X_AXIS);
|
758
|
|
- if (dy < 0) SBI(db, Y_AXIS);
|
759
|
|
- if (dz < 0) SBI(db, Z_AXIS);
|
|
745
|
+ if (da < 0) SBI(dm, X_AXIS);
|
|
746
|
+ if (db < 0) SBI(dm, Y_AXIS);
|
|
747
|
+ if (dc < 0) SBI(dm, Z_AXIS);
|
760
|
748
|
#endif
|
761
|
|
- if (de < 0) SBI(db, E_AXIS);
|
762
|
|
- block->direction_bits = db;
|
|
749
|
+ if (de < 0) SBI(dm, E_AXIS);
|
|
750
|
+ block->direction_bits = dm;
|
763
|
751
|
|
764
|
752
|
block->active_extruder = extruder;
|
765
|
753
|
|
|
@@ -872,29 +860,29 @@ void Planner::buffer_line(ARG_X, ARG_Y, ARG_Z, const float &e, float fr_mm_s, co
|
872
|
860
|
#if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ)
|
873
|
861
|
float delta_mm[7];
|
874
|
862
|
#if ENABLED(COREXY)
|
875
|
|
- delta_mm[X_HEAD] = dx * steps_to_mm[A_AXIS];
|
876
|
|
- delta_mm[Y_HEAD] = dy * steps_to_mm[B_AXIS];
|
877
|
|
- delta_mm[Z_AXIS] = dz * steps_to_mm[Z_AXIS];
|
878
|
|
- delta_mm[A_AXIS] = (dx + dy) * steps_to_mm[A_AXIS];
|
879
|
|
- delta_mm[B_AXIS] = (dx - dy) * steps_to_mm[B_AXIS];
|
|
863
|
+ delta_mm[X_HEAD] = da * steps_to_mm[A_AXIS];
|
|
864
|
+ delta_mm[Y_HEAD] = db * steps_to_mm[B_AXIS];
|
|
865
|
+ delta_mm[Z_AXIS] = dc * steps_to_mm[Z_AXIS];
|
|
866
|
+ delta_mm[A_AXIS] = (da + db) * steps_to_mm[A_AXIS];
|
|
867
|
+ delta_mm[B_AXIS] = (da - db) * steps_to_mm[B_AXIS];
|
880
|
868
|
#elif ENABLED(COREXZ)
|
881
|
|
- delta_mm[X_HEAD] = dx * steps_to_mm[A_AXIS];
|
882
|
|
- delta_mm[Y_AXIS] = dy * steps_to_mm[Y_AXIS];
|
883
|
|
- delta_mm[Z_HEAD] = dz * steps_to_mm[C_AXIS];
|
884
|
|
- delta_mm[A_AXIS] = (dx + dz) * steps_to_mm[A_AXIS];
|
885
|
|
- delta_mm[C_AXIS] = (dx - dz) * steps_to_mm[C_AXIS];
|
|
869
|
+ delta_mm[X_HEAD] = da * steps_to_mm[A_AXIS];
|
|
870
|
+ delta_mm[Y_AXIS] = db * steps_to_mm[Y_AXIS];
|
|
871
|
+ delta_mm[Z_HEAD] = dc * steps_to_mm[C_AXIS];
|
|
872
|
+ delta_mm[A_AXIS] = (da + dc) * steps_to_mm[A_AXIS];
|
|
873
|
+ delta_mm[C_AXIS] = (da - dc) * steps_to_mm[C_AXIS];
|
886
|
874
|
#elif ENABLED(COREYZ)
|
887
|
|
- delta_mm[X_AXIS] = dx * steps_to_mm[X_AXIS];
|
888
|
|
- delta_mm[Y_HEAD] = dy * steps_to_mm[B_AXIS];
|
889
|
|
- delta_mm[Z_HEAD] = dz * steps_to_mm[C_AXIS];
|
890
|
|
- delta_mm[B_AXIS] = (dy + dz) * steps_to_mm[B_AXIS];
|
891
|
|
- delta_mm[C_AXIS] = (dy - dz) * steps_to_mm[C_AXIS];
|
|
875
|
+ delta_mm[X_AXIS] = da * steps_to_mm[X_AXIS];
|
|
876
|
+ delta_mm[Y_HEAD] = db * steps_to_mm[B_AXIS];
|
|
877
|
+ delta_mm[Z_HEAD] = dc * steps_to_mm[C_AXIS];
|
|
878
|
+ delta_mm[B_AXIS] = (db + dc) * steps_to_mm[B_AXIS];
|
|
879
|
+ delta_mm[C_AXIS] = (db - dc) * steps_to_mm[C_AXIS];
|
892
|
880
|
#endif
|
893
|
881
|
#else
|
894
|
882
|
float delta_mm[4];
|
895
|
|
- delta_mm[X_AXIS] = dx * steps_to_mm[X_AXIS];
|
896
|
|
- delta_mm[Y_AXIS] = dy * steps_to_mm[Y_AXIS];
|
897
|
|
- delta_mm[Z_AXIS] = dz * steps_to_mm[Z_AXIS];
|
|
883
|
+ delta_mm[X_AXIS] = da * steps_to_mm[X_AXIS];
|
|
884
|
+ delta_mm[Y_AXIS] = db * steps_to_mm[Y_AXIS];
|
|
885
|
+ delta_mm[Z_AXIS] = dc * steps_to_mm[Z_AXIS];
|
898
|
886
|
#endif
|
899
|
887
|
delta_mm[E_AXIS] = 0.01 * (de * steps_to_mm[E_AXIS]) * volumetric_multiplier[extruder] * flow_percentage[extruder];
|
900
|
888
|
|
|
@@ -1196,22 +1184,34 @@ void Planner::buffer_line(ARG_X, ARG_Y, ARG_Z, const float &e, float fr_mm_s, co
|
1196
|
1184
|
*
|
1197
|
1185
|
* On CORE machines stepper ABC will be translated from the given XYZ.
|
1198
|
1186
|
*/
|
1199
|
|
-void Planner::set_position_mm(ARG_X, ARG_Y, ARG_Z, const float &e) {
|
1200
|
1187
|
|
1201
|
|
- #if PLANNER_LEVELING
|
1202
|
|
- apply_leveling(lx, ly, lz);
|
1203
|
|
- #endif
|
1204
|
|
-
|
1205
|
|
- long nx = position[X_AXIS] = lround(lx * axis_steps_per_mm[X_AXIS]),
|
1206
|
|
- ny = position[Y_AXIS] = lround(ly * axis_steps_per_mm[Y_AXIS]),
|
1207
|
|
- nz = position[Z_AXIS] = lround(lz * axis_steps_per_mm[Z_AXIS]),
|
|
1188
|
+void Planner::_set_position_mm(const float &a, const float &b, const float &c, const float &e) {
|
|
1189
|
+ long na = position[X_AXIS] = lround(a * axis_steps_per_mm[X_AXIS]),
|
|
1190
|
+ nb = position[Y_AXIS] = lround(b * axis_steps_per_mm[Y_AXIS]),
|
|
1191
|
+ nc = position[Z_AXIS] = lround(c * axis_steps_per_mm[Z_AXIS]),
|
1208
|
1192
|
ne = position[E_AXIS] = lround(e * axis_steps_per_mm[E_AXIS]);
|
1209
|
|
- stepper.set_position(nx, ny, nz, ne);
|
|
1193
|
+ stepper.set_position(na, nb, nc, ne);
|
1210
|
1194
|
previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
|
1211
|
1195
|
|
1212
|
1196
|
memset(previous_speed, 0, sizeof(previous_speed));
|
1213
|
1197
|
}
|
1214
|
1198
|
|
|
1199
|
+void Planner::set_position_mm_kinematic(const float position[NUM_AXIS]) {
|
|
1200
|
+ #if PLANNER_LEVELING
|
|
1201
|
+ float pos[XYZ] = { position[X_AXIS], position[Y_AXIS], position[Z_AXIS] };
|
|
1202
|
+ apply_leveling(pos);
|
|
1203
|
+ #else
|
|
1204
|
+ const float * const pos = position;
|
|
1205
|
+ #endif
|
|
1206
|
+ #if IS_KINEMATIC
|
|
1207
|
+ inverse_kinematics(pos);
|
|
1208
|
+ _set_position_mm(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], position[E_AXIS]);
|
|
1209
|
+ #else
|
|
1210
|
+ _set_position_mm(pos[X_AXIS], pos[Y_AXIS], pos[Z_AXIS], position[E_AXIS]);
|
|
1211
|
+ #endif
|
|
1212
|
+}
|
|
1213
|
+
|
|
1214
|
+
|
1215
|
1215
|
/**
|
1216
|
1216
|
* Sync from the stepper positions. (e.g., after an interrupted move)
|
1217
|
1217
|
*/
|
|
@@ -1237,12 +1237,7 @@ void Planner::reset_acceleration_rates() {
|
1237
|
1237
|
// Recalculate position, steps_to_mm if axis_steps_per_mm changes!
|
1238
|
1238
|
void Planner::refresh_positioning() {
|
1239
|
1239
|
LOOP_XYZE(i) steps_to_mm[i] = 1.0 / axis_steps_per_mm[i];
|
1240
|
|
- #if IS_KINEMATIC
|
1241
|
|
- inverse_kinematics(current_position);
|
1242
|
|
- set_position_mm(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], current_position[E_AXIS]);
|
1243
|
|
- #else
|
1244
|
|
- set_position_mm(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
1245
|
|
- #endif
|
|
1240
|
+ set_position_mm_kinematic(current_position);
|
1246
|
1241
|
reset_acceleration_rates();
|
1247
|
1242
|
}
|
1248
|
1243
|
|