Colour sensing (4)

A project log for Colour sorting machine for Lego

Automatically sort random Lego pieces by colour!

robgRobG 01/17/2024 at 14:350 Comments

With a light sensor positioned to detect the light from the illuminating LED it can now sense when a brick arrives and leaves. If two bricks come down together (of different colours) we need to make sure the diverter isn't moving whilst one is in transit else it will jam. So we need to implement a 'hold off' period where new bricks don't trigger a change of position:

This can be implemented using a state machine, with rising- and falling-edge interrupts driving some of the changes of state:

This is now coded up and seems to work ok, just need to adjust the value of T (about 100ms) to get the best compromise between fast changing of output bins and no jamming. (Note that the sensor output is inverted: high level means brick present, low = no brick.)

Also, I've added a thin piece of black card between the light source and colour sensing chip, plus BLK3.0 black paint on all the surfaces, to try and block any direct illumination which I'm sure will help:

[Update: this is now working very nicely, with pretty much zero instances of jamming the mechanism. Even the very smallest Lego pieces (4-5mm) get correctly detected. The remaining challenge is to ensure they are fed in one-at-a-time with ~100msec or more gaps between them.]