I started to write an application that calculates the estimated total print time from the G-code file for an already sliced model.

The program works and it's pretty accurate.

It works as follows:

  1. It scans the entire G-code file to identify all of the movements
  2. It calculates the time for each move by dividing segment distance by the speed in mm/s.

Let's assume this is the G-code:

G28 ; home all axes
G1 Z0.200 F5400.000
G1 X158.878 Y27.769 E6.65594 F900.000

This is the calculation it does:

totalTime = 0

# G28 ; home all axes
currentX = 0 mm
currentY = 0 mm
currentZ = 0 mm

# G1 Z0.200 F5400.000
newZ = 0.2 mm
mmPerSecond = 5400 / 60 = 90 mm/s
deltaZ = newZ - currentZ = 0.2 - 0 = 0.2 mm
segmentLength = deltaZ  = 0.2 mm
moveTime = segmentLength / mmPerSecond = 0.2 / 90 = 0.002 s
totalTime = totalTime + moveTime = 0 + 0.002 = 0.002 s

# G1 X158.878 Y27.769 E6.65594 F900.000
newX = 158.878 mm
newY = 27.769 mm
mmPerSecond = 900 / 60 = 15 mm/s
deltaX = newX - currentX = 158.878 - 0 = 158.878 mm
deltaY = newY - currentY = 27.769 - 0  = 27.769 mm
segmentLength = square_root(deltaX² + deltaY²) = 161.287 mm
moveTime = deltaZ / mmPerSecond = 161.287 / 15 = 10.755 s
totalTime = totalTime + moveTime = 0.002 + 10.755 = 10.757 s

In this example, the print will take approximately 10.7 seconds.

More generally, the formula used is, for each movement:

moveTime = segmentLength / mmPerSecond

By summing up all the move times, we have the total estimated print time.

I've seen that some forums state that the 3D print time also depends on some settings on the 3D printer, especially Acceleration X, Acceleration Y, Acceleration Z, Jerk, and Z-Jerk.

I'd like to make it possible to use those values to more accurately calculate print time; however, I don't understand how those values affect the move time:

  1. How should Acceleration and Jerk be considered; and, how do they speed up or slow down the print time?
  2. How should I edit my formula in order to include Acceleration and Jerk in the print time calculation?
  • $\begingroup$ How acccurate do you need to be? Yes you can plug in the accelerations, and compensate for short runs where the motors never reach full speed before decelerating, and so on, but if the net result is only off by, say, 2%, do you care? Try printing something simple like a square pyramid and compare your prediction to reality. $\endgroup$ – Carl Witthoft Dec 21 '16 at 14:25
  • $\begingroup$ I'd like to be as much precise as possible... Right now on a 9 hours print the difference between prediction and reality is 10-15 minutes, which is a lot. I'll look at marlin source code to find how acceleration and jerk are handled while printing $\endgroup$ – BackSlash Dec 21 '16 at 17:37

I have tried looking into the printer firmware to see how the Acceleration setting affects the machine movement. From what I could tell, Acceleration seemed to be implemented differently depending on what firmware I looked at and was also affected by what the settings used on the printer were. I didn't look any further because writing different rules for every different firmware seemed like too much trouble. Maybe someone that knows more about this would know if most firmware uses the same calculations.

I suspect that the acceleration setting will not make a lot of difference to the time that the print takes. They haven't seemed to make a difference on the small prints that I have done printing with slow speeds. If you were printing larger prints at faster speeds that had long paths where the nozzle had time to accelerate and decelerate then I suspect you would notice a bigger difference with the time.

I have found that the biggest error between the predicted time and the actual time has been the time the machine spends processing the instructions. When printing a model that has a lot of short movements that need to be sent to the printer and they need to be processed and calculated by the printer, I have noticed the printer will pause for a fraction of a second. It is not long enough to see a difference in the printers movements, but it is noticeable enough to hear. I suspect that on cheaper printers this would cause a bigger error than the acceleration.

If someone can find out how the acceleration settings are calculated by the printer and what G-code command can be used to get the acceleration settings out of the printer, I would be really interested in knowing more about this.

  • $\begingroup$ Thank you for your answer, I'll keep searching. Thanks for pointing me in the right direction: I can read the Marlin source code and search for the acceleration and jerk control parts, it will surely help, I didn't think about it! Thank you! $\endgroup$ – BackSlash Dec 21 '16 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.