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.
    • Phaedruxundefined
      Phaedrux Moderator
      last edited by Phaedrux

      Don't call resume from within pause. That's your problem.

      Or better yet, use M600 and filament-change.g?

      Z-Bot CoreXY Build | Thingiverse Profile

      Surgikillundefined 1 Reply Last reply Reply Quote 0
      • Surgikillundefined
        Surgikill @Phaedrux
        last edited by Surgikill

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

        Phaedruxundefined OwenDundefined 2 Replies Last reply Reply Quote 0
        • Phaedruxundefined
          Phaedrux Moderator @Surgikill
          last edited by

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

          Z-Bot CoreXY Build | Thingiverse Profile

          Surgikillundefined 1 Reply Last reply Reply Quote 0
          • OwenDundefined
            OwenD @Surgikill
            last edited by

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

            M600: 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 suffice

            M291 P"OK to resume?" S3 
            M24
            
            1 Reply Last reply Reply Quote 1
            • Surgikillundefined
              Surgikill @Phaedrux
              last edited by Surgikill

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

              OwenDundefined 1 Reply Last reply Reply Quote 0
              • Phaedruxundefined
                Phaedrux Moderator
                last edited by

                What firmware version are you using?

                Have you tried without M24 at the end?

                Z-Bot CoreXY Build | Thingiverse Profile

                Surgikillundefined 1 Reply Last reply Reply Quote 0
                • Surgikillundefined
                  Surgikill @Phaedrux
                  last edited by Surgikill

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

                  1 Reply Last reply Reply Quote 0
                  • Phaedruxundefined
                    Phaedrux Moderator
                    last edited by

                    I don't think M24 is needed because once the filament-change.g macro has completed it will resume.

                    Z-Bot CoreXY Build | Thingiverse Profile

                    Surgikillundefined Exerqtorundefined 3 Replies Last reply Reply Quote 0
                    • Surgikillundefined
                      Surgikill @Phaedrux
                      last edited by

                      @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
                      • Surgikillundefined
                        Surgikill @Phaedrux
                        last edited by

                        @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
                        • Phaedruxundefined
                          Phaedrux Moderator
                          last edited by

                          Remove the last M291.

                          Are you using DWC or a PanelDue?

                          Z-Bot CoreXY Build | Thingiverse Profile

                          1 Reply Last reply Reply Quote 0
                          • Exerqtorundefined
                            Exerqtor @Phaedrux
                            last edited by Exerqtor

                            @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
                            • OwenDundefined
                              OwenD @Surgikill
                              last edited by OwenD

                              @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
                              • OwenDundefined
                                OwenD @Surgikill
                                last edited by

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

                                Surgikillundefined 1 Reply Last reply Reply Quote 0
                                • OwenDundefined
                                  OwenD
                                  last edited by OwenD

                                  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
                                  				}
                                  
                                  Exerqtorundefined 1 Reply Last reply Reply Quote 1
                                  • Exerqtorundefined
                                    Exerqtor @OwenD
                                    last edited by

                                    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
                                    • Surgikillundefined
                                      Surgikill @OwenD
                                      last edited by

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

                                      dc42undefined 1 Reply Last reply Reply Quote 0
                                      • dc42undefined
                                        dc42 administrators @Surgikill
                                        last edited by dc42

                                        @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

                                        Exerqtorundefined Surgikillundefined 2 Replies Last reply Reply Quote 2
                                        • Exerqtorundefined
                                          Exerqtor @dc42
                                          last edited by Exerqtor

                                          @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
                                          
                                          OwenDundefined Surgikillundefined 2 Replies Last reply Reply Quote 2
                                          • Surgikillundefined
                                            Surgikill @dc42
                                            last edited by

                                            @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
                                            • First post
                                              Last post
                                            Unless otherwise noted, all forum content is licensed under CC-BY-SA