Hi All, Ok, it is color reader time again! This thing is startingto drive me crazy... or crazier, anyway!
Here is the problem. I take a unit. I test it in debug mode, taking multiple samples of various materials. I get a series of values and calibrations that will reliably read all the different color distinctions I need. I build it into a release version, and move the unit from my test enclosure to a permanent enclosure. All the calibrations are off, the color ranges are flakey, and it doesn't work well enough to give away, much less sell!
So, what could be causing such gross changes in my calibration? The cases are identical, except for the two holes to allow the programing/debug cable access. Even when I move the unit back into the original case, it is still off in calibration. Am I just trying to get more accuracy out of this sensor than it can provide?
A copy of the schematic is here:
I have three SM RA LEDs, red, green and blue on the top of the board powered off a 20mA supply and switched through a couple of compl. mosfets.
On the bottom of the board, I have an TEPT4400 ambient light sensor/photo transistor, collector to 3.3VDC emitter to 12.4K resistor feeding a buffer opamp with a 10K digital pot in series with 50K to provide an adjustible gain amplifier. This goes through a low pass filter of 1Kohm/.1uF to the ADC of my PIC24FJ128. It also feed to a second stage of the opamp with a fixed 3X gain to another ADC input.
Basic calibration is to place a known white sample (white felt) and turn on one of the LEDs. I adjust the digpot to get a reading of 2000 to 2020 out of a range of 2048. I then turn that LED off, turn on the next, and remeasure. After I have all three colors calibrated, I then put a known black sample, and measure my 'black' levels. I then scale the measured levels in color between these two levels.
My gain settings keep varying between 3-5 steps for the white levels, and the measured black level (typicall between 250 and 400) varies by almost 100 points! In any one session they stay pretty stable, but the next morning everything is way off.
So, any ideas what I am doing wrong? Any suggestions to improve things?