3D Printer Filament Sensor

While looking for a design project for school, my group and I were made aware that our college's 3D printers were have several issues. The first issue was bed adhesion. The second, and topic of this guide, was filament breaking during long prints.

Looking on the internet to see if there was a readily available solution found scores of projects using the marlin firmware's filament detector, but this was just a simple switch that detected the presence of filament. We wanted to detect filament motion to see if the printer was extruding properly.

Step 1: Materials

What you will need for this project.

An ATtiny85 (code will be added for the Uno/Nano) (ATtiny85)

A 3d printer with Marlin firmware and an LCD with knob installed

soldering iron (this is the one I own)

crimping tool (link here)

perfboard or blank circuit board (link here)

wire (link here)

connectors/ headers (link here)

a rotary encoder (link here)

a 5v voltage regulator (link here) or power supply (link here)

a couple 10k resisters (kit link here)

Various 3d printed parts (stl files included)

Step 2: Flashing Your Micro-controller

Included are files for flashing this project to your ATtiny85 with the Arduino IDE. (Files for the Uno and Nano will be added soon!)

ATtiny85:

Open the project with the Arduino IDE

Add the TinyDebugSerial.h library found (here)

Connect your Tiny with you favorite programmer

Flash the Arduino

Congratulations your micro-controller is ready to be connected

Step 3: Modifying Marlin

If you have a Lulzbot Taz 5 you can download the modified firmware HERE and flash your printer with it. There is an excellent guide on how to flash your 3D printer (here)

Open the version of Marlin that you have installed on your printer using the arduino IDE and save it under a new file name. Next we want to turn on the filament detection function by going into the configuration.h tab and uncommenting "#define FILAMENT_RUNOUT_SENSOR"

Next we want to configure what where the printer goes when it detects the error. Go to the Configuration_adv.h tab and look for this section of code.

// Add support for experimental filament exchange support M600; requires display
#if ENABLED(ULTIPANEL)

#define FILAMENTCHANGEENABLE

#if ENABLED(FILAMENTCHANGEENABLE)

#define FILAMENTCHANGE_XPOS 3

#define FILAMENTCHANGE_YPOS 3

#define FILAMENTCHANGE_ZADD 10

#define FILAMENTCHANGE_FIRSTRETRACT -2

#define FILAMENTCHANGE_FINALRETRACT -30 //

#define AUTO_FILAMENT_CHANGE //This extrude filament until you press the button on LCD #define AUTO_FILAMENT_CHANGE_LENGTH 30 //Extrusion length on automatic extrusion loop

#define AUTO_FILAMENT_CHANGE_FEEDRATE 300 //Extrusion feedrate (mm/min) on automatic extrusion loop

#endif

#endif

I have changed the XPOS and YPOS to move the extruder to the front of the printer to make it easier to service the printer. You can change any of the numbers to accommodate your specific printer.

We'll now go in under the stepper motor function and add a variable for outputting the motor control signal.

On the stepper_indirection.h tab search for "#define E_STEP_WRITE(v) {E0_STEP_WRITE(v)}" and change it to "#define E_STEP_WRITE(v) {E0_STEP_WRITE(v); E1_STEP_WRITE(v);}// !!! writes to E0 and E1"

Finally we'll add variables under program for the board that our printer uses. The printers I'm working on use the Rambo. Open the code for your printer's board and change "#define E1_STEP_PIN XX" to

"#define E1_STEP_PIN 23//(33 original) !!! changed for extruder step output" I saved the original pin in the comments so I could change it back later if I needed to.

Select your board under the tools option connect via USB and upload the firmware to your printer.

Step 4: 3D Printed Parts

Here are the .stl files for the rotary encoder mount. This mount is designed for, and works wonderfully with the Taz5 printer. In order to hold the filament guide we u

Step 5: Installing the Rotary Encoder

For this step you will need the rotatory encoder, 3d printed parts, and something to affix the encoder mount to your printer. Make sure the position you mount the encoder doesn't cause the filament to bend to much as we want it to move though the contact wheels as easily as possible. I would recommend attaching the mount with a good double sided tape (link here) or if your printer uses aluminum extrusions you can mount it with T-nuts. The wheels are press fit to the encoder shaft and snap into the other side and the cover is screwed to the mount with m3 screws. Next the flex tube is pressed into the hole in the top of the cover. Finally the wire should be neatly routed so it doesn't interfere with the print bed (see below).

Step 6: Building the Board

First I would recommend building this on a breadboard and testing that the system works prior to permanently soldering anything.

Second the rotary encoder needs to be connected to the ATtiny85 with a pull-up network (shown in image above)

We used perfboard with header pins to connect everything. An 8 pin DIP socket was used to install the ATtiny85. If you decided to do it this way VERIFY YOUR PIN TO PIN CONNECTIONS WITH A MULTI-METER BEFORE CONNECTING ANYTHING! The rotary encoder wires were routed through existing connectors on the Taz5 that had empty pins.Cables were made for all the pin connections. Finally everything was connected and a test print was done to verify everything was working together.

Step 7: Final Thoughts

This project is a work in-progress. We will be adding files for the Arduino Uno and Nano in the weeks to come as well as some better diagrams of the circuit layout to replace the white board ones. With that have fun and keep making.

Share

    Recommendations

    • Optics Contest

      Optics Contest
    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • Plastics Contest

      Plastics Contest

    Discussions