Преглед изворни кода

Include time scale in some planner vars

Scott Lahteine пре 6 година
родитељ
комит
46ed54cd8e
4 измењених фајлова са 38 додато и 38 уклоњено
  1. 1
    1
      Marlin/Marlin_main.cpp
  2. 6
    6
      Marlin/configuration_store.cpp
  3. 25
    25
      Marlin/planner.cpp
  4. 6
    6
      Marlin/planner.h

+ 1
- 1
Marlin/Marlin_main.cpp Прегледај датотеку

@@ -8797,7 +8797,7 @@ inline void gcode_M204() {
8797 8797
 inline void gcode_M205() {
8798 8798
   if (parser.seen('S')) planner.min_feedrate_mm_s = parser.value_linear_units();
8799 8799
   if (parser.seen('T')) planner.min_travel_feedrate_mm_s = parser.value_linear_units();
8800
-  if (parser.seen('B')) planner.min_segment_time = parser.value_millis();
8800
+  if (parser.seen('B')) planner.min_segment_time_us = parser.value_ulong();
8801 8801
   if (parser.seen('X')) planner.max_jerk[X_AXIS] = parser.value_linear_units();
8802 8802
   if (parser.seen('Y')) planner.max_jerk[Y_AXIS] = parser.value_linear_units();
8803 8803
   if (parser.seen('Z')) planner.max_jerk[Z_AXIS] = parser.value_linear_units();

+ 6
- 6
Marlin/configuration_store.cpp Прегледај датотеку

@@ -56,7 +56,7 @@
56 56
  *  163  M204 T    planner.travel_acceleration      (float)
57 57
  *  167  M205 S    planner.min_feedrate_mm_s        (float)
58 58
  *  171  M205 T    planner.min_travel_feedrate_mm_s (float)
59
- *  175  M205 B    planner.min_segment_time         (ulong)
59
+ *  175  M205 B    planner.min_segment_time_us      (ulong)
60 60
  *  179  M205 X    planner.max_jerk[X_AXIS]         (float)
61 61
  *  183  M205 Y    planner.max_jerk[Y_AXIS]         (float)
62 62
  *  187  M205 Z    planner.max_jerk[Z_AXIS]         (float)
@@ -335,7 +335,7 @@ void MarlinSettings::postprocess() {
335 335
     EEPROM_WRITE(planner.travel_acceleration);
336 336
     EEPROM_WRITE(planner.min_feedrate_mm_s);
337 337
     EEPROM_WRITE(planner.min_travel_feedrate_mm_s);
338
-    EEPROM_WRITE(planner.min_segment_time);
338
+    EEPROM_WRITE(planner.min_segment_time_us);
339 339
     EEPROM_WRITE(planner.max_jerk);
340 340
     #if !HAS_HOME_OFFSET
341 341
       const float home_offset[XYZ] = { 0 };
@@ -749,7 +749,7 @@ void MarlinSettings::postprocess() {
749 749
       EEPROM_READ(planner.travel_acceleration);
750 750
       EEPROM_READ(planner.min_feedrate_mm_s);
751 751
       EEPROM_READ(planner.min_travel_feedrate_mm_s);
752
-      EEPROM_READ(planner.min_segment_time);
752
+      EEPROM_READ(planner.min_segment_time_us);
753 753
       EEPROM_READ(planner.max_jerk);
754 754
 
755 755
       #if !HAS_HOME_OFFSET
@@ -1219,7 +1219,7 @@ void MarlinSettings::reset() {
1219 1219
   planner.retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
1220 1220
   planner.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
1221 1221
   planner.min_feedrate_mm_s = DEFAULT_MINIMUMFEEDRATE;
1222
-  planner.min_segment_time = DEFAULT_MINSEGMENTTIME;
1222
+  planner.min_segment_time_us = DEFAULT_MINSEGMENTTIME;
1223 1223
   planner.min_travel_feedrate_mm_s = DEFAULT_MINTRAVELFEEDRATE;
1224 1224
   planner.max_jerk[X_AXIS] = DEFAULT_XJERK;
1225 1225
   planner.max_jerk[Y_AXIS] = DEFAULT_YJERK;
@@ -1585,12 +1585,12 @@ void MarlinSettings::reset() {
1585 1585
 
1586 1586
     if (!forReplay) {
1587 1587
       CONFIG_ECHO_START;
1588
-      SERIAL_ECHOLNPGM("Advanced: S<min_feedrate> T<min_travel_feedrate> B<min_segment_time_ms> X<max_xy_jerk> Z<max_z_jerk> E<max_e_jerk>");
1588
+      SERIAL_ECHOLNPGM("Advanced: S<min_feedrate> T<min_travel_feedrate> B<min_segment_time_us> X<max_xy_jerk> Z<max_z_jerk> E<max_e_jerk>");
1589 1589
     }
1590 1590
     CONFIG_ECHO_START;
1591 1591
     SERIAL_ECHOPAIR("  M205 S", LINEAR_UNIT(planner.min_feedrate_mm_s));
1592 1592
     SERIAL_ECHOPAIR(" T", LINEAR_UNIT(planner.min_travel_feedrate_mm_s));
1593
-    SERIAL_ECHOPAIR(" B", planner.min_segment_time);
1593
+    SERIAL_ECHOPAIR(" B", planner.min_segment_time_us);
1594 1594
     SERIAL_ECHOPAIR(" X", LINEAR_UNIT(planner.max_jerk[X_AXIS]));
1595 1595
     SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(planner.max_jerk[Y_AXIS]));
1596 1596
     SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.max_jerk[Z_AXIS]));

+ 25
- 25
Marlin/planner.cpp Прегледај датотеку

@@ -94,7 +94,7 @@ float Planner::max_feedrate_mm_s[XYZE_N], // Max speeds in mm per second
94 94
 uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N],
95 95
          Planner::max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override by software
96 96
 
97
-millis_t Planner::min_segment_time;
97
+uint32_t Planner::min_segment_time_us;
98 98
 
99 99
 // Initialized by settings.load()
100 100
 float Planner::min_feedrate_mm_s,
@@ -140,7 +140,7 @@ float Planner::previous_speed[NUM_AXIS],
140 140
   // Old direction bits. Used for speed calculations
141 141
   unsigned char Planner::old_direction_bits = 0;
142 142
   // Segment times (in µs). Used for speed calculations
143
-  long Planner::axis_segment_time[2][3] = { {MAX_FREQ_TIME + 1, 0, 0}, {MAX_FREQ_TIME + 1, 0, 0} };
143
+  uint32_t Planner::axis_segment_time_us[2][3] = { { MAX_FREQ_TIME_US + 1, 0, 0 }, { MAX_FREQ_TIME_US + 1, 0, 0 } };
144 144
 #endif
145 145
 
146 146
 #if ENABLED(LIN_ADVANCE)
@@ -1036,15 +1036,15 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
1036 1036
   // Slow down when the buffer starts to empty, rather than wait at the corner for a buffer refill
1037 1037
   #if ENABLED(SLOWDOWN) || ENABLED(ULTRA_LCD) || defined(XY_FREQUENCY_LIMIT)
1038 1038
     // Segment time im micro seconds
1039
-    unsigned long segment_time = LROUND(1000000.0 / inverse_mm_s);
1039
+    uint32_t segment_time_us = LROUND(1000000.0 / inverse_mm_s);
1040 1040
   #endif
1041 1041
   #if ENABLED(SLOWDOWN)
1042 1042
     if (WITHIN(moves_queued, 2, (BLOCK_BUFFER_SIZE) / 2 - 1)) {
1043
-      if (segment_time < min_segment_time) {
1043
+      if (segment_time_us < min_segment_time_us) {
1044 1044
         // buffer is draining, add extra time.  The amount of time added increases if the buffer is still emptied more.
1045
-        inverse_mm_s = 1000000.0 / (segment_time + LROUND(2 * (min_segment_time - segment_time) / moves_queued));
1045
+        inverse_mm_s = 1000000.0 / (segment_time_us + LROUND(2 * (min_segment_time_us - segment_time_us) / moves_queued));
1046 1046
         #if defined(XY_FREQUENCY_LIMIT) || ENABLED(ULTRA_LCD)
1047
-          segment_time = LROUND(1000000.0 / inverse_mm_s);
1047
+          segment_time_us = LROUND(1000000.0 / inverse_mm_s);
1048 1048
         #endif
1049 1049
       }
1050 1050
     }
@@ -1052,7 +1052,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
1052 1052
 
1053 1053
   #if ENABLED(ULTRA_LCD)
1054 1054
     CRITICAL_SECTION_START
1055
-      block_buffer_runtime_us += segment_time;
1055
+      block_buffer_runtime_us += segment_time_us;
1056 1056
     CRITICAL_SECTION_END
1057 1057
   #endif
1058 1058
 
@@ -1109,34 +1109,34 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
1109 1109
     // Check and limit the xy direction change frequency
1110 1110
     const unsigned char direction_change = block->direction_bits ^ old_direction_bits;
1111 1111
     old_direction_bits = block->direction_bits;
1112
-    segment_time = LROUND((float)segment_time / speed_factor);
1112
+    segment_time_us = LROUND((float)segment_time_us / speed_factor);
1113 1113
 
1114
-    long xs0 = axis_segment_time[X_AXIS][0],
1115
-         xs1 = axis_segment_time[X_AXIS][1],
1116
-         xs2 = axis_segment_time[X_AXIS][2],
1117
-         ys0 = axis_segment_time[Y_AXIS][0],
1118
-         ys1 = axis_segment_time[Y_AXIS][1],
1119
-         ys2 = axis_segment_time[Y_AXIS][2];
1114
+    uint32_t xs0 = axis_segment_time_us[X_AXIS][0],
1115
+             xs1 = axis_segment_time_us[X_AXIS][1],
1116
+             xs2 = axis_segment_time_us[X_AXIS][2],
1117
+             ys0 = axis_segment_time_us[Y_AXIS][0],
1118
+             ys1 = axis_segment_time_us[Y_AXIS][1],
1119
+             ys2 = axis_segment_time_us[Y_AXIS][2];
1120 1120
 
1121 1121
     if (TEST(direction_change, X_AXIS)) {
1122
-      xs2 = axis_segment_time[X_AXIS][2] = xs1;
1123
-      xs1 = axis_segment_time[X_AXIS][1] = xs0;
1122
+      xs2 = axis_segment_time_us[X_AXIS][2] = xs1;
1123
+      xs1 = axis_segment_time_us[X_AXIS][1] = xs0;
1124 1124
       xs0 = 0;
1125 1125
     }
1126
-    xs0 = axis_segment_time[X_AXIS][0] = xs0 + segment_time;
1126
+    xs0 = axis_segment_time_us[X_AXIS][0] = xs0 + segment_time_us;
1127 1127
 
1128 1128
     if (TEST(direction_change, Y_AXIS)) {
1129
-      ys2 = axis_segment_time[Y_AXIS][2] = axis_segment_time[Y_AXIS][1];
1130
-      ys1 = axis_segment_time[Y_AXIS][1] = axis_segment_time[Y_AXIS][0];
1129
+      ys2 = axis_segment_time_us[Y_AXIS][2] = axis_segment_time_us[Y_AXIS][1];
1130
+      ys1 = axis_segment_time_us[Y_AXIS][1] = axis_segment_time_us[Y_AXIS][0];
1131 1131
       ys0 = 0;
1132 1132
     }
1133
-    ys0 = axis_segment_time[Y_AXIS][0] = ys0 + segment_time;
1133
+    ys0 = axis_segment_time_us[Y_AXIS][0] = ys0 + segment_time_us;
1134 1134
 
1135
-    const long max_x_segment_time = MAX3(xs0, xs1, xs2),
1136
-               max_y_segment_time = MAX3(ys0, ys1, ys2),
1137
-               min_xy_segment_time = min(max_x_segment_time, max_y_segment_time);
1138
-    if (min_xy_segment_time < MAX_FREQ_TIME) {
1139
-      const float low_sf = speed_factor * min_xy_segment_time / (MAX_FREQ_TIME);
1135
+    const uint32_t max_x_segment_time = MAX3(xs0, xs1, xs2),
1136
+                   max_y_segment_time = MAX3(ys0, ys1, ys2),
1137
+                   min_xy_segment_time = min(max_x_segment_time, max_y_segment_time);
1138
+    if (min_xy_segment_time < MAX_FREQ_TIME_US) {
1139
+      const float low_sf = speed_factor * min_xy_segment_time / (MAX_FREQ_TIME_US);
1140 1140
       NOMORE(speed_factor, low_sf);
1141 1141
     }
1142 1142
   #endif // XY_FREQUENCY_LIMIT

+ 6
- 6
Marlin/planner.h Прегледај датотеку

@@ -119,7 +119,7 @@ typedef struct {
119 119
     uint8_t valve_pressure, e_to_p_pressure;
120 120
   #endif
121 121
 
122
-  uint32_t segment_time;
122
+  uint32_t segment_time_us;
123 123
 
124 124
 } block_t;
125 125
 
@@ -144,9 +144,9 @@ class Planner {
144 144
                  axis_steps_per_mm[XYZE_N],
145 145
                  steps_to_mm[XYZE_N];
146 146
     static uint32_t max_acceleration_steps_per_s2[XYZE_N],
147
-                    max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override by software
147
+                    max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override
148 148
 
149
-    static millis_t min_segment_time;
149
+    static uint32_t min_segment_time_us; // Use 'M205 B<µs>' to override
150 150
     static float min_feedrate_mm_s,
151 151
                  acceleration,         // Normal acceleration mm/s^2  DEFAULT ACCELERATION for all printing moves. M204 SXXXX
152 152
                  retract_acceleration, // Retract acceleration mm/s^2 filament pull-back and push-forward while standing still in the other axes M204 TXXXX
@@ -204,11 +204,11 @@ class Planner {
204 204
 
205 205
     #ifdef XY_FREQUENCY_LIMIT
206 206
       // Used for the frequency limit
207
-      #define MAX_FREQ_TIME long(1000000.0/XY_FREQUENCY_LIMIT)
207
+      #define MAX_FREQ_TIME_US (uint32_t)(1000000.0 / XY_FREQUENCY_LIMIT)
208 208
       // Old direction bits. Used for speed calculations
209 209
       static unsigned char old_direction_bits;
210 210
       // Segment times (in µs). Used for speed calculations
211
-      static long axis_segment_time[2][3];
211
+      static uint32_t axis_segment_time_us[2][3];
212 212
     #endif
213 213
 
214 214
     #if ENABLED(LIN_ADVANCE)
@@ -419,7 +419,7 @@ class Planner {
419 419
       if (blocks_queued()) {
420 420
         block_t* block = &block_buffer[block_buffer_tail];
421 421
         #if ENABLED(ULTRA_LCD)
422
-          block_buffer_runtime_us -= block->segment_time; //We can't be sure how long an active block will take, so don't count it.
422
+          block_buffer_runtime_us -= block->segment_time_us; // We can't be sure how long an active block will take, so don't count it.
423 423
         #endif
424 424
         SBI(block->flag, BLOCK_BIT_BUSY);
425 425
         return block;

Loading…
Откажи
Сачувај