Manual filament-change.g syntax
-
@Phaedrux conditional gcode is the end goal to prevent unwanted behavior, but I'm still learning the ins and outs.
-
@Phaedrux Alright, apparently I'm just not understanding how the pause function works.
If I run this macro, the print head moves back to the last position and just sits there until I press 'resume' on the machine.
;Pause print and move printhead M98 P"0:/sys/pause.g" ; pause the print ;Retract filament, then prompt user to load filament T0 ;Select tool G1 E-55 F3000 ;Retract 100mm filament at high speed M84 E0 ;turn extruder motor off to let user unload if filament locked - M291 P"Insert filament, then press OK to load filament" R"Filament Change" S3 T0 ; Select tool G1 E55 F200 ; extrude 55mm at low speed M84 E0 ; turn extruder motor off so the user can feed by hand - change for another tool ;Prompt user to resume print if filament change is successful M291 P"Resume Print?" R"Resume Print?" S3 M98 P"0:/sys/resume.g" ; resume the print
If instead, I use this macro, the printer does nothing, even though M24 is in there, and will only resume once I press 'resume' on the machine.
;Pause print and move printhead M98 P"0:/sys/pause.g" ; pause the print ;Retract filament, then prompt user to load filament T0 ;Select tool G1 E-55 F3000 ;Retract 100mm filament at high speed M84 E0 ;turn extruder motor off to let user unload if filament locked - M291 P"Insert filament, then press OK to load filament" R"Filament Change" S3 T0 ; Select tool G1 E55 F200 ; extrude 55mm at low speed M84 E0 ; turn extruder motor off so the user can feed by hand - change for another tool ;Prompt user to resume print if filament change is successful M291 P"Resume Print?" R"Resume Print?" S3 M24
Is there any way I can get the resume function from the 'resume' button in a gcode command? Or do I have to run M25 in the file somewhere to get M24 to work?
-
Don't call resume from within pause. That's your problem.
Or better yet, use M600 and filament-change.g?
-
@Phaedrux This IS my filament-change.g which is called by M600. I mistakenly said M226 in my first post. I don't receive a resume prompt when using filament-change.g, which is what I am trying to incorporate in my filament-change.g file.
What I meant by not understanding how the pause function works, is what needs to happen for M24 to work. I call the pause.g in the beginning of my filament-change.g macro. This is my pause.g
; pause.g ; called when a print from SD card is paused ; ; generated by RepRapFirmware Configuration Tool v3.3.15 on Mon Dec 26 2022 22:40:57 GMT-0500 (Eastern Standard Time) M83 ; relative extruder moves G1 E-10 F3600 ; retract 10mm of filament G91 ; relative positioning G1 Z15 F360 ; lift Z by 15mm G90 ; absolute positioning G1 X0 Y0 F6000 ; go to X=0 Y=0
So all it is doing is moving the head to the home position. Then, the filament change happens in filament-change.g with the accompanying prompts. Then there is a final prompt, which I have tried with M24 and by calling resume.g with M98. Neither of these options actually resume the print. The printer will either move back to the last printing position and sit there, not resuming, OR, it will sit at the home position with M24, and only move back to the final position and resume printing once I press 'resume print' on the status page, so there is SOMETHING happening after my resume.g is run, otherwise the printer would resume printing after running resume.g.
-
@Surgikill said in Manual filament-change.g syntax:
I call the pause.g in the beginning of my filament-change.g macro.
I don't think you should do that. M600 should already be pausing and resuming on it's own.
-
@Surgikill said in Manual filament-change.g syntax:
This IS my filament-change.g which is called by M600. I mistakenly said M226 in my first post. I don't receive a resume prompt when using filament-change.g, which is what I am trying to incorporate in my filament-change.g file.
What I meant by not understanding how the pause function works, is what needs to happen for M24 to work. I call the pause.g in the beginning of my filament-change.g macro.As @Phaedrux said, you should not be calling pause.g
M600 already does a pauseM600: Filament change pause
Supported in firmware 2.02 and later.
This command behaves like M226 except that if macro file filament-change.g exists in /sys on the SD card, it is run in preference to pause.g.As you have a filament-change.g, it will run that file.
If you want to have a prompt to resume, then add it to the end of your filament-change.g or your filament load.g
An M291 call would sufficeM291 P"OK to resume?" S3 M24
-
@Phaedrux Okay, so what exactly does
M98 P"0:/sys/pause.g"
do?
From my understanding, all it does is run the file 'pause.g', which has no 'pause' in it, the pause has already occurred from the M600, and the 'pause.g' is just moving the extruder away from the print, not actually causing the pause to happen. If I renamed the file to 'move-extruder.g', it should do the same thing, no? Or is there something happening behind the scenes when I am invoking pause.g with M98, that is causing a double pause to happen?
Seeing as M600 is the same as M226, the M226 documentation says:
Initiates a pause in the same way as if the pause button is pressed, except that execution of all prior GCode commands in the same input stream is completed first. Then the SD card input stream is paused and file sys/pause.g is run.
which to me means that pause.g has no effect on pausing the print, seeing as the documentation says that the printer is paused BEFORE 'pause.g' is run.
To test it, this is now my filament-change.g
;Pause print and move printhead M98 P"0:/sys/move-extruder.g" ; pause the print ;Retract filament, then prompt user to load filament T0 ;Select tool G1 E-55 F3000 ;Retract 100mm filament at high speed M84 E0 ;turn extruder motor off to let user unload if filament locked - M291 P"Insert filament, then press OK to load filament" R"Filament Change" S3 T0 ; Select tool G1 E55 F200 ; extrude 55mm at low speed M84 E0 ; turn extruder motor off so the user can feed by hand - change for another tool ;Prompt user to resume print if filament change is successful M291 P"Resume Print?" R"Resume Print?" S3 M24
and this is move-extruder.g
M83 ; relative extruder moves G1 E-10 F3600 ; retract 10mm of filament G91 ; relative positioning G1 Z15 F360 ; lift Z by 15mm G90 ; absolute positioning G1 X0 Y0 F6000 ; go to X=0 Y=0
now I'm not calling out to 'pause.g', I am calling out to 'move-extruder.g'. The only pause command is M600, which is contained within the gcode file.
This still produces the same errors as before, wherein the print does not resume. Yes @OwenD I am using M291 and M24, but it is in the filament-change.g macro.
@dc42 Any ideas? I'm not sure where the issue is. I can run M24 from a macro, but it seems as though I can't run it from 'filament-change.g'.
-
What firmware version are you using?
Have you tried without M24 at the end?
-
@Phaedrux Version 3.4.5. I have not tried without M24. If it is any indication, the 'pause print' button is greyed out while 'filament-change.g' is being executed, so maybe there is a flag somewhere that is preventing M24 from running.
EDIT: I have tried by using M98 P"0:/sys/resume.g", which has the same effect as M24, but is not the M24 command.
-
I don't think M24 is needed because once the filament-change.g macro has completed it will resume.
-
@Phaedrux Then should it not resume regardless of if M24 is run or not? I have a print running and I'll try it without the M24 and see what happens.
-
@Phaedrux Removing M24 and just leaving the M291 at the end of the script does not work either.
-
Remove the last M291.
Are you using DWC or a PanelDue?
-
@Phaedrux said in Manual filament-change.g syntax:
I don't think M24 is needed because once the filament-change.g macro has completed it will resume.
That's not how my machine does it atleast (on 3.4 or 3.5). If i add a
M291 S2
dialouge infilament-change.g
it goes on to a paused state after pressing "OK" andfilament-change.g
ends. And when i then hit "Resume" from the paused state it runs throughresume.g
. This behaviour is the same on both DWC and PD.One should think that when adding
M24
at the very end offilament-change.g
(after aM291 S2
) on the other hand, it should automagicaly runresume.g
when the macro finishes up, so you don't have to go through the "extra step" of manually pushing "Resume". -
@Surgikill said in Manual filament-change.g syntax:
Any ideas? I'm not sure where the issue is. I can run M24 from a macro, but it seems as though I can't run it from 'filament-change.g'.
I've run some tests myself.
When M600 is used in a print, it looks like the pause start doesn't occur until after filament-change exits (or pause.g exits if filament-change.g didn't exist).
Therefore M24 within filament-change.g won't work as it's not yet in the paused state.
So I'm not sure how you can create a resume prompt.
You can't do it in the print file, because it won't be active until the print is resumed.
About all I can think of would be set a global in filament-change.g and do a check in daemon.g
something likeif global.doingChange = true && state.status="paused" M291 S4 K{"Yes","No",} R"Resume print?" if result = 0 M24 set global.doingChange = false
-
@Surgikill said in Manual filament-change.g syntax:
What I want to happen is the print to pause, the filament to automatically retract, swap filament, press a button to load filament, and then resume the print after a prompt.
Further to my post above, you could do the unloading and loading in filament-change.g
In my case I have a universal_load and universal_unload macro.
Each of my filaments load.g and unload.g this as does filament-change.gSo your filament.g could work per your original thinking as far a using M98 to call pause.g to do the movements
Then call your unload and reload macros
It will still not be in the paused state till after all this, so you've either got to it the resume button or do something like I posted above.
I don't see having to hit resume as being a big deal. -
A little further digging confirms that until filament-change.g has completed the printer status is pausing.
I put this in filament.change.g
echo "Printer state is: ", state.status
And got back
Printer state is: pausing
And looking at the 3.5b3 source for M24 it specifically ignores any M24 call in that statecase 24: // Print/resume-printing the selected file if (pauseState == PauseState::pausing || pauseState == PauseState::resuming) { // ignore the resume request }
-
I'm working out a solution to do what you're asking for now @Surgikill, based on what @OwenD mentioned above with a global and
daemon.g
.I've got a proof of concept
filament-change.g
&daemon.g
writen, but i haven't got time to test it before tomorrow. -
@OwenD My issue with resuming the print with the resume button is it is very easy to fat finger the cancel button. There also is no sanity check after hitting the cancel button, hence why I want the resume to happen in its own prompt, therefore no fat fingering can happen. Even having a system prompt occur to resume print after filament-change.g completes would be preferable to having to use the resume print function.
@Phaedrux I'm using it on dwc, but I also have a machine with a paneldue that I can try it on, but it appears that doesn't matter from what @OwenD has figured out.
@Exerqtor Could this just be a bug and M600 with filament-change.g is not working as intended? From the wording of the documentation, it seems like the order of operations is 'pause printer'>'execute filament-change.g (or pause.g)'. It seems as though the filament-change.g is locked inside the pause operation, although the source for 3.5b3 seems to indicate that it is intended to lock the printer in a pausing state during a filament change.
-
@Surgikill calling pause.g at the start of filament-change.g is OK if it does what you need at that point.
Perhaps we need to allow a M24 within filament-change.g to resume the print as soon as filament-change.g has completed.