Gcode to pause print indefinitely?

Have questions or comments about Simplify3D, Slic3r, Cura, Reptier, etc? Or wondering about which CAD software to use...discuss it here...
Post Reply
Posts: 2
Joined: Sun Mar 27, 2016 11:34 pm

Gcode to pause print indefinitely?

Post by BAleiHi » Mon Sep 25, 2017 4:07 am

I'm trying to add Gcode to pause my print indefinitely so I can change the color, then resume manually. I'm using the following code on an M2 right before the z-height command for the layer I want to print in the new color:
G91 ; set relative positioning
G1 E-5 F 300; Pull back a little
G0 Z100 F3600; raise Z (drop bed)
M84 S0 ; disable idle timeout
G1 E-95 F 300; Retract Old Color
G92 E0 ; Zero Extruder
G90 ; set absolute positioning
M0 ; Pause Print (I've tried different commands here)
G92 E0 ; Zero Extruder - NEEDED!

The printer pauses at the correct time, but only for about 20-30 seconds. It then resumes before I have time to change the color. I want it to pause indefinitely and resume only when I do that manually from PronterFace. I got the code from my brother who uses it successfully on his M2, but it's an earlier model. I've also tried M1, M25 (though my file is not on the SD card), and M226. They all behave the same way. Thanks in advance for any info or advice.

User avatar
Posts: 1136
Joined: Fri Apr 11, 2014 5:34 pm
Location: Halfway up the Hudson

Re: Gcode to pause print indefinitely?

Post by ednisley » Mon Sep 25, 2017 4:10 pm

BAleiHi wrote:pause my print indefinitely
Almost certainly, you're looking at an interaction between the program (S3D?) running on the PC and the Marlin firmware in the printer, with the results depending on which versions you have on each end of the USB cable.

In isolation, M0 would (probably) shut the printer down as described, but I suspect the PC program sends the M0 command, (probably) notes a distinct lack of response despite having a whole bunch of commands in hand, decides to send the remaining commands anyway, and the first of those kickstarts the printer, much as described for the adjacent M1 command.

There may be no way to enter a permanent pause, other than (manually) chopping the G-Code program into hunks and feeding each one to the printer as a separate file.

Now, as to why M0, M1, and all the similar M commands behave the way they do, consider G0 and G1. The former is allowed to make an uncoordinated move if that's faster, but (most ? versions of) Marlin treat it exactly the same as G1, which must coordinate the axes during the move. I'd be unsurprised to discover all the Mx commands have the same overlap, although you'd want to crawl through the source for your version of the firmware to be sure.

Programming should not be an experimental science ... [grin]

Post Reply