Posts Tagged ‘ pause

Howto: Pause RepRap Fimrware for filament reload at a specific layer number

Like my previous two posts on the subject:

…since I’ve switched my C-Bot 3d Printer to RepRap Firmware, I needed to figure out how to pause it at a specific layer height in gcode.  The wrinkle this time is I have no LCD hooked up to it, so I wasn’t sure how to unpause it.

As it turns out, it’s darn simple (as it should be):  Enter a M226 at the line you want it to pause:

... bunch of gcode....
; layer 2, Z = 0.38
M226

And bam:  It’ll stop right there, executing what’s in your pause.g macro.  From there, you can change filament as needed, then enter a M24 (executing the resume.g macro) via a connected serial console to start the print back up.

Optionally, like mentioned in the above posts, you can use your slicer software (if it supports it) to post-process the gcode to add in the M226 where you need.  Look to those posts as examples of how to do this.

Note:  I’ve had this fail via Octoprint:  3 hours into a 6 hour SD print the gcode triggered an M226 where it was supposed to.  I watched as the print paused, and then I heard all the fans kick off:  The whole board reset, thus canceling the print.  I tried simple tests with Octoprint using small calibration cubes and got similar (negative) results after only a few lines of printing.  Doing the same tests via Simplify3D’s serial console (still printing off the SD) worked however.  In fact, as a sanity check, during the pause I’d disconnect S3D entirely and unplug the USB, then reconnect USB and reconnect the serial console:  I was able to successfully issue a M24 to restart the print, so right now I’m going that route if I need to do a filament change.

Howto: Pause Repetier for filament reload at a specific layer number

Last year I posted Howto: Pause Marlin for filament reload at a specific layer number.  Since then I upgraded (I consider it an upgrade) to Repetier, and wanted to do the same thing.

The above link has a chunk of G and M codes  that could be inserted into the .gcode script at a given line number to pause it, allowing you to do a filament reload by hand. I figured you could do the same thing in Repetier.  As it turns out you can, and actually it’s a lot easier… presuming it works in the first place:

Repetier allows you to ‘Reload Filament’ via the LCD.  However, I immediately ran into a problem:  After the reload, it wouldn’t return to the correct position on the build plate:  It was always offset by some amount.  Basically ruining the print every time I tried.  Long story short:  You need to configure the firmware to “not home” after filament reload.  Two ways to do this:

Via the online configuration tool:  In the features tab under the “Filament Change” section, I set the “Homing after Filament Change” to “No Homing”.

Or in your Configuration.h set:

#define FILAMENTCHANGE_REHOME 0

Now, I can reload filament successfully via the LCD.

And via the M600 Mcode:  Up until then, whenever I’d try this code (which starts the filament reload process the LCD uses) I’d run into the exact same problem.  But now it works, so we can add it to our gcode file.

Why was this needed though?  You can follow the play-by-play on the Repetier firmware form here, but in a nutshell:  In my ‘start gcode’, I move my toolhead to the corner of my buildplate and ‘zero’ it there.  During Repetier’s ‘rehome’ operation during the reoload, it basically nukes those coordinates, thus putting an offset into my print.

Repetier’s ‘reload filament’ code is so simple (just that one line) compared to Marlin, you can easily enough by hand go into your gcode file, find the line number like this:

; layer 4, Z = 0.78

And insert it in where needed:

M600
; layer 4, Z = 0.78

Or, like mentioned in the previous post, you can use your slicer software (if it supports it) to post-process the gcode to add this in where you need.  Snip from last years post:

I slice using Simplify3D:  In a given process, it has a section in its ‘Scripts’ tab, at the bottom, called ‘Additional terminal commands for post processing’.  This allows you to enter in script to do a text-replace in your file, to edit it for you.  I learned about it on a forum post here.

To do the above using that system, you’d need to enter this text into that field:

{STRIP ";   postProcessing,"}
{REPLACE "; layer 4," "M600\n; layer 4,"}

