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

You can set the following in driver.c (line 48-50):

#undef EXTENDED_MODES      // enable to make all mode lines available
#undef PROGRAMMABLE        // user can re-program the mode slots
#undef PROGHELPER          // indicate programming timing by short flashes

Then go into the "Default" directory and do your build there.

Edit: I think we cross posted :-)

Or you could also choose to change how the "Fixed" version is built, by just editing the lines 188 to 193 to your taste:

#ifdef BUILD_FIXED
#undef PROGRAMMABLE
#undef EXTENDED_MODES
#undef PROGHELPER
#define EXTENDED_MODES
#endif

That's the one I had in mind

What voltage is the battery you are using? With my fuse settings, the µC would trigger a brown-out reset at 2.7V. Adding another 0.6V for the drop across the protective diode, your battery would have to be at or below 3.3V.

To build a driver without the extended modes group, just use the "Simple" configuration.

In this case It was a power supply, set to 4.0 V.

After enabling the prescaler in software and using 0x6A and 0xED for fuses the light is now almost perfect. Even the click response got better than before. The PWM frequency is about 260 Hz and there are no flickering to see. It is a 4 level, Simple model with outputs: 200 - 50 - 12 and 3 Lumen. There are almost proportionality between output and battery current so 1 Lumen costs about 5 mA in this light which is an Ultrafire WF-502B with R5.

Now I plan a bigger modding-event (strobe-killing) when my drivers arrives from DX, eventually.....

I have visions of you racing around the countryside hunting down strobes and killing them. ;)

I am totally on board... what do we use? Shotguns, dynamite or nukes? ;-) Death to all strobes (and low PWMs)... I don't even go in clubs and disco's any more... lol

sixty545, could you write up a small summary on which configurations you used and how well they worked? I'm a bit confused by all the information fragments scattered throughout the thread so far . The report about the light not turning on with the brown-out detection set to 2.7V got me a bit worried.

Has anyone played around with the programmable version of the driver yet? I'd really love to hear some opinions about the UI.

Is this related to Lumens-hunting (poor Mr. Lumen)?

No not yet - I would love to give you some feedback on the programmable version, but my BLF AA-Y4E board suddenly died last night (not related to your driver).

I am now waiting for some DX & KD driver boards to arrive so I can continue experimenting :-)

I went through a fast series of experiments and did'nt write them down in a protocol. I used this thread as a sort of protocol. I will not be able to recall the history of combinations (them old grey cells....) but I can try changing the brown-out bits again the next time I'm gonna program and then check if the light will start-up on the 4V power supply.

I'm trying to understand the button click functioning and timing, there are still too many non-reaction-clicks, I could use some hints here.

I found that the low frequency of PWM I have now, makes the digital lightmeter and the multimeter show varying values - I will try setting the CKDIV8 bit in low fuse back to 1 to have a faster frequency again but keep the divide-by-8 in software, let's see how that turns out.

Don't worry more, Tido. I tried the high fuse 0xEB again and this time it started fine. I must have had a broken power lead the first time .

I found out that a PWM period of about 1 msec is a good compromise between problems with narrow pulses (giving less than expected light) and problems with digital measuring instruments showing non-steady readout. I used 4.8MHz oscillator, clock divider = 8 (CKDIV8 = 0 ) and Timer Divider TCCR0B=1 (as in the original SW). Thus the low fuse is 0x69 and high fuse 0xEB.

The algorithm is quite simple. On start-up the program checks if the last time the light was on, it was on for more than two seconds (let's assume this is true for now). It then stores a marker in eeprom, saying that this time it was turned off after less than two seconds. Then it starts a timer and goes on setting up the light. This marker is removed after two seconds have elapsed.

Now let's assume that the light has been switched off before the marker has been removed. When the light is switched on again, the program finds the marker in eeprom and knows that it is supposed to change the mode.

So, you can only change the mode within two seconds after turning on the light and the power has to be off long enough to cause a shut-down or reset of the µC. If you want to change the mode after more than two seconds run time, you first have to tap once to start the two second timing and then again to actually change the mode.

Thank's, I think that really explains what happens.

Looking in the program I found this, are there writings to the eeprom all the time the light is on or am I missing something:

// write back state to eeprom but omit the mode configuration.
// Minimises risk of corruption. Everything else will right itself
// eventually, but modes will stay broken until reprogrammed.
eeprom_write_block(&state, 0, sizeof(State_t) - sizeof(state.mode_arr));
eeprom_busy_wait();

That would eventually destroy cells in the eeprom.

Not really.

Lumens are for capturing - they even get released outdoors.

Strobes are for hunting down and doing bad things to. Like soldering with a 500 amp welder. That works.

Or cutting up with a chainsaw...

or.......

:)

Yes, every time the light is switched on, the eeprom is written to. Given the 100000 write cycles per cell guaranteed by Atmel, you could click the light a hundred times per day and it would still take almost three years before that number is reached.

That number used to be two or three times lower with the older releases, as the cell used for recognising mode changes was written up to three times whenever the light was turned on. Femto over at http://www.taschenlampen-forum.de/ pointed this out to me and I have since added a wear levelling algorithm to alleviate this problem.

OK, I know about eeproms durability, but that was not really what I ment. For me the code seams to be repeated in loop inside main(), but I can understand that this is not the case - can you clarify for me why it only run once?

NO NEED! I got it!

while(1)
;
* mode funcs do not return, so this is never reached.

Hey, this is great stuff. I'm tempted to get some gear and start playing around. Modes are clearly a bit of a sore point on a lot of budget lights.

Do you guys think that there's any chance that these 13.5mm boost drivers from KD could be programmed? http://kaidomain.com/ProductDetails.aspx?ProductID=11063 unfortunately the pictures arn't detailed enough to really see the chips but the mode controller looks similar.

There is no way of telling from the pictures whether these use an ATtiny or a Pic. Since the Pic is more commonly used in driver PCBs, it is not really likely.

The only commonly available boost driver with an ATtiny I know about, is the NANJG-112A. But sadly that one seems to have been discontinued.

ALARM!

I just got my 4 pc. of sku7612 after 33 days from DX.

They were NOT! 101-AK as I ordered, but AK-47C. I thought that this was OK as I programmed an AK-47 earlier.

BUT THIS ONE HAS A PIC 12F629 PROCESSOR WHICH I CANNOT GET IN CONTACT WITH.

They have the 4 stars as normal for AK-47. The bags they were packed in are marked 2007612.

They were ment for programming the BLF program. I guess I have to make a complaint about this or are we going to do PIC's also?

Anyway the Strobe-killing event is off for a while... (sorry, Don and Vectrex).

Anyone else got one of theese?