This Old Mouse Keeps Track of Filament Usage

Keeping track of your 3D-printer filament use can be both eye-opening and depressing. Knowing exactly how much material goes into a project can help you make build-versus-buy decisions, but it can also prove gut-wrenching when you see how much you just spent on that failed print. Stock filament counters aren’t always very accurate, but you can roll your own filament counter from an old mouse.

[Bin Sun]’s build is based around an old ball-type PS/2 mouse, the kind with the nice optical encoders. Mice of this vintage are getting harder to come by these days, but chances are you’ve got one lying around in a junk bin or can scrounge one up from a thrift store. Stripped down to its guts and held in place by a 3D-printed bracket, the roller that used to sense ball rotation bears on the filament on its way to the extruder. An Arduino keeps track of the pulses and totalizes the amount of filament used; the counter handily subtracts from the totals when the filament is retracted.

Simple, useful, and cheap — the very definition of a hack. And even if you don’t have a 3D-printer to keep track of, harvesting encoders from old mice is a nice trick to file away for a rainy day. Or you might prefer to just build your own encoders for your next project.

35 thoughts on “This Old Mouse Keeps Track of Filament Usage

  1. Now I feel very ashamed for throwing out crates of these things when we upgraded the hospital computers. For *whatever reason* I kept about 30 USB-PS/2 adapters and 100 or so mouse balls though

    1. As long as the mouse balls weren’t from the research wing. Now that would be shameful.
      But, please, do tell me you keep them in a box clearly marked “Mouse Balls” where everyone can see?

  2. Tip – if you can’t get an old ball mouse anymore, every optical mouse with a scroll wheel has one of these encoders as well.

    Otherwise these quadrature encoder sensors are also common in inkjet printers – there they help to replace more expensive stepper motors when used with a regular DC brushed motor. You will probably get much better resolution from those too than from a mouse sensor. A discarded inkjet is very easy to find in a trash.

    And if you don’t find one, you can always buy one:
    https://www.broadcom.com/products/motion-control-encoders/incremental-encoders-code-wheels

    1. Interesting tip. My scroll wheel even has spring tension for keeping a good grip on the filament if you want to interface that wheel directly with the filament. You can still print the fixture to hold the mouse and guide the filament.

    1. The print head already has a wheel that moves in discrete increments along with the filament, and it’s even toothed so it maintains better traction on the filament.

      I just finished build my first Prusa i3 this week, but I’m not clear why a slipping-prone slick mouse roller would be more reliable than counting steps on the motor actually pulling the filament.

      1. I can see items with different colored/propertied filaments that one would want to meter separately. A simple head meter on the cool side, tapped off the filament feed pulse train would work. It might be able to just use the pulse train of the feed, if there is zero slippage? I would expect a positive, zero slippage feed system, so this should all be doable in software

  3. Mouse encoders are damned handy. Been putting them in projects for a while now. If I had a 3D printer I’d likely find a way to convert them to use for volume knobs without having to Rube Goldberg the process.

    Still have yet to incorporate them into my CNC machine. On the project list though.

  4. I understand the part about using old hardware etc etc. But most of us do not have these old mice hanging around, the thing is you can pick up an encoder for fairly cheap and probably reduce the footprint of the whole thing. One more idea is to reset the counter when the printer starts while keeping the total counter on a button. My .02c.. Hell most 3d printers already have an encoder, its called a click wheel.

    1. As much as I’d like to see reduced waste, but it’s often easier to design around a part that’s readily available. For a proof of concept, a test rig is fine, once the idea is tested sound then go on to a more formal device.

    2. The advantage of using the mouse is that the onboard processor actually is very neat, it takes care of the modulation of the IR signal (important for resistance of stray lights) and decoding the wheel movement to directional and distance measurement. It interfaces with Arduino nicely, you can simply query the mouse and it will tell you how the wheel has moved. This greatly simplifies the electronics. The mouse has actually two channels. I have used one so far, but it can be extended to dual extruders.

  5. Great hack, love it, BUT your printer already knows how much filament it’s using. No idea what machine you’re using but there has to be a way to get it from the slicer or printer interface or gcode. I added the below to pronterface:
    1336a1337,1341
    > fillengthPLA=320.0 # metres per kilogram
    > filcost=1500.0 # pence/kg
    > filcostm=filcost/fillengthPLA
    > filcostmm=(filcostm)/1000.0 #pence/mm
    > printcost=filcostmm*pronsole.totalelength(self.f)
    1337a1343
    > print _(“Estimated PLA cost: %d pence (at %0.2f p/m)\n”) % (printcost,filcostm)

    And now when I open a file it echoes something like:
    4021.9051 mm of filament used in this print
    Estimated PLA cost: 18 pence (at 4.69 p/m)

    1. That’s just processing output from a slicer, the printer doesn’t “know” that. Some firmwares do keep track, but default Marlin doesn’t seem to, Smoothieware doesn’t seem to either. Also, even if your machine keeps track, if your machine jams, it’s recording filament that doesn’t actually get used.

      1. To my mind, the filament slipping on that slick mouse roller is a MUCH bigger source of error than the extruder jamming. Also, if the printer jams I know it. If the roller slips, I don’t and end up with an underestimate of how much filament I’ve used.

    2. I second this. I just weighted 6 prints of the same object and they differ by max 0.8% from each other. using cura and the weight predictions are accurate.
      using el very cheapo filament

  6. Do you have a complete datasheet of these sensors and have you characterized its high speed behaviours? If i have an extruder with pretty quick retracts, how do i know the sensor circuit can keep up with that speed of filament without loosing steps? And how do i know the fast acceleration of the filament does not cause the sensor-wheel to slip? I would imagine the wheel at least needs to be rubberized so it has enough grip on the filament.
    On a sidenote, it would be really fun to just use a modern optical mouse sensor to measure the filament moving in front of it. I’d guess with the >5000dpi 1kHz sensors you could get pretty accurate results if the sensor can see enough structure in the filament surface to detect a moving pattern.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s