And (like last years post),  some really important things to note:

  • The fist line that says ‘STRIP’ is super important:  If you don’t do this, Simplify3D will embed a copy of the REPLACE line in the header of the gcode, but won’t properly comment it out, basically ruining the gcode.
  • In the STRIP line, there needs to be exactly three spaces between the semicolon ‘;’ and the ‘postProcessing text.  Any more or less will screw up the strip.  If you copy-paste this code, make sure there are three spaces in there.
  • As you can see, you need to insert newline characters (\n) into the string you’re building for it to show up properly in the gcode later.

I have been made aware that you can also do something similar via Repetier Host:  The goal of this is to print entirely untethered, with precisely defined pause-points in the code for filament change, so host software (Repetier or otherwise) is out  of the question what what I’m trying to solve.

Howto: Pause Marlin for filament reload at a specific layer number

I’ve had fun in the past printing maps with water (SF Bay, Oahu) : Using my Replicator 1 & it’s Sailfish firmware, it was easy via the LCD to set a specific layer number to pause at:  Doing this, I’d calculate which layer the print transitioned from water to land, pause it there, and swap filament.

Marlin firmware (which is on my C-Bot) gives you no such feature via the LCD :  Which means you have to monitor the print, and when it appears land is printing, you quickly pause the bot, go through the manual steps (via the LCD) to lower the bed, possibly move the hotend out the the way, and do the reload.  Afterwards (via the LCD) you have to get everything back into position. Awkward.  I am aware that the latest cut of Marlin allows for filament reload via the LCD:  I’ve been unable to get it to work.  And even if it did work, it’s still not accurate enough since I’m guessing at the layer to pause at.  There must be a better way!

There is:  You can directly edit the .gcode to insert a chunk that will do exactly what you need:  Lets say you want to pause just before layer 2 starts:  You’d find the line starting with the layer change comment…

; Layer 2

in your .gcode file, and then paste this right above it (I’ve included the layer change comment in the below code, plus comments for what the commands are doing):

G91                  ; Put in relative mode
G1 Z10               ; Lower bed by 10mm
G90                  ; Put back in absolute mode
G1 X0 Y0             ; Zero (home) the X & Y
M0 Click To Restart  ; Pause and wait for the user
G91                  ; Put in relative mode
G1 Z-10              ; Raise the bed back up 10mm
G90                  ; Put back in absolute mode
; layer 2, Z = 0.45

Works like a charm :)

If your slicing software supports post-processing of the gcode, it’s possible you can do this work directly in the slicer.  I slice using Simplify3D:  In a given process, it has a section in its ‘Scripts’ tab, at the bottom, called ‘Additional terminal commands for post processing’.  This allows you to enter in script to do a text-replace in your file, to edit it for you.  I learned about it on a forum post here.

To do the above using that system, you’d need to enter this text into that field:

{STRIP ";   postProcessing,"}
{REPLACE "; layer 2," "G91 \nG1 Z10 \nG90 \nG1 X0 Y0 \nM0 Click To Restart \nG91 \nG1Z-10 \nG90 \n; layer 2,"}

Some really important things to note:

  • The fist line that says ‘STRIP’ is super important:  If you don’t do this, Simplify3D will embed a copy of the REPLACE line in the header of the gcode, but won’t properly comment it out, basically ruining the gcode.
  • In the STRIP line, there needs to be exactly three spaces between the semicolon ‘;’ and the ‘postProcessing text.  Any more or less will screw up the strip.  If you copy-paste this code, make sure there are three spaces in there.
  • As you can see, you need to insert newline characters (\n) into the string you’re building for it to show up properly in the gcode later.

Other notes:

  • Handy-dandy gcode reference.
  • If you don’t enter in some text after the M0, it’ll never un-pause (at least for me).
  • I got most of the code on my own, but was able to finish it off based on the help from this thread.
  • My printer starts off in absolute mode by default:  I know this because up at the top of the gcode, I can see a G90 command.
  • The S3D forum post here (under “Additional Terminal Commands For Post Processing”) list other post-processing commands you can use.