Browse Source

Scale feedrate (mm/s to deg/s) for SCARA

Scott Lahteine 7 years ago
parent
commit
e8e60263c8

+ 1
- 1
.travis.yml View File

315
   # SCARA with TMC2130
315
   # SCARA with TMC2130
316
   #
316
   #
317
   - use_example_configs SCARA
317
   - use_example_configs SCARA
318
-  - opt_enable AUTO_BED_LEVELING_BILINEAR FIX_MOUNTED_PROBE USE_ZMIN_PLUG EEPROM_SETTINGS EEPROM_CHITCHAT ULTIMAKERCONTROLLER
318
+  - opt_enable AUTO_BED_LEVELING_BILINEAR FIX_MOUNTED_PROBE USE_ZMIN_PLUG EEPROM_SETTINGS EEPROM_CHITCHAT ULTIMAKERCONTROLLER SCARA_FEEDRATE_SCALING
319
   - opt_enable_adv HAVE_TMC2130 X_IS_TMC2130 Y_IS_TMC2130 Z_IS_TMC2130
319
   - opt_enable_adv HAVE_TMC2130 X_IS_TMC2130 Y_IS_TMC2130 Z_IS_TMC2130
320
   - opt_enable_adv MONITOR_DRIVER_STATUS STEALTHCHOP HYBRID_THRESHOLD SENSORLESS_HOMING
320
   - opt_enable_adv MONITOR_DRIVER_STATUS STEALTHCHOP HYBRID_THRESHOLD SENSORLESS_HOMING
321
   - build_marlin_pio ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM}
321
   - build_marlin_pio ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM}

+ 2
- 0
Marlin/src/config/examples/SCARA/Configuration.h View File

72
 //#define MAKERARM_SCARA
72
 //#define MAKERARM_SCARA
73
 
73
 
74
 #if ENABLED(MORGAN_SCARA) || ENABLED(MAKERARM_SCARA)
74
 #if ENABLED(MORGAN_SCARA) || ENABLED(MAKERARM_SCARA)
75
+
75
   //#define DEBUG_SCARA_KINEMATICS
76
   //#define DEBUG_SCARA_KINEMATICS
77
+  #define SCARA_FEEDRATE_SCALING // Convert XY feedrate from mm/s to degrees/s on the fly
76
 
78
 
77
   // If movement is choppy try lowering this value
79
   // If movement is choppy try lowering this value
78
   #define SCARA_SEGMENTS_PER_SECOND 200
80
   #define SCARA_SEGMENTS_PER_SECOND 200

+ 31
- 2
Marlin/src/gcode/motion/G2_G3.cpp View File

35
   #include "../../module/scara.h"
35
   #include "../../module/scara.h"
36
 #endif
36
 #endif
37
 
37
 
38
+#if ENABLED(SCARA_FEEDRATE_SCALING) && ENABLED(AUTO_BED_LEVELING_BILINEAR)
39
+  #include "../../feature/bedlevel/abl/abl.h"
40
+#endif
41
+
38
 #if N_ARC_CORRECTION < 1
42
 #if N_ARC_CORRECTION < 1
39
   #undef N_ARC_CORRECTION
43
   #undef N_ARC_CORRECTION
40
   #define N_ARC_CORRECTION 1
44
   #define N_ARC_CORRECTION 1
137
 
141
 
138
   millis_t next_idle_ms = millis() + 200UL;
142
   millis_t next_idle_ms = millis() + 200UL;
139
 
143
 
144
+  #if ENABLED(SCARA_FEEDRATE_SCALING)
145
+    // SCARA needs to scale the feed rate from mm/s to degrees/s
146
+    const float inv_segment_length = 1.0 / (MM_PER_ARC_SEGMENT),
147
+                inverse_secs = inv_segment_length * fr_mm_s;
148
+    float oldA = planner.position_float[A_AXIS],
149
+          oldB = planner.position_float[B_AXIS];
150
+  #endif
151
+
140
   #if N_ARC_CORRECTION > 1
152
   #if N_ARC_CORRECTION > 1
141
     int8_t arc_recalc_count = N_ARC_CORRECTION;
153
     int8_t arc_recalc_count = N_ARC_CORRECTION;
142
   #endif
154
   #endif
180
 
192
 
181
     clamp_to_software_endstops(raw);
193
     clamp_to_software_endstops(raw);
