Filament sensor debouncing?
-
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.
-
@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
-
@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?
-
@OwenD Are we using python-esque indentation is scope here?
-
-
@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 -
@zBeeble what problem is the bouncing causing? Bouncing should occur only when the state changes.
-
@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"
-
@OwenD Just got verification that this works (at least to sense the filament not running out).
... 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.
-
@zBeeble So... after some time, I finally did run out of filament, and that, then, verified both branches ... "This works" ...