瀏覽代碼

Include time scale in some planner vars

Scott Lahteine 7 年之前
父節點
當前提交
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
 inline void gcode_M205() {
8797
 inline void gcode_M205() {
8798
   if (parser.seen('S')) planner.min_feedrate_mm_s = parser.value_linear_units();
8798
   if (parser.seen('S')) planner.min_feedrate_mm_s = parser.value_linear_units();
8799
   if (parser.seen('T')) planner.min_travel_feedrate_mm_s = parser.value_linear_units();
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
   if (parser.seen('X')) planner.max_jerk[X_AXIS] = parser.value_linear_units();
8801
   if (parser.seen('X')) planner.max_jerk[X_AXIS] = parser.value_linear_units();
8802
   if (parser.seen('Y')) planner.max_jerk[Y_AXIS] = parser.value_linear_units();
8802
   if (parser.seen('Y')) planner.max_jerk[Y_AXIS] = parser.value_linear_units();
8803
   if (parser.seen('Z')) planner.max_jerk[Z_AXIS] = parser.value_linear_units();
8803
   if (parser.seen('Z')) planner.max_jerk[Z_AXIS] = parser.value_linear_units();

+ 6
- 6
Marlin/configuration_store.cpp 查看文件

56
  *  163  M204 T    planner.travel_acceleration      (float)
56
  *  163  M204 T    planner.travel_acceleration      (float)
57
  *  167  M205 S    planner.min_feedrate_mm_s        (float)
57
  *  167  M205 S    planner.min_feedrate_mm_s        (float)
58
  *  171  M205 T    planner.min_travel_feedrate_mm_s (float)
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
  *  179  M205 X    planner.max_jerk[X_AXIS]         (float)
60
  *  179  M205 X    planner.max_jerk[X_AXIS]         (float)
61
  *  183  M205 Y    planner.max_jerk[Y_AXIS]         (float)
61
  *  183  M205 Y    planner.max_jerk[Y_AXIS]         (float)
62
  *  187  M205 Z    planner.max_jerk[Z_AXIS]         (float)
62
  *  187  M205 Z    planner.max_jerk[Z_AXIS]         (float)
335
     EEPROM_WRITE(planner.travel_acceleration);
335
     EEPROM_WRITE(planner.travel_acceleration);
336
     EEPROM_WRITE(planner.min_feedrate_mm_s);
336
     EEPROM_WRITE(planner.min_feedrate_mm_s);
337
     EEPROM_WRITE(planner.min_travel_feedrate_mm_s);
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
     EEPROM_WRITE(planner.max_jerk);
339
     EEPROM_WRITE(planner.max_jerk);
340
     #if !HAS_HOME_OFFSET
340
     #if !HAS_HOME_OFFSET
341
       const float home_offset[XYZ] = { 0 };
341
       const float home_offset[XYZ] = { 0 };
749
       EEPROM_READ(planner.travel_acceleration);
749
       EEPROM_READ(planner.travel_acceleration);
750
       EEPROM_READ(planner.min_feedrate_mm_s);
750
       EEPROM_READ(planner.min_feedrate_mm_s);
751
       EEPROM_READ(planner.min_travel_feedrate_mm_s);
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
       EEPROM_READ(planner.max_jerk);
753
       EEPROM_READ(planner.max_jerk);
754
 
754
 
755
       #if !HAS_HOME_OFFSET
755
       #if !HAS_HOME_OFFSET
1219
   planner.retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
1219
   planner.retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
1220
   planner.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
1220
   planner.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
1221
   planner.min_feedrate_mm_s = DEFAULT_MINIMUMFEEDRATE;
1221
   planner.min_feedrate_mm_s = DEFAULT_MINIMUMFEEDRATE;
1222
-  planner.min_segment_time = DEFAULT_MINSEGMENTTIME;
1222
+  planner.min_segment_time_us = DEFAULT_MINSEGMENTTIME;
1223
   planner.min_travel_feedrate_mm_s = DEFAULT_MINTRAVELFEEDRATE;
1223
   planner.min_travel_feedrate_mm_s = DEFAULT_MINTRAVELFEEDRATE;
1224
   planner.max_jerk[X_AXIS] = DEFAULT_XJERK;
1224
   planner.max_jerk[X_AXIS] = DEFAULT_XJERK;
1225
   planner.max_jerk[Y_AXIS] = DEFAULT_YJERK;
1225
   planner.max_jerk[Y_AXIS] = DEFAULT_YJERK;
1585
 
1585
 
1586
     if (!forReplay) {
1586
     if (!forReplay) {
1587
       CONFIG_ECHO_START;
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
     CONFIG_ECHO_START;
1590
     CONFIG_ECHO_START;
1591
     SERIAL_ECHOPAIR("  M205 S", LINEAR_UNIT(planner.min_feedrate_mm_s));
1591
     SERIAL_ECHOPAIR("  M205 S", LINEAR_UNIT(planner.min_feedrate_mm_s));
1592
     SERIAL_ECHOPAIR(" T", LINEAR_UNIT(planner.min_travel_feedrate_mm_s));
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
     SERIAL_ECHOPAIR(" X", LINEAR_UNIT(planner.max_jerk[X_AXIS]));
1594
     SERIAL_ECHOPAIR(" X", LINEAR_UNIT(planner.max_jerk[X_AXIS]));
1595
     SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(planner.max_jerk[Y_AXIS]));
1595
     SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(planner.max_jerk[Y_AXIS]));
1596
     SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.max_jerk[Z_AXIS]));
1596
     SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.max_jerk[Z_AXIS]));

