3.2.13

Math

How many steps does the printer take to get up to speed? For example, if we have 78.74 steps/mm in X and Y (0.012mm resolution), and the maximum velocity is 120 mm/sec as set in software (Cura), and the maximum acceleration is 9000 mm/sec2 in the Marlin firmware, how many steps does it take to ramp up to the maximum velocity, and what is the corresponding distance?

We assume a trapezoidal velocity profile, i.e. constant acceleration until the maximum velocity is reached, starting from zero velocity and finishing at 120mm/sec. So with an acceleration of 9000 mm/sec2 the time taken to reach maximum velocity is 120/9000 is 0.0133 seconds (13.3 milliseconds). At the start the stepper is not stepping (0 steps per second) and at the end is stepping at 120×78.74 = 9449 steps per second or one step every 0.106 milliseconds.

From basic physics (anyone remember that?) the total distance is found by integrating under the steps per second velocity function. The number of steps to get up to speed can be found by just integrating over the time taken to reach the maximum velocity. That's the pretty blue area in the diagram. Because it is a linear function, the integration is just calculating the area of the triangle (half the base times the height) under the curve, or 0.5×0.0133×9449 = 63 steps, which is 63/78.74 = 0.8 mm.

The takeaway here is that with a 0.4 mm nozzle diameter, it's up to speed within two diameters.

So how does the F variable, the feedrate, in the GCode file correspond to the velocity. Here’s an example:

G1 X91.427 Y90.0 F3600.0 E3.2357

The 3600 is 30 times the Cura specified 120 mm/sec. Why? The answer is that the feed rate is in mm/minute, so this is 60 mm/sec. Why is it off by a factor of two then? Because I grabbed an example from the first few lines of the file (the bottom layer) which has a different maximum velocity (set to 60 mm/sec). If I look further down in the GCode file for example it is 120×60 = 7200 as expected:

G1 X93.376 Y97.826 F7200.0 E2.1045

Some notes:

The theoretical machine maximum velocity is 250.0 mm/sec in the Marlin firmware, but I don’t know anybody who prints that fast.

Some firmware will change from the previous command’s feed rate to the one specified in the current command as it does the move, but the Marlin firmware just sets the feed rate as a constant for the entire move. This means the top line in the trapezoidal profile is always horizontal for Marlin, but other firmware may have a sloped line.

The acceleration value is clipped based on the maximum acceleration of each axis – including Z and E – so the actual acceleration might be less than the example value used above.

1 comment:

  1. Before noting move-to-move feed rate smoothing, you might mention that the look-ahead stuff in Marlin can adjust the start and end speed up from zero, depending on the adjacent moves.

    ReplyDelete