Houston, We Have a Problem.

It seems that I may have spoken too soon regarding the consistency of the the tests on the "Voltage-based Sensing" page. My initial LEDs (courtesy of my local RadioShack) seemed to work fairly well in this setting. On Tuesday, I received a new shipment of white and red LEDs that I've been attempting to use. Thus far I have been unable to get consistent readings from the white LEDs - they seem to have exceptionally little variation between different brightness settings on the lightbox. The red LEDs - they actually emit red light; not just white LEDs with a red cover - are being conditioned right now. Further testing today will see if those will work.

Current issues with 6 LEDs in sequence:
- Readings from the first five LEDs are fairly similar - especially if they're red - but the sixth reading makes no sense. It is negative sometimes.
- These LEDs appear to be less sensitive to light than the ones I tested last week. They do not display the more extreme variations seen in last week's tests.
- This is using the same setup as last week - same wires, breadboard, pin locations, code (Orig_Voltage_test_7_1.pde), and discharge time (40ms).
I began my work with some simple, low-quality LEDs from my local RadioShack. These were 5mm, white LEDs that put out 7,000 mcd at 25mA and 3.3V. After doing some testing with them, I realized that the two packages of LEDs I had bought were in fact different from each other. Two sets of LEDs had two different responses to incoming light in the lightbox.

I figured that by purchasing some higher-quality stuff from a different supplier (Super Bright LEDs, Inc), I could decrease the chances for significant variances between LEDs like what I had noticed in the Voltage-based sensing. I had been directed to the St. Louis-based company from my advisor, and I found a variety of useful information on the website. Along with basic specifications for each LED, Super Bright displayed all of the technical data on the LED - its peak wavelength, graphs of voltage, amperage, and luminance, etc.

After perusing the catalog, I picked out red and white LEDs - twelve of each. The white LEDs (found here), named RL5-W6030, seemed to fit the bill fairly well. They had a normal forward current and voltage of 30mA and 3.4V respectively, putting out 6000 mcd at an angle of 30 degrees. This specification was quite similar to the off-the-shelf LEDs that I started the project with.
A white W8030. Note the diode with two wires running to it. This is a white LED, which contains a long-wavelength diode (blue, usually) and a phosphor to create white light.

The red LEDs (found here) are of a slightly different nature but still useful within this application. The RL5-R8030 has a normal forward current and voltage of 20mA and 2.2V (lower than the other LEDs), putting out 8000 mcd at 30 degrees.
The R8030. Note the small diode and single wire running to the diode.

Upon receiving these LEDs, though, I found that they did not work within my testing system - using the same setup as I had been using for the initial LED tests. I started by recalculating the values in the circuits - perhaps the resistors in the circuit make a significant difference when the LEDs are sensing? Despite a new set of resistors that I matched to the new LEDs, I couldn't get the new LEDs to give any sort of meaningful readings. The readout of the red LEDs, for example, would not change at all between the highest and lowest brightness settings in the lightbox, and some LEDs would read negative numbers for ambient light.

I figured that some of my troubles may lay with the resistors used - so I re-checked the specifications of the new LEDs, and learned that they had different voltage and amperage requirements than the original LEDs. I recalculated the resistance values using the new specifications of the LEDs. The red one required 2.2V at 30mA. Given that the Arduino runs 5V normally, I did the following calculation: (5V - 2.2V)/(0.02A) = 140 ohms. I rounded up to 150 ohms for this application.

"It's All Relative"

