This topic is a linked part of a larger work: “Open source optical coffee sorter project”.
Contains documentation for version 1 of the Open Source Coffee Sorter machine, from a user point of view (parts to get, assembly, usage etc.). All design decisions and the development process are documented in the project topic instead.
Content
1. Overview
We have arrived at a first, rough machine design, to be discussed / explored / improved. Note that this is still in the design / planning stage: no machine has been built yet, but we’re close to that now as the planning work below is nearly finished.
3D view of the structural parts (in the current state of the design work):
And a quick sketch of the machine parts and a description of their function:
The numbered parts and their function:
-
Feed funnel. Coffee beans “flow” easily, so a simple funnel is enough to feed them in. No vibration is needed if the vertical tube after the funnel has a large enough diameter (50 mm is for sure enough). A grid sieve to keep out large foreign objects (such as branch pieces) is needed to protect the interior of the machine.
-
Slow conveyor. The feed tube ends ca. 10 mm above a first conveyor belt. It is wide but moves slowly, moving 1-2 layers of beans.
-
Guide funnel. Guides the beans to the center of the fast conveyor as they fall off the slow conveyor.
-
Fast conveyor. To separate the beans, they fall off the slow conveyor onto a fast-moving one that is only wide enough for one bean at a time (assume 25 mm so there is enough space for the occasional foreign object, such as branch pieces). By moving faster and catching the falling beans from the slow one, beans will be spread out one after another on this conveyor. For a target of 100 beans per second and an average two-bean distance between beans, the speed of the conveyor would have to be 300 bean lengths per second, so 300 cm for an average bean length of 10 mm. 3 m/s is equivalent to 10.8 km/h. Might be too fast for a simple machine, in which case the capacity would be lower. But if we can achieve 100 beans / second this way, it would be equivalent to a throughput of 1.5 tons per day (see here, section 4.2).
-
Linear solenoids. They move sideways across the fast conveyor and have brushes attached to a lever by which they can move the beans into destination bins. This setup allows for any number of bins, unlike when directing the beans into an upper or lower bin when they fall off the end of the conveyor. In our case, we want three solenoids (of which only one is shown in the sketch). This allows four bins together with the end of the conveyor belt as final destination. Normal usage: (1) bad beans, (2) undecidable beans, (3) low-quality beans, (4) high quality beans.
-
Output funnel. Guides the beans to one of the output bins. Similar to the bean guides after the solenoids, but this time for the end of the conveyor belt.
-
Camera. Captures images of the beans while they are moving on the slow conveyor. An LED flasher will help to keep the images sharp even though the beans are moving with quite some speed.
For illustration, a 3D sketch of the path of the coffee beans through the machine:
Electrical schematics for the coffee sorter by @mmajdeb (components roughly as in the side view drawing above):
2. Usage
Programs planned for the “version 1.0” machine:
-
Standard program. The standard program sorts coffee beans into “bad, good and great” coffee beans. There are multiple versions or configurations, accessibly form a menu and sorted by coffee plant variety, country and growing altitude. It uses a quick, color based decision algorithm (targeting 100 beans / second), which is adequate for “normal commercial coffee” but not as exact as it can be with the coffee sorter’s hardware. This is the only program that will be available in the “version 1.0” machine, but
-
Standard training program. Training the machine with ones own beans will allow the most accurate sorting, but it needs manually sorted beans as input (good and bad ones) and some CPU time. A program on the Raspberry Pi will receive image data and calculate the configuration parameters for the color sorting algorithm.
Programs planned as later additions: The coffee sorter is also able to run other programs for specialized purposes and higher requirements. We can think of at least the following, which will be prepared in the software architecture of the version 1.0 machine, but implemented later:
-
Maximum accuracy sorting. In contrast to the quick standard program that relies on color sorting, this program can also rely on an AI image classifier when unsure, or even exclusively, then using the AI image classifier for every bean. It would achieve a throughput of ≤10 beans per second; while that is much slower than the 100 beans per second of the color sorting algorithm, it is still acceptable as the people using it for this purpose can invest 3000 EUR to run 10 machines in parallel, again achieving 100 beans per second (equiv. 1.5 t/day).
-
Training program for maximum accuracy sorting. This is effectively about training a neural network model. It requires a network connection and a server (on the local network or the Internet) that will receive the image data and calculate the neural network model, then offering it for download. This cannot be done on the Raspberry Pi, as it would simply take too long. Using the server on the Internet will be free of charge, but in exchange the coffee bean images and the resulting model will be open source licensed.
-
Flavor sorting. This is a hypothetical use case: with some cupping experiments, it should be possible to train an AI image classifier to sort beans by flavor profile, using combinations of attributes / hints that are not obvious to the human eye.
-
Size sorting. In larger quantities, sorting by size will be done with sieves, but for small farms, the optical coffee sorter can easily take over that task as well. With its four outputs, it can separate three sizes and a remainder, which is then fed back in to separate out another three sizes and so on.
Serial operation. When running a special program with many different output types (esp. size sorting), one can feed back the remainder into the same machine to separate out additional output types or (faster) feed it right into the input funnel of another, identical machine. The machine dimensions and the funnels will be designed to allow this.
Scaling. The machine has a narrow format (only 5-10 cm wide), because the idea is to operate many machines in parallel if there is a need. All would be fed from the same feed tube, if necessary with a steep slope to cover longer distances. Similarly, the four outputs can be collected by parallel sloped tubes running under the bottom of these machines.
Redundancy. Operating multiple machines in parallel has the advantage of high redundancy, as the machines operate independently. So when one machine breaks, one can simply keep operating the others without issue, while taking out and repairing the broken one and putting it back in. Of course the output will be lower while not all machines are active, but the idea with redundancy is that the highest capacity should be more than required. Redundancy is a better way to deal with failure than having a spare machine around: having a spare machine would need investment costs for twice the required processing capacity, while redundancy requires only (say) 120% processing capacity in the case of six mutually redundant machines. In addition, redundancy can deal with multiple failures (“four of six machines broken”), and when spare parts are not readily available, allows to combine broken machines with complementary defects into working ones.
3. Bill of Materials
-
funnel assembly
- CNC cut parts, plywood or plastic
-
casing
We want the casing (without the funnel) to fit inside a typical 600×400 mm Euro container made from plastic. It will allow for simple and cheap transport on pallets, protect the machine during any transport and protect it during storage against rain, dust, humidity etc… Due to the standardized internal dimensions of Euro containers, the machine’s side face should not exceed 540×360 mm in size. The width of the machine is rather unrestricted as Euro containers come in various heights. However, 10 cm width seems a reasonably achievable limit.- CNC cut parts, plywood or plastic
- nuts and bolts, stainless steel
-
upper conveyor assembly
- 1 belt, 25 - 75 mm wide
- 2 axles, with bearings
- 1 stepper motor, 5 V DC
We use a stepper motor instead of a simple DC motor to create more opportunities to improve the machine using better software. Among stepper motors, a 5 V motor seems best: they are readily available and can work with a cheap motor driver board without current limiting, such as the Adafruit 2348 board we have selected. And using 5 V products has the advantage that it can be the standard voltage of the machine, introduced by the requirement of the Raspberry Pi (“4.75 - 5.25 V”). So we will only need one 5 V power supply for the whole machine, reducing costs.
Examples of suitable motors: Minebea 17PM-K031-02V (here and here), Nippon Pulse Motor PF35T-48 (here), generic 5 V / 416 mA stepper (here). - CNC cut parts, plywood or plastic
-
lower conveyor assembly
- 1 belt, 25 mm wide
- 2 axles, with bearings
- 1 stepper motor, 5 V DC
A 5 V stepper motor seems best, see above. - CNC cut parts, plywood or plastic
-
gates assembly
- 3 linear solenoids, 5 V DC
Linear solenoids are a common type of electromagnetic actuator (introduction). Among them, 5 V solenoids are quite common and cheap, and suitable for the light task here of “just moving one coffee bean”. Using 5 V products has the advantage that it can be the standard voltage of the machine, introduced by the requirement of the Raspberry Pi (“4.75 - 5.25 V”). So we will only need one 5 V power supply for the whole machine, reducing costs. Suitable example products: 1, 2, 3, 4. - CNC cut parts, plywood or plastic
- 3 linear solenoids, 5 V DC
-
camera assembly
- 1 camera, UVC interface, not yet chosen, a camera for testing is available by using an Android phone and software that provides UVC access to its camera
- 1 LED flasher, white LEDs, ca. 6000 K color temperature (“cool white”), for camera imaging of the coffee beans in motion. Current proposal is the Adafruit 2433 DotStar LED Strip, or the same LEDs bought individually and mounted on suitable breakout boards. In both cases, the LEDs are addressable, so can be individually dimmed and switched on / off. Communication with these DotStar LEDs uses 2-wire SPI, so does not create realtime requirements for the microprocessor. As controlling these LEDs seems simple, it seems a good capability of the machine. Because with the same technique, other additional LEDs could be added and controlled as well lateron, extending the lighting setup to multi-spectral and IR imaging.
-
electronics
- 1 AC adapter, 5 V DC, ≥8 A, Adafruit 658 (25 USD)
Only one AC adapter is needed, as the whole machine will run on 5 V DC (Raspberry Pi, stepper motors, solenoid, camera. This reduces cost, complexity and points of failure. We currently have a “Rydges SpeedPower 100-240 V to 5 V 2.5 A” available that is sufficient for the Raspberry Pi, but will need a more powerful one for the whole machine: about 2.5 A for the Raspberry Pi incl. camera, 1 A per stepper motor, 1 A per solenoid. This power is normally never needed all at the same time, but over-dimensioning this does not hurt, as it makes the AC adaptor last longer. - 1 Raspbery Pi 3, available
- 2 motor driver boards, I2C interface, Adafruit 2348 “DC & Stepper Motor HAT for Raspberry Pi”, also known as “Adafruit Motor HAT” and “Adafruit DC and Stepper Motor HAT” (see). Available.
These boards come with: product info page, support page, manual, open source PCB schematics, Python library (only depending on a GPIO library), demo program in C#. There seems to be no C library, but Adafruit has a very similar board for Arduino (“Adafruit Motor Shield v2”), which comes with a C++ library.
The Adafruit 2348 motor HAT has no integrated current limiting, so it cannot be used with some types of stepper motors that require this. (Proof: The manual (p. 6) mentions that the board uses the TB6612 MOSFET driver. And in another document, Adafruit mentions that this chip has no current limiting.)
We intend to use these boards both for controlling the motors and the linear solenoids, instead of a relay board for the latter. This should be possible, as Adafruit mentions for a board using the same TB6612 MOSFET driver that it can “fire four solenoids, spin two DC motors or step one … stepper with 1.2A per channel”. After all, PWM output with 100% duty cycle is the same output as a relay would provide. Note that circuits with solenoids have to be protected against inductive kickbacks, but the TB6612 already includes built-in kick-back diodes (see here, p. 4) so no special protection has to be added.
One four-channel board is only enough for the two stepper motors, so we need two; the second would be able to fire up to eight solenoids (somehow). The advantage of two boards is redundancy (between machines) and fewer spare parts to organize. Also this way, there are several unused output channels for future uses or user-made changes. In addition, we get a MOSFET based design instead of relays, which should increase reliability by having fewer mechanical parts.
- 1 AC adapter, 5 V DC, ≥8 A, Adafruit 658 (25 USD)
4. Downloads
All data associated with the project is available on Github:
There is no software to control the machine yet, but a few useful bits and pieces:
- coffee beans training images
prepare-beans.py
, a script to split an image with 30-40 randomly aligned coffee beans into single-bean images, allowing you to easily create your own training dataset
5. Assembly
[TODO]