# Build simple but fast colour sensor

Joined Sep 22, 2019
7
Hi,

I need assistance in building a color sorter which can differentiate between peeled and unpeeled cloves see attached. I know this forums has some very smart people with electrical/electronics skills. If you can guide me through process designs it would be great.

after some research on the web i came across there are color sensors on the market which can be tought to learn a colour. So my ideal solution is to have my cloves pass through a conveyor belt with a width maybe 1.5 times the width of the cloves and then a color sensor monitor the cloves as they pass once it detects an unpeeled clove it would signal/trigger a mechanism to throw the clove off the conveyor belt. this process should be very fast because there could be 15 sacks of peeled vs unpeeled cloves ! im ready to have multiple sensors to work in parallel if need be. So this is the basic idea. keeping the circuitry / electronics as simple as possible !! So please suggest a good colour sensor which is cheap as a starter but yet good enough in your opinion and we move to the next step.

Thanks

#### Attachments

• 394.6 KB Views: 20

#### jpanhalt

Joined Jan 18, 2008
11,088
1) Single file past a color detector seems like a good approach;
2) I think using a microcontroller will the the simplest approach;
2) I would use a little more modern MCU than in the previous thread; a fast 8-bit should work; multiple 16-bit counters may be needed depending on the distance in number of cloves between detect and reject; and
3) You will need to count every garlic clove so when you detect one that is not peeled you will have a count to do the reject.

Aside from that, do you have a specific question about the color sensor?

Joined Sep 22, 2019
7
1) Single file past a color detector seems like a good approach;
2) I think using a microcontroller will the the simplest approach;
2) I would use a little more modern MCU than in the previous thread; a fast 8-bit should work; multiple 16-bit counters may be needed depending on the distance in number of cloves between detect and reject; and
3) You will need to count every garlic clove so when you detect one that is not peeled you will have a count to do the reject.

Aside from that, do you have a specific question about the color sensor?

Thanks for your reply. The issue is im very basic when it comes to electronics/electricals. Look at this color sensor I was under the impression with such a color sensor or similar i could teach it to recognize unpeeled cloves and once it detects it it would trigger some mechanism to push / eject the clove from the conveyor. Thats all i want to achieve nothing else fancy

Now the approach you had mentioned above will have to make me go through a steep learning curve to achieve this goal when we start adding MCU etc etc also i dont need to count peeled vs unpeeled cloves.

#### jpanhalt

Joined Jan 18, 2008
11,088
I went to : https://www.seltec.co.uk/products/details/11097.html

No datasheet. Do you have one?

I think you will need a reference beam, as reflection will probably vary from clove to clove and positioning in the single-file chute. Thus a white (reference) beam would be a control (just a thought, not a requirement depending on how it works). Can your reject mechanism be in the same location as your detection? That was part of the problem in the previous thread.

Is the product garlic? My garlic has mostly white rather than reddish membrane over it. Does it make a difference? If the garlic (?) is crushed, won't the membrane float regardless of color?

I recently saw a show about sorting tea leaves from debris. Similar problem. Some of the sorting is done by humans. Have you studied how similar problems are solved in other industries?

Last edited:

#### jpanhalt

Joined Jan 18, 2008
11,088
One thing you need to do is define how fast the sensor/reject process needs to work. From a brief search, garlic in the US is measured in "cartons" of 30# (13.6 kg) each. An average clove is 7 g. So, a carton is about 1944 cloves. How fast does a carton need to be sorted? How much does a "sack" of cloves weigh?

Joined Sep 22, 2019
7
I went to : https://www.seltec.co.uk/products/details/11097.html

I saw that sensor. isnt there a more affordable basic one below $100 ? No datasheet. Do you have one? No specific data sheet. However i could illustrate diiagramatically if need be. I think you will need a reference beam, as reflection will probably vary from clove to clove and positioning in the single-file chute. Thus a white (reference) beam would be a control (just a thought, not a requirement depending on how it works). Hmm.. I think you went beyond my level of understanding..didnt quite get you Can your reject mechanism be in the same location as your detection? That was part of the problem in the previous thread. Yes I envision the moment the reject colour is detected .. next-to or below or beside the sensor there would be an ejection technique and most likely like a solenoid valve which releases pressured air from a compressor so this is not a problem even if some peeled cloves are ejected is still not a problem they will be brought back in the conveyor for second and third rounds of sorting.. with more iterations the number of sorting cloves will be so little a human could manually and quickly sort. Is the product garlic? YES My garlic has mostly white rather than reddish membrane over it. Does it make a difference? Yes majority of the global population know garlic as white. This is a more rare, smaller variety but extremely intense in flavour. Just 1 Tea-spoon can be equivalent to 5 Table-spoons of the larger white variety of garlic you are already familiar with If the garlic (?) is crushed, won't the membrane float regardless of color? It would, but again this garlic is not ur typical garlic the outer cover is very tough. even the best of machines can peel with only upto 60-70% success rate. thats why i have to sort the remaining 30%. So coming to your question on crushing and floating of membrane you would end up with a meshed clove mixed with membrane they wont separate easily as you think. been there done that. I recently saw a show about sorting tea leaves from debris. Similar problem. Some of the sorting is done by humans. Have you studied how similar problems are solved in other industries? YES, alot infact. the only way to sort this is using$30,000+ machines. Which is difficult from a third worlds perspective thats why need you guys help.