182
 
194
 
183
-    planner.buffer_line_kinematic(raw, fr_mm_s, active_extruder);
195
+    #if ENABLED(SCARA_FEEDRATE_SCALING)
196
+      // For SCARA scale the feed rate from mm/s to degrees/s
197
+      // i.e., Complete the angular vector in the given time.
198
+      inverse_kinematics(raw);
199
+      ADJUST_DELTA(raw);
200
+      planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], raw[Z_AXIS], raw[E_AXIS], HYPOT(delta[A_AXIS] - oldA, delta[B_AXIS] - oldB) * inverse_secs, active_extruder);
201
+      oldA = delta[A_AXIS]; oldB = delta[B_AXIS];
202
+    #else
203
+      planner.buffer_line_kinematic(raw, fr_mm_s, active_extruder);
204
+    #endif
184
   }
205
   }
185
 
206
 
186
   // Ensure last segment arrives at target location.
207
   // Ensure last segment arrives at target location.
187
-  planner.buffer_line_kinematic(cart, fr_mm_s, active_extruder);
208
+  #if ENABLED(SCARA_FEEDRATE_SCALING)
209
+    inverse_kinematics(cart);
210
+    ADJUST_DELTA(cart);
211
+    const float diff2 = HYPOT2(delta[A_AXIS] - oldA, delta[B_AXIS] - oldB);
212
+    if (diff2)
213
+      planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], cart[Z_AXIS], cart[E_AXIS], SQRT(diff2) * inverse_secs, active_extruder);
214
+  #else
215
+    planner.buffer_line_kinematic(cart, fr_mm_s, active_extruder);
216
+  #endif
188
 
217
 
189
   // As far as the parser is concerned, the position is now == target. In reality the
218
   // As far as the parser is concerned, the position is now == target. In reality the
190
   // motion control system might still be processing the action and the real tool position
219
   // motion control system might still be processing the action and the real tool position

+ 83
- 25
Marlin/src/module/motion.cpp View File

498
 #if !UBL_SEGMENTED
498
 #if !UBL_SEGMENTED
499
 #if IS_KINEMATIC
499
 #if IS_KINEMATIC
500
 
500
 
501
-  #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
502
-    #if ENABLED(DELTA)
503
-      #define ADJUST_DELTA(V) \
504
-        if (planner.leveling_active) { \
505
-          const float zadj = bilinear_z_offset(V); \
506
-          delta[A_AXIS] += zadj; \
507
-          delta[B_AXIS] += zadj; \
508
-          delta[C_AXIS] += zadj; \
509
-        }
510
-    #else
511
-      #define ADJUST_DELTA(V) if (planner.leveling_active) { delta[Z_AXIS] += bilinear_z_offset(V); }
512
-    #endif
513
-  #else
514
-    #define ADJUST_DELTA(V) NOOP
501
+  #if IS_SCARA
502
+    /**
503
+     * Before raising this value, use M665 S[seg_per_sec] to decrease
504
+     * the number of segments-per-second. Default is 200. Some deltas
505
+     * do better with 160 or lower. It would be good to know how many
506
+     * segments-per-second are actually possible for SCARA on AVR.
507
+     *
508
+     * Longer segments result in less kinematic overhead
509
+     * but may produce jagged lines. Try 0.5mm, 1.0mm, and 2.0mm
510
+     * and compare the difference.
511
+     */
512
+    #define SCARA_MIN_SEGMENT_LENGTH 0.5
515
   #endif
513
   #endif
516
 
514
 
