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

Hmmm... Yes... that would make sense. I think it said that there are no blinky modes in programmable? I'm trying to set up a dedicated camping/tenting/trekking light and it would be nice to have some kind of SOS or other distress signal.

Soldering was actually not very hard. If you have someone to push enter, you only need to solder those 4 pins. That's what I did. My soldering skills are not so good that I would tried soldering those 4 pins on the upper side of the chip. It would have been one messed up driver after that. What I did was solder only the corner pins, which is no big deal, and then write (or copy/paste from flashlight-wiki) the command needed to command prompt. Then I stick the remaining 2 pins to the driver legs with my bare hands and ask the wife to come and push enter. Sorted :)

I need to get me one of those. The dogs are absolutely useless at that kind of thing.

Lol... Wife is not exactly a budget item, that's for sure. But it can be done without one. I've tried it with success but it's quite a hassle. You have to put the driver with all the leads on top of the keyboard, near the enter (well, depends on the keyboard you're using but that's the case with my laptop). Then connect the last two pins while not pressing hard enough for any other keyboard buttons to engage and try to hit the enter with your pinky. It's difficult and requires some precision. But after the wife has gone to bed saying something like "that's just stupid, go to bed, you have work day tomorrow and it's already 1 AM" there's really not many options but to cope with it.

More proof that too much internet makes you think in strange ways. The first thing I did after reading that sentence was to check whether budgetwifeforum.com was already registered.

I flashed the programmable today. Now I'm one step closer to my dream light.

One problem. I can't get the nomemory-function to work. I have defined it on lines 44 and 92, yet the light still remembers the last mode it was when turned off. How can I disable it for good? And seems that it's 3 modes, even when I have defined NUM_MODES 4 and also edited line 192 accordingly. And I can't seem to get the SOS to function. Strobe, police strobe and beacon are there, SOS is not.

But, even with these minor flaws, it's closer to perfect light than anything I can buy from any store or online. So big thanks to Tido and others for making it possible, and giving so good instructions that even noob like myself can successfully flash chips and program modes and do all kinds of HC stuff.

The predefined build settings 'Programmable', 'Fixed' and 'Simple' will override any configuration set in the block of #defines above. Those are reasonable default settings that will produce a driver image fitting into the ATtiny13's 1k program memory. If you want to build with your own configuration, you'll have to use 'Default' as the built option.

I got to test my Bridgelux LEDs last night on an integrating sphere light meter. Their raw output is spot on to the specs (try that with a Chinese LED). Unfortunately, you do lose about 25% of the light in the beam forming reflector and front glass.

Nyt huudetaan! (a Finnish shout of joy, often used when we score against Sweden in hockey)

I finally got the driver to work as I want. I don't actually know what I did, but it involved editing Tido's code in AVRStudio and some crazy amount of pin soldering and unsoldering (see my posts above). As I have no idea how that code or programming in general work it took some trial and error but it was worth it. Now my camping light is officially perfect. 4 modes including SOS. No memory so I don't have to worry about blinding myself if it was on high last time I used it. Starts with crazy low, which must be like 0,00something lumens as my 4Sevens Quark in moonlight seems like a car headlight compared to it and the Quark is ANSI rated as 0,2 lumens. Still enough to read map or navigate in dark indoors. Then low, high and SOS. Or, being programmable, If I don't feel like needing the SOS I can change it to 4 constant modes in couple of clicks from tailcap. This is the best thing ever. I'm at loss of words.

That's great news! Congratulations on getting everything working the way you want. I think that's the great promise of Tido's programs and why I haven't given up on the whole concept despite a few setbacks.

I got my brown clip in from eBay. I had a hard time getting a connection with the chip on the driver, I'm not sure why. It seems better made than the blue ones, but not as easy to line up with the leads from the chip. I was able to flash a new program into the chip eventually, but when I attached a spare LED to test it out, I got nothing. No light whatsoever (LED works; I checked). At one point in trying to communicate with the chip AVRDUDE gave me some kind of error about the fuses being reset to 0 and did I want to reset them. I think I said no because the command to upload the program already includes fuse settings, but I think the chip may be burned out. Or I could have burned out the chip with some bad soldering, but I checked everything I could for shorts and continuity and couldn't pin anything down. Seems like if there was something wrong with the chip that AVRDUDE would let me know.

