3D Printer Retraction Calibration Vol II – Calibration Generator Program Release

Good day. Karl here. It has been a while since I have submitted any articles. I got burned out and my normal day job picked up considerably. I have been keeping busy but not with anything I would share by itself. I will start out with an update on what I have been up to. You can skip to the 3D printer retraction calibration section with the release of the Calibration Generator tool if you are not interested.

What have I been up to?

First, I have been doing a lot of gaming. Been playing Fortnite, Red Dead Redemption 2, and some other random games. I am trying hard to keep up with my son.

Unraid OS Interface Screenshot – Click to Enlarge

Unraid OS. So many things to explore and learn. Docker, VM’s, and storage. There is so much goodness in this OS. I was able to consolidate several services into one box. I had a standalone NAS drive that I went way too long trusting my data with and a small windows box that had an atom processor which ran Home Assistant and my Unifi controller. What started my journey with Unraid was my son’s interest in PC gaming. I didn’t want to buy a whole new PC so I went down the “2 gamers 1 pc” path and now can run 2 gaming machines with 2 discreet graphics cards off of one box. Additionally, I added a SATA card, 2 USB PCIe boards for hotplug USB passthrough. It is such a pain not passing an entire USB controller through. Finally, I added a couple of hard drives for storage and parity.

Click to Enlarge

I have been reading and watching about sous-vide cooking and made a slow cooker sous-vide machine. It lacks a circulator but it seems just as effective. Sous-vide cooking is cooking at a precise temperature in a water bath. I chunk whatever I want to cook in a ziplock back with spices and let it cook.  I wasn’t about to spend a minimum of $100 for one of the machines to find out it wasn’t worth it. I spent about $7 for a temp sensor paired with a Sonoff basic I already had. I am happy with the setup and it seems to stay within a few degrees with only slight overshoot. Setup took a couple of hours and I am very satisfied with the results. Carrots are fantastic, probably my favorite thing to cook so far. I have cooked some country-style ribs and some inexpensive cuts of beef. This is one of my newer projects so I haven’t done a lot of experimenting.

New Home Office – Click to Enlarge

Finally, I remodeled my office and did a big purge. I work from home and started to get self-conscious about my workspace. I had pegboards on all my walls. Just didn’t look very professional.  I installed Zoom rooms and felt obligated to be on video on all calls. I have a couple of clean walls now so I don’t have to rely on virtual backgrounds. I just need to position my camera strategically. I still have some things I would like to do, but I’m much happier with my office now. Enough rambling… Let’s get down to business.

3D Printer Retraction Calibration Vol II

Retraction Calibration 3D Printers

Back in September 2019, I wrote an article entitled “How to Easily Calibrate Retraction in 3D Printers” It is where I first came up with the idea of how to systematically find the best retraction settings. This article expands on that. Since then I received a lot of feedback and help with testing. The spreadsheet was clunky and not the easiest to use. The spreadsheet laid the foundation and proof of concept and this application expands on that. Some people had issues and I wasn’t clear on a few items. I wanted to make it easier to use and add additional features that would have been very difficult if not impossible to do in google sheets.

Calibration Generator – Who and what is this for?

Anyone can use the Calibration Generator tool but is most useful for custom or modified stock printers. If you have a stock printer you can easily use the settings that have proven to work and shared by others from various sources from around the interwebs.

Let’s define a few things and discuss what retraction is. First, a 3D printer pushes a plastic filament through a heated nozzle and deposits plastic one layer at a time to form an object. I believe we all understand this. But, not all movements require molten plastic to come out of the nozzle. If a 3d printer only stopped pushing the filament during theses non extruding moves, the nozzle would ooze due to pressure build-up. This is where retraction comes into play. Retraction is when the motor pushing the filament through the heated nozzle runs backward to help alleviate this pressure. This introduces the first fundamental parameter. How far do we need to pull the filament back? Aka retraction distance. Then we need to talk about at what speed. Aka retraction speed. So far we have 2 variables. Retraction distance and speed. These 2 variables have the most influence on stringing and oozing and can be frustrating/ time consuming finding the perfect combination. Additionally, nozzle temperature and the part cooling influence this as well but will touch on this more later.

Before I created the previous spreadsheet I would try different combinations of speed and distance with a test model. This was time-consuming and where the Calibration Generator tool comes into play. It generates g-code based on user inputs to systematically test different combinations of speed and distance. Additionally from feedback, some additional parameters can be tested as well.

Source, Security, and other OS’s

