Prevent Failed Prints With A Filament Speed Sensor

If you have used a 3D printer for any length of time, you’ve probably experienced a failed print caused by a clogged nozzle. If you’re not around to stop the print and the nozzle stays hot and full of filament for hours, the clog gets even worse. [Florian] set out to solve this issue with an encoder that measures filament speed, which acts as an early warning system for nozzle clogs.[Florian] designed a small assembly with a wheel and encoder that measures filament movement. The filament passes under the encoder wheel before it’s fed into the 3D printer. The encoder is hooked up to an Arduino which measures the Gray code pulses as the encoder rotates, and the encoder count is streamed over the serial port to a computer.

When the filament slows down or stops due to a nozzle clog, the Python script plays a notification sound to let you know that you should check your nozzle and that your print might fail. Once [Florian] works out some of the kinks in his setup, it would be awesome if the script could stop the print when the nozzle fails. Have any other ideas on how to detect print failures? Let us know in the comments.

41 thoughts on “Prevent Failed Prints With A Filament Speed Sensor

      1. The pound shop in town now, amazingly, sells optical mice. They had the crappy ball type long after everyone else had abandoned them, but it’s amazing how much they can get the price down. Of course having no ethics at all helps.

        I believe there’s pins on the optical chip itself to allow access to the data, an article here a while back was about a guy who made a completely useless (no disrespect!) camera using one.

          1. I think he is talking about the extruder gears. In that case it is not a good idea: a clogged nozzle will still let the wheel spin, it generally “eats” in the filament until it can turn freely.

    1. Using optical mouse sensors for any sort of deterministic measurements is fraught with peril.

      There is a lot of info out there on this.

      Sadly a contact roller is more or less required for this application.

      1. Can you supply a reference for “peril” in using a mouse as distance sensor. I found one comment that says it doesn’t work because of a 0.1% error. I agree that trying to use the filament directly wouldn’t work, so a pinch roller would still be needed, but seems like a mouse sensor would work fine. My wireless mouse seems to have a minimum speed though.

  1. This is super cool.

    Maybe it could be made simpler to make a contact once / twice / n times per revolution?

    I would love to see this integrated into the RAMBO board (surely there must be a free input there) – then we could just add an interrupt and a snippet of code that regularly checks that the number is incrementing / filament is flowing.

    If there is no increment / insufficient within a certain period then just call the kill routine… that would mean we have an integrated solution that doesnt require an extra board / beeper / python etc etc

    Are there STLs for the 3d printed parts? I would love to have a bash at getting the above to work…

    1. It does look very functional. Mein Deutsche is nicht sehr gut but it looks like it’s essentially hall effect switch and a neodynium magnet rotating above it. Looks like it could be mounted between the extruder and the hotend, which I’ve had the misfortune to find nessecary.

      I would think that limits the resolution to “on” for 1/4 a turn and “off” fro 3/4 a turn. With magnets and binary sensors on both rollers you might be able to make an interleaved position encoder, but that would only make sense if they were mechanically linked (more complexity, more resistance to push/pull etc.)

      For big filament (3mm) and small nozzles / thin layers, that might make a big difference

    1. I agree, though I suggest finding a setting or plug-in to turn off GIF animations. I think turning it off for your browser is going to be easier than stopping web sites from using it. I have animation_mode set to “once” in Firefox. I think Chrome has a GIF stopping plug-in.

  2. Those animated gif things are neat, but not next to the text – it’s really distracting. At least put them above the text so you can scroll the movement off screen. Alternatively, you could shorten the animation to just the part with the wheel moving; something that isn’t so jarring.

    The project is really cool.

  3. I did this with my Rawstock Max, except I connected it the Step and Dir pins going to the stepper driver and Encoder. Then had a buzzer sound when there was a mismatch. I wanted to integrate the code into Repetier to have the print pause but that was beyond my abilities.

    Though thinking about it now, I could just inject serial data into the serial line between the FTDI chip in the Mega2560.

  4. I think the goal here should be to get a 100-400 count encoder that mounts inline with a bowden system right at the hot end. That way we can close the position loop and hopefully compensate for hysteresis and elasticity. Best case we could print flexible filament reliably, and greatly simplify calibration.

    It could basically revolutionize multimaterial printing since there would be no quality loss with 4+ long bowdens.

  5. Presently filament jam is the key issue in prints longer than a few hours. There are many reasons for it and not all of them can be “fixed” so… I’ve been “working” on a related concept:

    1) detect filament tension – filament wind up / knots
    This gives the ability to detect issues BEFORE they become failures.

    2) detect filament seed – contact speed sensor (similar to what you have)
    any good low friction encoder method should do.

    3) detect 4th axis step commands.
    so it can start with a good condition and not detect a jam by just timeout
    there are many ways to detect the stepper commands.

    4) output filament status – jam / good
    LED + dry contact output so it can be interfaced to anything.

    5) use sailfish firmware p-stop for automated jam recovery
    This only applies to Rep2 printers. But, a general E-Stop / P-Stop firmware input would seem to be a good option for all firmware to handle “issues”. I’m interested if anyone know what kind of interface information Octoprint, astroprint, 3dprinteros do?

    I have plans to use the wheel for “2” to also be related to “1” . I’ve already installed “5” and use p-stop for other issues.

  6. It’s worth noting that some newer consumer printers like the Robox are clever enough to actually detect these issues, including filament slippage and run-out, and either run a routine to try correct the issue – or pause and wait for you to come back and fix the issue.

  7. It’s a very nice add-on, and the difference in that one part is pretty staggering.

    I wish the source article had photos of the rest of the machine. If you’re getting a lot of jams, often putting in a little work elsewhere is a better idea. I think it’s likely there’s a fundamental problem that could be addressed, and this is covering the symptom of a different problem. I suspect something about the the extruder drive or hot end is causing these problems. And, if you have pets, a dust wiper on the filament intake can help a lot.

  8. This is great!

    Use the speed sensor along with this filament width sensor (, the width sensor can already change the speed of the extruder flow due to changes in the filament width. (This was designed for use on a filament extruder to measure homemade filament, and to be used on a printer loaded with filament that may not be the most consistent.)

    I’d also appreciate this system somehow making note of the gcode line number to make it easier to continue a failed print, if the design of the print and the failure mode allow for continuing after a feed or filament issue.

    With both sensors working, the last piece I’d want would be a notification sent to my phone so I can decide how to proceed when away from the printer; have my son fix the clog and resume, come home at lunch to fix it, etc. Maybe this already exists, but sending me the failure mode would be very useful.

    Side rant:
    These kinds of sensors, (notification aside) are exactly the kinds of features, along with automatic bed level compensation and “tings of dis nature” (to quote Arnold Schwarzenegger) that are necessary to take FDM 3D printing mainstream. The other step needed is to streamline the process of going from a model to a part, while I like the creativity and experimentation of the design, tweaking and gcode translation phases, for any 3D printing to become mainstream the goal is very very simple:

    1. load consumables into machine (i.e for FDM 3D printing this is filament, for paper printing the consumer has no problem loading paper and ink)
    2. an object is printed with less than 10 pushes of a button. (you can ink print documents with less than 10 clicks, and use a microwave with less than 10 button pushes)

    When these to simple rules are met, 3D printing will then be accepted by your grandparents. Setup as simple as the “quick setup guides” that Wifi routers use would also help a lot, but many non-“hands-on” or non-technical people are willing to pay for installation of kitchen appliances and setup of computers, so simple setup would be up to the manufacturer.

    One of the next great heroes of FDM 3D printing will be the inventor of an extruder and/or hotend that can clean itself via a software command, like the way ink jets can attempt to clean themselves.

    I view the lack of self cleaning parts as one of the biggest remaining hurdles that prevents the mainstream acceptance of FDM 3D printing, but given the pace and the high level of innovation seen in the last 10 years, I expect this will not be an issue too much longer.

  9. How about measuring the current to the head, shouldn’t that change if the filament don’t cool down the nozzle (and altering the resistance therefore)? Forgive me if I’m thinking too short here I don’t have a 3D-Printer and think of the nozzle like one of a hot glue gun, which I run with a watt-meter to see when it is ready to use, as the power draw changes rather steep.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.