# Sorting Optical Color Sensor

#### deather

Joined Nov 26, 2020
11
Hi Anyone can give a recommendation to a optical color sensor which can distinguish between peeled and unpeeled Garlic bulbs ?

Plan is to sort between peeled and unpeeled ! I cant afford purchasing a commercial sorter as its in thousands of  too costly for Africa

I prefer it to have the following capabilities.

1. You can teach it to memorize color or a color range for unpeeled
2. Once the Garlic bulbs are moving in a conveyor belt the sensors monitors Peeled vs unpeeled and when it senses unpeeled it will send a signal which i will the use it with some other device like a pneumatic ejector to eject the unpeeled garlic.

Please advise want something very simple as my electrical/electronic knowledge is very minimal as im learning as i keep researching.

Thanx

#### Attachments

• 187.1 KB Views: 12

#### Irving

Joined Jan 30, 2016
1,532
There isn't an easy 'simple' approach to this. Because the bulbs are mixed up you either need to get them separated individually on a chute, in which case a 'simple' colour or radiance sensor could differentiate between a single peeled or unpeeled bulb and route it accordingly, or use a camera and machine vision algorithms (machine learning/AI) to identify the peeled (or unpeeled, whichever is least) to drive some mechanism to extract the unwanted bulbs.

The 'one at a time' in a chute is much easier to implement physically... as long as the bulbs are roughly all the same size... and will have the lower error rate.

#### AlbertHall

Joined Jun 4, 2014
11,316
This is just a wild idea based on the peeled garlic being conductive and the unpeeled being insulated by the peel.
As described above one at a time, then they pass between two springy metal plates and you measure the resistance between the plates.

#### jpanhalt

Joined Jan 18, 2008
11,088
As I need a little garlic today for cooking kale, I just did a test. Using two pieces of copper clad about 2 to 3 cm^2, my meter on the 20 MΩ scale showed neither conducted. Moreover, both peeled and unpeeled are white. I believe the color varies with cultivar, and from a previous post on this subject, the variety being used is usually reddish and more intensely flavored: https://forum.allaboutcircuits.com/threads/build-simple-but-fast-colour-sensor.163312/#post-1434264 (post #6). Both pictures posted of the unsorted appear to be the same. Is this the same project?

Just FYI, both peeled and unpeeled float in water. (Hypothesis: Unpeeled would have entrained air and might have a lower average density. Maybe a different medium could be found?) Unpeeled appear more reflective.

Thus, it seems you may be stuck with color or reflectivity.

Edit: deleted duplicate word, "more."

Last edited:

#### deather

Joined Nov 26, 2020
11
There isn't an easy 'simple' approach to this. Because the bulbs are mixed up you either need to get them separated individually on a chute, in which case a 'simple' colour or radiance sensor could differentiate between a single peeled or unpeeled bulb and route it accordingly, or use a camera and machine vision algorithms (machine learning/AI) to identify the peeled (or unpeeled, whichever is least) to drive some mechanism to extract the unwanted bulbs.

The 'one at a time' in a chute is much easier to implement physically... as long as the bulbs are roughly all the same size... and will have the lower error rate.
Can you elaborate what you mean by a chute? i googled it it appears like a drop down pipe.. but i dont get the logic how that would help. because if u make a thing pipe/chute wiith an average diameter relative to garlic bulbs then some garlic would get stuck as there will always be large bulbs which are out of the ordinary

#### deather

Joined Nov 26, 2020
11
This is just a wild idea based on the peeled garlic being conductive and the unpeeled being insulated by the peel.
As described above one at a time, then they pass between two springy metal plates and you measure the resistance between the plates.
Nice ! Wild idea.. but someone already tested it above. Thanx for the effort. Try another approach

#### deather

Joined Nov 26, 2020
11
As I need a little garlic today for cooking kale, I just did a test. Using two pieces of copper clad about 2 to 3 cm^2, my meter on the 20 MΩ scale showed neither conducted. Moreover, both peeled and unpeeled are white. I believe the color varies with cultivar, and from a previous post on this subject, the variety being used is usually reddish and more intensely flavored: https://forum.allaboutcircuits.com/threads/build-simple-but-fast-colour-sensor.163312/#post-1434264 (post #6). Both pictures posted of the unsorted appear to be the same. Is this the same project?

Just FYI, both peeled and unpeeled float in water. (Hypothesis: Unpeeled would have entrained air and might have a lower average density. Maybe a different medium could be found?) Unpeeled appear more reflective.

Thus, it seems you may be stuck with color or reflectivity.

Edit: deleted duplicate word, "more."
Thanks for the effort ! Brilliant testing ! Now we know.. garlic doest conduct... but i bet if you puncture it it may conduct easily. but unfortunately we wont have punctured garlic.

With regards to your hypothesis...these bulbs are of different sizes and also vary in shape to some extent .. this wont be possible easily plus you would need a very sensitive instrument probably mechanical too ! so it wont be effective

#### jpanhalt

Joined Jan 18, 2008
11,088
Thanks for the effort ! Brilliant testing ! Now we know.. garlic doest conduct... but i bet if you puncture it it may conduct easily. but unfortunately we wont have punctured garlic.
Another reason, if you puncture it, then how could the skin provide electrical insulation? More simply it won't work.

