Thursday, December 15, 2011

Logging lux data with a hacked DX light meter

I've been using an Arduino Uno to log data for my buck converter project.  I've been logging the LED current using a high side current monitor and the wheel speed on my testing jig using the pulsed output of the dynamo, which I can count using a clever zero cross detector that is inherent to the inputs of all AVR microcontrollers.  The data is sent to a computer via serial interface.  Measuring LED current is all well and good, but the real performance measurement is the LED light output, which is not only current dependent, but also temperature dependent.  So, I got a cheap-o digital lux meter from DealExtreme branded as 'Ceto', which allowed me to take a few readings to see how the light output dropped with increased LED temperature.  


DealExtreme SKU 5100 digital light meter


It would be nice, though, if I could log this data digitally in the same way I can log current and velocity data.  I thought there might be a way to decode the signal going to the LCD to get a digital output, but it turns out that this is way complicated, requiring, at the very least, a datasheet for the LCD (and a touch of genius doesn't hurt either).  Disappointed, I resorted to looking up the identifiable ICs on the printed circuit board. There are some quad gatesbilateral switches and a dual flip flop, which I speculate are involved in analog to digital conversion and range switching.  Anyway, there was one lonely 27M2BC dual opamp right by the sensor input that looked promising.  The datasheet even has a little "Photo-Diode Amplifier" application circuit on page 32.

27M2B opamp on lux meter circuit board
Pin 7 has an output whose voltage matches the lux reading on the LCD

I probed around a bit to see if the designers had used the same circuit in the datasheet, but quickly found out that this chip didn't have the same pinouts as the label on the package suggested. Maybe it's a counterfeit? The Texas Instruments logo sure does look a bit fuzzy.  In any case, I found one pin (pin 7) whose voltage changes with light input, from 0 to about 2.2V.  Turns out the lux value displayed on the LCD is a base 10 multiple of the voltage on pin 7, the order of magnitude being determined by the range switch.  For example, when in the 2000 lux range, 0.178V = 178 lux:

Opamp output voltage is scaled by some factor of 10 to the actual lux reading
So, all that needs to be done is to read the voltage on the opamp's pin into the Arduino, multiply according to the range setting and be done with it.  The only issue is that my current monitor is read relative to the Arduino's 1.1V internal reference, so any value over 1.1 volts will be clipped by the ADC.  This essentially halves the lux value that each range can read, which isn't too big a deal.  The default reference of 5V would allow the full range to be measured.

I put a 3.5 mm mono jack in the front panel to get the signal out to the Arduino:

Pin 7 is brought out to the front panel via 3.5 mm mono jack
Some tweaking in code was required to get an accurate voltage reading. I'm using a fast ADC conversion on the Arduino, which makes things a little noisier.

Arduino pulling data from lux meter


So, now I'll be able to gather lux data at different speeds!

No comments: