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

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?

That's bad news. PICs are a different platform and need their own hardware for programming. Besides, the instruction set and I/O ports are totally different, so a port would likely end in a complete rewrite.

I got my last delivery from KD a few weeks ago and they where the best batch I ever had (good voltage divider and a low drop Schottky diode for polarity protection). You should try to get your money back from DX and order these instead: http://www.kaidomain.com/ProductDetails.aspx?ProductId=10996

Can anyone guide here:

Do I claim my money back through PayPal right away or the more polite way, write to DX (do they answer at all).

Well, it depends. I used to take the polite way of trying to settle things without resorting to threats. But given the last run-in I had with DX's customer support...

Give them a chance to rectify the situation, but file a dispute as soon as they start haggling. If you get the "We can give you $2 store credit, but that's all we can do" reply, you know what to do ;)

Tido, I programmed the same program into the BLF AA-Y4E as I did to the AK-47 board, but in the AA-Y4E it only starts up in the first level and do not react to tapping. I tried to remove brown-out detection in high fuse but it did'nt help. With brown-out detection the light flashes a few times (fast) at each start-up and is then steady.

Can you think why it does'nt react on taps as the AK-47 board? (I have re-fitted the two components that were removed to make space). I suspect it has something to do with slow rising and falling of the voltage to the ATtiny due to the PAM 2803 (but nkildal's BLF AA-Y4E worked).

It sounds like the buffer cap keeps the µC running for too long when the light is switched off. Are you sure you re-soldered the components correctly? Looking at the last picture nkildal posted, the black parts on the left of the µC look like diodes. The lower one seems to be part of a voltage monitoring circuit, which would help draining the cap. If you soldered it back the wrong way around, the cap would be isolated from the circuit and retain its charge much longer.

The diode was unsoldered in one end only. It comes (with kathode) from pin 2 on tiny13 in parallel with a 100kOhm. Where they end I have not found out yet. Perhaps the tiny13 is active in draining the capacitor?. The upper diode feeds the tiny13 pin 8 from VOut on the PAM2803. The only thing I changed from the original SW was the timing (PWM appr. 1 kHz, ON appr. 15 us in lowest mode). The PWM seems to work fine all the way to the LED's negative end, only the tapping, slow or fast, does not work.

The voltage to tiny13 collapses in about 10msec so it is unlikely that the watchdog should count for 2 sec

I'm afraid that I have destroyed the solder pad under one end of the capacitor near pin 4 on tiny13. If that is the reason for malfunctioning then I apologize, Tido.

Now I have no idea of where that capacitor goes to, I can't see the trace disappearing under the tiny13. nkildal, do you by any chance have an BLF AA-Y4E open so you can help me out?

Edit: I think I have found it - it goes to the end of the diode and 100 kOhm from pin 2 on tiny13 where I found no connection before!

I'm at work right now (probably shouldn't be following the forum then :-) ) but I would be happy to investigate it, as soon as I get home.

I'm happily retired, so I can do what I want, but I know your problem Wink. As I added in my previous post I think I found it but thank's anyway, now let's see what happens:

Nothing!. Re-connecting the condenser did'nt help.

Perhaps I should try the hex-files that nkildal got to work. Can you mail me them, nkildal?. Then I could see if it's a HW or a SW problem.

Yep - I will send them to you, as soon as I get home...