Joined Sep 22, 2019
7
One thing you need to do is define how fast the sensor/reject process needs to work. From a brief search, garlic in the US is measured in "cartons" of 30# (13.6 kg) each. An average clove is 7 g. So, a carton is about 1944 cloves. How fast does a carton need to be sorted? How much does a "sack" of cloves weigh?
Ok.. with 13.6kg people take around +/- 2 hours on average to sort. if i can get it down to 30min atleast as a start it would be perfect. because i can replicate the system and make multiple machines which run in parallel..way cheaper for me

#### jpanhalt

Joined Jan 18, 2008
11,088
So, using (1944 cloves per carton)/1800 s (30 min) = 1.1 cloves per second. That seems quite slow to me and should be easily done. I am familiar with things such as "flow cytometry" ( https://en.wikipedia.org/wiki/Flow_cytometry ) that require much faster identification and sorting.

It seems you need to find or build a color sensor within your budget. Maybe look at reflection from a light beam and determine whether the ratio of green (absorbed) to the source (reference) is decreased. Ordinary color filters might be used. The simplest method might be just to use green light and see whether its intensity decreases more than it does for peeled cloves, but that method may be less specific.

At that slow a rate, a simple comparator could be used to reject those cloves that reflect green poorly.

#### JohnInTX

Joined Jun 26, 2012
4,444
There are lots of 'color sorter' resources out there - it depends on how much you want to roll your own vs. buy a machine.
Adafruit and Sparkfun have color sensors that interface with an Arduino microcontroller.

It's not a trivial project but by breaking it down into small chunks, it's doable.
Welcome to AAC.

#### Attachments

• 319.8 KB Views: 4

Joined Sep 22, 2019
7
There are lots of 'color sorter' resources out there - it depends on how much you want to roll your own vs. buy a machine.
Adafruit and Sparkfun have color sensors that interface with an Arduino microcontroller.

It's not a trivial project but by breaking it down into small chunks, it's doable.
Welcome to AAC.
Thanks .. however this would be the last route i would decide to choose because i would have to start learning how to program micro controllers

Joined Sep 22, 2019
7

Thanks

So, using (1944 cloves per carton)/1800 s (30 min) = 1.1 cloves per second. That seems quite slow to me and should be easily done. I am familiar with things such as "flow cytometry" ( https://en.wikipedia.org/wiki/Flow_cytometry ) that require much faster identification and sorting.

It seems you need to find or build a color sensor within your budget. Maybe look at reflection from a light beam and determine whether the ratio of green (absorbed) to the source (reference) is decreased. Ordinary color filters might be used. The simplest method might be just to use green light and see whether its intensity decreases more than it does for peeled cloves, but that method may be less specific.

just out of curiosity why greenlight ? wats so special abt it ? and when you say color filters what are these exactly circuit boards emitting LED light ?.. just understand electronics is not my background just trying hard to understand it

At that slow a rate, a simple comparator could be used to reject those cloves that reflect green poorly.
Im interested to know and learn more about this comparator. is it possible to maybe give me a model of such a device which u have in mind so i can study more abt it ??

#### jpanhalt

Joined Jan 18, 2008
11,088
Thanks
Im interested to know and learn more about this comparator. is it possible to maybe give me a model of such a device which u have in mind so i can study more abt it ??
1) Find and load LT Spice (free). It will simulate almost any non-microcontroller circuit you want.
2) A comparator is a device that compares two analog voltages. If one is higher, the output is 1 (high); if one it lower, the output is 0 (low). That logic can be reversed easily. You can set the reference voltage with a simple voltage divider. Then when the color is "red," you can set the output to be either a 1 or 0, which will fire the reject mechanism. LT Spice will simulate that well.
3) None of us know anything about your budget or education/experience in electronics. I suspect that whatever you do, there will be a learning curve.

#### Marc Sugrue

Joined Jan 19, 2018
213
Just a thought but it may be easier to go down the route of a simple relectance light measurement. If you shine a known light and measure the reflelcted light back you can determine by a simple DC level whether or not a clove is pealed or not by the amount of light reflected into the sensing elecment. Just a quick google came up with this https://www.onsemi.com/pub/Collateral/QRE1113-D.PDF. If you power the LED and use the transistor as a current source into a resistor then a simple comparitor with DC reference can set your refectance level. The output of the comparitor would be your pealed/not pealed signal

#### Sensacell

Joined Jun 19, 2012
2,825
I think you will find that variations in angle, position, reflectance and a host of other factors will make this a rather tricky task.

Give yourself a fighting chance to "code your way through" the problems by using a microcontroller.
Analog is do-able, but fixing little problems becomes exponentially difficult- much simple to fix in code.