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

Triggering 'Load Filament' prompt with a macro

Scheduled Pinned Locked Moved
General Discussion
5
12
368
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
    last edited by 15 Nov 2024, 23:33

    Hello all,

    I am setting up triggers so that I can load/unload filament with physical buttons/filament sensors on my machine. I would like to have it so one of these triggers activates the 'Load Filament' prompt. I have not been able to find anywhere in the documentation if this is possible. Is it only something within DWC?

    Picture of the prompt I am talking about:
    ca6ee87e-96c4-4702-b5ed-86b590fe7800-image.png

    Can anybody help me with this? I know I could create a message with M291, and then select the filaments from there, but that seems to be a very roundabout way of doing it, and I need to make sure that the filaments in the dialog stay synced with the filaments in my filaments directory.

    Thank you

    undefined 1 Reply Last reply 16 Nov 2024, 08:23 Reply Quote 0
    • undefined
      droftarts administrators @Surgikill
      last edited by 16 Nov 2024, 08:23

      @Surgikill M701 triggers the 'load filament' dialogue. M702 triggers the unload filament, M703 configures filaments. See https://docs.duet3d.com/en/User_manual/Reference/DWC_filaments

      Ian

      Bed-slinger - Mini5+ WiFi/1LC | RRP Fisher v1 - D2 WiFi | Polargraph - D2 WiFi | TronXY X5S - 6HC/Roto | CNC router - 6HC | Tractus3D T1250 - D2 Eth

      undefined 1 Reply Last reply 16 Nov 2024, 12:22 Reply Quote 0
      • undefined
        chrishamm administrators @droftarts
        last edited by 16 Nov 2024, 12:22

        @droftarts Not quite right, M701 is triggered by the "load filament" dialog when a filament is selected.

        @Surgikill The dialog itself is a DWC-only feature. But you might be able to implement a work-around using a multiple choice M291 dialog (M291 S4). Otherwise you'd have to write a DWC plugin or fork DWC.

        Duet software engineer

        undefined 1 Reply Last reply 16 Nov 2024, 16:05 Reply Quote 0
        • undefined
          droftarts administrators @chrishamm
          last edited by 16 Nov 2024, 16:05

          @chrishamm Oops! Though could you trigger it by raising an event? eg

          M957 E"filament-error" D0 P3
          

          Ref
          https://docs.duet3d.com/en/User_manual/Reference/Gcodes#m957-raise-event
          https://docs.duet3d.com/User_manual/RepRapFirmware/Events
          https://docs.duet3d.com/User_manual/Connecting_hardware/Sensors_filament#event-system-filament-error-events

          Ian

          Bed-slinger - Mini5+ WiFi/1LC | RRP Fisher v1 - D2 WiFi | Polargraph - D2 WiFi | TronXY X5S - 6HC/Roto | CNC router - 6HC | Tractus3D T1250 - D2 Eth

          undefined undefined 2 Replies Last reply 16 Nov 2024, 20:32 Reply Quote 0
          • undefined
            Surgikill @droftarts
            last edited by 16 Nov 2024, 20:32

            @droftarts If I trigger it using a filament error event, then it's just going to go into the 'filament-error.g' macro, and I end up in the same boat of not being able to get the dialog to pop up on screen with a physical input. It seems like the only way to trigger this dialog is with the button on DWC.

            @chrishamm I know I can do it with M291, but that seems pretty clunky, unless there is a way I can extract the filaments by filepath in a subdirectory. I'm not sure of a way to do this.

            1 Reply Last reply Reply Quote 0
            • undefined
              chrishamm administrators @droftarts
              last edited by 18 Nov 2024, 10:03

              @droftarts No, that dialog is a DWC-only feature and it isn't coupled to any firmware mechanism.

              @Surgikill You could write a DWC plugin which reacts to a specific global variable change and which displays a filament dialog whenever that variable changes. But of course that would require some coding skills, yet it should be technically possible.

              Duet software engineer

              undefined 1 Reply Last reply 20 Nov 2024, 02:09 Reply Quote 0
              • undefined
                Surgikill @chrishamm
                last edited by 20 Nov 2024, 02:09

                @chrishamm So I'm guessing there is no way I can implement a M291 prompt that pulls variables based on filepaths inside a folder?

                undefined undefined 2 Replies Last reply 20 Nov 2024, 18:48 Reply Quote 0
                • undefined
                  dc42 administrators @Surgikill
                  last edited by 20 Nov 2024, 18:48

                  @Surgikill you can certainly have a trigger generate a M291 dialog.

                  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 1 Reply Last reply 20 Nov 2024, 23:56 Reply Quote 0
                  • undefined
                    Surgikill @dc42
                    last edited by 20 Nov 2024, 23:56

                    @dc42 Yes, I am doing that now. However, I want the prompt to contain options that are dynamically created based on the content of "0:/filaments". I don't want to update the prompt every time I add a filament, or modify the name of a filament. Just like how DWC creates the prompt when pressing the 'Load Filament' button.

                    undefined undefined 2 Replies Last reply 21 Nov 2024, 10:48 Reply Quote 0
                    • undefined
                      droftarts administrators @Surgikill
                      last edited by 21 Nov 2024, 10:48

                      @Surgikill As far as I'm aware, the list of filaments isn't stored in the Object Model, only the filaments directory (though do check here: https://github.com/Duet3D/RepRapFirmware/wiki/Object-Model-Documentation). I don't know if you could read the filaments directory contents in as an array, then use that as your list. Someone better at Meta Gcode than me would have to advise you if this is possible.

                      Ian

                      Bed-slinger - Mini5+ WiFi/1LC | RRP Fisher v1 - D2 WiFi | Polargraph - D2 WiFi | TronXY X5S - 6HC/Roto | CNC router - 6HC | Tractus3D T1250 - D2 Eth

                      1 Reply Last reply Reply Quote 0
                      • undefined
                        chrishamm administrators @Surgikill
                        last edited by 21 Nov 2024, 17:27

                        @Surgikill Not without a DWC plugin or a custom fork.

                        Duet software engineer

                        1 Reply Last reply Reply Quote 0
                        • undefined
                          OwenD @Surgikill
                          last edited by 21 Nov 2024, 20:21

                          @Surgikill said in Triggering 'Load Filament' prompt with a macro:

                          @dc42 Yes, I am doing that now. However, I want the prompt to contain options that are dynamically created based on the content of "0:/filaments". I don't want to update the prompt every time I add a filament, or modify the name of a filament. Just like how DWC creates the prompt when pressing the 'Load Filament' button.

                          At present RRF doesn't have any string handling routines and no way of extracting file information or file lists.
                          The best you can do is use the object model item
                          move.extruders[0].filament
                          which will show the currently loaded filament (or null)
                          I ran into a similar issue trying to create a filament change macro to use from PanelDue as my printer is in the shed and my computer inside.
                          I had to manually list all the filament types I use in an array.

                          This is what I came up with.
                          It may (or may not) help in your case.

                          ; ChangeFilament.g
                          ; requires RRF 3.5 or later!
                          ; list of filaments must follow rules for array
                          ; https://docs.duet3d.com/User_manual/Reference/Gcode_meta_commands#array-expressions
                          var filaments = {"ABS","ABS-CF","ABS-GF","ASA","EDGE","eFlex","eLastic","FLEX","HIPS","NGEN","NYLON","PA-CF","PC","PCABS","PDVF","PEEK","PEI","PEKK","PET","PETG","PLA","POM","PP","PSU","PVA","SCAFF","TPE","TPU",} ; list your filaments here
                          var maxBtns = 10; Max number of buttons per page on PanelDue. Adjust as required. 5 works OK on 7"paneldue - 9 is max!
                          ; don't change below here
                          var thisTool = state.currentTool
                          var allTools = vector(#tools,null)
                          if var.thisTool = -1
                          if #tools > 1
                          while iterations < #tools
                          set var.allTools[iterations] = tools[iterations].name ^ ""
                          M291 S4 P"Select tool" K{var.allTools} F0
                          T{input}
                          G4 S1
                          if state.currentTool = -1
                          abort "No tool selected"
                          else
                          set var.thisTool = state.currentTool
                          else
                          T1
                          var thisExtruder = 0
                          var allExtruders = vector(#tools[var.thisTool].extruders,null)
                          if #tools[var.thisTool].extruders > 1
                          while iterations < #tools[var.thisTool].extruders
                          set var.allExtruders[iterations] = iterations ^ ""
                          M291 P"Select extruder" S4 K{var.allExtruders} F0
                          set var.thisExtruder = input
                          var thisFilament = move.extruders[tools[var.thisTool].extruders[var.thisExtruder]].filament
                          var newFilament = null
                          if var.maxBtns > 10
                          set var.maxBtns = 10
                          echo "Paneldue can only display 10 buttons in total"
                          echo "Max buttons has been reset"
                          var thisPage = vector(var.maxBtns,"")
                          var numPages = floor(#var.filaments / (var.maxBtns - 1))
                          if mod(#var.filaments , var.maxBtns - 1) > 0
                          set var.numPages = var.numPages + 1
                          var pagesDone = 0;
                          var btnsDone = 0
                          var nextFilament = ""
                          var nextItem = 0
                          while var.pagesDone < var.numPages
                          set var.thisPage = vector(var.maxBtns,"")
                          set var.btnsDone = 0
                          while var.btnsDone < var.maxBtns-1
                          set var.nextItem = iterations + (var.pagesDone * (var.maxBtns-1))
                          if var.nextItem = #var.filaments
                          break
                          set var.thisPage[var.btnsDone] = var.filaments[var.nextItem]
                          set var.nextFilament = var.filaments[var.nextItem]
                          set var.btnsDone = var.btnsDone + 1
                          if var.pagesDone = var.numPages - 1
                          set var.thisPage[{var.maxBtns-1}] = "Cancel"
                          else
                          set var.thisPage[{var.maxBtns-1}] = "Next"
                          set var.pagesDone = var.pagesDone + 1
                          M291 P"Select filament" S4 K{var.thisPage}
                          if input = var.maxBtns-1
                          continue
                          else
                          set var.newFilament = var.thisPage[input]
                          break
                          if (var.newFilament = null) || (var.newFilament = "")
                          abort "No filaments chosen"
                          else
                          echo "Filament chosen : ", var.newFilament, " : commence change"
                          ; M701 only works if the tool only has one extruder
                          ; If more than one extruder is present on the tool, we'll directly call the macros for load, unload and config
                          ; It's unclear if the filament will be marked as loaded in DWC after this approach.
                          if var.newFilament = "noFilament"
                          if #tools[var.thisTool].extruders > 1
                          M98 P{directories.filaments ^ var.newFilament ^ "/load.g"} S{var.thisExtruder}
                          M98 P{directories.filaments ^ var.newFilament ^ "/config.g"} S{var.thisExtruder}
                          else
                          M701 S{var.newFilament}
                          if result != 0
                          abort "Error during loading"
                          M703
                          else
                          if (var.thisFilament != "noFilament") && (var.thisFilament != null)
                          if #tools[var.thisTool].extruders > 1 ; M701 only works if the too only has one extruder
                          M98 P{directories.filaments ^ var.newFilament ^ "/unload.g"} S{var.thisExtruder}
                          M98 P{directories.filaments ^ var.newFilament ^ "/load.g"} S{var.thisExtruder}
                          M98 P{directories.filaments ^ var.newFilament ^ "/config.g"} S{var.thisExtruder}
                          else
                          M702
                          M701 S{var.newFilament}
                          if result != 0
                          abort "Error during loading"
                          M703
                          1 Reply Last reply Reply Quote 4
                          7 out of 12
                          • First post
                            7/12
                            Last post
                          Unless otherwise noted, all forum content is licensed under CC-BY-SA