Software apps and online services
Hand tools and fabrication machines
The FilamentBot is a Amazon Dash Replenishment Service (DRS) enabled smart filament counter that will contentiously track the filament usage by measuring the actual length of the filament that has been dispensed on any 3D printer, and automatically re-order the filament through Amazon DRS service when the filament is running low. It also features a Amazon Dash button that allows the user to manually order filament at any time.
The FilamentBot consists of a Filament Sensor Unit and a Controller. The Filament Sensor is designed to be clipped onto the filament line between the spool and the extruder. The Controller is Wi-Fi enabled and features a large back-lit LCD screen and can be placed nearby the the 3D printer control panel for easy access.
I own several 3D printers myself and go through many rolls of filament every month. It is difficult to track how much filament have been used on each printer, especially those have close filament compartment. I wish to have a device that can automatically track the filament usage physically.
There are in general two ways to track the physical usage of the filament: by weight, or by length. The weight of filament roll fluctuates a lot due to the pulling force of the extruder especially near the end of the roll, so the measurement by weight is not accurate (If you're interested, I have made a filament scale as well and can be found here). It is more accurate to track the extrusion length but there's lack of low-cost solution. People have tried different ideas such as Arduino rotary encoders or optical sensors but their use is limited, mainly due to the complex electronics required to make them work. Then I realized that the old PS/2 mechanic mouse is a perfect candidate to be hacked into a practical filament sensor with the help of Arduino due to its simplicity. The mechanic mouse seems a bit dated but it has all the electronic circuit and requires minimum hardware support from the host.
I published the original filament counter project last year, and one of the visitor commented:
Great design, we need one of these for the printer at the library :)
We have a number of 'maker space' at local public library and schools. Imaging how much work it would be if you have to keep eyes on the printer farm, track the filament usage and make sure that the filament is always in stock. With the help of the FilamentBot, all these tasks can be handled automatically.
A mouse has two axes: `X` and `Y`. The mechanical mouse utilizes encoder wheels to track the movement. When the wheel rotates, the infra-red (IR) light emitted by an IR Light Emitting Diode (LED) is interrupted repeatedly, at a rate proportional to the rate of wheel rotation. A pair of detectors is used on another side the wheel which generate quadrature encoding, so that mouse knows the direction of rotation.
The PS/2 mouse can communicate with a host device using the PS/2 protocol. It can be connected to a host device using the 6 pin mini DIN connector. The PS/2 connector has one pin for Data and another pin for Clock and using only these two pins the mouse communicate with the host device with PS/2 protocol at TTL voltage. The mouse also also takes care of the modulation of the IR signal to prevent the interference from ambient light.
The mouse will continuously give output which can be decoded to get the movement in the X-Y plane and also the status of the buttons on the mouse. The Arduino then can decode the transmission into the actual movement information, essentially the direction and the distance of movement. This is great for tracking the usage of filament since the filament may move in both directions during extrusion and retraction.
In this project, only the parts for X axis is utilized, but the filamentbot can be easily expended to have second channel (thinking of a dual-extruder printer) by moving the Y axis IR transmitter and sensor as well as the encoder wheel to a secondary filament sensor. The Arduino sketch needs to be modified to monitor the X and Y movement separately in this case.
The filament sensor unit is 3D printed. The detailed assembly instructions can be found at my project page for the original digital filament counter.
- 100% Arduino IDE compatible.
- Utilizes the Atmel ATWINC1500 WiFi Module(TLS capable w/ onboard SHA-256 encryption).
- Small form factor
However, a logic level converter is needed to match the mouse interface voltage at TTL level. Below is the part list and how it looks on the breadboard.
The pictures below show the detailed parts, circuit board assembly and finished product of the FilamentBot including the Filament Sensor unit and the Control unit as well as the screenshots to demonstrate firmware functions.
In order to start with the Amazon Dash Replenishment Service for the FilamentBot, follow the following steps:
- Sign up for an Amazon Developer account: aws.amazon.com
- Create a new Amazon LWA Security Profile: developer.amazon.com
In this step, I created the Security Profile for the FialmentBot and provide the allowed return URL which is required for the Authorization Code grant. Copy the account information such as Client ID, Client Secret for later use. You may also upload a Logo image here so the customer will recognize your service when register to your device.
Create a SNS topic and subscribe to the topic. The Amazon Dash Replenishment Service will notify you the changes to the subscription status etc. by email or SMS etc..
- Create a new Device at the Dash Replenishment Console
Finally it is time to create my own DRS device, the FilamentBot. This can be done at the Amazon Dash Replenishment Console. For each device you can create multiple 'Slot' which like the pre-loaded shopping carts so the end user can easily select the items they would like to order by the FilamentBot. I created a Slot named "Regular PLA" and loaded with my favorite Hatchbox filaments. Copy the Device ID and Slot ID created in this step.
These steps are rather straight forward and I'm going to skip the detailed descriptions here for now.
With the above AWS information obtained, I then proceeded with setting up the FilamentBot Product Registration Page at http://filamentbot.artsuzhou.com. The website is hosted on Amazon AWS Simple Storage Service (S3) using the Amazon AWS Route 53 DNS management service. The example html code for the website can be found on the project Github repository.
Once the product registration is successful, a new Authorization Code will be displayed which is required in the next steps so the FilamentBot can place the order on your behalf.
This project is made possible thanks for the Arduino AmazonDRS library written by Brian Carbonette. Brian also created detailed instructions on the topic.
Once you have accomplished the LWA Authorization Code grant process as explained above, follow actions have to be taken in order to make the FilamentBot work.
- Exchanged the auth_code for the refresh token by running the authCodeGrant example sketch.
- Updated the AmazonTokens.h header file in your AmazonDRS library 'src' directory with values for...client id, client secret, refresh token, and redirect uri.
- Upload the FilamentBot sketch with your WiFi credential etc. to the FilamentBot using Arduino IDE. Set the calibration factor if needed.
- Also set the target threshold for initializing the DRS request. Typical length for 1 kg 1.75 mm PLA filament spool is ~ 330 meters. I set the threshold at 80%, i.e. 264000 millimeters.
Finally the FilamentBot is ready to go! There are two ways in which the FilamentBot can help you initiate a purchase of the filament:
- By pressing the Amazon Dash button on the FilamentBot.
- Let the FilamentBot automatically initiate the DRS request on your behalf when the filament extruded over a preset amount!
And then confirmation emails arrived....Success!