After digging through more content on the Arduino website, I decided that it might be worthwhile to change the reference value on the Arduino's pins to compensate for what seemed to be a lack of LED sensitivity. Readings for the voltage-based test were done through the Arduino's "analog in" pins, which run to the board's A/D (analog-to-digital) converter. The on-board A/D converter has a resolution of 10 bits, returning integers between 0 and 1023 (for a total of 1024 subdivisions).
The problem here was that the red LEDs would only vary by a few counts (perhaps only 10 or 15) between the lightbox's highest and lowest settings! In other tests, the difference of a few counts was considered absolutely negligible to me - variances in other tests could be +/- 50 counts at any given light level. This was at the board's default reference voltage of 5 volts. To make things a little easier to read, then, I decided to change the board's reference voltage by calling analogReference(INTERNAL1V1) for the Mega 2560 (for other Arduinos, you simply call analogReference(INTERNAL)). Now, instead of subdividing 5 volts into 1024 counts, the board was subdividing 1.1 volts into 1024 counts. This, in theory, would make it easier to detect voltage changes at the red LEDs.
The change in the reference voltage did allow me to see some of the variances caused by the change in lighting - but the results (in the graph above) are not promising for a scientific device. There is enough variance in the readings that it's difficult to get any sort of good reading from these LEDs. They show a slight downward trend, but the deviation at each brightness level is just too high. The 1.1-volt internal reference voltage is the lowest internal reference that can be set on the board - while it is possible to set an even lower reference via an external power source, I don't think it would do much. It would really only exaggerate the problem here.

Two Steps Forward, One Step Back.

With the results of the revised voltage-based system inconclusive at best, I decided to backtrack to my previous timing-based sensing system. I figured that, perhaps, the older system might provide better results with these new sensors:
Unfortunately, no - these results do not strike me as particularly useful. There are portions where the brightness changes but the LED discharge time does not change, which seems odd to me. Something is going on here, but I'm not sure what exactly.

Moving on...

After two sets of poor results from the red LEDs, I moved on to the white LEDs. These were connected with a 68-ohm resistor at the cathode. I was unable to find a reference voltages that would produce decent results from these LEDs. The Mega 2560 has two "lower" reference voltages at 2.56 and 1.1 volts. Setting the reference at 1.1 resulted a constant readout of 1023 counts; a reference of 2.56 volts showed such little variation between brightness and darkness that it wasn't worth the time and effort of collecting data. I don't have any regulated power supplies on site, so I gave up on the voltage-based system and tried to collect some data with the timing system:
These results look a little better than the timer-based results that came off the red LEDs, but they're still nowhere near as good as the results from the voltage-based tests of my first LEDs on the "Voltage-based Sensing" page. LED4 was properly hooked up, but apparently it didn't feel like tripping its pins LOW today. Normally I would associate this with electronic interference of some sort, but this exact same test was used with my first LEDs, and it did not show any of the variations that are seen here.

One More Test.

It is known that LEDs have internal resistance - not only as an inherent property of a conducting material, but also as a protective measure to keep the LED from being fried by overcurrent (note: you can overcome these resistors easily). Typical 5mm, T1 3/4 LEDs have a general resistance of around 20 ohms. Knowing this (and also remembering that LEDs are cheap), I decided to (at the request of my advisor) hook up the new LEDs without any external resistors. Perhaps it was, after all, the new resistors that were contributing to the problems. The good news is that there was no "snap, crackle, pop" from my LEDs, though unfortunately this didn't appear to have much of an effect on the problems I've been experiencing this week:
This graph is color-coded: the same LEDs have the same color. We are comparing the voltage from the LED with and without a resistor in place. As we can see, there isn't really anything that would describe the odd behavior of our new LEDs here. Removing the resistor on the RadioShack LEDs results in lower voltage values, which doesn't really come as a surprise - the LED bleeds down to zero voltage more quickly without a resistor in the way, I suspect. The red LED (R8030) displayed a similar trend of a shift in data. This is interesting but it's not really useful here - merely shifting the LED's response isn't what I'm trying to do. The output from the red LED (as well as its counterpart, the white LED, W6030) is not very useful for scientific measurement. These were all done at a reference voltage of 2.56 volts, the lowest possible voltage that would give legitimate readings from all three tested LEDs at all brightness settings.