517
   /**
515
   /**
566
     // gives the number of segments
564
     // gives the number of segments
567
     uint16_t segments = delta_segments_per_second * seconds;
565
     uint16_t segments = delta_segments_per_second * seconds;
568
 
566
 
569
-    // For SCARA minimum segment size is 0.25mm
567
+    // For SCARA enforce a minimum segment size
570
     #if IS_SCARA
568
     #if IS_SCARA
571
-      NOMORE(segments, cartesian_mm * 4);
569
+      NOMORE(segments, cartesian_mm * (1.0 / SCARA_MIN_SEGMENT_LENGTH));
572
     #endif
570
     #endif
573
 
571
 
574
     // At least one segment is required
572
     // At least one segment is required
576
 
574
 
577
     // The approximate length of each segment
575
     // The approximate length of each segment
578
     const float inv_segments = 1.0 / float(segments),
576
     const float inv_segments = 1.0 / float(segments),
579
-                cartesian_segment_mm = cartesian_mm * inv_segments,
580
                 segment_distance[XYZE] = {
577
                 segment_distance[XYZE] = {
581
                   xdiff * inv_segments,
578
                   xdiff * inv_segments,
582
                   ydiff * inv_segments,
579
                   ydiff * inv_segments,
584
                   ediff * inv_segments
581
                   ediff * inv_segments
585
                 };
582
                 };
586
 
583
 
587
-    // SERIAL_ECHOPAIR("mm=", cartesian_mm);
588
-    // SERIAL_ECHOPAIR(" seconds=", seconds);
589
-    // SERIAL_ECHOLNPAIR(" segments=", segments);
590
-    // SERIAL_ECHOLNPAIR(" segment_mm=", cartesian_segment_mm);
584
+    #if DISABLED(SCARA_FEEDRATE_SCALING)
585
+      const float cartesian_segment_mm = cartesian_mm * inv_segments;
586
+    #endif
591
 
587
 
592
-    // Get the current position as starting point
588
+    /*
589
+    SERIAL_ECHOPAIR("mm=", cartesian_mm);
590
+    SERIAL_ECHOPAIR(" seconds=", seconds);
591
+    SERIAL_ECHOPAIR(" segments=", segments);
592
+    #if DISABLED(SCARA_FEEDRATE_SCALING)
593
+      SERIAL_ECHOLNPAIR(" segment_mm=", cartesian_segment_mm);
594
+    #else
595
+      SERIAL_EOL();
596
+    #endif
597
+    //*/
598
+
599
+    #if ENABLED(SCARA_FEEDRATE_SCALING)
600
+      // SCARA needs to scale the feed rate from mm/s to degrees/s
601
+      // i.e., Complete the angular vector in the given time.
602
+      const float segment_length = cartesian_mm * inv_segments,
603
+                  inv_segment_length = 1.0 / segment_length, // 1/mm/segs
604
+                  inverse_secs = inv_segment_length * _feedrate_mm_s;
605
+
606
+      float oldA = planner.position_float[A_AXIS],
607
+            oldB = planner.position_float[B_AXIS];
608
+
609
+      /*
610
+      SERIAL_ECHOPGM("Scaled kinematic move: ");
611
+      SERIAL_ECHOPAIR(" segment_length (inv)=", segment_length);
612
+      SERIAL_ECHOPAIR(" (", inv_segment_length);
613
+      SERIAL_ECHOPAIR(") _feedrate_mm_s=", _feedrate_mm_s);
614
+      SERIAL_ECHOPAIR(" inverse_secs=", inverse_secs);
615
+      SERIAL_ECHOPAIR(" oldA=", oldA);
616
+      SERIAL_ECHOLNPAIR(" oldB=", oldB);
617
+      safe_delay(5);
618
+      //*/
619
+    #endif
620
+ 
621
+     // Get the current position as starting point
593
     float raw[XYZE];
622
     float raw[XYZE];
594
     COPY(raw, current_position);
623
     COPY(raw, current_position);
595
 
624
 
596
-
597
     // Calculate and execute the segments
625
     // Calculate and execute the segments
598
     while (--segments) {
626
     while (--segments) {
599
 
627
 
613
       #endif
641
       #endif
614
       ADJUST_DELTA(raw); // Adjust Z if bed leveling is enabled
642
       ADJUST_DELTA(raw); // Adjust Z if bed leveling is enabled
615
 
643
 
616
-      planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], raw[E_AXIS], _feedrate_mm_s, active_extruder, cartesian_segment_mm);
644
+      #if ENABLED(SCARA_FEEDRATE_SCALING)
645
+        // For SCARA scale the feed rate from mm/s to degrees/s
646
+        // i.e., Complete the angular vector in the given time.
647
+        planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], raw[Z_AXIS], raw[E_AXIS], HYPOT(delta[A_AXIS] - oldA, delta[B_AXIS] - oldB) * inverse_secs, active_extruder);
648
+        /*
649
+        SERIAL_ECHO(segments);
650
+        SERIAL_ECHOPAIR(": X=", raw[X_AXIS]); SERIAL_ECHOPAIR(" Y=", raw[Y_AXIS]);
651
+        SERIAL_ECHOPAIR(" A=", delta[A_AXIS]); SERIAL_ECHOPAIR(" B=", delta[B_AXIS]);
652
+        SERIAL_ECHOLNPAIR(" F", HYPOT(delta[A_AXIS] - oldA, delta[B_AXIS] - oldB) * inverse_secs * 60);
653
+        safe_delay(5);
654
+        //*/
655
+        oldA = delta[A_AXIS]; oldB = delta[B_AXIS];
656
+      #else
657
+        planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], raw[E_AXIS], _feedrate_mm_s, active_extruder, cartesian_segment_mm);
658
+      #endif
617
     }
