Monday, 9 November 2020

Prusa Slicer Pausing Octoprint and MK3S to Embed Magnets


There are many ways of pausing a 3D printer in order to insert magnets, all of which require the GCode (which is downloaded to the printer) to be modified.

This note takes you through a quick how-to, and a few common methods.

Inserting the GCode

The easiest way to insert the GCode to trigger a pause is to do it within PrusaSlicer.  Immediately after you have sliced your model, you can drag the vertical slider to the right of the platter image down to the layer at which you want to insert a pause.

Simply right-click on the (+) to get to the insert GCode options.

Hint: If you don't see a (+), make sure that your Print Settings / Output Options / Sequential Printing / Complete Individual Options is disabled.

Using the M600 Option

M600 Pause Showing

M600 is designed to allow a filament change.  What the printer does, is push the job to the back so that the head can be easily accessed.  It should be noted that the head belt is locked quite tightly so it will be very difficult to knock out the print alignment when the job resumes.

It forces you to go through a removal and re-insertion of the filament.

The removal and re-insertion of the filament can cause bleed through of other colours that have been in the head beforehand.  This can be seen in the photo on the right.

However it performs a good retraction and pre-load so that there are no gaps in the final item.

M601 Resuming after heatbed has
been allowed to cool down

Using the M601 Option

M601 is a Pause Print command - unlike the M600 option this pushes the print job forward so that it can be accessed.  It doesn't go through a filament reload sequence, and it allows you to restart the printing through the front panel.

Note that the way the M601 code operates within the Prusa printer has evolved over time, and there have been problems with continuous loops.

The head and bed cool down whilst paused, and heat up again afterwards, which can result in parts becoming detached when printing resumes.

Using Custom G1/M1 Code

The G1 code is used to move the print head, and the M1 code is used to pause/ resume.

G1 X10.000 Y200.000 E0;


In this case, the job is pushed forward so it can be accessed, but in this case, the restart has to be done through the Octoprint interface (Resume is not offered on the front panel).

This code does not result in the bed or head cooling down, so the part remains adhered to the bed (at least until any safety timeouts occur).

Because the head remains heated, and no retraction is performed, it will tend to ooze, and when the print resumes, there may be missing filament as can be seen in the left-hand image below.

This can be "hidden" by changing the print to print the internal fill first, and the external layer last.  This should not be a method of choice if your print job has overhangs, however.

Print Pause using G1/M1 with Perimeters First shown on the left,
and Infill First shown on the right

Using Custom Octoprint Pause

In this case, Octoprint itself is responsible for managing the pause.  

Octoprint can intercept the @pause instruction, which can be be inserted into the GCode at the desired layer using the mechanism described above  Note that this command must be in lower case, otherwise the pause is ignored.

In the Octoprint Settings / GCode Scripts, there are two sections for before and after pause.  It is important that the crafted code is consistent with whether the print jobs are constructed using absolute / relative coordinates.

So in the Printer Advanced settings, make sure that "Use relative E distances" is selected. If you are going to use the following code.

The following code retracts filament, moves the head away, and then leaves the heatbed on, but allows the head to cool down to half its normal temperature.

On resuming, the head is heated up to its normal temperature + 5 degrees (in this example).  The head is primed and a compensation for any oozing or stringing is applied.  The head is then set to drift back its normal temperature as printing resumes.

In Octoprint, Insert the following GCode into the "After print job is paused" section:

{% if pause_position.x is not none %}

  M300 S261.63 P100 ; Beep C4

  ; relative XYZE

  ; retract filament
  G1 E-2.5 F4500

  ; move Z slightly upwards
  G1 Z+15 F4500

  ; absolute XYZE

  M300 S329.63 P100
; Beep E4

  ; move to a safe rest position, adjust as necessary
  G1 X20 Y180

  {% if pause_temperature[0] and pause_temperature[0]['target'] is not none %}

      ; set temp to orgtemp/2 but don't wait
      M104 S{{pause_temperature[0]['target']/2}}

  {% endif %}

  M300 S440.00 P100 ; Beep A4

{% endif %}

And the following GCode into the "Before print job is resumed" section (note see below for compensation factor):

{% if pause_position.x is not none %}

  ; absolute XYZ


  ; relative extruder


  M300 S261.63 P100 ; Beep C4

  ; set temp to orgtemp and wait

  {% if pause_temperature[0] and pause_temperature[0]['target'] is not none %}

      ; set temp to orgtemp and wait

      M109 S{{pause_temperature[0]['target']}}

  {% endif %}

  M300 S329.63 P100 ; Beep E4

  ; prime nozzle

  G1 E-2.5 F4500

  G1 E2.5 F4500

  G1 E2.5 F4500

  {% if pause_temperature[0] and pause_temperature[0]['target'] is not none %}

      ; set temp to slightly increased orgtemp and wait

      M109 S{{pause_temperature[0]['target']+5}}

      ; set temp to orgtemp but don't wait

      M104 S{{pause_temperature[0]['target']}}

  {% endif %}

  ; Ooze compensation

  G1 E<<compensation factor>> F4500

  M300 S440.00 P100 ; Beep A4

  ; absolute E


  ; reset E

  G92 E{{ pause_position.e }}

  ; move back to pause position XY

  G1 X{{ pause_position.x }} Y{{ pause_position.y }} F4500

  ; move back to pause position Z

  G1 Z{{ pause_position.z }} F4500

  ; reset to feed rate before pause if available

  {% if pause_position.f is not none %}

      G1 F{{ pause_position.f }} 

  {% endif %}

{% endif %} 

Note that the above scripts support a printer with a single head (i.e. pause_temperature[0] refers to the first head).

Oozing Compensation

Despite all effort, the printer will still lose some filament through oozing or stringing during the pause process.  A larger retraction could be applied, but there is always the danger of retracting hot filament into the thermal break.

If you can measure the amount of filament oozed (or more likely, left stringing when the head retracts) and this amount of filament is of a relatively consistent size, you can apply a compensation factor which will further pre-load the head.  If you do not need this factor, you can simply comment out the line in the GCode.

The compensation factor depends on the size of filament used, and size of nozzle.  Use the following table to translate oozed/strung mm of filament to an E compensation factor.