[GUIDE] Octoprint + (stock) Filament runout detection

I finally sat down and worked through getting runout detection working in octoprint using the stock sensor, so I figured I should put it up here in case others want it as well.

Prerequisites

  1. You must set your slicer to use relative extrusions. I use Prusaslicer, and the setting is called “Use relative E distances”. IHNI if luban supports it, but let’s be honest, if you’re using octoprint, you’re probably not using luban :slight_smile:
  2. You should have octoprint set up already, and understand how any settings you’ve configured that aren’t mentioned in this guide may affect the runout resume process.
  3. You will need to install the Terminal Response plugin for octoprint (use the plugin manager).
  4. You will need to flash new firmware to your machine:
    Snapmaker_V4.7.2A_20250115.zip (170.1 KB) (see below for detailed instructions).

Setup

  1. Install the Terminal Response plugin. You should be able to do this using the plugin manager in octoprint.
  2. Go to octoprint settings > GCODE Scripts and set up the following:
GCODE Scripts
Before print job starts
M75
After print job completes
M77
After print job is cancelled
M77
Before print job is resumed
; ======= OCTOPRINT RESUME START =======
M77
M75
; ======= RELOAD POSITION =======
{% if last_position.x is not none %}

; absolute XYZ
G90

; move back to pause position XYZ
G1 X{{ last_position.x }} Y{{ last_position.y }} Z{{ last_position.z }} F4500

; reset to feed rate before pause if available
{% if last_position.f is not none %}G1 F{{ last_position.f }}{% endif %}
; relative E, since octoprint extrude sets to absolute
M83
{% endif %}

  1. In octoprint settings > printer > serial connection disable both Log position on pause and Log position on cancel.
    When this setting is enabled, octoprint sends a M114 after the pause, which causes a loss of the Z position when resuming the print. I tried using this and pause_position, but it wasn’t working correctly for me in octoprint Version 1.10.3
  2. In octoprint settings > plugins > Terminal response add a response:
Terminal response

regex
Filament OUT
command

M114
M600
M76

  1. Save the settings
  2. Install my custom firmware: Snapmaker_V4.7.2A_20250115.zip
Firmware installation
  1. Download the firmware
  2. Unzip it
  3. Place the firmware on a USB stick (for my machine, only the stick that came with the machine seems to work, so probably best to use that)
  4. Plug the USB stick into the machine
  5. Go to Files
  6. Go to USB
  7. Click the .bin file
  8. Agree to the prompt to install

If installing the firmware didn’t reset your octoprint connection, you should probably disconnect/reconnect (or even just reboot your Snapmaker) to make sure all the settings take effect.

Usage

Unfortunately, even with everything done, it’s still a bit of a hacky setup in octoprint to be able to use the filament runout sensor.

  1. Start a print
  2. Run out of filament (I tested this many times by just cutting the filament right above the extruder)
  3. The machine should now automatically move to the park position (“top right”)
  4. Octoprint will look to be unresponsive (all buttons grayed out)
  5. Go to the terminal tab, and expand the Advanced options
  6. Click Fake Acknowledgement
  7. You can now use octoprint to feed in some filament via the Control tab
    WARNING: The first extrude command seems to go super fast for me, I set my extrude amount to only 5mm and do multiple extrudes. The subsequent extrudes will be at the right speed.
    NOTICE: I have not tested feeding filament into both extruders, if you do this, make sure to set the tool back to the right tool that was active at the time of pause, octoprint doesn’t have a good setup to restore the active tool when the filament ran out and will just restart the print with whatever tool is currently active.
    FURTHER NOTICE: The setup I’ve detailed does not do anything to restore the bed/tool temperature, so make sure you don’t change those since your slicer probably doesn’t update the temp, so the print will continue with whatever setting you set last.
  8. Once the filament is fed in, it’s probably best to back out ~5mm to prevent filament leaking
  9. Click Resume in print controls

FAQ

Why does it require a custom firmware/does this include the vibration compensation branch?

Unfortunately, the stock firmware actually disables the runout detection when printing from anything other than the screen or luban (which goes through the screen). The change to enable runout detection is quite simple and I’ve opened a pull request for the Snapmaker team to look at.

@Zoe or @Alan it’d be great if the pull request could be included in the next release (and the vibration compensation branch) so people don’t need to install a custom firmware. Also, if you pointed me at a repo for the vibration compensation branch, I’d be happy to make a pull request there as well.

Alternatively, if someone else wants to dig through the firmware to find somewhere where there’s a gcode command that lets us set the systemservice.cur_status_ to SYSTAT_WORK, then we could use that instead of M75 that I made work in my custom firmware (but I looked and didn’t see anything).

Will this work on the J1

No, it’s a different firmware and the problem is probably different (runout detection seems to go through a totally different code path).

Will this work with the single extruder

Probably? I’ve honestly never plugged my single extruder back in after getting the dual extruder, so IHNI if things are different there (but e.g. the M600 code appears to run single extruder functions, even when the dual extruder is connected).

Can you make the usage process simpler/less hacky?

I didn’t see why the fake acknowledge is required, there doesn’t seem to be anything explicitly in the firmware code that sends the acknowledge that octoprint expects (for any gcode command), so I don’t know what octoprint is expecting. It could also be that the M600 is the problem, but that seems to be what triggers octoprint to see the M76 as a runout instead of just a pause. You could probably also set a macro that includes a reasonable feed speed so you don’t need to feed 5mm at a time. However what I’ve done works, and works consistently to go back to the correct spot in the print to resume printing.

5 Likes

Totally awesome! Thanks for digging into this, and Snapmaker, please consider to add it to the official firmware!!!

Thats great News. Hopefully snapmaker will add that.
But i have still one problem with octoprint in some cases: that i cannot Change z level while printing as snapmaker provide it in Touchscreen. It is a useful option. The babystep addon did not work for me. How do you handle that?

Yea, baby stepping might be the next thing I look at. AFAIU, it’s currently only available via a special message from the touch screen (i.e. the touch screen uses SerialConnection instead of gcode). It would need to be another firmware modification to make it work.

1 Like

Thanks for this, but its just a bit too complicated at this stage, maybe Gina from octoprint could make a minor change to make it a bit more friendly and Snapmaker include your suggestion so we don’t need special firmware so we can still update to the latest as they happen. Keep up the good work.