Lego Sorter — Mechanical Design
In this blog, I will illustrate the overall design that I followed for the Lego Sorter, hopefully saving you tens of hours if you pursue a similar endeavor.
It was clear from the start, that having an automated way of capturing hundreds or even thousands of images would be a central capability to successfully implement a Neural Network.
I had no prior experience with the “Internet of Things”, but after taking some advice and doing some research, I decided to base the automated sorter on a Raspberry Pi augmented with boards to handle Motors and Sensors.
My objective was to build the “shortest path” that would enable me to hit the software stage, where I would focus on the Artificial Intelligence.
Tip: During the course of this project, I realized that the Raspberry Pi is very flexible but does have some limitations as a micro-controller, even when using Hats (things like bus speeds become a limitation, etc.). In retrospective, I would have used Arduino, specifically to control the motors.
The Overall Layout of the Lego Sorter
First Iteration
This was my first design, and it had some important limitations:
- The feeder would drop multiple blocks aligned in parallel to the conveyor drop, which defeated any separation attempt.
- The conveyor was too narrow, which made some pieces fall off and prevent the addition of guiding walls to regulate speed.
Final Design
Before you start, get yourself a 3D printer
I don’t believe achieving this would have been possible without having access to a reliable 3D Printer. I used a Prusa Mk2 printer and it enable me to very quickly design and build all the parts that I needed on demand.
I’ve been asked to share the 3d printed parts. I took a very iterative approach to building the sorter, but you can access some of the parts here: https://www.thingiverse.com/thing:3377239
The Feeder Mechanism
I did some research across documented approaches to sorting a bulk set of Legos, and found two great references:
akiyuki: Lego Mindstorm Sorter
I was already inspired by akijuki’s design, planning on building two conveyor belts, so I decided to avoid having to build a third conveyor, so I took the approach from akiyuki: using a mechanical pusher and incline to feed the Legos.
The feeder can roughly hold 100–150 pieces on average, and it’s operated by a continuously rotating servo, using an elliptical servo adapter to drive the pusher up and down.
The Conveyor Belt System
The conveyor belt system is the centerpiece of the separation activities, and again, I did use a lot of inspiration from akiyuki’s Lego Mindstorm Sorter.
The fundamental design relies on speed differentials enable the Lego blocks to separate individual (in preparation for image capture).
There is a half and inch drop between conveyors, which are moving at different speeds. I quickly found that this was not enough to reliable separate the pieces, and had to do some more research.
I found some great industrial application of conveyor based sorting and separation and decided to implement guiding was to further drive speed differential along the route to the image capture. You can see here where I took the inspiration:
Infrared Beam Sensor
I mulled over a two options to identify when the block was in place. I could continuously capture Video and through Image recognition detect the piece, or I could place a IR Beam Sensor to physically identify when the block was in range of the camera.
At this stage, I still hadn’t dwelved into OpenCV, so I decided for the IR Beam Sensor option and placed three IR Beam sensors across the machine: one at the location of the image capture, and one at the end of each conveyor.
From a software perspective, I only used one of the sensors: the signal of the image capture sensors.
LED Backlight
Part of the Image Capture modules rely on OpenCV and image recognition. I found that when White blocks would come into range, I couldn’t reliably detect their contours or edges.
Placing a LED Backlight provided much better contrast to the image capture and increased the detection accuracy very close to 100%.
Sorting Mechanism
I initially chose a three way separator using two servo motors which proved to not be a good approach. It was a bit complex to setup and it proved to be extremely limiting in terms of the ability to test a neural network across many classes.
I did some research and found that the easiest way to achieve multi-bin sorting was through rotation, which also simplified the design by relying on a single servo.
My current build has 12 bins and could probably support up to 14 or 15 in total.
From a software perspective, I use 1 bin to sort pieces that did not achieve mechanical separation, which reduces the effective sorting capacity down to 11 bins.
5 Parts to This Blog
This part of a 5 Blog Series to cover the mechanical and software design for the Lego Sorter, as well as sharing the training set and some evaluation sets:
1. Lego Sorter using TensorFlow on Raspberry
2. Mechanical Separation (Design, Motors and Sensors)
3. Overview of the Software stack
4. Using Inception V3 to Identify LEGO vs. Generic Bricks
5. Try It Yourself: 2 Big Data Sets so you can Replicate this Project