My final, last-ditch attempt to get these LEDs to produce good results was to use very large resistors. All LEDs have different responses based on voltage and amperage, and I believed that a large resistor in place could put these LEDs in a more productive range of output voltages/amperages. Not so, again.

The Investigation Continues...

After a weekend away from the lab, I've come back to the same problems I had last week. I still have a set of no-name LEDs from RadioShack that work, and two sets of (supposedly high-quality) LEDs from a good supplier that really don't work. After doing some more general work this morning with LED sensing (see the earlier posts on this wiki for details on that), I decided that I might be able to diagnose some of my problems by using an oscilloscope. For those youngsters out there, an oscilloscope is a handy tool that essentially provides a graphical readout of voltage from a circuit. They've been around forever, and even new ones look ancient, but they're fantastically useful (especially in this application).
I hooked up my Arduino and re-loaded the code for a single LED. The parameters were the same as in previous tests, using the timer-based method. The RadioShack LED had a 100-ohm resistor on its cathode, and both anode and cathode were wired to their respective digital pins on the controller. With this setup complete, I wired the oscilloscope into the circuit and fired it up. After some fiddling with knobs and dials on the 'scope, I eventually was able to capture a shot of the voltage at the LED falling to zero. This was inconclusive in terms of describing why the LEDs were different, but I did learn some things from the setup:
- the "reverse bias" mode is quick. In fact, it's very fast - less than 100 microseconds should have the LED fully reverse biased. This can technically make the sensing process very fast indeed. If the whole process is limited by how quickly the LEDs can sense data, then hundreds of collections could be taken in a second.
- the RadioShack LEDs have a much higher output voltage than my other LEDs, it seems.
Unfortunately, the 'scope readings don't say much for the LED's ability to receive light, or why my starting LEDs are different from the ones I've purchased.

Problem Solved!

A good student should always ask questions. Especially in class when there's a teacher or supervisor who can actually answer such questions. In the world of LED sensing (at least right now), that's not quite as easy to do. There aren't many people who use LEDs to sense light! However, I have managed to find some help for my problem, from Mike Cook. Mike created some code for Arduinos for LED sensing that I've been basing some of my tests off of, and I hoped that he could help me in my dilemma.
After some e-mail conversations back and forth with Mike, I think I've found the problem. My newest LEDs are actually too nice. While all of my LEDs (white W6030s, red R8030s, and RadioShack LEDs) are 5mm, T1 3/4 size, they are substantially different internally. Not only do they use different conductive materials, but they also have substantially (visibly) different junction sizes. The white W6030s have very small junctions indeed, and the actual diode part of the light is very small too. For sensing purposes, we want LEDs that have a huge junction size and very high capacitance. Perhaps that's why these particular LEDs were the worst sensors of all! The red LEDs had a smaller junction than the RadioShack LEDs, and thus were able to do at least some sensing - not much, and not very accurately - but some sensing was possible.
The solution? Buy low-quality or old-stock LEDs for the project. New, modern LEDs seem to have smaller junctions and lower capacitance. These will make inherently poor LED sensors. Older LEDs may not suffer from these problems. It is entirely possible that when Ben-Ezra et. al were building their BRDF measurement device in 2007-08 that their LED suppliers had not begun to miniaturize their diode components. Given the pace of progress in the LED industry, this seems possible to me. With smaller diodes, companies could use the same diode assemblies for different-sized housings, eliminating the costs of manufacturing different diodes for different sizes. This cost reduction seems advantageous enough to provide a significant drive to downsize existing diode designs.
This would also explain why I initially got decent readings from a set of 10mm white LEDs earlier on in the project - they are physically larger and have bigger junctions than the little 5mm LEDs. It's all starting to make sense, now.

Letting Go (of Charge)

One of the keys here is the ability of the LED to act as a capacitor. The more charge it can hold as a capacitor, the better. This explains why my readings for the red LEDs were so low, especially in timer-based mode - it seems that most red LEDs I've run across are terrible capacitors. For example, a red LED from Kingbright (see PDF here) with a maximum luminous intensity of 12,000 mcd has a capacitance of 27 picofarads. Without much ability to hold a charge, that particular LED cannot be a particularly good sensor. I haven't been able to dig up any specifications on the capacitance of warm white LEDs, which I'd like to see.

