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

Filament sensor debouncing?

Scheduled Pinned Locked Moved
Duet Hardware and wiring
3
10
349
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
    zBeeble
    last edited by 14 Jan 2023, 19:05

    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.

    undefined undefined 2 Replies Last reply 14 Jan 2023, 19:16 Reply Quote 0
    • undefined
      OwenD @zBeeble
      last edited by 14 Jan 2023, 19:16

      @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
      undefined 3 Replies Last reply 14 Jan 2023, 19:19 Reply Quote 0
      • undefined
        zBeeble @OwenD
        last edited by 14 Jan 2023, 19:19

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

        undefined 1 Reply Last reply 14 Jan 2023, 19:38 Reply Quote 0
        • undefined
          zBeeble @OwenD
          last edited by 14 Jan 2023, 19:26

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

          undefined 1 Reply Last reply 14 Jan 2023, 19:40 Reply Quote 0
          • undefined
            OwenD @zBeeble
            last edited by 14 Jan 2023, 19:38

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

            1 Reply Last reply Reply Quote 0
            • undefined
              OwenD @zBeeble
              last edited by 14 Jan 2023, 19:40

              @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
              • undefined
                dc42 administrators @zBeeble
                last edited by 14 Jan 2023, 20:01

                @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

                undefined 1 Reply Last reply 14 Jan 2023, 20:38 Reply Quote 0
                • undefined
                  zBeeble @dc42
                  last edited by 14 Jan 2023, 20:38

                  @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
                  • undefined
                    zBeeble @OwenD
                    last edited by 14 Jan 2023, 20:41

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

                    undefined 1 Reply Last reply 16 Jan 2023, 04:57 Reply Quote -1
                    • undefined
                      zBeeble @zBeeble
                      last edited by 16 Jan 2023, 04:57

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