659
     }
618
 
660
 
619
     // Ensure last segment arrives at target location.
661
     // Ensure last segment arrives at target location.
620
-    planner.buffer_line_kinematic(rtarget, _feedrate_mm_s, active_extruder, cartesian_segment_mm);
662
+    #if ENABLED(SCARA_FEEDRATE_SCALING)
663
+      inverse_kinematics(rtarget);
664
+      ADJUST_DELTA(rtarget);
665
+      const float diff2 = HYPOT2(delta[A_AXIS] - oldA, delta[B_AXIS] - oldB);
666
+      if (diff2) {
667
+        planner.buffer_segment(delta[A_AXIS], delta[B_AXIS], rtarget[Z_AXIS], rtarget[E_AXIS], SQRT(diff2) * inverse_secs, active_extruder);
668
+        /*
669
+        SERIAL_ECHOPAIR("final: A=", delta[A_AXIS]); SERIAL_ECHOPAIR(" B=", delta[B_AXIS]);
670
+        SERIAL_ECHOPAIR(" adiff=", delta[A_AXIS] - oldA); SERIAL_ECHOPAIR(" bdiff=", delta[B_AXIS] - oldB);
671
+        SERIAL_ECHOLNPAIR(" F", (SQRT(diff2) * inverse_secs) * 60);
672
+        SERIAL_EOL();
673
+        safe_delay(5);
674
+        //*/
675
+      }
676
+    #else
677
+      planner.buffer_line_kinematic(rtarget, _feedrate_mm_s, active_extruder, cartesian_segment_mm);
678
+    #endif
621
 
679
 
622
     return false; // caller will update current_position
680
     return false; // caller will update current_position
623
   }
681
   }

+ 16
- 0
Marlin/src/module/motion.h View File

340
   void set_home_offset(const AxisEnum axis, const float v);
340
   void set_home_offset(const AxisEnum axis, const float v);
341
 #endif
341
 #endif
342
 
342
 
343
+#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
344
+  #if ENABLED(DELTA)
345
+    #define ADJUST_DELTA(V) \
346
+      if (planner.leveling_active) { \
347
+        const float zadj = bilinear_z_offset(V); \
348
+        delta[A_AXIS] += zadj; \
349
+        delta[B_AXIS] += zadj; \
350
+        delta[C_AXIS] += zadj; \
351
+      }
352
+  #else
353
+    #define ADJUST_DELTA(V) if (planner.leveling_active) { delta[Z_AXIS] += bilinear_z_offset(V); }
354
+  #endif
355
+#else
356
+  #define ADJUST_DELTA(V) NOOP
357
+#endif
358
+
343
 #endif // MOTION_H
359
 #endif // MOTION_H

+ 24
- 17
Marlin/src/module/planner.cpp View File

185
 #endif
185
 #endif
186
 
186
 
187
 #if ENABLED(LIN_ADVANCE)
187
 #if ENABLED(LIN_ADVANCE)
188
-  float Planner::extruder_advance_K, // Initialized by settings.load()
189
-        Planner::position_float[XYZE]; // Needed for accurate maths. Steps cannot be used!
188
+  float Planner::extruder_advance_K; // Initialized by settings.load()
189
+#endif
190
+
191
+#if HAS_POSITION_FLOAT
192
+  float Planner::position_float[XYZE]; // Needed for accurate maths. Steps cannot be used!
190
 #endif
193
 #endif
191
 
194
 
192
 #if ENABLED(ULTRA_LCD)
195
 #if ENABLED(ULTRA_LCD)
