After receiving some encouragement, I went ahead and breadboarded the measurement circuit for the LED calculator. Someone may suggest a better way to do it, but here’s what I’ve been carrying around in my head:
R2, a 1KΩ potentiometer used as a variable resistor, controls the LED brightness. R1, a precision 100Ω resistor, limits the maximum LED current and acts as a sense resistor.
By measuring V1, we can calculate I1 = V1 / 100Ω. Since ILED = I1, we’ve determined the LED current. And VLED = V2 – V1, so we can determine the LED voltage drop as well.
The value of R2 isn’t critical. With a supply voltage of 9V and a very low LED drop of 1V, a 1KΩ variable resistor allows us to test LED currents down to (9V – 1V) / (1KΩ + 100Ω) ≈ 7mA, which is probably low enough for most applications. To be able to test lower, increase the range of R2.
I built this much of the circuit and took measurements of a few different LEDs at a few different brightnesses, to make sure the potentiometer would really work the way I expected, and that I hadn’t made any stupid mistakes in the voltage calculations.
The measurements make sense — each LED’s forward voltage drop increases slightly as the current increases. If I remember my semiconductor theory correctly, that’s called the ohmic region of operation, in which a diode behaves like a very low-valued resistor.
Automating the Measurement
In a self-contained LED calculator, the voltages will need to be read by a microcontroller, which will also drive an LCD. For now, I used my Arduino and had it send results to the host computer.
Depending on the position of potentiometer R2, V2 can range up to the supply voltage of 9V (or whatever); and V1 can range up to the LED’s forward voltage drop less than that. I’m pretty sure the microcontroller’s A/D converters don’t like inputs over 5V, so I needed to divide V1 and V2 to lower their ranges before feeding them into the ADCs. I used two pair of precision 10KΩ resistors for that.
All put together on the breadboard, it looks like this.
And with a little Arduino program running to read the inputs, scale from 1024 steps back up to a range of 5V and then double to compensate for the voltage division, and calculate all the values, I get this.
Putting It in a Box
I’ll probably program an Atmel chip directly, because I don’t need all the USB baggage. Even a Boarduino has prototyping parts on it that I don’t need here.
I need to think carefully about the LCD screen, to have enough room to display all the information and still be small enough to fit into a reasonable project box. A cell phone screen would be the perfect form factor, but really drives up the cost and complexity. I think about a 4×16 character display would be okay; 4×10 would be tight for the text and I’m afraid 4×20 would be too wide for the box.
LED 2.10V 35mA DRV 8.4V 180ohm
Okay, 2×15 is a bare minimum. All Electronics has a 2×16 module that’s 4″ wide and another that’s 3.15″ wide, which suggests having to build the calculator in landscape mode. Not wild about that. Digi-Key has 4×16 starting at $27 and — hey! — a comparatively svelte 2.6″ wide 2×16 at $5.88.