#### deather

Joined Nov 26, 2020
11
Guys,

Think of using this sensor would it work??

#### AlbertHall

Joined Jun 4, 2014
11,316
That would only seem to detect white and black. This one looks more promising but I have no idea whether it would work with garlic.

#### jpanhalt

Joined Jan 18, 2008
11,088
Guys,

Think of using this sensor would it work??
Who knows? Your video has music but virtually no information about the sensor. Distinguishing white from black is not the problem you described. How did the other student's project work out? Reflectivity does appear to be different between peeled and unpeeled. Different sizes will reflect differently too.

The approach you described needs to distinguish color, not reflectivity or intensity. I would probably use double-beam like detection.* Look up how a double-beam colorimeter or spectrophotometer works.

*Edit: Added "like" to mean the need to create a reference intensity for non-reddish cloves of the same size and reflectivity.

Last edited:

#### Irving

Joined Jan 30, 2016
1,532
Can you elaborate what you mean by a chute? i googled it it appears like a drop down pipe.. but i dont get the logic how that would help. because if u make a thing pipe/chute wiith an average diameter relative to garlic bulbs then some garlic would get stuck as there will always be large bulbs which are out of the ordinary
A chute doesn't have to be a tube. Industrial 'serialisers' usually use an open-topped, flat-bottomed, U or V shaped (U has curved sides, V straight ones) which accommodates a wide range of sizes. In one such design, the items to be 'serialised' drop onto a rotating table, or platter, and centrifugal force pushes them to the outer edge where a collecting vane channels the items into the chute, the rotation of the table giving them enough tangential velocity to propel them along the chute at a known speed, or there may be a gating mechanism to release them at fixed intervals, the velocity controlled by the chute angle.. The sensor is then mounted above the chute, controlling a trap-door or cross-pusher sorting mechanism downstream. There is often more than one chute on the table periphery.

If the range of sizes is significant then the table may have to have several platters with a grating so smaller items fall through to a lower platter to be 'serialised'.

#### MrChips

Joined Oct 2, 2009
23,535
You mean like this?
Watch the grape sorting machine at 1:41

#### deather

Joined Nov 26, 2020
11
A chute doesn't have to be a tube. Industrial 'serialisers' usually use an open-topped, flat-bottomed, U or V shaped (U has curved sides, V straight ones) which accommodates a wide range of sizes. In one such design, the items to be 'serialised' drop onto a rotating table, or platter, and centrifugal force pushes them to the outer edge where a collecting vane channels the items into the chute, the rotation of the table giving them enough tangential velocity to propel them along the chute at a known speed, or there may be a gating mechanism to release them at fixed intervals, the velocity controlled by the chute angle.. The sensor is then mounted above the chute, controlling a trap-door or cross-pusher sorting mechanism downstream. There is often more than one chute on the table periphery.

If the range of sizes is significant then the table may have to have several platters with a grating so smaller items fall through to a lower platter to be 'serialised'.
Ok I get your point now ! Thanx

#### jpanhalt

Joined Jan 18, 2008
11,088
That seems to be a nice sensor. Since it gives 3 outputs, I suggest @deather consider using white light and look at the ratio of reflected red to either green or blue. Relative intensity of red should decreaseincrease for unpeeled cloves. Ratiometric instead of simply intensity will mitigate changes that might affect reflectivity or illumination. He might want to use more than one sensor in case a clove is only partially peeled and oriented with the peeled part toward the sensor.

EDIT: I was half asleep. Unpeeled cloves will absorb blue and green; therefore, relative intensity of red increases.

Last edited:

#### DickCappels

Joined Aug 21, 2008
7,441
Another approach is to turn things around - use a single photodetector (large silicon photo diode or solar cell followed by an amplifier and an A/D converter and then look at the reflectivity in two or more bands in the spectrum by switching on different colored LEDs one at a time. For example, a peeled garlic clove would have good response to Red, Green, and Blue but one that is not pealed will have distinctly reduced reflectivity in Blue.

#### deather

Joined Nov 26, 2020
11
DickCappels after reading BH1745NUC-E2 yes it looks easy but will involve alot of effort from my end as im not from an electrical / electronic background ! While through researching I came across the OpenMV board.. i thought it could be easier as has lest electronics...what do you think about it ?

Alternatively DickCappels jpanhalt Would you mind helping me with Code to upload to my Arduino Mega and make me achieve the project ? because I just managed to purchase the TCS230 / TCS3200 color sensor. ?

#### DickCappels

Joined Aug 21, 2008
7,441
BH1745NUC-E2 is approximately equivalent to the OpenMV board for your purposes. The price for the OpenMV camera looks good, but I don't know about the interface. Maybe somebody on here has that information.

(some text removed for clarity)

Alternatively DickCappels jpanhalt Would you mind helping me with Code to upload to my Arduino Mega and make me achieve the project ? because I just managed to purchase the TCS230 / TCS3200 color sensor. ?
I am sorry but I am not familiar with the Arduino development environment and am similarly ignorant of the language. I think that for a project like this you will ultimately need a software engineer on your site testing with real hardware with real garlic.