How To Build a Flashlight With Perfect Modes (picture heavy)

I'm a week ahead of you, ha ha

and ordered 4x101-AK too.

exciting...

Good! I'm going to need some help.

Version 0.2 of the BLF-VLD is ready for download here. There have been some substantial changes, especially for the programmable version of the driver. Light levels are not freely programmable anymore, but can be selected from a predefined set of nine logarithmically spaced levels and a few strobe modes. The programming procedure has been simplified a lot, thanks to agenthex's suggestions.

The driver can also be built in two non-programmable versions. The first gives access only to a subset of modes defined at compile time. The second version also has a fixed subset of modes in the standard mode group, but can access all modes defined in the extended group by switching modes x times in a row (configurable at compile time). This way a flashlight may have just three or four default light levels, but special modes like moonlight mode or strobes are still accessible without getting in the way on everyday use.

Thank's for the new SW, Tido.

I expect my programming equipment at my door in about one week.

I have calculated a little (or more) around the actual output from the emitters taking into account the degrading of output with temperature. There is quite a loss at full power.
I presume using a NANJG 101-AK with 1050mA for XR-E, 1400 mA for XP-G and 2800 mA for XM-L and that the LEDS reach about 125 degree C at full power. If DC was used instead of PWM one woud have to degrade also from the fall in efficacy with current.
That gives the following result if you want a doubling of light for each step:

XP-E Q5 at max 1046 mA:
Flux(LM) mA output code
191 1046 255
96 446 109
48 210 51
24 103 25
12 51 12,4
6 25.2 6.1
3 12.6 3.1
1.5 6.3 1.5
XP-G R5 at max 1395 mA:
Flux(LM) mA output code
341 1395 255
171 606 111
85 288 53
43 141 26
21.3 70 12.7
10.7 34.6 6.3
5.3 17.2 3.2
2.7 8.6 1.6
XM-L T6 at max 2790 mA:
Flux(LM) mA output code
629 2790 255
315 1127 103
157 527 48
79 256 23.4
39 126 11.5
19.7 63 5,7
9.8 31 2.9
4.9 16 1.4

Ofcourse you have to round the output code.

(corrected to PWM).

In "pwm" the current is pulsed at max with the given % duty cycle so it's close to a completely linear relationship. The cree graphs are for a steady current, not any waveform with given average current density.

I agree. In PWM the output versus current curve can not be used, only the point for the drive current, which leaves the degradation due to temperature. I will have to re-calculate for PWM. But linear it is certainly not.

I have now corrected the numbers in the former mail.

How are you assuming the junction temperature?

The assumption is that at full power the junction reach 125 degr.C. That of course depends heavily on the construction of the light. Perhaps 125 is a little too high looking at Don's measurements from turn-on until 2 min. (this looks more like 90-80% as for 100-120 deg.C)

The Cree curves output vs. current give the output at full current before degradation from temperature.

Using the Cree curves for nominal output vs. temperature I find the derate values at 1/4 - 1/2 - 3/4 - full power (AVG. current) corresponding to 50 deg, 75 deg, 100 deg and 125 deg C.
Then I use curve fitting to find the formula for nominal output vs. avg. current.
To find Lumens from this you just have to multiply with the actual bin's nominal Lumen output.

Now I just have to get my programmer board and clip and 101-AK to try it out.
Ebay and DX, come on!
Can't wait...

My drivers are stuck in pending at DX. Dammit.

But...Kinect computer drivers are out (no obfuscation over usb, it seems), so that's something very very cool to play with. $150 for probably the most advanced piece of equipment you can have in your house.

I just received three 101-AKs and a NANJG-106 from KD (took only 13 days from ordering to get to my doorstep!) and all of them are flashable.

Let us know if the NANJG 106 is really 2.8A as it should be. Also I know you will be flashing them, but it would be good to know how the modes are spaced by default and whether they can be changed by soldering to the stars. That could be a really great driver for P7's, MC'E's, and XM-L LED's.

I can't test if it really delivers 2.8A because I don't have any LED capable of handling such a current. It does have 8x AMC7135 in parallel, so it should be a able to regulate at 2.8A. I'll test the modes once I removed the 4 "spare" 7135.

I'm not convinced this will make a good MCE/P7/XM-L driver, as it can only be used with a single Li-Ion cell. There are also no buffer caps for the 7135, which are needed according to the datasheet.

Yes, it will run out of regulation rather fast and act as direct drive, only less effective due to the AMC's own voltage drop.

Hm, I think they may be only needed when used with a switching power supply?

I just did a quick test and the stars work just like they do on the AK-47. You get exactly the same mode groups.

One version of the datasheet states that a 0.1µF ~ 1µF buffer cap should be added to the output pin if the LED is not mounted on the same PCB. It's probably true that this will only have an effect if the supply current is not steady, but with PWM we're having a switching frequency of up to 20kHz.

I'm just a software guy, so when the datasheet strongly recommends adding this caps, I try sticking to it. Do we have an EE around here who could comment on this?

That is so awesome! Thanks for checking, Tido!

The capacitor is used to limit oscillations that can occour when switching large currents through inductive paths like a long wire. The oscillations produces voltages that could be destructive for the components and/or violates EMC regulations. EMC = Electro-Magnetic Compatibility. This concerns noise disturbance of other electronic equipment. A driver without the capacitor could make a "dirty" light.

The clip showed up today. Hopefully I'll get the USB stick soon and be ready to try this thing out. If I do a programmable UI, I'm thinking I'll set up 4 modes and set them L-H-L-H to start with. Then if I need a medium or a different Low, I can set that. But L-H-L-H will be like having a 2-mode light with an option for 4 modes.

All my stuff has arrived. I just can't find the time to test it the first few days

I got my programmer today, but I'm not having any luck yet. I downloaded WinAVR first, then Eclipse C/C++ and configured it using instructions here:

http://interactive-matter.org/how-to/developing-software-for-the-atmel-avr-with-avr-eclipse-avr-gcc-avrdude/

But when I tried to get the settings from the device, I got an error. So then I started using AVRdude to see if I could read the chip and I don't think I'm getting a connection. I don't know if it is the driver or the clip, but I get one message when I have a bad connection (same message I get when I don't even connect to the clip) and another when I am connected, but it still can't seem to find the chip. I'm using USBasp as the programmer which I guess is right for the thing I got from eBay.

There is a jumper on the board that I am leaving in place. Also, I hope I didn't fry the board but one time I was grabbing it and my finger was across the 3 resistors near the USB jack and they felt very hot or maybe even shocked me. Also I guess it is okay to pull the programmer out of the USB port whenever I want? And I can connect or disconnect the flashlight driver while it is plugged in? Also does it matter which way the clip is attached? I've tried both ways to make sure I'm not clipped upside-down.

This is the no connection error (programmer has a green LED lit, a red LED flashes briefly when I send this command):

C:\>avrdude -c usbasp -p t13

avrdude: warning: cannot set sck period. please check for usbasp firmware update
.
avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.


avrdude done. Thank you.

This is the other one I get when I seem to have the clip on the chip correctly (green light is off):

C:\>avrdude -c usbasp -p t13
avrdude: error: could not find USB device "USBasp" with vid=0x16c0 pid=0x5dc