+ 25
- 25
Marlin/planner.cpp 查看文件

94
 uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N],
94
 uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N],
95
          Planner::max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override by software
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
 // Initialized by settings.load()
99
 // Initialized by settings.load()
100
 float Planner::min_feedrate_mm_s,
100
 float Planner::min_feedrate_mm_s,
140
   // Old direction bits. Used for speed calculations
140
   // Old direction bits. Used for speed calculations
141
   unsigned char Planner::old_direction_bits = 0;
141
   unsigned char Planner::old_direction_bits = 0;
142
   // Segment times (in µs). Used for speed calculations
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
 #endif
144
 #endif
145
 
145
 
146
 #if ENABLED(LIN_ADVANCE)
146
 #if ENABLED(LIN_ADVANCE)
1036
   // Slow down when the buffer starts to empty, rather than wait at the corner for a buffer refill
1036
   // Slow down when the buffer starts to empty, rather than wait at the corner for a buffer refill
1037
   #if ENABLED(SLOWDOWN) || ENABLED(ULTRA_LCD) || defined(XY_FREQUENCY_LIMIT)
1037
   #if ENABLED(SLOWDOWN) || ENABLED(ULTRA_LCD) || defined(XY_FREQUENCY_LIMIT)
1038
     // Segment time im micro seconds
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
   #endif
1040
   #endif
1041
   #if ENABLED(SLOWDOWN)
1041
   #if ENABLED(SLOWDOWN)
1042
     if (WITHIN(moves_queued, 2, (BLOCK_BUFFER_SIZE) / 2 - 1)) {
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
         // buffer is draining, add extra time.  The amount of time added increases if the buffer is still emptied more.
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
         #if defined(XY_FREQUENCY_LIMIT) || ENABLED(ULTRA_LCD)
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
         #endif
1048
         #endif
1049
       }
1049
       }
1050
     }
1050
     }
1052
 
1052
 
1053
   #if ENABLED(ULTRA_LCD)
1053
   #if ENABLED(ULTRA_LCD)
1054
     CRITICAL_SECTION_START
1054
     CRITICAL_SECTION_START
1055
-      block_buffer_runtime_us += segment_time;
1055
+      block_buffer_runtime_us += segment_time_us;
1056
     CRITICAL_SECTION_END
1056
     CRITICAL_SECTION_END
1057
   #endif
1057
   #endif
1058
 
1058
 
1109
     // Check and limit the xy direction change frequency
1109
     // Check and limit the xy direction change frequency
1110
     const unsigned char direction_change = block->direction_bits ^ old_direction_bits;
1110
     const unsigned char direction_change = block->direction_bits ^ old_direction_bits;
1111
     old_direction_bits = block->direction_bits;
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
     if (TEST(direction_change, X_AXIS)) {
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
       xs0 = 0;
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
     if (TEST(direction_change, Y_AXIS)) {
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
       ys0 = 0;
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
       NOMORE(speed_factor, low_sf);
1140
       NOMORE(speed_factor, low_sf);
1141
     }
1141
     }
1142
   #endif // XY_FREQUENCY_LIMIT
1142
   #endif // XY_FREQUENCY_LIMIT

+ 6
- 6
Marlin/planner.h 查看文件

119
     uint8_t valve_pressure, e_to_p_pressure;
119
     uint8_t valve_pressure, e_to_p_pressure;
120
   #endif
120
   #endif
121
 
121
 
122
-  uint32_t segment_time;
122
+  uint32_t segment_time_us;
123
 
123
 
124
 } block_t;
124
 } block_t;
125
 
125
 
144
                  axis_steps_per_mm[XYZE_N],
144
                  axis_steps_per_mm[XYZE_N],
145
                  steps_to_mm[XYZE_N];
145
                  steps_to_mm[XYZE_N];
146
     static uint32_t max_acceleration_steps_per_s2[XYZE_N],
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
     static float min_feedrate_mm_s,
150
     static float min_feedrate_mm_s,
151
                  acceleration,         // Normal acceleration mm/s^2  DEFAULT ACCELERATION for all printing moves. M204 SXXXX
151
                  acceleration,         // Normal acceleration mm/s^2  DEFAULT ACCELERATION for all printing moves. M204 SXXXX
152
                  retract_acceleration, // Retract acceleration mm/s^2 filament pull-back and push-forward while standing still in the other axes M204 TXXXX
152
                  retract_acceleration, // Retract acceleration mm/s^2 filament pull-back and push-forward while standing still in the other axes M204 TXXXX
204
 
204
 
205
     #ifdef XY_FREQUENCY_LIMIT
205
     #ifdef XY_FREQUENCY_LIMIT
206
       // Used for the frequency limit
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
       // Old direction bits. Used for speed calculations
208
       // Old direction bits. Used for speed calculations
209
       static unsigned char old_direction_bits;
209
       static unsigned char old_direction_bits;
210
       // Segment times (in µs). Used for speed calculations
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
     #endif
212
     #endif
213
 
213
 
214
     #if ENABLED(LIN_ADVANCE)
214
     #if ENABLED(LIN_ADVANCE)
419
       if (blocks_queued()) {
419
       if (blocks_queued()) {
420
         block_t* block = &block_buffer[block_buffer_tail];
420
         block_t* block = &block_buffer[block_buffer_tail];
421
         #if ENABLED(ULTRA_LCD)
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
         #endif
423
         #endif
424
         SBI(block->flag, BLOCK_BIT_BUSY);
424
         SBI(block->flag, BLOCK_BIT_BUSY);
425
         return block;
425
         return block;

Loading…
取消
儲存