Ever wonder how much filament did you actually use for a project? Have an old mechanical ball mouse laying around waiting for recycling? Let's convert it into a filament counter with simple Arduino and 3D printed parts. The mechanical PS/2 mouse contains fairly high-resolution encoder wheels and a simple serial interface as well as electronics to process the quadrature input signals from the encoder wheels. There are Arduino libraries written to talk to the mouse and get the direction of the distance of rotation of the encoder wheels. By connecting the encoder wheel to a filament roller, we can track the actual usage of the filament for each project by using the Arduino and display the results in millimeter on a LCD display. Since the mouse outputs the relative position to its original position in both directions, the counter is able to accurately measure and actual usage of the filament even when the filament direction is reversed occasionally due to retraction.
Step 1: What you need
Here is a list of all the materials you need. The Dell M-SAW34 PS/2 ball mouse is made by Logitech which can be easily found online cheaply. Additionally you'll need some wires and screws, as well as access to a 3D printer (I assume you already do if you're interested in making a filament counter), and a soldering iron. Also I recommend to buy a bottle of rosin based liquid soldering flux which is also used as a coating to the filament idler wheel to increase friction.
- 1×PS/2 Mouse Dell Logitech 2-Button PS/2 Ball Mouse M-SAW34
- 1×Serial LCD 1602 16x2 Module With IIC/I2C Adapter Blue or green
- 1×12x12x7.3mm Momentary Tactile Push Button Switch with key cap
- 1×625zz 5x16x5 Shielded Miniature Ball Bearing
- Dupont jumper wires or 16-18 AWG stranded wires, several
Step 2: Print the sensor body and the box
I printed all the parts use PLA with 25% infill. The STL files are attached, and are also available here:
Step 3: Assembly of the sensor unit
Take the mouse apart, what we need is the circuit board and one of the encoder wheels. The mouse has two encoder wheels for X and Y axis respectively, we only use one of the wheel on the X-axis.
- Cut the encoder to half near the small rims in the middle.
- Prepare the idler wheel. Use a 2mm drill to clear out the mounting hole. Coat the idler wheel with the liquid lux. Once dry, the rosin residual will help to increase the surface friction.
- Insert the printed idler wheel into the 625zz bearing, apply small amount of the Teflon spray lubricant then insert the bearing into the printed sensor body. Use epoxy if needed, make sure the bearing and the idler wheel assembly is perpendicular to the sensor body.
- Insert the mouse encoder wheel to the other end of the idler wheel, again make sure the encoder wheel is perpendicular with minimum wobbling.
- Mount the mouse printed circuit board, use a tweezer to adjust the location of the IR emitter and receiver so the encoder wheel is in the middle and cover at leat 1/2 of the receiver.
Step 4: Electronics
Wiring the rest of the circuit according to the wiring schematic. You can use either Dupont jumper wires or solder the wires directly to the pin headers.
Step 5: Programming
- Add the ps2 library to your Arduino IDE
- Connect your Arduino to the computer and install the sketch.
Step 6: How to use
The display has two rows. "U" is the current filament usage in millimeters. "T" is the total filament usage from the beginning. There is one RESET button. A short click will reset the "U" counter to zero, which is useful for each new project. A double click will reset the "T" to zero which s useful when replace the filament rolls. Additionally, when the unit powered up, the user is able to choose the direction of the filament movement, i.e. forward or backward depending on the mounting position of the sensor unit by pressing the Reset button.