Filament Sensor for 3D printers and filament extruders

A prototype sensor that can measure filament diameter in real time for your 3D printer or Filament extruder.

3D printer parts and enhancements

    Creative Commons Attribution Noncommercial Share Alike

    Commercial use is not allowed, you must attribute the creator, you may remix this work and the remixed work should be made available under this license.

    Learn more or download attribution tags

    Description

    What it Is

    This is a prototype for an optical sensor that measures the width of plastic filament in real time as it goes into a 3D printer or a filament extruder. It is prototype #3 (other 2 are on Thingiverse ).

    What it Does

    The idea is that with a real-time width measurement the 3D printer (or filament extruder) could compensate the extruded flow for changes in filament width. Also if there is variation between spools of filament, there is no need to calibrate for that when slicing. The g-code is independent of the filament diameter. For filament extruders, the measured width can be used as feedback in the extrusion process.This version includes a custom designed pc board as well as a housing.

    For 3D Printers

    A version of Marlin is modified to use the sensor data.

    The sensor outputs a voltage in millimeters (3v=3mm) that is shown on the voltmeter.

    I made some changes to Marlin to read the filament diameter real-time and compensate the extrusion rate. Code uses a buffer to manage the transit delay between the sensor measurement and the nozzle.

    The main branch of Marlin now has initial support for the sensor. However, it does not have LCD support (yet - pull request was submitted). You can find the version with LCD support at https://github.com/filipmu/Marlin/tree/Filament-Sensor

    For Filament Extruders

    This prototype sensor is compatible with the design of the latest Lyman extruder. I worked with Hugh on building the controller and incorporating the sensor into the system.

    http://www.thingiverse.com/thing:380987

    Other applications

    • Could use stand-alone with a voltmeter or an LED panel display and 5v supply (think USB charger). To show filament width without interfacing to printer or extruder. Can also hook up to a data logger to track filament diameter.
    • Can measure width or diameter of any object in this size range (wire, plant stems, etc)

    Sensor Specs (my Estimates)

     

    1. Accuracy: Practical usage: 0.02- 0.05mm in ratiometric mode for 3mm filament. Theoretical: The sensor has .06mm wide pixels, and with the subpixel edge detection, my guess is that it is 5-10 times better, so .01mm.

    2. Sampling Speed: Internal sampling of image is 100Hz, output is averaged to update roughly once every second.

    3. Limitations: May not work with clear or translucent filament. Not fully tested for 1.75mm filament but should work.

     How it works: see attached doc.

    INSTRUCTIONS

     

    See the following video for additional info on construction and usage:

     

    First step - decide if you want a sensor for 3D printing or Filament extrusion.

     

    Procurement

     


    1. Get the PC board made.
    See Seeedstudio_order_v2.0.zip for files needed to order a board from Seeedstudio. The specs are on the PC_board_BOM.pdf.

    Alternatively, use the EagleCAD files to order from somewhere else. PCB thickness is critical in the design to ensure case closes. Should be 1.6mm as listed on the PC Board BOM.

    2. Order parts from the BOMs (PC Board and either the Extruder_version_BOM or Printer_version_BOM)

    Alternatively, I have a small supply of presoldered and tested boards here: http://owi.storenvy.com/

    Make the Case Parts


    1. Print out the relevant parts
    (Printer or Extrusion .stl's) in ABS with 20% infill, .5mm nozzle, .4mm
    layer height.
    2. Paint inside of tower and top
    plate sensor area with flat black craft paint (reduces light reflections).

    3. Drill out the hole in the
    tower to fit an LED (if needed) using #9 (0.196inch) Drill out the screw
    holes in the top plate with a #50 (0.07 inch) to allow the 2-56 screws to
    self-tap.

    Make the Electronics 


    1. Use solder paste in a syringe and an electric skillet to reflow solder the parts to the PC board. See http://www.instructables.com/id/Simple-Skillet-Surface-mount-Soldering/
    2. Check the PC board with a meter for solder shorts and fix them.
    3. Solder two 4 inch wires to the 5mm through-hole LED that will be put in the sensor tower.

    4. Flash the MCU using http://www.evbplus.com/freescale_usbdm_osbdm/usbdm_osbdm_bdm_multilink.html.
      • If all you want to do is load the firmware on the mcu you can use the software that came with the programmer board (USBDM board). If you install the drivers, it installs some flash programmer software, one called HCS08 Programmer. This software lets you load the compiled firmware 'hex' file (called FilamentSensorproto2.abs.s19 in the directory called FLASH in the zipped project) into the MCU. No need for the IDE in this case.
      • If you want to open the code in the IDE, see the dev tools for free from freescale: freescale.com/webapp/sps/site/overview.jsp?code=CW_SPECIALEDITIONS - look for the one for microcontrollers, eclipse version.

    Final Assembly


    1. Use ABS juice to glue the tower onto the top plate using the attached photos as a guide. Hole in tower should line up with hole in top plate.
    2. Print out the Case_labels.pdf on an injet printer and cut out the label to paste on the back of the case. Glue with ABS juice. Can let ABS juice soak in to the paper.
    3. Press the PC board into the printed Base Plate. Make sure it fully seats against the standoffs (use an exacto knive to clear plastic)
    4. Push the Top Plate assembly onto the Bottom Plate (they should mate) and fasten with the 2-56 screws (3 for extruder version, 4 for printer)
    5. Attach the LED wires to the +An and -Cath screw terminals. LED has a flat on the -Cath terminal side.
    6. Insert the LED into the tower (should fit gently) and screw on the ABS Cap while holding the leads in place.

     

    Testing and Calibration


    1. Connect a voltmeter to the 'Out' terminal and 'Gnd' terminal.
    2. Provide 5 volt power to the correct terminals (I use a USB charger and cut-off USB cable)
    3. LEDs should light up and voltmeter should read below 1v.
    4. Place a piece of calibration rod (precise 1/16 in drill rod) in the sensor and gently hold level and down. - Voltage should show >1volt. Press and hold the button on the sensor for >3 seconds - indicator LED will go off and then on when complete.
    5. Output voltage should show 1.56 volts, assuming power voltage is exactly 5.00 volts. Can press button <1 sec to switch modes to absolute output to confirm calibration. - see Board_instructions file for more details.

     

    Attach the Sensor to 3D Printer or Filament Extruder

     

    See Filament Extruder thing for instructions for Filament Extruder:

    http://www.thingiverse.com/thing:380987

    For 3D Printer:


    1. Connect the sensor to an A/D
    input and +5v power on 3D printer control board - see 3D
    Printer_hookup.pdf file.


    2. Download the modified version
    of Marlin from Github https://github.com/filipmu/Marlin/tree/Filament-Sensor - hopefully this will be
    incorporated into the official Marlin some time in the future.


    3. Change the Config file as
    needed for your printer. There are some new defines for the filament
    sensor in this code.


    4. Upload firmware into your 3D
    printer.

    Using the Sensor with your Extruder or Printer





    See Filament Extruder thing for instructions for Filament
    Extruder:

    http://www.thingiverse.com/thing:380987

    For 3D Printer:


    1. Add custom g code to your
    slicer software to enable sensor:

    M405 ; turn on filament control


    2. While printer is idle you can
    see the filament sensor reading by keying in and sending an M407 to your
    printer. It will return the diameter to the log.



    What's New in this Prototype
    Version (#3)

    I improved the PC board (now Version 2) to use screw terminals for the connections. I removed the unused components. Board has the same dimensions as previous V1 for Prototype #2. Note that Prototype #1 had board V0 (hand-made), so board version number is one behind the Prototype #.

    There are two case designs, one for 3D printers and one for filament extruders. The same PC board works in both.

     

    Information on Prior Versions

    There is lots of relevant discussion at the prior version sites:

    Version 2:http://www.thingiverse.com/thing:89044

    Version 1:http://www.thingiverse.com/thing:70775

     

    Obtaining Parts (Vendor Sources)

    1. PC Board - The files include everything you need to submit to Seeedstudio's board service: http://www.seeedstudio.com/service/index.php?r=pcb

    2. Electronic components can be ordered from Mouser. Digikey is also an alternative.

    3. Enco provides the calibration drill rod:http://www.use-enco.com/CGI/INSRIT?PMAKA=408-0001&PMPXNO=939654&PARTPG=INLMK32

    4. If you want to avoid making and soldering your own board, I am selling a limited number of completed and tested pc board kits at:http://owi.storenvy.com/

    Where to take it from here:

    Here are some thoughts on where to take this idea, some suggested by others:

    1. It only measures diameter in 1 dimension. Filament may be oval, so measure in more dimensions. Some options are multiple image sensors, or using an RC servo to physically scan the sensor around the filament and make a geometric average.

    2. Improve existing precision - use lenses or better illumination to ensure filament distance from sensor does not affect reading. Also could use small rollers to hold filament in place.

    3. Improve output so that it produces a digital I2C output rather than analog voltage.

    4. Update Marlin so that the sensor also checks for end of filament.

    5. Sensor should work for 1.75mm filament, but more info/feedback/work needed to refine the design (I don't have a printer that uses 1.75 mm filament)

    6. The calibration rod is difficult to source in Europe, so make the board work with a 3mm calibration rod as well.

    7. Make a version with an Atmel processor so it can use Arduino toolchain.

    8. Use existing Arduino board and sensor board:

    Materials and methods

    Summary list (see attached documents for details)

    - ABS Filament
    - Black acrylic craft paint
    - sensor PC board (see specs attached)
    - electronic components for sensor board (see specs attached)
    - electronic supplies (solder, smd solder paste, hookup wire, etc)
    - Freescale HCS08 programmer (see details)
    - Modified marlin software (see details)
    - calibration rod (.0630mm drill rod)

    Documents

    • Placeholder
      3 D Printer Hookup
      PDF  β€“  350 kb
      Version 1 - Dec 14, 2014
    • Placeholder
      Back Case Filament Extruder Proto 3
      FUN  β€“  1.8 mb
      Version 1 - Dec 14, 2014
    • Placeholder
      Back Case Proto 3
      FUN  β€“  1.7 mb
      Version 1 - Dec 14, 2014
    • Placeholder
      Board Instructions V3
      PDF  β€“  190 kb
      Version 1 - Dec 14, 2014
    • Placeholder
      Case Labels
      PDF  β€“  98 kb
      Version 1 - Dec 14, 2014
    • Placeholder
      Extruder Version Bom
      PDF  β€“  180 kb
      Version 1 - Dec 14, 2014
    • Placeholder
      Filament Width Sensor V2 Opt
      SCH  β€“  540 kb
      Version 1 - Dec 14, 2014
    • Placeholder
      Filament Width Sensor V2 Opt
      BRD  β€“  62 kb
      Version 1 - Dec 14, 2014
    • Placeholder
      Freescale 8 Bit Code 06012014
      ZIP  β€“  220 kb
      Version 1 - Dec 14, 2014
    • Placeholder
      Front Case Filament Extruder Proto 3
      FUN  β€“  1.7 mb
      Version 1 - Dec 14, 2014
    • Placeholder
      Front Case Proto 3
      FUN  β€“  2 mb
      Version 1 - Dec 14, 2014
    • Placeholder
      How It Works
      PDF  β€“  180 kb
      Version 1 - Dec 14, 2014
    • Placeholder
      Light Tower Extruder Proto 3
      FUN  β€“  1.2 mb
      Version 1 - Dec 14, 2014
    • Placeholder
      Light Tower Proto 3
      FUN  β€“  1.2 mb
      Version 1 - Dec 14, 2014
    • Placeholder
      Pc Board Bom
      PDF  β€“  200 kb
      Version 1 - Dec 14, 2014
    • Placeholder
      Printer Version Bom
      PDF  β€“  180 kb
      Version 1 - Dec 14, 2014
    • Placeholder
      Seeedstudio Order V2.0
      ZIP  β€“  44 kb
      Version 1 - Dec 14, 2014
    • Span1 jamrendering 4578 1530320160402 22668 yzrpe7
      Sensor Base Plate Extruder Version V3
      STL  β€“  370 kb
      Version 1 - Apr 01, 2016
      Updated on 01-04-2016  β€“  0:40 h  β€“  4 g  β€“  54×41×8 mm
    • Span1 jamrendering 4578 1530420160402 22804 143ey39
      Sensor Base Plate Printer Version V3
      STL  β€“  460 kb
      Version 1 - Apr 01, 2016
      Updated on 01-04-2016  β€“  0:36 h  β€“  4 g  β€“  57×41×5 mm
    • Span1 jamrendering 4578 1530520160404 29861 1i0bhzg
      Sensor Top Plate Extruder Version V3
      STL  β€“  330 kb
      Version 1 - Apr 01, 2016
      Updated on 01-04-2016  β€“  0:56 h  β€“  6 g  β€“  57×41×13 mm
    • Span1 jamrendering 4578 1530620160402 22981 n9c80n
      Sensor Top Plate Printer Version V3
      STL  β€“  500 kb
      Version 1 - Apr 01, 2016
      Updated on 01-04-2016  β€“  1:10 h  β€“  7 g  β€“  57×41×13 mm
    • Span1 jamrendering 4578 1530720160404 29738 l8t9nr
      Sensor Tower And Cap Extruder Version V3
      STL  β€“  420 kb
      Version 1 - Feb 04, 2015
      Updated on 04-02-2015
    • Span1 jamrendering 4578 1530820160402 23148 s2p4kh
      Sensor Tower And Cap Printer Versio V3
      STL  β€“  430 kb
      Version 1 - Apr 01, 2016
      Updated on 01-04-2016  β€“  0:52 h  β€“  4 g  β€“  51×17×41 mm

    Issues

    Issues are used to track todos, bugs or requests. To get started, you could create an issue.

    Comments

    8845e3fc7f47d42c4b0ddcd13819bed2?default=blank&size=40GrGin added this to the Ender 3 collection ago
    A81dfa73139089aa5fb819f51c96b824?default=blank&size=40matiuhart added this to the Prusa collection ago
    F5611b85d28f178c5e68af7f7b5ef8e8?default=blank&size=40demian 75 added this to the Ender 3 collection ago
    Ab070ed6bd35e37649fec781889e92f4?default=blank&size=40stachas added this to the filament collection ago
    730a061596c420c8915d9f20bd5d89e1?default=blank&size=40Marcus Wolschon commented ago

    Is the stated accuracy of +-0.05mm even relevant?

    a) only measuring the diameter in one instead of 2 dimension and

    b) potentially being +0.05mm off without the filament actually changing diameter

    any compensations will probably do more harm then good.

    B1e5d2d82881c6c179ef909349555ce2?default=blank&size=40chantling added this to the 3D Printing collection ago
    Da031295f3c4ff46886fd5db0dcb8033?default=blank&size=40Nacho Garcia added this to the Things to do collection ago
    2811205745a43cae618e4e6afda1dd16?default=blank&size=40Robert Wallace added this to the 3D Printer collection ago
    758daed9695e35894f4aaa1628e6cfb0?default=blank&size=40yootis commented ago

    Very cool. Have you detected significant variations in filament diameter? And does this active measuring produce a noticeable improvement in results?

    758daed9695e35894f4aaa1628e6cfb0?default=blank&size=40yootis added this to the printrbot collection ago
    A4e2598b60cb6c86ac56f99c84bc8442?default=blank&size=40Matthew Grant added this to the tools collection ago
    Mini aviator2 small png iconChris added this to the UM2 Parts collection ago
    24ee2577539ae18c4b0af758a9234ad4?default=blank&size=40Tongdam added this to the Extruder collection ago
    Mini 3501  13 exilhamburger added this to the Ultimaker collection ago
    Mini lisca mangaLisca added this to the Calibration collection ago
    Fa358a0b437d628e89e39b1cc89b1c11?default=blank&size=40Eghia Hay added this to the 1 collection ago
    A5c0f84d51eb49dc910dd074c2b19dff?default=blank&size=40ChrissyP added this to the Upgrade collection ago
    2713e666abadb03b0b02d5aa09f2cbcd?default=blank&size=40faker added this to the things to do collection ago
    Mini screen shot 2013 07 15 at 6.49.36 pmErik de Bruijn added this to the Cool projects collection ago
    Mini screen shot 2013 07 15 at 6.49.36 pmErik de Bruijn added this to the Ultimaker 2 upgrades! collection ago
    84f8cb9a58a8292f1607d21cf261436e?default=blank&size=40Mircea Nistor added this to the reprap upgrades collection ago
    D8ca6d420a762c77de52529cbf3e2398?default=blank&size=40Biogoly added this to the 3D Printer Hardware collection ago
    B236ffc98e4aff5bb419036342c3ef76?default=blank&size=40Charlie Fenwick added this to the mMy Prints collection ago
    Mini web   marchio compatto psd  1 Fablab Imola added this to the ultimaker collection ago
    Acacbff64b0aff3dde7e149f4f1f3dfd?default=blank&size=40favabr added this to the reprap collection ago
    Df52ecb8324ce3c259d8e251d69d2518?default=blank&size=40filipmulier published this design ago