Cura icon indicating copy to clipboard operation
Cura copied to clipboard

Add Post Processing script to set initial extruder offset

Open ansonl opened this issue 1 year ago • 0 comments

Description

This post processing script sets multi-extruder printers' initial extruder positions to the correct value after retracting the filament during start G-code.

image

  1. Before priming a nozzle at the beginning of the print, the position of the filament in the nozzle is unknown but assumed to be between switch_extruder_retraction_amount and 0 because the filament may have been retracted the extended switch_extruder_retraction_amount length at the end of the last print (or not). When a print is started and the filament position is assumed to be 0 (at the nozzle already) no/underextrusion occurs for switch_extruder_retraction_amount distance of filament because the slicer assumes the printer is extruding filament when the filament is still moving down the heatbreak towards the nozzle.

  2. Normally multiple nozzles on a multi-extruder printer are primed by extruding some filament during the start g-code to ensure the filament is at a known position in the extrusion train. E.g. Prime by switch_extruder_retraction_amount + a bit more.

  3. When the printer has more than a single nozzle, the extruders that are NOT the initial_extruder_nr need to be retracted by switch_extruder_retraction_amount after priming to avoid oozing.

  4. After start G-code ends and the printing starts, the slicer assumes that each extruder starts from 0 position rather than -switch_extruder_retraction_amount. When switching to each extruder for the first time, the extruder printing movements start with E position of 0 leading to no extrusion for a while until the filament moves down the heatbreak into the nozzle.

  5. The slicer remembers the extruder position when it generates code to retract the extruder by switch_extruder_retraction_amount when the extruder is switched away from in the toolchange and restores the extruder position by moving the filament forward by switch_extruder_retraction_amount distance when the extruder is switched to in a toolchange. So this no/under extrusion problem only happens on the first toolchange until the extruder has extruded at least switch_extruder_retraction_amountmm of filament.

I fixed this issue by creating the post processing script to set the correct position for the extruder to -switch_extruder_retraction_amount for the first time each extruder is used. G92 E0 is corrected to G92 E-16 (if the printer had a switch_extruder_retraction_amount of 16).

I drew the below diagram to visually show the extruder position problem.

extrusion issue

Another solution for this problem would be if Cura assumes that each extruder has been retracted to switch_extruder_retraction_amount distance at the end of the start G-code and starts each extruder's initial position at the start of the print G-code to -switch_extruder_retraction_amount instead of 0.

Type of change

  • [ X] New feature (non-breaking change which adds functionality)

How Has This Been Tested?

I have run this post processing script on multiple prints and extrusion is improved due to setting extruder position to the correct value. No oozing occurs after priming because the extruder retracts filament by switch_extruder_retraction_amount in start G-code and extrusion begins immediately when the slicer switches to that extruder.

Test Configuration:

  • Operating System: Win10

Checklist:

  • [X] My code follows the style guidelines of this project as described in UltiMaker Meta and Cura QML best practices
  • [X] I have read the Contribution guide
  • [X] I have commented my code, particularly in hard-to-understand areas
  • [X] I have uploaded any files required to test this change

ansonl avatar Mar 07 '24 04:03 ansonl