That was my last spare driver, so now if I want to try anything I will have to take a driver out of an existing light. I did just this with my Mr.Lite BLF-Y4E but when I saw the board and tried to hook up the clip, I remembered reading about a capacitor or something in the way. I repaired the inductor that I accidentally knocked loose and the light still works at least.

I may order some new drivers. Still not sure how I will be able to rewrite and compile the BLF-VLD to get my "perfect" light: 2-mode with a programmable Low (no sense in programming High; I think having 1 programmable mode should make things a lot easier), but can't really play around with it until I get a driver connected.

If the fuses are erased, the chip won't start up on its own and therefore can't be programmed via the serial protocol any more. You would need a high voltage programmer to revive this one.

I'm not familiar with C so wanna ask for help. How can I change total number of modes in group? For example, I want to have less then 9 constant modes in extended menu, I removed unnecessary "MODE_LVLxxx", left only 3, but when switching through the modes, I still have to cycle through disabled six modes, difference is diode doesn't light up on them. And can I change the order of modes in extended menu? I'd like strobes to go first, then constant modes

Good question and welcome to BLF! I'm still trying to figure out Tido's program too, so I can't give you an answer. Hope that someone will chime in.

To change the number of modes in the extended group, you will have to change the '#define NUM_EXT_MODES 12' accordingly. You can reorder the modes by re-arranging the order in the array 'const uint8_t EEMEM eeprom[64]'.

If you delete mode-lines, you will have to adjust the array size accordingly (4 bytes per mode), otherwise the compiler may complain. But the best way to "remove" modes is to move the ones you want to the front of the array and set NUM_EXT_MODES to their number.

Tido Aha! That really works :) Thank you! And is there a way to start extended mode not from mode# 0x00, but from another one? To start extended mode from strobes

No, but you can just re-order the array so that the strobes are in front.

But in this case main mode would start from strobes too, and since I have only 2 modes in it, it wouldn't be very useful to have both of them strobes :) or there is a way to set different order of modes for main and extended?

The main group consists of indices into the extended group, you can't have modes in main that are not in extended. Let's take a look at the configuration array:


const uint8_t EEMEM eeprom[64] =
{   0x00, 0xFF, 0xFF, 0x00,
    0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00,
    // initial mode programming, indices to mode lines in the following array
    0x03, 0x06, 0x08, 0x00, 0x00,
    // mode configuration starts here. Format is:
    // offset in mode_func_arr, func data1, func data2, func data3
    MODE_LVL001,    // 0x00
    MODE_LVL002,    // 0x01
    MODE_LVL004,    // 0x02
    MODE_LVL008,    // 0x03
    MODE_LVL016,    // 0x04
    MODE_LVL032,    // 0x05
    MODE_LVL064,    // 0x06
    MODE_LVL128,    // 0x07
    MODE_LVL255,    // 0x08
    MODE_STROBE,    // 0x09
    MODE_POLICE,    // 0x0A
    MODE_BEACON     // 0x0B
};

The main group is configured by the line:


    // initial mode programming, indices to mode lines in the following array
    0x03, 0x06, 0x08, 0x00, 0x00,

These are offsets into the extended group. The first mode is at offset 0x03 (MODE_LVL008), the second is at offset 0x06 (MODE_LVL64) and the third is at offset 0x08 (MODE_LVL255). The fourth and fifth slot are not used because NUM_MODES is set to 3. If you re-arrange the modes in the extended group, you will have to adjust these indices.

Oh, that's my bad, I just forgot about this line. So, I start the extended mode from strobes and arrange main to start from constant - that's what I needed so much from bicycle light. 2 constant modes with option to adjust brightness of "low" and hidden police strobe. Great respect Tido for your work, chinese engineers never would make something as exciting :) Only sad thing that ATTiny13A has as low as 1kb of memory, that is not enough for battery mon and programming, but that's I can stand with

edit: Redundant. :P