• Stars
    star
    279
  • Rank 147,967 (Top 3 %)
  • Language
    Rust
  • License
    MIT License
  • Created over 3 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Klipper print time estimator

klipper_estimator is a tool for determining the time a print will take using the Klipper firmware. Currently it provides the following modes:

  • estimate mode outputs detailed statistics about a print job
  • post-process mode can be used as a Slicer post-processing script, updating the gcode output file with corrected time estimates.
  • dump-moves mode dumps planning data for every move in a file

The estimation is done using an implementation of Klippers kinematics, but may in some cases be slightly off due to rounding modes. If the timing is far off(e.g. more than a minute over a >12 hour print), this is considered a bug.

Note that currently delta kinematic limits are not implemented.

Getting klipper_estimator

Pre-built binaries are available for the latest release on the GitHub Releases page. If you wish to build the tool yourself or poke around the source, see the Building section.

Binaries are provided for Windows, Linux, Mac OS X, and Raspberry Pi targets. On Linux and Mac OS X, ensure that you give the downloaded file executable permissions. This can be done in the terminal as follows:

$ chmod +x klipper_estimator

Change the filename (last parameter) to match the downloaded file.

For Arch Linux, an AUR package klipper_estimator is available, courtesy of Wilhelm Schuster. Thanks!

Usage

Basic usage info can be found by running klipper_estimator with no arguments.

Configuration

In order to provide accurate times, klipper_estimator needs printer settings including maximum velocity, acceleration, etc. It can take these either from a config file(--config_file option) or grab them directly from Moonraker(using the --config_moonraker_url option and, if authentication is required, --config_moonraker_api_key). Note that the Klipper configuration files cannot be used directly.

To experiment with settings, one can use the dump-config command together with --config_moonraker_url to generate a config file based on the current printer settings. The config file can then be modified and used as input for the other commands.

To dump a config, use e.g.:

$ ./klipper_estimator --config_moonraker_url http://192.168.0.21 dump-config > config.json

