Flashlight Firmware Repository

Thanks for the help! Let’s see how well I follow what you said…

-

The reason a number different than 255 was used for ‘Turbo’ is so that we would still have 255 as a valid option on the main PWM channel without triggering the FET. Can the end goal still be accomplished with 245 as the shortcut?

-

As far as Pin3 not being switched off anywhere, I know it switches off in normal mode cycling, but are you saying the language (on line 602) of stepping down to the second-highest mode wouldn’t automatically turn off pin3?

-

So you’re saying that the entirety of line 544 should be just “DDRB |= (1 << FET_PIN);”

instead of

“DDRB = (1 << PWM_PIN) | (1 << ALT_PWM_PIN) | (1 << FET_PIN);” ?

I don’t follow that at all, but I’ll make that change if you think it will help overall.

There is always a way :).
I assumed the FET has to turn on when you are in mode 4/4 or 7/7. When does it turn on? I do not see it happening in the code…

Yes, it will switch off in normal mode cycling (or, more correctly, not turn back on as the mode is being set up after each boot). But you will need to add some logic to have it turn it off after the turbo time-out - if required.

Yes. The shorter code sets the PWM_PIN pin for output, without messing with the other bits in the DDRB register. It is just shorthand for DDRB = DDRB | (1 << FET_PIN). The current code does keep the two PWM outputs alive while activating the FET output, but does not take into account that the OTC pin is also set for output somewhere else in the code. That may, or may not, give weird long press/short press detection.

When does it happen in the code? I have no idea… pyro did that :wink:
that code that I linked is what pyro sent me. I changed the mode levels for testing. What i’m using is this:

On the driver I have it set up with one 7135 on the small circuit, 3 on the bigger circuit, plus the FET. With my little power supply I can see what kind of power the driver is pulling to tell what’s happening. As I cycle modes I see it go ~0.38A -> ~1.1A -> 2.0A (psu limited, it’s the FET)

Ok that makes sense to me. Now, what do I need to add for that to work and where do I need to add it?

I don’t really understand most of that, but one thing stuck out to me. Where/why is the OTC pin set for output anywhere?

I'VE BEEN AWAY ooops, I've been away for awhile and you guys are now working on something with a fet. I'm lost but I intend to catch up.

OK, that explains why the FET was actually turning on. The output variable does get to be 245 (in mode 3) - Forget what I said above about 245/255. Just add something to switch it off after turbo timeout and you should be good.

Some boolean gibberish :), as per the earlier post:

It sets the I/O port register bit related to FET_PIN to zero, without disturbing the other bits of the register. Basically you AND the register with a word that consists of all 1’s, except for the bit you want to turn of.
E.g. XXXXXXXX & 11111011 = XXXXX0XX, where X = bits that are any value and that we do not want to touch.

The OTC pin is only in input mode briefly during boot to check its residual charge. After that it is set to output, and high, in lines 501/502 to keep it charged. Line 544 inadvertently sets it back to input.

Ok, I’ve added that to line 602 and it didn’t seem to do anything. I also tried it after the “save state” command before the ending curly brace, and I tried using ‘0’ instead of the ‘1’. Any more thoughts? Maybe I’m just putting it in the wrong place?

Here is the current version of the code”:http://pastebin.com/YgA2jqhC I’m working with.

Hi PD,

Looking more closely at the bigger structure, that ‘if…then’ in 600-606 in will never execute, it is blocked by the the ‘if…then’ in lines 542-546.

Will need to rework the program structure a little…will get back to you!

Thanks for your help! If it makes any difference, either stepping down to the previous mode or stepping down to a pre-set value will work for turbo. Idk if that would be easier to get working.

With some hints I can look at the code and kinda figure out what’s going on, but I don’t know the language well enough to write the code myself.

So I have tried to browse the code and I think I missed it, but is there an adaption of the BLF A6 firmware for single PWM driver, like the BLF17DD/A17DD-SO8 etc?

Apologies If I missed it, I know much of the code works with those driver, but I really like the A6 software and would love to use it on my other lights.

OK, back at the computer and reworked the code a little.

You can try this:

I moved the ON+OFF control for the FET pin to the set_output function in line 377.
This is a little cleaner than patching it into the main.

It compiles (does not fit on a Tiny13 with my compiler), but I do not have a convenient way to test it. Just let me know if it is not exactly what you need.

It should work as is, just adapt the levels for the 1st PWM output to what you need.
By default they are 0 for the lower levels.

Look for these defines around lines 119 and 129 respectively:

First one contains the levels for the 7-mode group, the other for the 4-mode group. Change the zeroes to useful levels.

As far as I can tell at this point, everything is working perfectly. I’ll of course report if I notice anything weird with more use. For me it compiled at 93% of capacity for the 13a. Thanks so much! My S8 can finally get a new heart :wink:

TK: I feel this would be a good one to add to the repository. It is so far the only one that works with my TripleDown driver boards.

Ahhhh I see how you’ve done it. Very clever.

:slight_smile:

HELP!!!

I’m having issues flashing. Over christmas I upgraded my PC to Win10 and since can no longer flash firmware. I have tried different USBasp driver but I’m getting this message:

avrdude: verifying …
avrdude: 250 bytes of flash verified
avrdude: reading input file “0╬75”
avrdude: invalid byte value (0╬75) specified for immediate mode
avrdude: read from file ‘0╬75’ failed

Can anybody help?

Run it from a virtual machine

Tried flashing with AVRDudess (GUI for AVRDude) and I’ve not got the error message. Will find out how well this has worked on thursday

I have a problem with one of the eight fet + 1 drivers that i built. All of them are running the blf a6 firmware but one driver i can’t get to the soft config mode (blink where i have to select the 2nd group and memory mode). It just continuously goes to the next mode after 15 or more taps. I don’t know if it’s a bug in the firmwware but all of my drivers are using the same firmware and this is the only one that is having that problem so maybe not firmware. May it’s the mcu? or the otc?

I´m searching for a FW similar to TKs STAR_momentary (which I use atm), but with the possibility to switch off faster. I believe I will like dth_Momentary_v1_1 but I need also dual PWM output.

Any ideas?

BTW I´m not familiar in programming, just able to change mode values and flashing to driver.

Thanks for your help!

And yes, I didn´t read the whole thread… :wink:

It’s not difficult to change STAR (not TK’s btw) so that a long(er/ish) press goes to off instead of going backwards. That’s what I use. Short press always goes forward, long press from off goes to turbo, long press from on turns off.