• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

Manual filament-change.g syntax

Scheduled Pinned Locked Moved
Gcode meta commands
6
33
1.9k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • undefined
    Surgikill @Phaedrux
    last edited by 19 Apr 2023, 22:33

    @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.

    1 Reply Last reply Reply Quote 0
    • undefined
      Surgikill @Phaedrux
      last edited by 19 Apr 2023, 23:44

      @Phaedrux Removing M24 and just leaving the M291 at the end of the script does not work either.

      1 Reply Last reply Reply Quote 0
      • undefined
        Phaedrux Moderator
        last edited by 20 Apr 2023, 05:14

        Remove the last M291.

        Are you using DWC or a PanelDue?

        Z-Bot CoreXY Build | Thingiverse Profile

        1 Reply Last reply Reply Quote 0
        • undefined
          Exerqtor @Phaedrux
          last edited by Exerqtor 4 Jan 2024, 12:57 20 Apr 2023, 06:21

          @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 in filament-change.g it goes on to a paused state after pressing "OK" and filament-change.g ends. And when i then hit "Resume" from the paused state it runs through resume.g. This behaviour is the same on both DWC and PD.

          One should think that when adding M24 at the very end of filament-change.g (after a M291 S2) on the other hand, it should automagicaly run resume.g when the macro finishes up, so you don't have to go through the "extra step" of manually pushing "Resume".

          1 Reply Last reply Reply Quote 2
          • undefined
            OwenD @Surgikill
            last edited by OwenD 20 Apr 2023, 08:58

            @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 like

            if global.doingChange = true && state.status="paused"
            M291 S4 K{"Yes","No",} R"Resume print?"
            if result = 0
            M24
            set global.doingChange = false
            1 Reply Last reply Reply Quote 0
            • undefined
              OwenD @Surgikill
              last edited by 20 Apr 2023, 09:34

              @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.g

              So 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.

              undefined 1 Reply Last reply 20 Apr 2023, 22:06 Reply Quote 0
              • undefined
                OwenD
                last edited by OwenD 20 Apr 2023, 09:50

                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 state

                case 24: // Print/resume-printing the selected file
                if (pauseState == PauseState::pausing || pauseState == PauseState::resuming)
                {
                // ignore the resume request
                }
                undefined 1 Reply Last reply 20 Apr 2023, 19:40 Reply Quote 1
                • undefined
                  Exerqtor @OwenD
                  last edited by 20 Apr 2023, 19:40

                  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.

                  1 Reply Last reply Reply Quote 0
                  • undefined
                    Surgikill @OwenD
                    last edited by 20 Apr 2023, 22:06

                    @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.

                    undefined 1 Reply Last reply 21 Apr 2023, 01:43 Reply Quote 0
                    • undefined
                      dc42 administrators @Surgikill
                      last edited by dc42 21 Apr 2023, 01:43

                      @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.

                      Duet WiFi hardware designer and firmware engineer
                      Please do not ask me for Duet support via PM or email, use the forum
                      http://www.escher3d.com, https://miscsolutions.wordpress.com

                      undefined undefined 2 Replies Last reply 21 Apr 2023, 10:07 Reply Quote 2
                      • undefined
                        Exerqtor @dc42
                        last edited by Exerqtor 21 Apr 2023, 10:07

                        @dc42
                        That would surely make life a bit easier 😆


                        @Surgikill
                        This is how I've "solved" it:
                        filament-change.g:

                        ; /sys/filament-change.g v2.1
                        ; Called when M600 is sent
                        ; Used to do a filament change while printing
                        ;---/
                        ; -/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--
                        ; THIS MACRO ONLY WORKS WITH RRF 3.5.0b1 AND LATER!!
                        ;--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--
                        ;-/
                        ; ====================---------------------------------------------------------
                        ; Settings section
                        ; ====================
                        ; Will not be used if you're using a "goto" macro
                        var x = 40 ; The X axis location where you want the hotend to "park" while changing filament
                        var y = 0 ; The Y axis location where you want the hotend to "park" while changing filament
                        var lift = 40 ; The Z clearance you want your nozzle to have from the print while changing filament
                        var lights = true ; true / false depending if you have chamber lights or not that you want to turn on
                        ; If you don't have lights you want to turn on don't mess with these
                        var io = 0 ; The GPIO port number (set by M950) for the lights you want to turn on
                        var pwm = 1 ; The PWM to be set on the GPIO port above, 0=off 1=full power
                        var purge = 60 ; The amount of filament your hotend need to purge for a clean filament/color change
                        ; Will be swaped out with global.unload_length if you have that defined!
                        var unload = 12 ; The length of which filament have to be retracted to clear the meltzone
                        ; Don't touch anyting beyond this point(unless you know what you're doing)!!
                        ; ====================---------------------------------------------------------
                        if exists(global.unload_length)
                        set var.unload = global.unload_length
                        if var.lights
                        M42 P{var.io} S{var.pwm} ; Turn on the lights
                        if fileexists("/sys/lib/beep/l.g")
                        M98 P"/sys/lib/beep/l.g" ; Long beep
                        M400 ; Wait for moves to finish
                        G91 ; Relative positioning
                        M83 ; Extruder relative positioning
                        G10 ; Retraction
                        G1 Z1.00 X20.0 Y20.0 F20000 ; Short quick move to disengage from print
                        G1 Z{var.lift - 1} F800 ; Go to spesified Z clearance
                        if !fileexists("/sys/lib/goto/front_right.g")
                        G90 ; Absolute positioning
                        G1 X{var.x} Y{var.y} F6000 ; Move the nozzle to the location defined in the settings section
                        if fileexists("/sys/lib/goto/front_right.g")
                        M98 P"/sys/lib/goto/front_right.g" ; Move to front right for filament change
                        G1 E2 F800 ; Extrude slightly to help form a nice tip on the filament
                        G1 E{-(var.unload)} F800 ; Retract filament from the meltzone
                        M400 ; Wait for moves to finish
                        if fileexists("/sys/lib/beep/xl.g")
                        M98 P"/sys/lib/beep/xl.g" ; Extra long beep
                        M291 R"Manual Filament Change" P"Change & prime filament, then press OK." K{"OK","SKIP",} S4
                        ; "OK"
                        if input = 0
                        G1 E{var.purge} F200 ; Purge filament
                        ; "SKIP"
                        if input = 1
                        G1 E{var.unload} F800 ; Extrude filament back to the meltzone
                        if !exists(global.FilamentCHG)
                        global FilamentCHG = true
                        else
                        set global.FilamentCHG = true

                        daemon.g:

                        ; /sys/daemon.g
                        ; Used to execute regular tasks, the firmware executes it and once the end of file is reached it waits. If the file is not found it waits and then looks for it again.
                        ; Loop, to be able to turn on/off daemon.g
                        while global.RunDaemon
                        ; Stuff goes here
                        ; Resume after filament change
                        if exists(global.FilamentCHG)
                        if global.FilamentCHG = true && state.status="paused"
                        M24 ; Resume the pause automatically now that the manual filament change is done
                        set global.FilamentCHG = false

                        resume.g

                        ; resume.g
                        ; Called before a print from SD card is resumed
                        G1 R1 X0 Y0 Z5 F6000 ; Go to 5mm above position of the last print move
                        G1 R1 X0 Y0 ; Go back to the last print move
                        M83 ; Relative extruder moves
                        undefined undefined 2 Replies Last reply 22 Apr 2023, 03:30 Reply Quote 2
                        • undefined
                          Surgikill @dc42
                          last edited by 21 Apr 2023, 14:26

                          @dc42 Putting the printer in a pause state before filament-change.g is run would also work, although that seems like it may be more work. Either one would be great though.

                          1 Reply Last reply Reply Quote 0
                          • undefined
                            OwenD @Exerqtor
                            last edited by 22 Apr 2023, 03:30

                            @Exerqtor
                            Your M24 is not indented in the example

                            undefined 1 Reply Last reply 22 Apr 2023, 06:15 Reply Quote 1
                            • undefined
                              Exerqtor @OwenD
                              last edited by Exerqtor 22 Apr 2023, 06:15

                              @OwenD said in Manual filament-change.g syntax:

                              @Exerqtor
                              Your M24 is not indented in the example

                              It should be 🤣 Typo when I pasted it into the forum 😳

                              I'm using it right now btw, and the pause-resume handeling is working just like intended ✌️ (the rest if the macro needs a little polishing though)

                              1 Reply Last reply Reply Quote 0
                              • undefined
                                Surgikill @Exerqtor
                                last edited by 22 Apr 2023, 15:47

                                @Exerqtor Thanks for that. I'm going to try modify those files a bit to set them up the way I want. From the documentation it looks like daemon.g will work on 3.4.5.

                                undefined 1 Reply Last reply 22 Apr 2023, 16:25 Reply Quote 0
                                • undefined
                                  Exerqtor @Surgikill
                                  last edited by Exerqtor 22 Apr 2023, 16:25

                                  @Surgikill

                                  No problem! Yeah sorry I just copied that part from my daemon.g which contains if fileexists farther down (I'll edit the post straight away).

                                  If you're running pre 3.5 the only thing you would HAVE to change in filament-change.g is to remove the following lines:

                                  • 41-42
                                  • 52
                                  • 54-55
                                  • 63-64

                                  EDIT:

                                  I forgot to mention you would of course also swap out the M291 (line 66-72) with something pre RRF3.5 friendly, like this for instance:

                                  M291 S2 R"Manual Filament Change" P"Change & prime filament, then press OK."
                                  G1 E{var.purge} F200 ; Purge filament
                                  undefined 1 Reply Last reply 22 Apr 2023, 21:00 Reply Quote 1
                                  • undefined
                                    Exerqtor @Exerqtor
                                    last edited by 22 Apr 2023, 21:00

                                    For who it might concern/help, I feel like I've got filament-change.g working decently well at this point:

                                    ; /sys/filament-change.g v2.2
                                    ; Called when M600 is sent
                                    ; Used to do a filament change while printing
                                    ;---/
                                    ; -/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--
                                    ; THIS MACRO ONLY WORKS WITH RRF 3.5.0b1 AND LATER!!
                                    ;--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--/--
                                    ;-/
                                    ; ====================---------------------------------------------------------
                                    ; Settings section
                                    ; ====================
                                    ; Will not be used if you're using a "goto" macro
                                    var x = 40 ; The X axis location where you want the hotend to "park" while changing filament
                                    var y = 0 ; The Y axis location where you want the hotend to "park" while changing filament
                                    var spd = 15000 ; The speed of which you want the hotend to move to the "park" location
                                    var lift = 20 ; The Z clearance you want your nozzle to have from the print while changing filament
                                    var lights = true ; true / false depending if you have chamber lights or not that you want to turn on
                                    ; If you don't have lights you want to turn on don't mess with these
                                    var io = 0 ; The GPIO port number (set by M950) for the lights you want to turn on
                                    var pwm = 1 ; The PWM to be set on the GPIO port above, 0=off 1=full power
                                    var purge = 60 ; The amount of filament your hotend need to purge for a clean filament/color change
                                    ; Will be swaped out with global.unload_length if you have that defined!
                                    var unload = 12 ; The length of which filament have to be retracted to clear the meltzone
                                    ; Don't touch anyting beyond this point(unless you know what you're doing)!!
                                    ; ====================---------------------------------------------------------
                                    if exists(global.unload_length)
                                    set var.unload = global.unload_length
                                    var pwm_res = state.gpOut[{var.io}].pwm ; Store the PWM from the PPIO port so that it can be returned after changing filament
                                    if var.lights
                                    M42 P{var.io} S{var.pwm} ; Turn on the lights
                                    if fileexists("/sys/lib/beep/l.g")
                                    M98 P"/sys/lib/beep/l.g" ; Long beep
                                    M400 ; Wait for moves to finish
                                    G91 ; Relative positioning
                                    M83 ; Extruder relative positioning
                                    G10 ; Retraction
                                    G1 Z1.00 X20.0 Y20.0 F20000 ; Short quick move to disengage from print
                                    G1 Z{var.lift - 1} F800 ; Go to spesified Z clearance
                                    if !fileexists("/sys/lib/goto/front_right.g")
                                    G90 ; Absolute positioning
                                    G1 X{var.x} Y{var.y} F{var.spd} ; Move the nozzle to the location defined in the settings section
                                    if fileexists("/sys/lib/goto/front_right.g")
                                    M98 P"/sys/lib/goto/front_right.g" {var.spd} ; Move to front right for filament change
                                    G1 E2 F800 ; Extrude slightly to help form a nice tip on the filament
                                    G1 E{-(var.unload)} F800 ; Retract filament from the meltzone
                                    M400 ; Wait for moves to finish
                                    if fileexists("/sys/lib/beep/xl.g")
                                    M98 P"/sys/lib/beep/xl.g" ; Extra long beep
                                    M291 S4 R"Manual Filament Change" P"Change & prime filament, then press OK." K{"OK","SKIP",}
                                    ; "OK"
                                    if input = 0
                                    G1 E{var.purge} F200 ; Purge filament
                                    ; "SKIP"
                                    if input = 1
                                    G1 E{var.unload} F800 ; Extrude filament back to the meltzone
                                    M400 ; Wait for moves to finish
                                    if var.lights
                                    M42 P{var.io} S{var.pwm_res} ; Return lights to previous state
                                    if !exists(global.FilamentCHG)
                                    global FilamentCHG = true
                                    else
                                    set global.FilamentCHG = true
                                    1 Reply Last reply Reply Quote 3
                                    • undefined Exerqtor referenced this topic 1 Apr 2024, 12:49
                                    26 out of 33
                                    • First post
                                      26/33
                                      Last post
                                    Unless otherwise noted, all forum content is licensed under CC-BY-SA