Browse Source

Add/correct time units on planner vars / M205 B

Scott Lahteine 7 years ago
parent
commit
3e8754a38a

+ 1
- 1
Marlin/src/gcode/config/M200-M205.cpp View File

121
 void GcodeSuite::M205() {
121
 void GcodeSuite::M205() {
122
   if (parser.seen('S')) planner.min_feedrate_mm_s = parser.value_linear_units();
122
   if (parser.seen('S')) planner.min_feedrate_mm_s = parser.value_linear_units();
123
   if (parser.seen('T')) planner.min_travel_feedrate_mm_s = parser.value_linear_units();
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
   if (parser.seen('X')) planner.max_jerk[X_AXIS] = parser.value_linear_units();
125
   if (parser.seen('X')) planner.max_jerk[X_AXIS] = parser.value_linear_units();
126
   if (parser.seen('Y')) planner.max_jerk[Y_AXIS] = parser.value_linear_units();
126
   if (parser.seen('Y')) planner.max_jerk[Y_AXIS] = parser.value_linear_units();
127
   if (parser.seen('Z')) planner.max_jerk[Z_AXIS] = parser.value_linear_units();
127
   if (parser.seen('Z')) planner.max_jerk[Z_AXIS] = parser.value_linear_units();

+ 7
- 7
Marlin/src/module/configuration_store.cpp View File

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

+ 25
- 25
Marlin/src/module/planner.cpp View File

112
 uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N],
112
 uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N],
113
          Planner::max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override by software
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
 // Initialized by settings.load()
117
 // Initialized by settings.load()
118
 float Planner::min_feedrate_mm_s,
118
 float Planner::min_feedrate_mm_s,
159
   // Old direction bits. Used for speed calculations
159
   // Old direction bits. Used for speed calculations
160
   unsigned char Planner::old_direction_bits = 0;
160
   unsigned char Planner::old_direction_bits = 0;
161
   // Segment times (in µs). Used for speed calculations
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
 #endif
163
 #endif
164
 
164
 
165
 #if ENABLED(LIN_ADVANCE)
165
 #if ENABLED(LIN_ADVANCE)
1057
   // Slow down when the buffer starts to empty, rather than wait at the corner for a buffer refill
1057
   // Slow down when the buffer starts to empty, rather than wait at the corner for a buffer refill
1058
   #if ENABLED(SLOWDOWN) || ENABLED(ULTRA_LCD) || defined(XY_FREQUENCY_LIMIT)
1058
   #if ENABLED(SLOWDOWN) || ENABLED(ULTRA_LCD) || defined(XY_FREQUENCY_LIMIT)
1059
     // Segment time im micro seconds
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
   #endif
1061
   #endif
1062
   #if ENABLED(SLOWDOWN)
1062
   #if ENABLED(SLOWDOWN)
1063
     if (WITHIN(moves_queued, 2, (BLOCK_BUFFER_SIZE) / 2 - 1)) {
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
         // buffer is draining, add extra time.  The amount of time added increases if the buffer is still emptied more.
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
         #if defined(XY_FREQUENCY_LIMIT) || ENABLED(ULTRA_LCD)
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
         #endif
1069
         #endif
1070
       }
1070
       }
1071
     }
1071
     }
1073
 
1073
 
1074
   #if ENABLED(ULTRA_LCD)
1074
   #if ENABLED(ULTRA_LCD)
1075
     CRITICAL_SECTION_START
1075
     CRITICAL_SECTION_START
1076
-      block_buffer_runtime_us += segment_time;
1076
+      block_buffer_runtime_us += segment_time_us;
1077
     CRITICAL_SECTION_END
1077
     CRITICAL_SECTION_END
1078
   #endif
1078
   #endif
1079
 
1079
 
1130
     // Check and limit the xy direction change frequency
1130
     // Check and limit the xy direction change frequency
1131
     const unsigned char direction_change = block->direction_bits ^ old_direction_bits;
1131
     const unsigned char direction_change = block->direction_bits ^ old_direction_bits;
1132
     old_direction_bits = block->direction_bits;
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
     if (TEST(direction_change, X_AXIS)) {
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
       xs0 = 0;
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
     if (TEST(direction_change, Y_AXIS)) {
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
       ys0 = 0;
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
       NOMORE(speed_factor, low_sf);
1161
       NOMORE(speed_factor, low_sf);
1162
     }
1162
     }
1163
   #endif // XY_FREQUENCY_LIMIT
1163
   #endif // XY_FREQUENCY_LIMIT

+ 6
- 6
Marlin/src/module/planner.h View File

123
     uint8_t valve_pressure, e_to_p_pressure;
123
     uint8_t valve_pressure, e_to_p_pressure;
124
   #endif
124
   #endif
125
 
125
 
126
-  uint32_t segment_time;
126
+  uint32_t segment_time_us;
127
 
127
 
128
 } block_t;
128
 } block_t;
129
 
129
 
154
                  axis_steps_per_mm[XYZE_N],
154
                  axis_steps_per_mm[XYZE_N],
155
                  steps_to_mm[XYZE_N];
155
                  steps_to_mm[XYZE_N];
156
     static uint32_t max_acceleration_steps_per_s2[XYZE_N],
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
     static float min_feedrate_mm_s,
160
     static float min_feedrate_mm_s,
161
                  acceleration,         // Normal acceleration mm/s^2  DEFAULT ACCELERATION for all printing moves. M204 SXXXX
161
                  acceleration,         // Normal acceleration mm/s^2  DEFAULT ACCELERATION for all printing moves. M204 SXXXX
162
                  retract_acceleration, // Retract acceleration mm/s^2 filament pull-back and push-forward while standing still in the other axes M204 TXXXX
162
                  retract_acceleration, // Retract acceleration mm/s^2 filament pull-back and push-forward while standing still in the other axes M204 TXXXX
214
 
214
 
215
     #ifdef XY_FREQUENCY_LIMIT
215
     #ifdef XY_FREQUENCY_LIMIT
216
       // Used for the frequency limit
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
       // Old direction bits. Used for speed calculations
218
       // Old direction bits. Used for speed calculations
219
       static unsigned char old_direction_bits;
219
       static unsigned char old_direction_bits;
220
       // Segment times (in µs). Used for speed calculations
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
     #endif
222
     #endif
223
 
223
 
224
     #if ENABLED(LIN_ADVANCE)
224
     #if ENABLED(LIN_ADVANCE)
439
       if (blocks_queued()) {
439
       if (blocks_queued()) {
440
         block_t* block = &block_buffer[block_buffer_tail];
440
         block_t* block = &block_buffer[block_buffer_tail];
441
         #if ENABLED(ULTRA_LCD)
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
         #endif
443
         #endif
444
         SBI(block->flag, BLOCK_BIT_BUSY);
444
         SBI(block->flag, BLOCK_BIT_BUSY);
445
         return block;
445
         return block;

Loading…
Cancel
Save