202
 void Planner::init() {
205
 void Planner::init() {
203
   block_buffer_head = block_buffer_tail = 0;
206
   block_buffer_head = block_buffer_tail = 0;
204
   ZERO(position);
207
   ZERO(position);
205
-  #if ENABLED(LIN_ADVANCE)
208
+  #if HAS_POSITION_FLOAT
206
     ZERO(position_float);
209
     ZERO(position_float);
207
   #endif
210
   #endif
208
   ZERO(previous_speed);
211
   ZERO(previous_speed);
745
  *  extruder    - target extruder
748
  *  extruder    - target extruder
746
  */
749
  */
747
 void Planner::_buffer_steps(const int32_t (&target)[XYZE]
750
 void Planner::_buffer_steps(const int32_t (&target)[XYZE]
748
-  #if ENABLED(LIN_ADVANCE)
751
+  #if HAS_POSITION_FLOAT
749
     , const float (&target_float)[XYZE]
752
     , const float (&target_float)[XYZE]
750
   #endif
753
   #endif
751
   , float fr_mm_s, const uint8_t extruder, const float &millimeters/*=0.0*/
754
   , float fr_mm_s, const uint8_t extruder, const float &millimeters/*=0.0*/
775
       #if ENABLED(PREVENT_COLD_EXTRUSION)
778
       #if ENABLED(PREVENT_COLD_EXTRUSION)
776
         if (thermalManager.tooColdToExtrude(extruder)) {
779
         if (thermalManager.tooColdToExtrude(extruder)) {
777
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
780
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
778
-          #if ENABLED(LIN_ADVANCE)
781
+          #if HAS_POSITION_FLOAT
779
             position_float[E_AXIS] = target_float[E_AXIS];
782
             position_float[E_AXIS] = target_float[E_AXIS];
780
           #endif
783
           #endif
781
           de = 0; // no difference
784
           de = 0; // no difference
786
       #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
789
       #if ENABLED(PREVENT_LENGTHY_EXTRUDE)
787
         if (labs(de * e_factor[extruder]) > (int32_t)axis_steps_per_mm[E_AXIS_N] * (EXTRUDE_MAXLENGTH)) { // It's not important to get max. extrusion length in a precision < 1mm, so save some cycles and cast to int
790
         if (labs(de * e_factor[extruder]) > (int32_t)axis_steps_per_mm[E_AXIS_N] * (EXTRUDE_MAXLENGTH)) { // It's not important to get max. extrusion length in a precision < 1mm, so save some cycles and cast to int
788
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
791
           position[E_AXIS] = target[E_AXIS]; // Behave as if the move really took place, but ignore E part
789
-          #if ENABLED(LIN_ADVANCE)
792
+          #if HAS_POSITION_FLOAT
790
             position_float[E_AXIS] = target_float[E_AXIS];
793
             position_float[E_AXIS] = target_float[E_AXIS];
791
           #endif
794
           #endif
792
           de = 0; // no difference
795
           de = 0; // no difference
857
     block->steps[X_AXIS] = labs(da);
860
     block->steps[X_AXIS] = labs(da);
858
     block->steps[B_AXIS] = labs(db + dc);
861
     block->steps[B_AXIS] = labs(db + dc);
859
     block->steps[C_AXIS] = labs(db - dc);
862
     block->steps[C_AXIS] = labs(db - dc);
863
+  #elif IS_SCARA
864
+    block->steps[A_AXIS] = labs(da);
865
+    block->steps[B_AXIS] = labs(db);
866
+    block->steps[Z_AXIS] = labs(dc);
860
   #else
867
   #else
861
     // default non-h-bot planning
868
     // default non-h-bot planning
862
     block->steps[A_AXIS] = labs(da);
869
     block->steps[A_AXIS] = labs(da);
892
       powerManager.power_on();
899
       powerManager.power_on();
893
   #endif
900
   #endif
894
 
901
 
895
-  //enable active axes
902
+  // Enable active axes
896
   #if CORE_IS_XY
903
   #if CORE_IS_XY
897
     if (block->steps[A_AXIS] || block->steps[B_AXIS]) {
904
     if (block->steps[A_AXIS] || block->steps[B_AXIS]) {
898
       enable_X();
905
       enable_X();
1463
   // Update the position (only when a move was queued)
1470
   // Update the position (only when a move was queued)
1464
   static_assert(COUNT(target) > 1, "Parameter to _buffer_steps must be (&target)[XYZE]!");
1471
   static_assert(COUNT(target) > 1, "Parameter to _buffer_steps must be (&target)[XYZE]!");
1465
   COPY(position, target);
1472
   COPY(position, target);
1466
-  #if ENABLED(LIN_ADVANCE)
1473
+  #if HAS_POSITION_FLOAT
1467
     COPY(position_float, target_float);
1474
     COPY(position_float, target_float);
1468
   #endif
1475
   #endif
1469
 
1476
 
1501
     LROUND(e * axis_steps_per_mm[E_AXIS_N])
1508
     LROUND(e * axis_steps_per_mm[E_AXIS_N])
1502
   };
1509
   };
1503
 
1510
 
1504
-  #if ENABLED(LIN_ADVANCE)
1511
+  #if HAS_POSITION_FLOAT
1505
     const float target_float[XYZE] = { a, b, c, e };
1512
     const float target_float[XYZE] = { a, b, c, e };
1506
   #endif
1513
   #endif
1507
 
1514
 
1508
   // DRYRUN prevents E moves from taking place
1515
   // DRYRUN prevents E moves from taking place
1509
   if (DEBUGGING(DRYRUN)) {
1516
   if (DEBUGGING(DRYRUN)) {
1510
     position[E_AXIS] = target[E_AXIS];
1517
     position[E_AXIS] = target[E_AXIS];
1511
-    #if ENABLED(LIN_ADVANCE)
1518
+    #if HAS_POSITION_FLOAT
1512
       position_float[E_AXIS] = e;
1519
       position_float[E_AXIS] = e;
1513
     #endif
1520
     #endif
1514
   }
1521
   }
1547
     #define _BETWEEN(A) (position[A##_AXIS] + target[A##_AXIS]) >> 1
1554
     #define _BETWEEN(A) (position[A##_AXIS] + target[A##_AXIS]) >> 1
1548
     const int32_t between[ABCE] = { _BETWEEN(A), _BETWEEN(B), _BETWEEN(C), _BETWEEN(E) };
1555
     const int32_t between[ABCE] = { _BETWEEN(A), _BETWEEN(B), _BETWEEN(C), _BETWEEN(E) };
1549
 
1556
 
1550
-    #if ENABLED(LIN_ADVANCE)
1557
+    #if HAS_POSITION_FLOAT
1551
       #define _BETWEEN_F(A) (position_float[A##_AXIS] + target_float[A##_AXIS]) * 0.5
1558
       #define _BETWEEN_F(A) (position_float[A##_AXIS] + target_float[A##_AXIS]) * 0.5
1552
       const float between_float[ABCE] = { _BETWEEN_F(A), _BETWEEN_F(B), _BETWEEN_F(C), _BETWEEN_F(E) };
1559
       const float between_float[ABCE] = { _BETWEEN_F(A), _BETWEEN_F(B), _BETWEEN_F(C), _BETWEEN_F(E) };
1553
     #endif
1560
     #endif
1555
     DISABLE_STEPPER_DRIVER_INTERRUPT();
1562
     DISABLE_STEPPER_DRIVER_INTERRUPT();
1556
 
1563
 
1557
     _buffer_steps(between
1564
     _buffer_steps(between
1558
-      #if ENABLED(LIN_ADVANCE)
1565
+      #if HAS_POSITION_FLOAT
1559
         , between_float
1566
         , between_float
1560
       #endif
1567
       #endif
1561
       , fr_mm_s, extruder, millimeters * 0.5
1568
       , fr_mm_s, extruder, millimeters * 0.5
1564
     const uint8_t next = block_buffer_head;
1571
     const uint8_t next = block_buffer_head;
1565
 
1572
 
1566
     _buffer_steps(target
1573
     _buffer_steps(target
1567
-      #if ENABLED(LIN_ADVANCE)
1574
+      #if HAS_POSITION_FLOAT
1568
         , target_float
1575
         , target_float
1569
       #endif
1576
       #endif
1570
       , fr_mm_s, extruder, millimeters * 0.5
1577
       , fr_mm_s, extruder, millimeters * 0.5
1575
   }
1582
   }
1576
   else
1583
   else
1577
     _buffer_steps(target
1584
     _buffer_steps(target
1578
-      #if ENABLED(LIN_ADVANCE)
1585
+      #if HAS_POSITION_FLOAT
1579
         , target_float
1586
         , target_float
1580
       #endif
1587
       #endif
1581
       , fr_mm_s, extruder, millimeters
1588
       , fr_mm_s, extruder, millimeters
1603
                 nb = position[B_AXIS] = LROUND(b * axis_steps_per_mm[B_AXIS]),
1610
                 nb = position[B_AXIS] = LROUND(b * axis_steps_per_mm[B_AXIS]),
1604
                 nc = position[C_AXIS] = LROUND(c * axis_steps_per_mm[C_AXIS]),
1611
                 nc = position[C_AXIS] = LROUND(c * axis_steps_per_mm[C_AXIS]),
1605
                 ne = position[E_AXIS] = LROUND(e * axis_steps_per_mm[_EINDEX]);
1612
                 ne = position[E_AXIS] = LROUND(e * axis_steps_per_mm[_EINDEX]);
1606
-  #if ENABLED(LIN_ADVANCE)
1613
+  #if HAS_POSITION_FLOAT
1607
     position_float[X_AXIS] = a;
1614
     position_float[X_AXIS] = a;
1608
     position_float[Y_AXIS] = b;
1615
     position_float[Y_AXIS] = b;
1609
     position_float[Z_AXIS] = c;
1616
     position_float[Z_AXIS] = c;
1635
 void Planner::sync_from_steppers() {
1642
 void Planner::sync_from_steppers() {
1636
   LOOP_XYZE(i) {
1643
   LOOP_XYZE(i) {
1637
     position[i] = stepper.position((AxisEnum)i);
1644
     position[i] = stepper.position((AxisEnum)i);
1638
-    #if ENABLED(LIN_ADVANCE)
1645
+    #if HAS_POSITION_FLOAT
1639
       position_float[i] = position[i] * steps_to_mm[i
1646
       position_float[i] = position[i] * steps_to_mm[i
1640
         #if ENABLED(DISTINCT_E_FACTORS)
1647
         #if ENABLED(DISTINCT_E_FACTORS)
1641
           + (i == E_AXIS ? active_extruder : 0)
1648
           + (i == E_AXIS ? active_extruder : 0)
1656
     const uint8_t axis_index = axis;
1663
     const uint8_t axis_index = axis;
1657
   #endif
1664
   #endif
1658
   position[axis] = LROUND(v * axis_steps_per_mm[axis_index]);
1665
   position[axis] = LROUND(v * axis_steps_per_mm[axis_index]);
1659
-  #if ENABLED(LIN_ADVANCE)
1666
+  #if HAS_POSITION_FLOAT
1660
     position_float[axis] = v;
1667
     position_float[axis] = v;
1661
   #endif
1668
   #endif
1662
   stepper.set_position(axis, v);
1669
   stepper.set_position(axis, v);

+ 8
- 3
Marlin/src/module/planner.h View File

130
 
130
 
131
 } block_t;
131
 } block_t;
132
 
132
 
133
+#define HAS_POSITION_FLOAT (ENABLED(LIN_ADVANCE) || ENABLED(SCARA_FEEDRATE_SCALING))
134
+
133
 #define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1))
135
 #define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1))
134
 
136
 
135
 class Planner {
137
 class Planner {
194
     #endif
196
     #endif
195
 
197
 
196
     #if ENABLED(LIN_ADVANCE)
198
     #if ENABLED(LIN_ADVANCE)
197
-      static float extruder_advance_K,
198
-                   position_float[XYZE];
199
+      static float extruder_advance_K;
200
+    #endif
201
+
202
+    #if HAS_POSITION_FLOAT
203
+      static float position_float[XYZE];
199
     #endif
204
     #endif
200
 
205
 
201
     #if ENABLED(SKEW_CORRECTION)
206
     #if ENABLED(SKEW_CORRECTION)
417
      *  millimeters - the length of the movement, if known
422
      *  millimeters - the length of the movement, if known
418
      */
423
      */
419
     static void _buffer_steps(const int32_t (&target)[XYZE]
424
     static void _buffer_steps(const int32_t (&target)[XYZE]
420
-      #if ENABLED(LIN_ADVANCE)
425
+      #if HAS_POSITION_FLOAT
421
         , const float (&target_float)[XYZE]
426
         , const float (&target_float)[XYZE]
422
       #endif
427
       #endif
423
       , float fr_mm_s, const uint8_t extruder, const float &millimeters=0.0
428
       , float fr_mm_s, const uint8_t extruder, const float &millimeters=0.0

Loading…
Cancel
Save