Is there a dynamic way to set the hotend temperature and position after print resume?

I'm reusing the z endstop of my Ender 3 as a filament runout sensor, I already configured the plugin and the sensor is connected to the Pi, and everything works fine, but I want to setup some after-pause and before-resume scripts and I need some help.

These are my current scripts:

M117 Print Paused  ; Comment
G91                         ; Set to relative positioning mode
G1 F300 Z15          ; Move hotend away from part by 15mm
G1 F9000 X20 Y20 ; Move away from the print
M104 S0                  ; standby temperature
G90                          ; Set to absolute positioning mode
M117 Print Resumed ; Comment
G91                            ; Set to relative positioning mode
M109 S195                ; resume temperature
G1 F9000 X-20 Y-20  ; Move to the print
G1 F300 Z-15            ; Move hotend back down by 15mm
G90                            ; Set to absolute positioning mode

What is the problem?

I don't know how to dynamically set the temperature back to where it was without hardcoding a magic number, because I don't always print at 195ΒΊC.
I also like to move the hotend to the 0,0 coord (that's easy G90 G1 X0 Z0) but then I don't know how to return to the previous position.

What did you already try to solve it?

So I tried using these snippets, and I copypasted afterPrintPaused and beforePrintResumed as is to the GCODE Scripts of my OctoPrint settings, but with these scripts, the hotend returns to the proper position in the X and Y but not in the Z, and the hotend doesn't heats before resuming the print.

I believe the problem is that I don't undertand where pause_position gets the data and where disable_hotends. disable_bed and resume_heaters come from.

Have you tried running in safe mode and if so did it solve the issue?

No.

Complete Logs

I don't think you need logs but here they are anyway. :stuck_out_tongue:
octoprint (1).log (369.9 KB)
serial (1).log (660.6 KB)

Additional information about your setup

  • OctoPrint 1.4.2
  • Python 2.7.16
  • OctoPi 0.17.0
1 Like

As I was typing this question, I realized about some stuff (as it usually happens when asking for help, lol).

The docs talk about this:

Unless configured otherwise, OctoPrint expects scripts to be located in the scripts/gcode folder in OctoPrint configuration directory (per default ~/.octoprint on Linux, %APPDATA%\OctoPrint on Windows and ~/Library/Application Support/OctoPrint on macOS).

Should I place those snippets in that folder? And then how do I call them?

1 Like

OK, some new development...

When I hit Resume in the OctoPrint web interface and then check the console, the comment I put in the begining of the BeforeResume snippet is not being displayed, and no code in that snippet is being run, at all.

In the other hand, the AfterPause snippet runs OK. :thinking:

The plugin I'm using to pause the print is Filament Sensor Reloaded, I don't know if that's related.

1 Like

Hello :slight_smile:

I'm on the same path, reusing the old z-axis contactor ! But I'm probably two to three days behind you, I just created a case, played with the printer and ... not yet taken care of the connection itself :stuck_out_tongue:

So, as said, I may lack a bit of experience. I'd ask : is it possible that the M117 command sent is overwritten by an other M117 ? Then, you will not see the message but it could be a no-proof that the script doesn't work ?

In your position, I would probably :
1 - run in safe mode, without any plugin displaying info on the screen (to be sure my M117 is not overwritten)
2 - try something more visible than M117. M112, for example. Crashing a print is worth it if it's a proof :smiley:

Cheers,
K.

1 Like

That's the easy part! Hehehe.

I've put M112 at the beginning of the resume script and it was ignored, even in Safe Mode...

1 Like

Eheh, I guess I'll have to make my project go forward fast if I want to help you. That's a great motivation, thanks :wink:

I'll be back in a few, but hopefully someone will be able to help more so you don't have to wait. The only thing I could think of now : take care of the script naming, especially the lower case of the first letter. I know, silly advice but that's the only thing I have :D.

Maybe @foosel will have more troubleshoot test to understand why the beforeResume script is not triggered ?

Cheers,
K.

1 Like

I didn't edit the script in the folder manually, I always use Octoprint's web interface!

Ok I may have three things to check :slight_smile:

1 - names are case sensitive on the filesystem, so be carefull
2 - did you test with the script only ? like in "remove code in the config on the web panel before putting it in the script on the filesystem" :slight_smile: (and vice-versa)
3 - did you put your scripts in the subfolder snippet ? I know nothing about this (yet) but it seems like beforeResume could be a snippet,and treated as is. If you did so, maybe you want to move the script under the scrips/gcode folder :wink:

https://docs.octoprint.org/en/master/features/gcode_scripts.html#snippets

EDIT : nevermind, you don't use scripts in the ~octoprint's directory, so none of these test is actually useful to you. Better wait for the knowledge of @foosel.

1 Like

I mean, I could edit the scripts in the ~octoprint directory, but that's the same as editing from the web UI, changing one changes the other because the UI writes to these files.

OK, so, I just have a M117 comment to these scripts:

After print job is paused: "M117 HELLO OCTOPRINT PEEPS!! This is the "After print job is paused" script"

Before print job is resumed: "M117 HELLO OCTOPRINT PEEPS!! This is the "Before print job is resumed" script".

I'm going to set up a dummy print, pause and resume it and put the serial logs and you'll see that the resume script is not run. I'm not crazy, I swear!

1 Like

Ahah I'm sure you're not :slight_smile:

Actually I was unsure of one thing you just confirmed : the UI write to these files, so it's nearly impossible to make a typo in the name, write in the wrong dir, …

So, the bug you're encoutering is greatly simplified : "beforePrintResumed is not executed".

I'm lost. There's a print in progress on my printer for the next 1.5 hours, it took me 6 hours so I don't want to burn it with tries but in 90mn, I'll be trying a dummy print with scripts so I can reproduce the bug :slight_smile:

1 Like

Of course a simple test is now working. LOL

2020-10-21 19:07:58,737 - Changing monitoring state from "Printing" to "Pausing"
2020-10-21 19:08:02,876 - Send: N655 M117 HELLO OCTOPRINT PEEPS!! This is the "After print job is paused" script*97
2020-10-21 19:08:02,886 - Recv: //action:notification HELLO OCTOPRINT PEEPS!! This is the "After print job is paused" script
2020-10-21 19:08:02,902 - Changing monitoring state from "Pausing" to "Paused"
2020-10-21 19:08:10,434 - Changing monitoring state from "Paused" to "Resuming"
2020-10-21 19:08:10,593 - Send: N656 M117 HELLO OCTOPRINT PEEPS!! This is the "Before print job is resumed" script*116
2020-10-21 19:08:10,603 - Recv: //action:notification HELLO OCTOPRINT PEEPS!! This is the "Before print job is resumed" script
2020-10-21 19:08:10,625 - Changing monitoring state from "Resuming" to "Printing"
2020-10-21 19:08:40,200 - Changing monitoring state from "Printing" to "Pausing"
2020-10-21 19:08:44,883 - Send: N715 M117 HELLO OCTOPRINT PEEPS!! This is the "After print job is paused" script*100
2020-10-21 19:08:44,893 - Recv: //action:notification HELLO OCTOPRINT PEEPS!! This is the "After print job is paused" script
2020-10-21 19:08:44,908 - Changing monitoring state from "Pausing" to "Paused"
2020-10-21 19:09:06,092 - Changing monitoring state from "Paused" to "Resuming"
2020-10-21 19:09:06,221 - Communication timeout while printing, trying to trigger response from printer. Configure long running commands or increase communication timeout if that happens regularly on specific commands or long moves.
2020-10-21 19:09:06,281 - Send: N717 M117 HELLO OCTOPRINT PEEPS!! This is the "Before print job is resumed" script*112
2020-10-21 19:09:06,291 - Recv: //action:notification HELLO OCTOPRINT PEEPS!! This is the "Before print job is resumed" script
2020-10-21 19:09:06,303 - Changing monitoring state from "Resuming" to "Printing"
2020-10-21 19:09:20,800 - Changing monitoring state from "Printing" to "Cancelling"
2020-10-21 19:09:21,912 - Recv: //action:notification Ender 3 Ready.
2020-10-21 19:09:25,654 - Changing monitoring state from "Cancelling" to "Operational"

serial.log (125.3 KB)

So... there's something else amiss here! Hope is not lost yet. :smiley:

Mouahahahah...

That may be a karma thing :slight_smile:

I don't know if there's a linter which check GCODE before actually triggering the snippet/script. That might be useful to keep it a short as possible and make tests every time you add a line. Maybe there's a special char or something messy in the copy/pasted code ?

K.

1 Like

Now I just used the scripts from here: https://docs.octoprint.org/en/master/features/gcode_scripts.html#id4...

And these work... OK, I'm narrowing it down! :muscle: :muscle:

Edit: I now realize that I've been trying to do all of this for nothing, really, it's better to keep these scripts simple and do the reheating and filament replacement manually. Less issues, more control to you. And I don't have the time or the willpower to keep messing with this stuff... got stuff to print!!

1 Like

Well, at least it was a nice chat and you gave me great inputs for when my time to rage against a filament detector comes. I guess I owe you thanks, so !

Cheers, and have some great prints :slight_smile:
K.

1 Like

Sure! Just let me know when you reach my point and we can keep taking a look at this.

But I honestly think you are better off enabling some Marlin features to do it manually.

#define NOZZLE_PARK_FEATURE

#define ADVANCED_PAUSE_FEATURE
#define PARK_HEAD_ON_PAUSE
#define FILAMENT_LOAD_UNLOAD_GCODES

With these settings enabled you can preheat the Nozzle/bed with Octoprint or the LCD and extrude some filament to load more or change the spool.

1 Like