I created this program in Python and PyQT, and the executable is not signed. It looks like it would cost about $500 per year to purchase a certificate. If you have any concerns all source code is available on Github. Please forgive my code. I am not a programmer. I attempted to compile for Ubuntu and macOS but with my limited skills, I was not successful. Maybe the next step is to create a website to truly make this universal. [Update: It works on Ubuntu 20.04, see comments section]

  • X Dimension: Input your printers x size here. For delta printers set to 0.
  • Y Dimension: Input your printers y size here. For delta printers set to 0.
  • Starting Retraction Distance: This is the first retraction distance that will be tested in mm.
  • Increment Retraction: Retraction distance that is added to each subsequent test in mm. The default settings of .5 starting retraction distance and .5 increment retraction will generate gcode that tests .5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8 retraction distances.
  • Start Retraction Speed: This is the first retraction speed that will be tested.
  • Retraction Speed Increment: Retraction speed that is added to each subsequent test. The default settings of 10 starting retraction speed and 10 retraction speed increment will generate gcode that tests 10,20,30,40,50,60,70,80,90,100,110,120,130,140,150 mm/s retraction speeds.
  • Print Speed: Printing speed in mm/s
  • Starting Temp: First nozzle temperature that will be tested in C
  • Increment Temp: Temperature increased each subsequent test in C
  • Bed Temp: Bed Temperature in C
  • Fan Speed %: First fan speed that will be tested 0-100%
  • Fan Speed Increment: Fan speed that is added to each subsequent test in %
  • Nozzle Diameter: Diameter of the nozzle in mm
  • Layer Height: Layer height in mm
  • Filament Diameter: Filament diameter in mm
  • Extrusion Multiplier: Extrusion multiplier .9 will extrude slightly less. 1.1 will extruder slightly more
  • Travel Speed: Travel speed in mm/s
  • Custom Gcode: Add any custom gcode or autobed leveling here.
  • Layers per Test: Number of layers in each test group (Affects height on the print)
  • Numbers of Tests: Number of tests (Affects height and affects how many Retraction Speeds, Nozzle Temperatures, and Fan Temperatures will be tested)

Any incremental variable can be set to 0 to statically assign the variable. Only test 1 of the following incremental variables at a time. Retraction Speed Increment, Increment Temp, Fan Speed Increment. Set the remaining to 0. Review variables by height in gcode.

Once all your variables are set press Generate Gcode. Save the gcode somewhere easy to find and open with a text editor.

Before we look at the gcode let’s understand what we are printing. Pictures and animated gif will help to explain.

3d printer retraction testing

  • At the start of each new test, there is a loop. The origin has a larger loop.
  • The dots indicate where the retraction points are
  • The retraction distance increases incrementally at each new dot
  • The non-extruding movement represented with yellow lines
  • In the picture above, you can see where the retraction speed increases as you go up the tower

Here is an example with everything default. You will need this to identify optimal settings and analyze the print.

The first section is to help identify the retraction distance. The perspective is from a top-down view with the origin at the bottom left between .5 and 8mm. Starting Retraction Distance and Increment Retraction dictate what retraction lengths are tested. Defaults are shown.

Variables by height show the Retraction Speed, Nozzle Temp, and Fan Speeds based on Layers per Test and Number of Tests. If the Number of Tests was set to 10 Testing would stop at a retraction speed of 100mm/s. This area shows the variables when looking from the side. Defaults are shown.

All Inputs show all the input variables for reference.

Send the gcode to your printer via your usual method. I have not tested with Octoprint.

Open Mind and Setup

Please go into this with an open mind. Please try defaults first before deviating from the default values, especially when it comes to printing temps and fan speeds. All the defaults are for PLA and you will need to adjust accordingly for other materials.

Direct drive. Traditionally with direct drive printers, retraction distances are relatively short compared to Bowden style printers. I would recommend deviating from the default .5 increment retraction to a .25 increment retraction with a direct drive.

Fan Speed. If you have a sir blows a lot fan(s) I recommend the slower fan speed. Cooling is one of the easier printer mods and I feel is very easy to push too much air and influence the print in a negative way. I am sorry I don’t know how to quantify this without special tools. In my experience, a whoosh is better than a jet of air.

Hotend temps. In my experience, 210°C is the sweet spot with PLA filament,  235-240°C for PETG/ABS. This tool tunes retraction to the material and temperature. So far I have only had to deviate adding 5°C to get rid of little wisps of filament.

Caveats and Unknowns

This all sounds wonderful but we don’t live in a perfect world. I have had a few people share results that were unreadable. I don’t know why but all the tests look the same. I don’t know if a firmware issue or maybe calibration issue. Or maybe the gcode is malformed. The printers I have have been obvious and easy to read. On the Sovol SV01, I did have to be very critical and magnify the retraction points to find the best speed. If you run into results like this I created a Facebook group for this software, so we can share experiences and figure out why some printers behave this way.

Please note is that I only have a limited amount of printers to test with so my experiences are limited to these and the dozen or so people I have worked with. If you have time please share your experiences on the Facebook group. This will absolutely help.

After some time I will do an additional article sharing any gained knowledge from the FB group.

Thank you

A really huge shout out to Gene. There would be absolutely no way that I could have got this done this quickly without his help. He helped me get the building blocks for the program setup during a live stream.

Here is a link to the Windows version of Calibration Generator tool.

Happy Printing!

Support CNX Software - Donate via PayPal or become a Patron on Patreon
Notify of
newest most voted
Jean-Luc Aufranc (CNXSoft)

I have no problem building it and running it in Ubuntu 20.04:


And finally, I can run it as follows: 


30 days ago

Excellent. Thank you

28 days ago

Says the file has a Trojan Virus and gets blocked by my computer.

28 days ago

Yes I got that too on one of my vm’s. I contacted Microsoft about it once already for a previous version. To get around this I went into security panel and told it was ok and restore.

28 days ago

Thanks, Karl. Great work!

16 days ago

I have a web version available temporarily on http://prahjister.duckdns.org

Karl Johnson
Karl Johnson
8 days ago

There was a bug in my extrusion calculation that has been corrected now. 1.3.3 is now live.

The temporary webpage is updated, link up above is updated, as well as github