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

    Filament sensor debouncing?

    Scheduled Pinned Locked Moved
    Duet Hardware and wiring
    3
    10
    350
    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.
    • zBeebleundefined
      zBeeble
      last edited by

      So... I looked at my previous filament sensor post --- and this deserves a new post.

      I bought some cheap filament sensors on Amazon. AFICT, they produce a positive spuriously but briefly. Now ... I could fix this with some sort of capacitor circuit --- but that is just not my wheelhouse.

      Now... my filament sensor is about 15 to 20 cm from the extruder --- so I'm fairly confident that a 1 second debounce could be added to software and/or to the M command that sets it up --- and that this would solve my problem.

      Equally, yes, I could not buy sensors on Amazon, but since I have, I'm hoping that this little feature request my save my (and other) butts in hindsight.

      OwenDundefined dc42undefined 2 Replies Last reply Reply Quote 0
      • OwenDundefined
        OwenD @zBeeble
        last edited by

        @zBeeble
        You can check for bouncing in filament-error.g
        Note: On some firmware versions the name could be filament_error.g
        Something like this is sufficient if it is a simple switch.

        ; check if switch is bouncing
        G4 P10 ; delay 10ms to debounce
        if sensors.filamentMonitors[0].status="ok"
        	echo "switch bounce detected - error cancelled"
        	M99 ; break out if sensor value is zero again (bouncing)
        
        ;error persists so we pause print
        echo "Filament error - pause print"
        M25
        
        
        zBeebleundefined 3 Replies Last reply Reply Quote 0
        • zBeebleundefined
          zBeeble @OwenD
          last edited by

          @OwenD OK. Awesome. I don't even know where to look for this functionality in the docs, but I'm ecstatic that it's there. My mind is immediately thinking about a retry loop for certain types of actions...

          But back to the project --- my firmware is 3.4.1. Nearly current. filament-error.g?

          OwenDundefined 1 Reply Last reply Reply Quote 0
          • zBeebleundefined
            zBeeble @OwenD
            last edited by

            @OwenD Are we using python-esque indentation is scope here?

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

              @zBeeble
              Yes should be filament-error.g
              See M591 and Events for more info

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

                @zBeeble said in Filament sensor debouncing?:

                Are we using python-esque indentation is scope here?

                Yes.
                See here for more info on conditional code and meta commands

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

                  @zBeeble what problem is the bouncing causing? Bouncing should occur only when the state changes.

                  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

                  zBeebleundefined 1 Reply Last reply Reply Quote 0
                  • zBeebleundefined
                    zBeeble @dc42
                    last edited by

                    @dc42 bouncing may not entirely be the right term. Maybe noise? I think the code will be correct, tho.

                    Basically, the filament enstop is "detected" ... but the filament went out --- and the LED is on. I can only assume that the sensor was only "off" for a very short time... as "off" is the runout condition.

                    I can feel a little microswitch in the sensor (it "clicks" when I push through a new filament). Given my recent experience with mouse switches, I can only assume the same thing --- that noise due to the switch being "on" (or contacting) but moving a bit --- noise is causing a momentary sensing of "off"

                    1 Reply Last reply Reply Quote 0
                    • zBeebleundefined
                      zBeeble @OwenD
                      last edited by

                      @OwenD Just got verification that this works (at least to sense the filament not running out).

                      5ece2725-a5a9-49de-a8fb-7b1e21150e45-image.png

                      ... I increased it to 100ms to be pessimistic, but that would be correct... the printer is still (for a little while) in filament. It should run out for real (testing the other branch) before this print is through.

                      zBeebleundefined 1 Reply Last reply Reply Quote -1
                      • zBeebleundefined
                        zBeeble @zBeeble
                        last edited by

                        @zBeeble So... after some time, I finally did run out of filament, and that, then, verified both branches ... "This works" ...

                        1 Reply Last reply Reply Quote 1
                        • First post
                          Last post
                        Unless otherwise noted, all forum content is licensed under CC-BY-SA