What better way to test a colour sensor then to create a brick sorting robot! After getting my hands on a HiTechnic colour sensor, I first took a stab at creating a robot that could navigate a room and detect colour. There was only one problem, it could not really do what I was hoping for. I was nieve in thinking that I could build this robot and it could detect colours from a distance. After reading the fine print on the provided documentation, I quickly realized that the colour sensor is only capable of reading colours at very close range (~ 1 cm). My bad. Of course, you could still build a robot that uses the ultrasonic or other sensor to get it close to objects, then read the colour… but that’s for another time.

BrickSorter uses this colour sensor to detect the colour of bricks and sort them into a variety of cups. The program is quite simple, gravity and studless beams allow for each brick to slide down the track on its own. when a brick is next, the colour sensor takes a reading (more on this later), the sort motor turns the sort rails to the correct cup, the sort rail motor changes its angle depending if the cup is close or far and finally the kicker motor kicks the brick in motion.

After a lot of fooling around with the cup placement (which seemed to be the hardest part of this project!), I managed to get the sorting pretty much bang on. Of course, the video shows some goofs, but that is mostly due to the small sized cups (its all I had!)… Anyway, I found the sensor to be accurate most of the time, but ambient light still influenced the readings at times and caused for the odd random sort error of a brick. I had to shoot the video about 10 times to get cup placement and sorting goofs worked out.

BrickSorter in action…

The HiTechnic colour sensor – up close and personal. The 2 lenses (side) are used to detect the colour. The specifics can be found at HiTechnic’s site, but the general idea is that in one, there are 3 coloured LED’s emitting RGB light, the light bounces off the brick surface, and the range of colours reflected back to the reading portion allow it to determine the colour.

A close-up view of the sensor section. The sensor is mounted very close to the bricks. This reduces the amount of ambient light that can affect the colour reading. Even at this range, tests done in daylight (coming in from the back window) and in the evening (room lights on) yielded some flaws in the readings which would cause random misses in sorting resulting in some colours not finding themselves in the right cup.

The code behind the sorting is relatively simple. Timing is more important as the robot has to follow the following steps:
Take reading, move sorter, change sorter angle, then kick the brick out. Colour readings are taken by collecting 20 samples per brick with 20ms delays between. Then the values are averaged. The reasoning is to reduce the possibility of erroneous readings from ambient light. So, if the readings for blue are 4,4,4,8,4,4,5,4,4,4,4,3,4,4,4,4,4,3,5,4, they will average out to 4 (rounded down) – which is the value we want.

 

The brick sorter shown here is not the most current. In the design here, there was only 1 row of cups with a limit of ~5 colours. In the new design, I re-created this sorter unit and its base is made of a NXT servo motor that controls the angle of its lower portion. When sorting, the unit can turn to each cup, while at the same time the motor within it can change the angle of the slope to have the brick slide to the cup directly below, or one further away (see the video for a view of this).

 

This shows a view of the kicker motor unit. Its quite simple and uses a #10 axle to push each brick out of the hopper. This is another demonstration of the benefit of the servo motor encoders. Through code, I simple tell it to rotate a full 360 degrees to push the brick out. Simple.

 

Here is another view of the kicker motor unit. You can also see the sorter turntable and gearing below in the distance. Also shown is the gray axle mounted in the rubber TECHNIC axle joiner. These things are great as they allow you to twist the rules of TECHNIC building a little by mounting things in different ways. In this case, I needed something to fine tune the point at which a brick would “fall” off the hopper when being pushed out. This did the trick perfectly. If you are looking to build this robot, the original design was built only with the NXT set parts and the HiTechnic colour sensor. In the newer version, some additional pieces were used to make the sort motor angle unit (the motor was still from the original set). So, with the NXT set, a few additional pieces and a HiTechnic colour sensor, you can make your own as well!

 

The following shoes the sorter unit changing angles to sort to near or far bins. Using the built-in motor encoder, the angle changes approx 30 degrees up/down.

Due to popular demand, I have included some more pictures of BrickSorter in lieu of building instructions. Hopefully, these will provide more detail in the event that you want to build it for yourself. There is also a zip file containing high resolution images for you to download to the right.

Download RobotC Source

Download RBT

Rate This Post: 1 Star2 Stars3 Stars4 Stars5 Stars (5 votes, average: 5.00 out of 5)

Loading...