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

    Filament runout script doesn't work

    Scheduled Pinned Locked Moved
    Filament Monitor
    3
    4
    485
    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.
    • Acidundefined
      Acid
      last edited by Acid

      Hi,

      I've made my own filament sensor using an optical sensor and a proxy that blocks this sensor whenever the filament is loaded. I've declared its pins in the config.g and tested it and can confirm this part is working.

      However, when I cut the filament manually to test my script, the machine moves to the designated location G1 X1 Y75 F3000 but it doesn't stop the print. Instead it goes back to where it was printing and continues to print.

      It then shows a popup on my LCD screen from the first M291 and when I press 'ok' the extruder starts to unwind filament WHILE the machine just keeps on printing as if nothing happened.

      I'm running on 3.4.4 so pause isn't automatically triggered.

      I specifically don't want to run pause.g because that has commands in it that conflict with my filament-error.g

      I looked at other examples by other users and examples found on the forum and decided to make my own script as I didn't want to make it as complicated as some of the examples and I wanted to keep it within my understanding so that if an issue came up I could solve it myself.

      It seems I may have forgotten to use M25 to pause and M24 to resume, but I haven't found this in scripts by others, so I'm wondering what may be my problem.

      This is the source of filament-error.g

      ; Step 1 > Pause > move to a spot center-front for easy access
      G60 S0          ; Save position to slot 0
      G1 E-10 F3600   ; retract 10mm of filament
      M568 A1         ; set tool to standby temp
      G91             ; relative positioning
      G1 Z5 F360      ; lift Z by 5mm
      G90             ; absolute positioning
      G1 X1 Y75 F3000	; Move out of the way
      
      ; Step 2 > Ask user to intervene
      M291 P"Filament runout detected, proceed?" R"Filament out" S2
      
      ; Step 3 > After checking you click okay and it starts reversing filament
      M302 P1         ; Allow cold extrusion
      G1 E-520 F3000  ; Unwind the filament 400mm
      
      ; Step 4 > Notify user and offer option to place new filament
      M291 P"Remove remaining filament, insert new filament and continue" R"Insert new filament" S2
      G1 E480 F2000   ; Load filament 480mm fast
      G1 E20 F750     ; Load the last bit a little slower
      
      ; Step 5 > heatup hotend back to extruding temperatures and extrude a little extra to prime the nozzle
      M568 A2         ; Set active temperature of the active tool
      M116            ; wait until hotend reaches set temperature
      M302 P0         ; Disable cold extrusion
      G1 E20 F60      ; Prime the nozzle a little bit
      M291 P"Remove the extruded string and click to continue" R"Printer ready" S2
      
      ; Step 6 > Resume the print
      G1 R1 X0 Y0 Z5 F36000   ; go to 5mm above position of the last print move
      G1 R1 X0 Y0 Z0          ; go back to the last print move
      

      Maybe the issue is clear to the advanced user, maybe there are more issues in my script. I'm pretty new to RRF, have my machine up and running for a while now without issues, but writing files like these are still a bit difficult for me.

      Thanks for your time.

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

        @Acid you need to pause, but you don't want to run pause.g. I have it in mind to add an option to M25 to do that, but it isn't implemented yet. So for now I suggest you use a global variable to indicate to pause.g whether it should run or not, like this:

        • In config.g add global inFilamentError=false
        • Add if !global.inFilamentError at the start of pause.g, then indent the remaining commands so as to be inside that condition
        • At the start of filament-error.g add this:
        set global.inFilamentError=true
        M25 ; pause print
        set global.inFilamentError=false
        
        • At the end of filament-error.g add M24 ; resume print. This will resume the print, running resume.g first. If there are any commands in resume.g that you don't want to run, you can use the same global variable again to make them conditional.

        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

        Acidundefined 1 Reply Last reply Reply Quote 1
        • Acidundefined
          Acid @dc42
          last edited by

          @dc42

          Thanks a lot for the suggestions, I have added this, and I also added some more variables to make sure a the filament runout script cannot be run when the print hasn't started yet because I had the issue that it would start to retract when I restarted the printer without any filament present.

          So my filament-error.g looks like this now:

          ; first check that we are not currently in an error state and the switch has been toggled again.
          if (global.filamentDistance !=0) || (state.status != "processing")
          	echo "Filament sensor triggered, but no print in progress.  No action taken"
          	M99 ; exit macro
          
          set global.inFilamentError=true
          M25 ; pause print
          set global.inFilamentError=false
          
          ; Step 1 > Pause > move to a spot center-front for easy access
          G60 S0          ; Save position to slot 0
          G1 E-10 F3600   ; retract 10mm of filament
          M568 A1         ; set tool to standby temp
          G91             ; relative positioning
          G1 Z5 F360      ; lift Z by 5mm
          G90             ; absolute positioning
          G1 X1 Y75 F3000	; Move out of the way
          
          ; Step 2 > Ask user to intervene
          M291 P"Filament runout detected, proceed?" R"Filament out" S2
          
          ; Step 3 > After checking you click okay and it starts reversing filament
          M302 P1         ; Allow cold extrusion
          G1 E-520 F3000  ; Unwind the filament 400mm
          
          ; Step 4 > Notify user and offer option to place new filament
          M291 P"Remove remaining filament, insert new filament and continue" R"Insert new filament" S2
          G1 E480 F2000   ; Load filament 480mm fast
          G1 E20 F750     ; Load the last bit a little slower
          
          ; Step 5 > heatup hotend back to extruding temperatures and extrude a little extra to prime the nozzle
          M568 A2         ; Set active temperature of the active tool
          M116            ; wait until hotend reaches set temperature
          M302 P0         ; Disable cold extrusion
          G1 E20 F60      ; Prime the nozzle a little bit
          M291 P"Remove the extruded string and click to continue" R"Printer ready" S2
          
          ; Step 6 > Resume the print
          G1 R1 X0 Y0 Z5 F36000   ; go to 5mm above position of the last print move
          G1 R1 X0 Y0 Z0          ; go back to the last print move
          M24 ; resume print
          

          Going to give this a try!

          holmbotundefined 1 Reply Last reply Reply Quote 0
          • natty15dundefined natty15d referenced this topic
          • holmbotundefined
            holmbot @Acid
            last edited by

            @Acid I used this as the basis to get my first filament-error.g action running. Thanks!

            I'm confused by the slot numbers of saved position vs. the resume position. We save in slot 0 using G60 S0 and resume using slot 1 with G1 R1. Is there a difference in 0/1 based slot counting? Typo, but works for other reasons? Not complaining since it works, but want to learn.

            ; Step 1 > Pause > move to a spot center-front for easy access
            G60 S0          ; Save position to slot 0
            ...
            ; Step 6 > Resume the print
            G1 R1 X0 Y0 Z5 F36000   ; go to 5mm above position of the last print move
            G1 R1 X0 Y0 Z0          ; go back to the last print move
            M24 ; resume print
            
            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Unless otherwise noted, all forum content is licensed under CC-BY-SA