Filament Thickness Sensors, What Are They And What Are They Good For?

I keep up with the trends in 3D printing reasonably well. The other day my friend mentioned that filament thickness sensing had been added to the latest version of the Marlin firmware. I had no idea what it was, but it certainly sounded cool. I had to find out more.

In industrial settings, filament is made by pulling extruding molten plastic at a certain speed into a cooling bath. The nozzle for 2.85mm filament and 1.75 mm filament is actually the same size, but the filament is stretched more or less as it leaves the nozzle. By balancing these three variables the extrusion machine can produce any size filament desired. Like any mechanical system, it needs constant adjustment to maintain that balance. This is usually done by measuring the filament with a laser after it has cooled, and then feeding this information back into the system. The better filament manufacturers have multiple lasers and very fast feedback loops. Some of the best offer +-0.04mm or less variation in thickness between any two points on the filament. Some of the worst have larger errors such as +-.10mm. Because the plastic is fed into the extruder at a fixed linear speed, this makes a variation in the volume of the plastic coming out of the nozzle per second. With the best we see a 4.41% variation in the volume of plastic extruded. With the worst we start to see 10.51% or more.

FIlament variation showing up as a cosmetic defect.
Filament variation showing up as a cosmetic defect.

A printer is dumb. It works under the assumption that it is getting absolutely perfect filament. So when it gets 10.51% more plastic, it simply pushes it out and continues with its life. However, if the filament is off enough, this can actually show up as a visible defect on the print. Or in worse cases, cause the print to fail by over or under extrusion of plastic.

So, what does a filament thickness sensor do to correct this issue? To start to understand, we need to look at how the filament is dealt with by the software. When the slicer is compiling the G-code for a 3D print, it calculates the volume of plastic it needs in order to deposit a bead of plastic of a certain width and of a certain height per mm of movement. That was a mouthful. For example, when a printer printing 0.2mm layers moves 1mm it wants to put down a volume that’s 1.0mm long x 0.4mm wide x 0.2mm high. The filament being pushed into the nozzle has a volume per mm determined by the diameter of the filament.

(\pi (radius_{filament})^{2}*length_{filament extruded})=volume

The volume out per mm of filament in.

(layer_{height}*layer_{width}*length_{move}) = volume

The equation we are trying to balance.

Our goal is to integrate the thickness sensor into these functions to see what the thickness sensor is doing. This is a linear equation, so there’s nothing fancy here. Now, the layer height, layer width, and length of the move are determined by settings and model geometry respectively. These are fixed numbers so we don’t care about them. That leaves us the diameter of the filament and the length of filament extruded. As we mentioned before, typically the filament is assumed to be a fixed diameter. So all the software has to calculate is the length of filament that needs to be extruded per mm of combined movement in the x and y so that our volumes match.

But, we know that one of these variables is actually changing per millimeter as well. The filament diameter! So now we have a problem. If the filament diameter is changing all the time, our equation will never balance! In order to fix this we can add a multiplier to our equation. Since we have no control over the width of the filament we can’t modify that value. However, if we know the width of the filament, and we know the value its supposed to be, we can change the length of the filament extruded. This is because unlike the filament, we have control over the stepper motor that drives the extruder. This value is called the extrusion multiplier, and its determination is what the thickness sensor is all about.

So all the filament sensor does is measure the filament’s current diameter. It takes expected diameter and divides it by the value it just measured to get a simple percentage. It feeds that number back into our system as the extruder multiplier and slows or speeds up the stepper motor as needed. Pretty simple.

Shadows on the sensor from [inornate]’s variation.
There are a few thickness sensors being toyed with right now. The first, as far as I can tell; let me know if I am wrong in the comments, was by [flipper] on thingiverse. He is in his third version now. The sensor works by casting a shadow of the filament as it passes by onto an optical sensor. The firmware then counts the pixels and works backwards to get the diameter. This value is sent to the Marlin firmware on the printer which does the rest. As is usual and wonderful in the open source community, it wasn’t long before others started working on the problem too. [inoranate] improved on the idea by casting more shadows on the sensor. The technique is still brand new, but it will be interesting to see what benefits it reaps.

Now comes the next question,”Is it worth upgrading my printer with a thickness sensor?” If you typically run poor filament, or if you extrude your own, yes. The current sensors can only measure +- .02mm. So for the best filament, you won’t really see a difference, but for worse stuff, you might. The latest firmware of the Lyman filament extruder, for making your own filament, also supports these sensors, letting you feed back into your production system like the industrial machines. All in all a very interesting development in the world of 3D printers.