The config file format is Json5 and thus allows normal JSON with some extensions(see https://json5.org/).

After generating a config, one can use this in other commands like so:

$ ./klipper_estimator --config_file config.json estimate ...

Quirks

Be aware of the following "quirks" when using klipper_estimator compared to Klipper itself:

Relative extrusion by default

klipper_estimator assumes relative extrusion and absolute movement by default. This is different from Klipper, which assumes absolute extrusion as well. This difference exists because klipper_estimator can't see inside macros. Most users use relative extrusion, and put the M83 command in their print start macro, making it invisible to klipper_estimator.

If you wish to use absolute extrusion, you must ensure that an M82 command is inserted in your slicer start gcode. E.g.:

PRINT_START
M82

estimate mode

Estimation mode is useful for determining statistics about a print, in order to optimize print times. It gives a high level summary.

Basic usage:

$ ./klipper_estimator [config options] estimate ~/3DBenchy.data
Sequences:
 Run 0:
  Total moves: 42876
  Total distance: 73313.01640025008
  Total extrude distance: 3407.877500000097
  Minimal time: 1h29m9.948s (5349.947936969622)
  Average flow: 1.5321468696371368 mm3/s
  Phases:
    Acceleration: 27m4.291s
    Cruise:       35m1.116s
    Deceleration: 27m4.291s
  Moves:
  Layer times:
         0 => 2.536s
         ... [some lines omitted for brevity]
        48 => 4.834s
  Kind times:
   4m23.463s            => FILL
   2.639s               => Other
   18m0.185s            => SOLID-FILL
   28m29.706s           => WALL-INNER
   38m13.706s           => WALL-OUTER

The calculations are done based only on the commands found in the file, with no regards for macro expansions. This means that print_start type macros will count as zero seconds, as well heat up times, homing, etc. Therefore the time output should be considered a "minimal time", assuming these extra factors take no time.

post-process mode

In post-process mode klipper_estimator directly modifies the filename passed in in-place, updating time estimations in the file.

When using klipper_estimator in post-process mode, simply add a post-processing script in your slicer like so:

/path/to/klipper_estimator --config_moonraker_url http://192.168.0.21 post-process

Change the path and config options to fit your situation.

Currently the following slicers are supported:

  • PrusaSlicer
  • SuperSlicer
  • OrcaSlicer
  • ideaMaker
  • Cura
  • Simplify3D

In PrusaSlicer, SuperSlicer, and OrcaSlicer Post-processing scripts are set in Output Options under Print Settings:

PrusaSlicer, Orcaslicer, and SuperSlicer Post-processing scripts option

Note that ideaMaker does not have support for post-processing scripts, and thus cannot automatically run klipper_estimator on export.

For Cura, using klipper Preprocessor is recommended. See their git repository for information on how to set up this tool.

In Simplify3D the relevant estimation command must be added under Scripts in the Additional terminal commands for post processing field. This field is just called Post Processing in V5.x, and the command should be appended with a [output_filepath].

/path/to/klipper_estimator --config_moonraker_url http://192.168.0.21 post-process [output_filepath]

dump-moves mode

The dump-moves mode is used like estimate mode, but instead of providing a summary, move planning data is dumped for every move.

Accurately estimating PRINT_START/PRINT_END macros

Klipper macros can perform arbitrarily complex operations. klipper_estimator has no hope of estimating how long these will take, as the Jinja templates can access any state of the read printer. However it is often the case that the amount of print time actually spent within the macro is constant. A prime example of this is print start macros. The macro may execute homing and heating commands, but the print timer does not start until the first material is extruded. This generally happens when the prime line is started.

This gives rise to an offset in print time that we cannot estimate, but the user can easily measure it after a print is over.

To compensate for this, klipper_estimator understands the following gcode comment(generally syntax followed by some examples):

; ESTIMATOR_ADD_TIME <duration, seconds> [description]
; E.g.:
; ESTIMATOR_ADD_TIME 21
; ESTIMATOR_ADD_TIME 21 Print start

When klipper_estimator encounters a comment with this format, it will add the requested duration to the total print time. The time will also be tracked as a "move kind", if the description field is given.

Note that only the upper-case string ESTIMATOR_ADD_TIME, on a separate comment line, will trigger this behaviour. Any whitespace between the ; and E characters will however be ignored.

The intended usage of this functionality is for print start macros, when executed by the slicer. E.g. in PrusaSlicer, SuperSlicer, or OrcaSlicer, one might set their print start gcode like this:

; ESTIMATOR_ADD_TIME 20 Prime line
print_start extruder=[first_layer_temperature] bed=[first_layer_bed_temperature]

Building

klipper_estimator is written in Rust. Version 1.58 or newer is required to compile the tool. Assuming a Rust toolchain is installed, along with git, one can build klipper_estimator by running:

$ git clone https://github.com/dalegaard/klipper_estimator.git
$ cd klipper_estimator
$ cargo build --release
// Resulting binary will be at `target/release/klipper_estimator`(.exe on Windows)

Acknowledgements

This project is in no way endorsed by the Klipper project. Please do not direct any support requests to the Klipper project.

More Repositories

1

Sherpa_Mini-Extruder

A smaller version of the sherpa extruder, direct and bowden supported
713
star
2

TradRack

A MMU system developed by ANNEX Engineering
Python
507
star
3

Gasherbrum-K3

Open Air or Fully Enclosed, Small Format, Moving Bed, CartesianXY, FDM 3D Printer with Direct Drive Extrusion System
376
star
4

Sherpa_Micro-Extruder

a more compact version of sherpa mini
197
star
5

Annex-Engineering_User_Mods

mods created by users of ANNEX Engineering printers
Python
177
star
6

Quickdraw_Probe

A Magnetically Coupled, Removable, Z Probe and Dock System
160
star
7

Belay

A sensor for FFF 3D printers for keeping a secondary extruder in sync with the primary extruder, with an accompanying Klipper module
Python
148
star
8

Chhogori-K2

Fully Enclosed, Medium Format, Moving Bed, FDM 3D Printer with Direct Drive Extrusion System
148
star
9

Other_Printer_Mods

Modifications created by Annex Engineering for other printers (i3s, etc)
141
star
10

Masherbrum-K1

Fully Enclosed, Medium Format, Moving Gantry, FDM 3D Printer with Direct Drive Extrusion System
108
star
11

Folded_Ascender-Extruder

a small stepper powered, worm geared, direct drive extruder/toolhead system
66
star
12

anchor

Anchor, a Rust Klipper protocol implementation
Rust
55
star
13

Redoubt

Papejellys Pet Project - Moving Gantry - Fixed Bed - CoreXY
53
star
14

Rebreather

48
star
15

Annex_Engineering_PCBs

PCBs Designed by the ANNEX Group
HTML
42
star
16

Denali

A CoreXY, Tri-motor Moving Bed, Direct Drive, FDM Printer
38
star
17

Misc_Designs

Misc Designs that dont have a home
26
star
18

Sherpa_Heavy-Extruder

Sherpa Mini's fat cousin, built to push filament to flowrates of 100mm^3/s
25
star
19

the_moron

mentals portal theme'd voron files
24
star
20

Sherpa-Extruder

A 6:1 Bowden and Direct Drive Extruder Platform
22
star
21

Constellation

a series of control boards from ANNEX Engineering
21
star
22

Chhogori-K2-Basecamp-Edition

Open Air, Medium Format, Moving Bed, FDM 3D Printer with Direct Drive Extrusion System
18
star
23

windlass

Windlass, a Rust Klipper host side protocol implementation
Rust
15
star
24

Gasherbrum-K3-Plus

K3s Big Brother, Fully Enclosed, Small Format, Moving Bed, CartesianXY, FDM 3D Printer with Direct Drive Extrusion System
13
star
25

Annex-Engineering.github.io

11
star
26

crampon_anchor

A crampon firmware built on anchor in rust
Rust
6
star
27

Filament_Cabinet

Filament Cabinet for 1 5kg spool or 3 1kg spools
5
star
28

ANNEX-Printer-Firmware

Firmware configurations and guides for ANNEX Printers
Python
4
star
29

Tycho

yea, dont build one of these
4
star
30

Software

Software written by the Annex-Engineering team
Python
3
star
31

tools

Web-based tools living at tools.annex.engineering
TypeScript
1
star
32

LeConte

Mental's Pet Project
1
star
33

Matterhorn

The Printer that Started ANNEX
1
star