|
@@ -594,13 +594,14 @@ void Planner::check_axes_activity() {
|
594
|
594
|
* Planner::_buffer_line
|
595
|
595
|
*
|
596
|
596
|
* Add a new linear movement to the buffer.
|
597
|
|
- * Not apply the leveling.
|
598
|
597
|
*
|
599
|
|
- * x,y,z,e - target position in mm
|
600
|
|
- * fr_mm_s - (target) speed of the move
|
601
|
|
- * 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
|
602
|
603
|
*/
|
603
|
|
-void Planner::_buffer_line(const float &lx, const float &ly, const float &lz, 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) {
|
604
|
605
|
// Calculate the buffer head after we push this byte
|
605
|
606
|
int next_buffer_head = next_block_index(block_buffer_head);
|
606
|
607
|
|
|
@@ -611,36 +612,36 @@ void Planner::_buffer_line(const float &lx, const float &ly, const float &lz, co
|
611
|
612
|
// The target position of the tool in absolute steps
|
612
|
613
|
// Calculate target position in absolute steps
|
613
|
614
|
//this should be done after the wait, because otherwise a M92 code within the gcode disrupts this calculation somehow
|
614
|
|
- long target[NUM_AXIS] = {
|
615
|
|
- lround(lx * axis_steps_per_mm[X_AXIS]),
|
616
|
|
- lround(ly * axis_steps_per_mm[Y_AXIS]),
|
617
|
|
- 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]),
|
618
|
619
|
lround(e * axis_steps_per_mm[E_AXIS])
|
619
|
620
|
};
|
620
|
621
|
|
621
|
|
- long dx = target[X_AXIS] - position[X_AXIS],
|
622
|
|
- dy = target[Y_AXIS] - position[Y_AXIS],
|
623
|
|
- 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];
|
624
|
625
|
|
625
|
626
|
/*
|
626
|
627
|
SERIAL_ECHOPAIR(" Planner FR:", fr_mm_s);
|
627
|
628
|
SERIAL_CHAR(' ');
|
628
|
629
|
#if IS_KINEMATIC
|
629
|
|
- SERIAL_ECHOPAIR("A:", lx);
|
630
|
|
- SERIAL_ECHOPAIR(" (", dx);
|
631
|
|
- SERIAL_ECHOPAIR(") B:", ly);
|
|
630
|
+ SERIAL_ECHOPAIR("A:", a);
|
|
631
|
+ SERIAL_ECHOPAIR(" (", da);
|
|
632
|
+ SERIAL_ECHOPAIR(") B:", b);
|
632
|
633
|
#else
|
633
|
|
- SERIAL_ECHOPAIR("X:", lx);
|
634
|
|
- SERIAL_ECHOPAIR(" (", dx);
|
635
|
|
- SERIAL_ECHOPAIR(") Y:", ly);
|
|
634
|
+ SERIAL_ECHOPAIR("X:", a);
|
|
635
|
+ SERIAL_ECHOPAIR(" (", da);
|
|
636
|
+ SERIAL_ECHOPAIR(") Y:", b);
|
636
|
637
|
#endif
|
637
|
|
- SERIAL_ECHOPAIR(" (", dy);
|
|
638
|
+ SERIAL_ECHOPAIR(" (", db);
|
638
|
639
|
#if ENABLED(DELTA)
|
639
|
|
- SERIAL_ECHOPAIR(") C:", lz);
|
|
640
|
+ SERIAL_ECHOPAIR(") C:", c);
|
640
|
641
|
#else
|
641
|
|
- SERIAL_ECHOPAIR(") Z:", lz);
|
|
642
|
+ SERIAL_ECHOPAIR(") Z:", c);
|
642
|
643
|
#endif
|
643
|
|
- SERIAL_ECHOPAIR(" (", dz);
|
|
644
|
+ SERIAL_ECHOPAIR(" (", dc);
|
644
|
645
|
SERIAL_CHAR(')');
|
645
|
646
|
SERIAL_EOL;
|
646
|
647
|
//*/
|
|
@@ -679,24 +680,24 @@ void Planner::_buffer_line(const float &lx, const float &ly, const float &lz, co
|
679
|
680
|
#if ENABLED(COREXY)
|
680
|
681
|
// corexy planning
|
681
|
682
|
// these equations follow the form of the dA and dB equations on http://www.corexy.com/theory.html
|
682
|
|
- block->steps[A_AXIS] = labs(dx + dy);
|
683
|
|
- block->steps[B_AXIS] = labs(dx - dy);
|
684
|
|
- 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);
|
685
|
686
|
#elif ENABLED(COREXZ)
|
686
|
687
|
// corexz planning
|
687
|
|
- block->steps[A_AXIS] = labs(dx + dz);
|
688
|
|
- block->steps[Y_AXIS] = labs(dy);
|
689
|
|
- 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);
|
690
|
691
|
#elif ENABLED(COREYZ)
|
691
|
692
|
// coreyz planning
|
692
|
|
- block->steps[X_AXIS] = labs(dx);
|
693
|
|
- block->steps[B_AXIS] = labs(dy + dz);
|
694
|
|
- 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);
|
695
|
696
|
#else
|
696
|
697
|
// default non-h-bot planning
|
697
|
|
- block->steps[X_AXIS] = labs(dx);
|
698
|
|
- block->steps[Y_AXIS] = labs(dy);
|
699
|
|
- 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);
|
700
|
701
|
#endif
|
701
|
702
|
|
702
|
703
|
block->steps[E_AXIS] = labs(de) * volumetric_multiplier[extruder] * flow_percentage[extruder] * 0.01 + 0.5;
|
|
@@ -720,33 +721,33 @@ void Planner::_buffer_line(const float &lx, const float &ly, const float &lz, co
|
720
|
721
|
block->e_to_p_pressure = baricuda_e_to_p_pressure;
|
721
|
722
|
#endif
|
722
|
723
|
|
723
|
|
- // Compute direction bits for this block
|
724
|
|
- uint8_t db = 0;
|
|
724
|
+ // Compute direction bit-mask for this block
|
|
725
|
+ uint8_t dm = 0;
|
725
|
726
|
#if ENABLED(COREXY)
|
726
|
|
- if (dx < 0) SBI(db, X_HEAD); // Save the real Extruder (head) direction in X Axis
|
727
|
|
- if (dy < 0) SBI(db, Y_HEAD); // ...and Y
|
728
|
|
- if (dz < 0) SBI(db, Z_AXIS);
|
729
|
|
- if (dx + dy < 0) SBI(db, A_AXIS); // Motor A direction
|
730
|
|
- 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
|
731
|
732
|
#elif ENABLED(COREXZ)
|
732
|
|
- if (dx < 0) SBI(db, X_HEAD); // Save the real Extruder (head) direction in X Axis
|
733
|
|
- if (dy < 0) SBI(db, Y_AXIS);
|
734
|
|
- if (dz < 0) SBI(db, Z_HEAD); // ...and Z
|
735
|
|
- if (dx + dz < 0) SBI(db, A_AXIS); // Motor A direction
|
736
|
|
- 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
|
737
|
738
|
#elif ENABLED(COREYZ)
|
738
|
|
- if (dx < 0) SBI(db, X_AXIS);
|
739
|
|
- if (dy < 0) SBI(db, Y_HEAD); // Save the real Extruder (head) direction in Y Axis
|
740
|
|
- if (dz < 0) SBI(db, Z_HEAD); // ...and Z
|
741
|
|
- if (dy + dz < 0) SBI(db, B_AXIS); // Motor B direction
|
742
|
|
- 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
|
743
|
744
|
#else
|
744
|
|
- if (dx < 0) SBI(db, X_AXIS);
|
745
|
|
- if (dy < 0) SBI(db, Y_AXIS);
|
746
|
|
- 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);
|
747
|
748
|
#endif
|
748
|
|
- if (de < 0) SBI(db, E_AXIS);
|
749
|
|
- block->direction_bits = db;
|
|
749
|
+ if (de < 0) SBI(dm, E_AXIS);
|
|
750
|
+ block->direction_bits = dm;
|
750
|
751
|
|
751
|
752
|
block->active_extruder = extruder;
|
752
|
753
|
|
|
@@ -859,29 +860,29 @@ void Planner::_buffer_line(const float &lx, const float &ly, const float &lz, co
|
859
|
860
|
#if ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(COREYZ)
|
860
|
861
|
float delta_mm[7];
|
861
|
862
|
#if ENABLED(COREXY)
|
862
|
|
- delta_mm[X_HEAD] = dx * steps_to_mm[A_AXIS];
|
863
|
|
- delta_mm[Y_HEAD] = dy * steps_to_mm[B_AXIS];
|
864
|
|
- delta_mm[Z_AXIS] = dz * steps_to_mm[Z_AXIS];
|
865
|
|
- delta_mm[A_AXIS] = (dx + dy) * steps_to_mm[A_AXIS];
|
866
|
|
- 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];
|
867
|
868
|
#elif ENABLED(COREXZ)
|
868
|
|
- delta_mm[X_HEAD] = dx * steps_to_mm[A_AXIS];
|
869
|
|
- delta_mm[Y_AXIS] = dy * steps_to_mm[Y_AXIS];
|
870
|
|
- delta_mm[Z_HEAD] = dz * steps_to_mm[C_AXIS];
|
871
|
|
- delta_mm[A_AXIS] = (dx + dz) * steps_to_mm[A_AXIS];
|
872
|
|
- 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];
|
873
|
874
|
#elif ENABLED(COREYZ)
|
874
|
|
- delta_mm[X_AXIS] = dx * steps_to_mm[X_AXIS];
|
875
|
|
- delta_mm[Y_HEAD] = dy * steps_to_mm[B_AXIS];
|
876
|
|
- delta_mm[Z_HEAD] = dz * steps_to_mm[C_AXIS];
|
877
|
|
- delta_mm[B_AXIS] = (dy + dz) * steps_to_mm[B_AXIS];
|
878
|
|
- 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];
|
879
|
880
|
#endif
|
880
|
881
|
#else
|
881
|
882
|
float delta_mm[4];
|
882
|
|
- delta_mm[X_AXIS] = dx * steps_to_mm[X_AXIS];
|
883
|
|
- delta_mm[Y_AXIS] = dy * steps_to_mm[Y_AXIS];
|
884
|
|
- 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];
|
885
|
886
|
#endif
|
886
|
887
|
delta_mm[E_AXIS] = 0.01 * (de * steps_to_mm[E_AXIS]) * volumetric_multiplier[extruder] * flow_percentage[extruder];
|
887
|
888
|
|
|
@@ -1184,12 +1185,12 @@ void Planner::_buffer_line(const float &lx, const float &ly, const float &lz, co
|
1184
|
1185
|
* On CORE machines stepper ABC will be translated from the given XYZ.
|
1185
|
1186
|
*/
|
1186
|
1187
|
|
1187
|
|
-void Planner::_set_position_mm(const float &lx, const float &ly, const float &lz, const float &e) {
|
1188
|
|
- long nx = position[X_AXIS] = lround(lx * axis_steps_per_mm[X_AXIS]),
|
1189
|
|
- ny = position[Y_AXIS] = lround(ly * axis_steps_per_mm[Y_AXIS]),
|
1190
|
|
- 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]),
|
1191
|
1192
|
ne = position[E_AXIS] = lround(e * axis_steps_per_mm[E_AXIS]);
|
1192
|
|
- stepper.set_position(nx, ny, nz, ne);
|
|
1193
|
+ stepper.set_position(na, nb, nc, ne);
|
1193
|
1194
|
previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
|
1194
|
1195
|
|
1195
|
1196
|
memset(previous_speed, 0, sizeof(previous_speed));
|