The capacitance of white LEDs appears to be (on average) about four times greater than some of the red LEDs I've seen. This must be why the red LEDs would discharge so quickly in the timer-based approach! Unfortunately, Super Bright LEDs does not publish specifications for their LEDs' capacitance. I can't assume that the one I had was much different from the 12,000 mcd LED. Based on some other specifications that I've seen, it looks like capacitance falls off a cliff after a certain intensity - say, 6000 mcd. Below that, higher capacitances can be found. Perhaps this is where I need to stay?

So in conclusion:
The RadioShack LEDs work because they must have a high capacitance and a big p-n junction.
The RED R8030s almost work because they have a large enough p-n junction but a low capacitance - they discharge too quickly to read accurately!
The White W6030s don't work because although they have a high capacitance like the RadioShack LEDs (all white LEDs have a similar capacitance it seems), the p-n junction is too small. It was probably designed for a 3mm (T1) housing to save manufacturing costs.

More LEDs.

After having tested the new LEDs from SuperBrightLEDs (R8030s and W6030s) and discovered that they were both poor sensors, it was time to attempt to find other LEDs for the sensing system. The only question is where? Specifications such as capacitance and junction size are not common on LED data sheets - nobody really bothers with such specifications. The important things to know about the LED are its operating voltage and amperage, intensity, output angle, and peak emitted wavelength. I started by just picking a few sets of cheap LEDs to test - perhaps I would find something good. I ordered another set of LEDs from SuperBrightLEDs, this time a set of warm white LEDs. My first LEDs from SuperBright were cool white (poor sensors), and the RadioShack LEDs were warm white (good sensors). Perhaps there was some relation there?

Unfortunately, no. The new warm white LEDs (WW7035) had similar specifications to the RadioShack LEDs I tested initially, but they too were poor sensors. From there, I tried to find some older-stock LEDs - some really cheap things that were designed a long time ago (10 years +), before the diodes of LEDs became smaller. These generic red LEDs were of a very high intensity (15,000 mcd), but they had extremely small junctions and (based on what I know now), likely a very low capacitance. These were similarly terrible sensors. Despite my best efforts, I was unable to produce any sort of meaningful output from either of these sets of LEDs - both with the voltage-based test and the timer-based test.
The WW7035, a poor sensor.

Luckily, though, after some particularly thorough searching, I found a company which actually publishes the capacitance of its LEDs in data sheets. Kingbright USA (found here) publishes highly detailed data sheets for its products. From these data sheets, I determined that high-output LEDs (particularly red ones) have terribly low capacitance - usually around 25 picofarads. That is an incredibly small accumulated charge. Lower-intensity red LEDs may have a capacitance of about 100 picofarads, four times greater than their high-intensity counterparts. I chose a red 5mm LED (model #WP1503SRC/F) with a high capacitance and fairly high intensity (C = 95-picofarads, Lv = 5200 mcd). These LEDs just arrived today (7/21/11) and I will be conducting tests on them later in the day. Hopefully, with a high capacitance and fairly large junction size, these diodes will be well-suited to LED sensing. Results will be posted later in the afternoon.

The Kingbright WP1503SRC/F red LED. A winner, perhaps?

No, the latest order from Kingbright also contains sensors that aren't spectacular. The results of the voltage-based testing method:
These sensors provided very little useful information during the voltage-based tests. There is high variation and the results seem to have little overall variation from darkness to high brightness. Perhaps these sensors can do better in the timer-based tests (below):
These results are about as useful as the previous ones. While variation for most brightness levels is fairly low, the count readings from the Arduino don't change enough between brightness levels to be able to make any sort of accurate readings. The Kingbright LEDs are now out of the picture; they are poor sensors.