Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Announcements and Chat > General Discussion

Reply
 
Thread Tools Search this Thread Display Modes
Old 6th April 2018, 10:46   #1  |  Link
viviantern
Registered User
 
Join Date: Mar 2018
Posts: 1
Could you tell me how to calibratea a 1$ color sensor?

My adventures in electronics continue. While talking with a friend about colors, he told me about color sensors. Later I remembered the video where they sort smarties and so I wanted to know more. Watching some videos I found one with a LDR and a RGB led. They say it's not precise. Looking at the various builds of those sensors I guess that part of the problems are the case that holds everything together. Most of them have a lot of space between the LDR and the colored surface, some have the leds in front of the LDR... that cannot work.

There should be no other light source than the RGB led. Put the LDR and RGB Led inside a small tube, inside needs to be black. I couldn't find a tube made of this material. so I took a thick Pen.
Direct lightning of the rgb should be avoided. To get a nice homogeneous color I put a white semitransparent piece of plastic in front of the Led.


The LDR should only get the reflected light. Put the sensor on top of the white plastic. The light needs to be behind the LDR!.

It cannot work for everything. You can use it for only specific surfaces. For example I use glossy photo paper. Opaque would be better probably. but I had some photopaper in the printer and so I printed a colorpalette & a black and white palette.

You need to know more about the Led & LDR. That is basically the problem. The Red, Green and Blue emitted by the led are not 100% red green and blue. The LDR cannot absorb every color perfectly .

Without looking other codes I hooked up this color sensor pen to the arduino... and measured how much time it needs to turn on the various colors. I ended up with 50ms for each color. Done that I just let the LDR print some values on the screen. Black and white... how much range do I have from black to white? I wrote a code where it autocalibrates the black and white. Basically I measured the light asbsorbment on the previously printed black and white photo paper. I was actually impressed how much range i could have. From the total of 1023 range aviable on the arduino I go a black of around 30-50 on all colors and a white around 700. That means the color sensor has a theoretically precision of, let's say an average range of 650 on each color, 650*650*650 =274.625.000, around 270 million colors. Thats alot ...rgb has 16million colors. I personally know about 5-6 colors. At that point I started to test. to make it simple I placed another rgb led on the board and a white plastic hut on the led. The colors appeared already similar but to much lighness. Also on dark surfaces I got the led turn on. I then decreased the range at about 10% at the bottom and 10% from top. And wow.. color looks the same. But lets see the numbers. Printing the rgb values on screen gave different numbers than those I measured ... but opening a rgb color selector on screen and displaying it... showed approximately the right color ... so it was actually very correct.Even if my printer is a photoprinter it does not means that the colors are printed correctly. I never calibrated a printer or a monitor...So there can be a big difference. So I tried to calibrate the various colors based on the printed palette. Turned the red light on and decreased the range of green and blue to 0 while on red... the same for grren and blue.I finally found the real problems. The red is almost perfect. The blue is slightly shifted towards the red. The green has not enough light? When on green I need to put the red and blue levels very low. But doing that drops the precision a lot . I get perfect red(255,0,0), blue(0,0,255), green(0,255,0), yellow(255,255,0),fuchsia(255,0,255),aqua(0,255,255). the range of every color is dropped so much that at the end I probably can measure only about 10-15 main colors.

How could I calibrate a 1$ color sensor?

Every led color is shifted slightly.

The green does not output enough light.

My printer didn't print the right colors.

The LDR does not read every color correctly (wavelength,light....)

I think somewhere out there is a mathematical calculation that allows the vitrual shifting of each color.

I posted this here because it's a vast question that needs the basics of electronics engineering. While I think most problems could be solved with a complex mathematical function I could be wrong and solve the problem with some simple dimming of the led, adding more leds, maybe filter the light source or just move the sensor up or down inside the tube.what about just by changing the resistors?. In all cases a electronic engineer is needed. The way the leds emit the light and the sensor absorbs it has to do with the individual wavelength...i'm not an electronical enginer.

I think also it's worth to ask because of the fact that color sensors are normally not that cheap.

RGB led: LL0548RGB:http://www.3lco.biz/attachment.php?id_attachment=2

LDR: FW300A1: http://www.kynix.com/Detail/4419/FW300A1.html

Short clip that shows the sensor:https://www.youtube.com/watch?v=SK4a...ature=youtu.be
viviantern is offline   Reply With Quote
Old 6th April 2018, 11:34   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 5,505
Cant really help, but the same phenomenon can be experienced in subtractive 3 and 4 color printing, CMY/CMYK due to impurities in the colored inks.
Partial correction is done by replacing some component part of the C-M-Y with K black ink, where they call the correction Under Color Removal.
(also saves on ink costs and reduces the amount of ink applied, ie paper dont get quite so soaking wet).

CMY (from memory), Cyan ink tends to contain Magenta (and sometimes a little yellow), Magenta tends to contain quite a bit of yellow, and yellow can in a lot of cases be near perfect. Inks from differing manufacturers can be quite a lot different (there are books written on the subject, complications include printed dot size, and dot spread [EDIT: I used to have a 3 inch thick book called the 'Printers Ink Manual']).

CMY impurities:- https://www.google.co.uk/search?clie....0.02c18cU0stU

Under Color Removal:- https://www.google.co.uk/search?q=un...BsfU8gfNxYiwBQ

Good luck.

EDIT: HP Deskjet used to produce dark green when 3 color CMY used in equal amount to simulate black, many ribbon based printers eg Citizen 24 dot matrix printer used to produce dark red.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 6th April 2018 at 11:42.
StainlessS is offline   Reply With Quote
Old 6th April 2018, 12:20   #3  |  Link
Phanton_13
Registered User
 
Join Date: May 2002
Posts: 75
The cheapest way to optain a narrow band ligth source is using laser diodes properly drived, other option for a good ligth source is using an HiD lamp with some filters in this case the ligth depends strongly of the filter, although good filter are not cheap (In my case I have been using some dichroic filters that I savaged frome a "1 hour automatic film develop machine").
Phanton_13 is offline   Reply With Quote
Old 10th April 2018, 20:37   #4  |  Link
pandy
Registered User
 
Join Date: Mar 2006
Posts: 1,038
Perhaps you should at least consider to use dedicated colour sensor (like TCS 3200, TCS34725 etc) LDR response is not uniform over spectrum and you need to address this in your code.
Black chamber can be created by using some black flock, plush, velvet etc. Colour sensor may help you to calibrate LDR based sensor (if your goal is really to use LDR as light sensor).
Also you can improve light selectivity by using filters with known characteristic - search for colour filter films used commonly in photography and theatre (so called gel film filter like this https://www.amazon.com/Colour-Primar.../dp/B00582K3YS) - they are not so expensive and they have accurately specified spectral characteristic. Also LED's from reputable source and manufacturer (Nichia, Cree, Lumileds, Osram) are recommended.
pandy is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 20:51.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.