Light Meter

UPDATE 2014-09-26
After implementing binary long division in assembler and other such thrilling pastimes, and moving all my electronics gear I found myself with a sensor that would only return zeroes for sensor data for some unknown reason. The error persisted even after reverting back to older, known to be working, code revisions as well as swapping out the microcontroller. So given that I had no second sensor to try with, and that I found an acceptable deal on a spot meter, I ended up with a Soligor Digital Spot instead. In other words, this project can be considered being put on ice indefinitely. The code stays available on github though.

Well, so I went and bought myself a medium format camera, a Mamiya RB67 Pro SD to be specific. It is fully mechanic and requires no batteries, well, unless one gets hold of a motor film back, and/or a viewfinder with a built in light meter. nknown (not cached I did neither, and the lack of the latter means that will have to rely on external equipment to get a correct exposure, equipment I currently do not have, or well, I do own other cameras, with built in light meters, but it is a bit cumbersome to go that route.

There are a lot of second hand light meters available so I thought the logical thing—of course—would be to ignore that fact and try to build my own. (Well I did shop around a bit and almost bought a spot meter


The light sensor I decided on is AMS TSL2561 (breakouts available from sparkfun and adafruit, whose product range is available for me in Sweden from lawicel-shop) which has two sensors built in: One that reacts on both infrared and visible light, and one that reacts on infrared alone. With readings from both sensors, one can to some extent compensate for any available infrared light. Furthermore, this may be the first project where I use a TI MSP430 family microcontroller, I have focused on Atmel's AVR offerings so far for my projecs, as I am comfortable with the tools available for linux (avr-gcc avrdude etc). Nevertheless I bought the first msp launchpad verision out of curiosity but did never find a fittng project. Perhaps this is it.

physical design

Building it as an incident light meter would be the easiest way, as it would more or less amount to hiding the sensor under half a table tennis ball, but I want to have the possibility to use it as a reflected light meter first and foremost. This is a little more finicky, since I want to make sure that it takes up light from the same place as the lens sitting on the camera.

With some caveats, the angle can be calculated as angle_of_view = 2*atan(d/(2*f)) where f is the focal length, and d is the length of one of the sides of the negative, or the diagonal depending on what one prefers to use.
In my case, with a 90mm normal and using the diagonal I get 54.243deg = 2*atan(sqrt(60^2+70^2)/(2*90))
So how to achieve that then? At first I thought about building something like a pin-hole camera setup, only with the 'film' being a translucent diffusor behind which I would place the sensor, but that would need a somewhat pinhole-like setup and I want to limit the light available to the sensor as little as possible. Of course, since I don't need the generated image to be in focus at all I could get away with a large pinhole but since I haven't done any optics math for quite a while there is a bit of a risk of mucking things up.
Instead I suspect it is enough to approximate the sensor area as a point and place it at the bottom of a well with dark sides. Then the sensor point and the opening of the well would form an isoceles triangle with the angle at the sensor point being angle_of_view = 2*atan(d/(2*l)) where d is the diameter of the well opening and l is the length (depth) of the well. …not so different from the lens angle of view formula.
That means I get d/l = 2*tan(54.243/2) which is about 1, or simpler put; I need to put the sensor in a hole that is as deep as it is wide.

talking to the sensor

I do not not at the time of writing and development have a working C compiler toolchain for the msp430, but the instruction set is nice enough to not be too cumbersome to write assembly for, so that is what I will do; using naken_asm to assemble and mspdebug to upload the hex file to the mcu. I seem to have the i2c communication up and running, as well as a soft usart pushing read lighting levels to the computer for plotting.

The blue line plot the values from the sensor visible to both IR and visible light, and the green line correspond to the sensor values from the sensor sensitive to only IR.

For some reason the chip ID and the (power) control registers of the sensor do not return the values I expect from reading the datasheet. The control register reads as 0x33 when 0x03 is expected, and the ID register reads as 0x50, when the datasheet has me expecting 0x1R wher R in the lower nibble is the chip revision. Seeing as practically everything in this project is terra incognita for me, the sensor, the communications method, the microcontroller, it is quite hard for me to find the cause of these errant bits. It could even be the datasheet that is outdated, and that there is some new chip ver...or something.

spying on the I2C bus

No comments:

Post a Comment