If you frequently use a 3D printer for your projects then you may experience issues calculating the material weight and length usage. If so, then you might be interested in this project using Arduino.
My goal with this project was to be able to dynamically know the filament status during the 3D printer operation. I developed this project by mixing design, 3D printing, electronics, software, and of course, an Arduino. I used an Arduino UNO rev 3, but it is not difficult to adapt the project to a different model, or an Arduino-compatible board.
How to Monitor the Filament Usage?
The answer appears relatively easy: by calculating the continuous weight variation. Following the weight approach, it will also be easy to build the monitoring platform; it will be sufficient to use a weight sensor. Unfortunately, there are a series of collateral issues that make this solution more complex. Most 3D printers depend on the extruder pulling the filament. This creates false readings on the weight sensor.
To solve this problem I followed the opposite approach, i.e. the problem should become the solution.
Whenever the extruder pulls the filament, it produces a false value while reading the weight change. Though, this change is significantly different when compared to the variations occurring under normal conditions, i.e. when there is no extruder activity. This difference in weight change under different circumstances was key in helping me find a correct solution and to be able to code an efficient and reliable algorithm.
This algorithm has three key moments to calculate the weight:
- When the extruder is not pulling on the filament there is simple sensor noise variation. This can be ignored.
- During the initial pull from the extruder during start of extrusion (which is a sort moment in time lasting less than a second), the weight sensor detects an approximate change of 50 gm or more depending on the force of the extruder. This is our first trigger.
- When the sensor detects a considerable weight change (for example, 20-30 gm), we detect the end of activity, or in other words, the extruder has stopped feeding. This is is the second trigger. At this moment we can not take a new weight measurement and calculate the exact amount of material consumed with high accuracy (less than a gram).
The conversions between weight and length and vice-versa is the last easy job. To do this, I sought references online to find the specific weight of each of the different 3D printing materials (PLA, ABS, etc.).
The Project Explained
The Base and Support Design
The base design focuses on two issues, weight measurement, and easy rotation of the filament roll.
To do this we need a scale with a special support where the filament spool can rotate freely and without friction.
First, I started by modifying the design of a previous project: the 3D printer filament dispenser.
As shown in the images the new design has the dispenser sitting on a bottom base with the weight sensor in the middle acting as the support. The sensor can support a weight up to 5 kg. It is relatively flexible, though not weak with 1-2 Kgs of printing filament supported on it.
The design modification consisted of replicating the original base of the dispenser while adding holes to fix the sensor to a second bottom plane.
Electronics and Wiring
It is possible to connect the Arduino to a PC or mobile device while monitoring the 3D printer filament usage via a USB to serial connection, and is useful for several reasons, including the ability to create log files of our jobs. Despite this utility, it may not always be efficient. In some cases it is better to have less information, but able to update that information in real time. To facilitate this I have included an alphanumeric LCD display. I used the LCD Alpha [http://www.electroschematics.com/11155/alphanumeric-lcd-shift-register-arduino-part-1/]. For those that are interested, I wrote about this project on ElectroSchemactics a while back. Feel free to go back and take a look.
Note: the shift lcd Arduino library distributed on the net is no longer working with the most recent Arduino IDE versione (starting from 1.6). Replace the library with the SHIFLcd library attached to this article for the LCD Alpha to work correctly
The weight sensor (max 5 kgs) is sold together with a signal amplifier so it can be directly connected to the Arduino pins following the instructions of the HX711 Arduino library. The other three pins should be reserved for the LCD display connected via SPI through a serial to parallel shift register.
Due to the low power required by the sensor amplifier, a single Arduino board can connect more monitoring platforms at the same time, depending on the available pins on the board.
The sensor amplifier is a small breakout board based on the HX711 IC, an analog to digital converter specialized for high precision weight sensors used in many industrial applications (see the HX711 datasheet). An advantage of using this component is the availability of a Arduino library – See below for source –
I included a couple of buttons to set and reset the parameters when needed (e.g. after a roll change) while the monitor is running. A led flashes every reading signaling the regular monitoring activity.
Software
As we have mentioned above the most challenging part of this project is the math. The first series of assumptions can be found in filament.h including the file where the environment constraints are defined. In the current version I have setup only the PLA and ABS materials, but it is fine to include more parameters to profile other kind of 3D printer filaments. For every material I have set – hard coded in the sources – the weight and size definitions that can be easily found on the net.
* Filament material parameters * * PLA * Density: 1.25 g/cm^3 * Volume: 0.80 cm^3/g or 800 cm^3/kg * 1.75 mm filament length for 1 kg spool: ~ 330 meters * 3.00 mm filament length for 1 kg spool: ~ 110 meters * * ABS * Density: 1.04 g/cm^3 * Volume: 0.96 cm^3/g or 960 cm^3/kg * 1.75 mm filament length for 1 kg spool: ~ 400 meters * 3.00 mm filament length for 1 kg spool: ~ 130 meters As the different measuring conditions are triggered by the weight-per-time we read the algorithm is a state machine where the states are defined as follows: #define SYS_READY "Ready" // System ready #define SYS_PRINTING "Print" // Filament in use #define SYS_LOAD "Load" // Roll loaded #define SYS_STARTED "Started" // Application started // Status codes #define STAT_NONE 0 #define STAT_READY 1 #define STAT_PRINTING 2 #define STAT_LOAD 3
There are two kind of events changing the current machine state: the manual push buttons and the weight reading. The constant value is the frequency the sensor is read. This made it easy to design the main loop that assumes different behavior depending on the current state:
// Check the current status of the system switch(statID) { case STAT_READY: // Set the initial weight to calculate the consumed material during a session initialWeight = lastRead; prevRead = lastRead; showLoad(); break; case STAT_LOAD: showStat(); break; case STAT_PRINTING: // Avoid fluctuations due the extruder tension if( (lastRead-prevRead) >= MIN_EXTRUDER_TENSION) { // Restore the previous reading lastRead = prevRead; } showStat(); break; default: showInfo(); break; } // switch
This content was originally published here.