48 thoughts on “Filament Thickness Sensors, What Are They And What Are They Good For?

      1. It’s a shame, really, but people don’t realize the error in prints is probably compounded more by density variations in the filament than thickness/width. If your printer is working you’re better off making it more xy accurate than layerthickness accurate.

      1. Probably have to be a Piezo electric device. Something small you could insert into a hole drilled near the nozzle in the extrude. Maybe a piezo ‘washer’ in between sections of the extruder. I think the difficult part would be actually building it.

        1. Pressure sensors for extruders are not an easy thing to build: I spent a lot of time playing with one of these×239.jpg and they have a pressure sensor on the hot end which is such a lump it makes designing an efficient die a real pain.We did a lot of hunting to try to find a small pressure sensor that could survive in the conditions and not be a random number generator, we had zero success.

      2. I seems to remember a discussion with a friend about this. I think we had to change the dynamics of the system completely to get something that would reasonably work well. A stepper fed in feedstock into a larger melt chamber but not directly into the nozzle. the chamber would need to be sealed somehow around the feedstock and then an “air over plastic” pressure system would have to maintain pressure to the nozzle. Alternatively, the expected material for the next layer or two would need to be fed in between layers and then resealed. A small load cell would allow you to check the loaded weight of the material between prints. This is effectively a micro filastruder for pre-colored pellets.

        Effective, heavy, and expensive.

      3. Maybe the flex sensor out of those cheap drug scales you can buy in so many shops? They’re accurate (or claimed to be) down to 0.1gram. They’re already mounted to a bit of metal. Bit of cutting up might give you what you need.

    1. You’re going to have to contend with the noise from changes in the feedstock velocity as well as temperature variations. The actual different in pressure from the filament alone will be negligible.

    2. Wouldn’t a precision balance be a cheap and cheerful solution? Maybe use the idea from Will’s recent calculus articles: measure the mass of filament deposited so far, compare against the amount that should have been (given uniform filament diameter) and adjust the extruder stepper motor speed proportional to the current and historic differences between the two masses?

      1. I think the feedback would be too slow. If the filament deposited is off, it would be far too late to do anything about it. You would be no better than not having any sort of width feedback at all.

        1. !!!!! Sorry, I fat-fingered the report link by mistake; I’m typing on a phone !!!!

          Surely, the feedback depends on how precise the balance is, no?

          The width measurement is, after all, just an attempt to derive the mass deposited, subject to all the problems people have pointed out in the comments.

      2. “Precision balance” and “cheap” are mutually exclusive. You’re talking about being down in the milligram range, and costs go up exponentially to add each extra decimal point.

        Example: take a 1 cm long piece of ABS at 1.75 mm and one at 1.73 mm. Using 1 g/cu. cm for density, the 1.75 mm piece would be 0.0241 g [ pi* (.175 cm/2)^2 * 1 cm * 1 g/cu cm = 0.0241 g]. The 1.73 mm piece would be 0.0235 g. A simple analytical balance that can get you that type of resolution can cost a couple grand easily.

        Measuring the amount deposited would also be difficult in that you’d have a moving base (or, assuming a completely fixed bed, a moving hot end in contact with the base/part) that would add a ton of noise to the system.

  1. Why not just pull the filament through a series of spring loaded rollers. One set could have the spring mounted to a pressure sensor, a change in pressure equals a change in diameter. I would think you could extrapolate the filament size fairly easily from this.

    1. As the wheel wears down, how would it be calibrated and against what? The filament would be no good because you can’t decisively determine the width without outside tools.

  2. Don’t forget some type of buffer, as the measured position is not the extruded position. Example. If sensor is 50mm away, then make a 50 byte fifo buffer, and place offset onto buffer, then extruder uses the first byte in buffer to compensate.

    Just my 2cents

  3. The real fun only starts once you realize the filament is never perfectly round, but actually more of an oval shape. And i would not be surprised if that oval shape is not steady, but probably turns around the center of the filament axle. So, you should probably measure at least in 3 different axis with 120° offset around the filament to really take into account the odd shape.
    I wonder if there is not a way to use a different approach, something like these coriolis flow meters that get used for gas and liquid process controls? I have a feeling that by passing the filament thru an ultrasonic barrier, you could measure the amount of filament passing thru by detecting and precisely measuring the sonic absorption rate of the filament? Just an idea, but i cant really tell if that is anywhere near practical, especially with all thedifferent blends of plastics, that probably have very different absorption rates to begin with. And if you go by how much these industrial flow sensor cost to get anywhere near high precision results, i guess you would just blow your printers price way out of the consumer range again.

    1. Volumetric measurement using a fluid that is hydrophobic to the filament. You know there is X linear length of filament and at Y uniform thickness the level Z should be this high. Extrapolate for variations in the filament

    2. Extrapolating RobHeffo’s idea in a different way: use a PTFE coated belt of some type. Have it wrap around the filament in a spiral, single or multiple turn, and have it fixed on one end and spring loaded on the other. Use a sensor to detect minute motion of the belt end (probably optical, but I’d prefer an analog capacitive or inductive sensor for cleanliness). Bonus: clears dust off the filament before to reaches the hot end. Downside: will wear and need recalibration somewhat regularly.

      The belt could also be wrapped around PTFE “fingers” to multiply the variation, remove belt binding issues, and reduce the wear rate drastically.

    3. Interesting. We are working on an optical imaging tool to provide real time filament diameter measurement for accuracy to the micron level. Such data could be used for feedback loop control of the extrusion machine to provide quality control and improving yields.

      1. As instructed: ABSOLUTELY NOTHING! HUH!

        Well, i find them useful to use better way cheaper filament, or even extrude it at home from pellets or scrap parts. Homemade filament costs around 10-15€/kg, commercial from amazon 20-25€/kg. Considering filament the biggest expense after human labor, an upgrade that lowers the variable cost of printing and also improve print quality is a really good deal!

  4. the multiplier is to account for measurement errors. newer firmware and slicers allow for volumetric extrusion. the slicer requests volume, and the firmware tries to meet that volume by using the value you entered for the diameter. this means that the firmware allows for hardware to change that diameter, instead of using some sort of extrusion multiplier.

  5. How about pre-sizing the filament? Run it through two pairs of rollers 90 degrees to each other, with precision cut grooves to force it into the exact diameter. It would only work for plastics that can be cold worked and which will retain the new dimensions. Like drawing metal wire, squeezing the filament down to size would slightly increase its length.

    1. That sounds more like bad sushi.

      Biggest issue with most of the mechanical methods (which match to what you suggested) is the absolutely small space we’re trying to measure. Analog pots would use less than 0.1% of their range to detect any bad variation unless heavily mechanically advantaged, and that can push us well near the noise floor.

  6. I hope this can be made to work and be useful, difficult as it sounds.

    I gave in after 10 years of watching inexpensive 3d printers barely mature… And.. I was right. they basically suck.

  7. I’ve read a lot of how to monitor the pressure, but none is easy to implement.
    Since the chanber pressure increases as a result of larger diameter, the stepper has to work harder to push it out therfore consuming more current monitor that instead of preasure.
    More current, reduce the stepper speed, decrease in current, increase stepper speed.

  8. Isn’t this a bit useless? When you’re 3D printing, the bare extrusion from the nozzle is way thicker than the thickness of each layer you put down, since it’s being pushed down by the printer. If you want smooth prints you’d be better off dynamically adjusting the z-position of your extruder head (with a piezo or mini-stepper) than trying to make the cross-section of your extrusion consistent.

  9. Appreciating the time and energy you put into your site
    and in depth inforrmation you present. It’s awesome to come across a bloog every once inn a while that isn’t the same
    oldd rehashed information. Wonderful read! I’ve saved your site and I’m including your RSS feeds too my Google account.

    Here is our Website:

  10. Does anyone know what mechanism is used in the now inexpensive digital calipers? Mine includes a zeroing function so wear and tear can be accounted for. Two sensors could theoretically handle the out of round filament. This could also be handled with a second optical sensor or some clever optical way to use multiple light sources and focus the image/shadow on a single sensor. Just my 2 cents :-)

  11. I bet you could do this the same way ATM’s measure the thickness of notes to confirm that they aren’t dispensing the wrong number of notes. Its a very high precision needle bearing pressed against a roller gently with a strain gauge. As the filament travels through, variations in diameter would affect a change in the strain gauge.

  12. Sure you can work with digital calipers. I do so and read the values via RS232 into my laptop. Usually they give me a good idea of where I am (I am producing my own ABS filament), but once in a while they suffer from insufficient mechanical precision. But hey, in general they do a good job. You can see them here and on some other fotos/videos on the page:

  13. the main problem with torque oder current sensing on extruder motor is the granules which will become pinched between the auger and the barrel. This generates high spikes of torque to shear them down into 2 parts.

    there will be a lot of interpreting and filtering the values to get the errors away before the values may be used to feed it back to the control loop

  14. We are developing an optical imaging tool to provide real-time filament diameter measurement for accuracy up to a few microns (~0.005mm). Such data could be used for feedback loop control of the extrusion machine to provide quality control and improving yields. It is non-contact and best for volume filament production.

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.