Parcourir la source

Add/correct time units on planner vars / M205 B

Scott Lahteine il y a 7 ans
Parent
révision
3e8754a38a

+ 1
- 1
Marlin/src/gcode/config/M200-M205.cpp Voir le fichier

@@ -121,7 +121,7 @@ void GcodeSuite::M204() {
121 121
 void GcodeSuite::M205() {
122 122
   if (parser.seen('S')) planner.min_feedrate_mm_s = parser.value_linear_units();
123 123
   if (parser.seen('T')) planner.min_travel_feedrate_mm_s = parser.value_linear_units();
124
-  if (parser.seen('B')) planner.min_segment_time = parser.value_millis();
124
+  if (parser.seen('B')) planner.min_segment_time_us = parser.value_ulong();
125 125
   if (parser.seen('X')) planner.max_jerk[X_AXIS] = parser.value_linear_units();
126 126
   if (parser.seen('Y')) planner.max_jerk[Y_AXIS] = parser.value_linear_units();
127 127
   if (parser.seen('Z')) planner.max_jerk[Z_AXIS] = parser.value_linear_units();

+ 7
- 7
Marlin/src/module/configuration_store.cpp Voir le fichier

@@ -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)
@@ -68,7 +68,7 @@
68 68
  *  219            z_fade_height                    (float)
69 69
  *
70 70
  * MESH_BED_LEVELING:                               43 bytes
71
- *  223  M420 S    planner.leveling_active         (bool)
71
+ *  223  M420 S    planner.leveling_active          (bool)
72 72
  *  224            mbl.z_offset                     (float)
73 73
  *  228            GRID_MAX_POINTS_X                (uint8_t)
74 74
  *  229            GRID_MAX_POINTS_Y                (uint8_t)
@@ -305,7 +305,7 @@ void MarlinSettings::postprocess() {
305 305
     EEPROM_WRITE(planner.travel_acceleration);
306 306
     EEPROM_WRITE(planner.min_feedrate_mm_s);
307 307
     EEPROM_WRITE(planner.min_travel_feedrate_mm_s);
308
-    EEPROM_WRITE(planner.min_segment_time);
308
+    EEPROM_WRITE(planner.min_segment_time_us);
309 309
     EEPROM_WRITE(planner.max_jerk);
310 310
     #if !HAS_HOME_OFFSET
311 311
       const float home_offset[XYZ] = { 0 };
@@ -699,7 +699,7 @@ void MarlinSettings::postprocess() {
699 699
       EEPROM_READ(planner.travel_acceleration);
700 700
       EEPROM_READ(planner.min_feedrate_mm_s);
701 701
       EEPROM_READ(planner.min_travel_feedrate_mm_s);
702
-      EEPROM_READ(planner.min_segment_time);
702
+      EEPROM_READ(planner.min_segment_time_us);
703 703
       EEPROM_READ(planner.max_jerk);
704 704
 
705 705
       #if !HAS_HOME_OFFSET
@@ -1166,7 +1166,7 @@ void MarlinSettings::reset() {
1166 1166
   planner.retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
1167 1167
   planner.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
1168 1168
   planner.min_feedrate_mm_s = DEFAULT_MINIMUMFEEDRATE;
1169
-  planner.min_segment_time = DEFAULT_MINSEGMENTTIME;
1169
+  planner.min_segment_time_us = DEFAULT_MINSEGMENTTIME;
1170 1170
   planner.min_travel_feedrate_mm_s = DEFAULT_MINTRAVELFEEDRATE;
1171 1171
   planner.max_jerk[X_AXIS] = DEFAULT_XJERK;
1172 1172
   planner.max_jerk[Y_AXIS] = DEFAULT_YJERK;
@@ -1504,12 +1504,12 @@ void MarlinSettings::reset() {
1504 1504
 
1505 1505
     if (!forReplay) {
1506 1506
       CONFIG_ECHO_START;
1507
-      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>");
1507
+      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>");
1508 1508
     }
1509 1509
     CONFIG_ECHO_START;
1510 1510
     SERIAL_ECHOPAIR("  M205 S", LINEAR_UNIT(planner.min_feedrate_mm_s));
1511 1511
     SERIAL_ECHOPAIR(" T", LINEAR_UNIT(planner.min_travel_feedrate_mm_s));
1512
-    SERIAL_ECHOPAIR(" B", planner.min_segment_time);
1512
+    SERIAL_ECHOPAIR(" B", planner.min_segment_time_us);
1513 1513
     SERIAL_ECHOPAIR(" X", LINEAR_UNIT(planner.max_jerk[X_AXIS]));
1514 1514
     SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(planner.max_jerk[Y_AXIS]));
1515 1515
     SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.max_jerk[Z_AXIS]));

+ 25
- 25
Marlin/src/module/planner.cpp Voir le fichier

@@ -112,7 +112,7 @@ float Planner::filament_size[EXTRUDERS],         // As a baseline for the multip
112 112
 uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N],
113 113
          Planner::max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override by software
114 114
 
115
-millis_t Planner::min_segment_time;
115
+uint32_t Planner::min_segment_time_us;
116 116
 
117 117
 // Initialized by settings.load()
118 118
 float Planner::min_feedrate_mm_s,
@@ -159,7 +159,7 @@ float Planner::previous_speed[NUM_AXIS],
159 159
   // Old direction bits. Used for speed calculations
160 160
   unsigned char Planner::old_direction_bits = 0;
161 161
   // Segment times (in µs). Used for speed calculations
162
-  long Planner::axis_segment_time[2][3] = { {MAX_FREQ_TIME + 1, 0, 0}, {MAX_FREQ_TIME + 1, 0, 0} };
162
+  uint32_t Planner::axis_segment_time_us[2][3] = { { MAX_FREQ_TIME_US + 1, 0, 0 }, { MAX_FREQ_TIME_US + 1, 0, 0 } };
163 163
 #endif
164 164
 
165 165
 #if ENABLED(LIN_ADVANCE)
@@ -1057,15 +1057,15 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
1057 1057
   // Slow down when the buffer starts to empty, rather than wait at the corner for a buffer refill
1058 1058
   #if ENABLED(SLOWDOWN) || ENABLED(ULTRA_LCD) || defined(XY_FREQUENCY_LIMIT)
1059 1059
     // Segment time im micro seconds
1060
-    unsigned long segment_time = LROUND(1000000.0 / inverse_mm_s);
1060
+    uint32_t segment_time_us = LROUND(1000000.0 / inverse_mm_s);
1061 1061
   #endif
1062 1062
   #if ENABLED(SLOWDOWN)
1063 1063
     if (WITHIN(moves_queued, 2, (BLOCK_BUFFER_SIZE) / 2 - 1)) {
1064
-      if (segment_time < min_segment_time) {
1064
+      if (segment_time_us < min_segment_time_us) {
1065 1065
         // buffer is draining, add extra time.  The amount of time added increases if the buffer is still emptied more.
1066
-        inverse_mm_s = 1000000.0 / (segment_time + LROUND(2 * (min_segment_time - segment_time) / moves_queued));
1066
+        inverse_mm_s = 1000000.0 / (segment_time_us + LROUND(2 * (min_segment_time_us - segment_time_us) / moves_queued));
1067 1067
         #if defined(XY_FREQUENCY_LIMIT) || ENABLED(ULTRA_LCD)
1068
-          segment_time = LROUND(1000000.0 / inverse_mm_s);
1068
+          segment_time_us = LROUND(1000000.0 / inverse_mm_s);
1069 1069
         #endif
1070 1070
       }
1071 1071
     }
@@ -1073,7 +1073,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
1073 1073
 
1074 1074
   #if ENABLED(ULTRA_LCD)
1075 1075
     CRITICAL_SECTION_START
1076
-      block_buffer_runtime_us += segment_time;
1076
+      block_buffer_runtime_us += segment_time_us;
1077 1077
     CRITICAL_SECTION_END
1078 1078
   #endif
1079 1079
 
@@ -1130,34 +1130,34 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
1130 1130
     // Check and limit the xy direction change frequency
1131 1131
     const unsigned char direction_change = block->direction_bits ^ old_direction_bits;
1132 1132
     old_direction_bits = block->direction_bits;
1133
-    segment_time = LROUND((float)segment_time / speed_factor);
1133
+    segment_time_us = LROUND((float)segment_time_us / speed_factor);
1134 1134
 
1135
-    long xs0 = axis_segment_time[X_AXIS][0],
1136
-         xs1 = axis_segment_time[X_AXIS][1],
1137
-         xs2 = axis_segment_time[X_AXIS][2],
1138
-         ys0 = axis_segment_time[Y_AXIS][0],
1139
-         ys1 = axis_segment_time[Y_AXIS][1],
1140
-         ys2 = axis_segment_time[Y_AXIS][2];
1135
+    uint32_t xs0 = axis_segment_time_us[X_AXIS][0],
1136
+             xs1 = axis_segment_time_us[X_AXIS][1],
1137
+             xs2 = axis_segment_time_us[X_AXIS][2],
1138
+             ys0 = axis_segment_time_us[Y_AXIS][0],
1139
+             ys1 = axis_segment_time_us[Y_AXIS][1],
1140
+             ys2 = axis_segment_time_us[Y_AXIS][2];
1141 1141
 
1142 1142
     if (TEST(direction_change, X_AXIS)) {
1143
-      xs2 = axis_segment_time[X_AXIS][2] = xs1;
1144
-      xs1 = axis_segment_time[X_AXIS][1] = xs0;
1143
+      xs2 = axis_segment_time_us[X_AXIS][2] = xs1;
1144
+      xs1 = axis_segment_time_us[X_AXIS][1] = xs0;
1145 1145
       xs0 = 0;
1146 1146
     }
1147
-    xs0 = axis_segment_time[X_AXIS][0] = xs0 + segment_time;
1147
+    xs0 = axis_segment_time_us[X_AXIS][0] = xs0 + segment_time_us;
1148 1148
 
1149 1149
     if (TEST(direction_change, Y_AXIS)) {
1150
-      ys2 = axis_segment_time[Y_AXIS][2] = axis_segment_time[Y_AXIS][1];
1151
-      ys1 = axis_segment_time[Y_AXIS][1] = axis_segment_time[Y_AXIS][0];
1150
+      ys2 = axis_segment_time_us[Y_AXIS][2] = axis_segment_time_us[Y_AXIS][1];
1151
+      ys1 = axis_segment_time_us[Y_AXIS][1] = axis_segment_time_us[Y_AXIS][0];
1152 1152
       ys0 = 0;
1153 1153
     }
1154
-    ys0 = axis_segment_time[Y_AXIS][0] = ys0 + segment_time;
1154
+    ys0 = axis_segment_time_us[Y_AXIS][0] = ys0 + segment_time_us;
1155 1155
 
1156
-    const long max_x_segment_time = MAX3(xs0, xs1, xs2),
1157
-               max_y_segment_time = MAX3(ys0, ys1, ys2),
1158
-               min_xy_segment_time = min(max_x_segment_time, max_y_segment_time);
1159
-    if (min_xy_segment_time < MAX_FREQ_TIME) {
1160
-      const float low_sf = speed_factor * min_xy_segment_time / (MAX_FREQ_TIME);
1156
+    const uint32_t max_x_segment_time = MAX3(xs0, xs1, xs2),
1157
+                   max_y_segment_time = MAX3(ys0, ys1, ys2),
1158
+                   min_xy_segment_time = min(max_x_segment_time, max_y_segment_time);
1159
+    if (min_xy_segment_time < MAX_FREQ_TIME_US) {
1160
+      const float low_sf = speed_factor * min_xy_segment_time / (MAX_FREQ_TIME_US);
1161 1161
       NOMORE(speed_factor, low_sf);
1162 1162
     }
1163 1163
   #endif // XY_FREQUENCY_LIMIT

+ 6
- 6
Marlin/src/module/planner.h Voir le fichier

@@ -123,7 +123,7 @@ typedef struct {
123 123
     uint8_t valve_pressure, e_to_p_pressure;
124 124
   #endif
125 125
 
126
-  uint32_t segment_time;
126
+  uint32_t segment_time_us;
127 127
 
128 128
 } block_t;
129 129
 
@@ -154,9 +154,9 @@ class Planner {
154 154
                  axis_steps_per_mm[XYZE_N],
155 155
                  steps_to_mm[XYZE_N];
156 156
     static uint32_t max_acceleration_steps_per_s2[XYZE_N],
157
-                    max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override by software
157
+                    max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override
158 158
 
159
-    static millis_t min_segment_time;
159
+    static uint32_t min_segment_time_us; // Use 'M205 B<µs>' to override
160 160
     static float min_feedrate_mm_s,
161 161
                  acceleration,         // Normal acceleration mm/s^2  DEFAULT ACCELERATION for all printing moves. M204 SXXXX
162 162
                  retract_acceleration, // Retract acceleration mm/s^2 filament pull-back and push-forward while standing still in the other axes M204 TXXXX
@@ -214,11 +214,11 @@ class Planner {
214 214
 
215 215
     #ifdef XY_FREQUENCY_LIMIT
216 216
       // Used for the frequency limit
217
-      #define MAX_FREQ_TIME long(1000000.0/XY_FREQUENCY_LIMIT)
217
+      #define MAX_FREQ_TIME_US (uint32_t)(1000000.0 / XY_FREQUENCY_LIMIT)
218 218
       // Old direction bits. Used for speed calculations
219 219
       static unsigned char old_direction_bits;
220 220
       // Segment times (in µs). Used for speed calculations
221
-      static long axis_segment_time[2][3];
221
+      static long axis_segment_time_us[2][3];
222 222
     #endif
223 223
 
224 224
     #if ENABLED(LIN_ADVANCE)
@@ -439,7 +439,7 @@ class Planner {
439 439
       if (blocks_queued()) {
440 440
         block_t* block = &block_buffer[block_buffer_tail];
441 441
         #if ENABLED(ULTRA_LCD)
442
-          block_buffer_runtime_us -= block->segment_time; //We can't be sure how long an active block will take, so don't count it.
442
+          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.
443 443
         #endif
444 444
         SBI(block->flag, BLOCK_BIT_BUSY);
445 445
         return block;

Chargement…
Annuler
Enregistrer