2
\$\begingroup\$

I need to build a circuit that detects whether a green object is in front of it.

As I do not need to know which color is in front of the sensor, but only if there is a green object, I thought a color sensor might be a little overkill.

My idea was to use a reflective sensor (more specifically the Vishay CNY70), with a green filter in front of it.

Would this work, and would this also work for darker greens? What could be a possible filter?

\$\endgroup\$
6
  • 5
    \$\begingroup\$ This will mistake white objects for green objects. \$\endgroup\$ – user_1818839 Mar 31 '16 at 14:06
  • 1
    \$\begingroup\$ You could sequentially turn on and off a red, green and blue LED that shine on the object, then use a light sensor to record how much of that light reflects back. If there is much more green reflection than red and blue, you can say that the color detected is green. This eliminates the white detection problem because if the object is white, a reflection will be picked up in the red and blue readings. \$\endgroup\$ – MichaelK Mar 31 '16 at 14:18
  • 1
    \$\begingroup\$ I trick I use for industrial vision application assessment is to take a colour photo of the object and then split the image into the R, G and B channels. A program such as XNView does this quite easily, giving a grey-scale image for each channel. The images can be compared to each other to get a feel for how a monochrome camera or sensor will perceive the object under various lighting or filter conditions. This technique may help you assess the best solution for this application. \$\endgroup\$ – Transistor Mar 31 '16 at 14:24
  • 1
    \$\begingroup\$ Obviously, you DO need to determine which color is in front of the sensor, at least to the level of distinguishing "green" from "not-green". Therefore, you will need to sense a minimum of two colors (or two sets of colors such as green and its complement, magenta) in order to determine whether you have no object, a green object, or an object that is some color other than green. In any case, mass-produced color image sensors are incredibly cheap these days, so even if it's overkill, it's more cost-effective to use one instead of building a custom sensor. \$\endgroup\$ – Dave Tweed Mar 31 '16 at 14:29
  • \$\begingroup\$ @DaveTweed I tried some color sensors before (TCS 3200 and others) and those did not work great. Is there any color sensor you would recommend? \$\endgroup\$ – joelsa Mar 31 '16 at 14:52
3
\$\begingroup\$

If you had checked the data sheet of the part you listed, you would have noticed that the CNY70 is an infrared emitter/detector. The detector probably doesn't care, but it is behind a filter that only lets infrared reach the detector. The emitter only sends infrared.

No filter you could possibly use will make it respond reliably to green objects because green is just too far away from the operating spectrum of the part.

To do it using reflection, you will need a green emitter and a detector with a green filter.

Phototransistors have a very wide spectrum response, so no problem there. You need to pair a green LED with a phototransistor, and put both of them behind a piece of green glass or plastic.

As @BrianDrummond noted in a comment, a detector with a green filter will detect green objects, but also white objects because white also reflects green.

So, you can only use a green detector if you can guarantee that all objects to be detected will only have colors that contain green, and that all objects that should not be detected will not reflect green.

Alternatively, you must detect all colors separately (RGB) and evaluate the three detectors to decide what green is really green.

\$\endgroup\$
1
\$\begingroup\$

Brian's comment leads to the answer:

Simple solution: I recommend to use a magenta filter i. e. a filter letting pass every wavelenght except green ones. Then put a red or blue background behind the plane where your objects will appear. Green, dark green and — unfortunately — black objects will trigger your circuit.

Interesting solution: If you want to discriminate green from black objects you will have to use either two sensors (tricky) or two light sources (simple with LED). Irradiate the object alternatingly with green and magenta light. The latter by using a red and a blue led. The sensor should work without a filter. You then can check, if the object is white, green, not green or black.

But for both solutions you will need a totally different sensor. The sensor given is only suitable for infrared. you need a sensor for visible light. Depending on the type you will have to calibrate it.

\$\endgroup\$
1
  • \$\begingroup\$ so much downvotes. Why? \$\endgroup\$ – Ariser Apr 2 '17 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.