Ball sorter

The first robot I designed and built myself is a ball sorter. The design process was very organic, trying and building parts of the machine, seeing if they would work. The first elements I came up with were the rotator and the container, which I will describe later on. The hardest part was to design something that would allow only one ball at a time to pass. A lot of things I came up with for this didn't work consistently, got stuck regularly or would throw the balls all over my floor. I finally ended up with the loader mechanism, which also will be described further on in this article. The resulting robot can be seen in the image on the right.

On an abstract level the ball sorter consists of four elements. First there is the container, which holds the balls that are going to be sorted. The task of the second element, the loader mechanism is to identify the colour of the ball, and to let only one ball at a time through to the next stage. This third stage is a rotating element (the rotator) whose purpose is to make sure that the ball ends up in the correct bin, the final element of the machine. There are four bins, one for each colour.

Design elements

The container is located at the top of the machine. It consists of four identical sloped segments. At the bottom in the shaft there is a small hole, which allows only one ball at a time to pass through. The hole is made smaller using two thin liftarms and an axle to reduce the chance that balls get stuck or that they block each other when being pushed out by the loader mechanism. Balls still get stuck when they block each other from falling down into the shaft and loader. Pushing a ball down manually solves this situation. You can see this happening in the videos below.

Located at the bottom of the container is the loader mechanism with the colour sensor attached to it. In the picture on the left I have removed the container so the mechanism can be seen clearly. The loader has two seperate parts. The top part, which also houses the colour sensor, is attached to a motor and can move forward and backwards sending a single ball to the next stage in the process. The lower part remains stationary, allowing a ball to rest in the space between the colour sensor and part of the top element that pushes the ball.

After the sensor has identified the colour of the ball, the second motor starts turning the rotator element to the correct bin. This rotator is a turntable with a slide attached to it. After the slide is rotated to the correct position, the loader is activated and lets a single ball fall down the slide, into the correct bin. The rotator has a starting position, so we know the orientation of the when the program is started. The shut down procedure for the program rotates the rotator back to this starting position before exiting.

Programming and modeling

Writing the code for the ball sorter was pretty straight forward. There are two tasks in the program. The first task watches the colour sensor until it sees a ball. When it sees one, the rotator is rotated to the correct position and the loader is activated, sending the ball into the correct bin. When no ball is seen for a few seconds, it is assumed that the balls are stuck and the loader is activated to try and shake the balls loose. The second task waits for the centre button to be pressed on the NXT, and when that happens the program is shut down after rotating the rotator back to it's starting position.

I recreated the ball sorter as a model in Lego Digital Designer. Pictures of the model can be viewed below. A few alterations where made to the model, I colored all the bins in the model so it's more clear where the balls are supposed to go. Also the axle with the worm gears, which drives the rotator is longer in the built version, for some reason I wasn't allowed to put the larger axle in place. Also some parts that weren't in LDD were substituted at various places.

Additional media

Files

LDD Design (.LXF) LDD design (.LXF)
Download the Lego Digital Designer containing the (slightly modified) model of the ball sorter.
Source code (.NXC) Source code (.NXC)
Download the source code for the ball sorter project. The code is written in NXC.

Comments