Flashlight Firmware Repository

2231 posts / 0 new
Last post
LightRider
LightRider's picture
Offline
Last seen: 2 years 2 months ago
Joined: 08/05/2015 - 09:52
Posts: 2007
Location: U.P. MI, USA

i have been preparing myself for using the triple down drivers for some lights to spot game at night. So I was thrown off a bit when I was asked to build some lights with red emitters. Anyway, I searched for some code for 7135 drivers that could be modified with an “off” mode as well as battery check mode. Ironically, the code I now have working is tk’s s7 firmware which is designed for advanced flashy modes. It now has five modes, off-low-med-high-battcheck, and memory is disabled. So from any mode I can turn the light off and then back on again without a “click”. I’ve found the click from a tailcap switch to carry quite far in the still of the night. I will be curious to see if this is helpful or not.
Thanks to tk and the other firmware builders!

pyro1son
pyro1son's picture
Offline
Last seen: 2 months 1 week ago
Joined: 03/21/2013 - 08:18
Posts: 432
Location: UK

I’m after a bit of help. I have a MTG2 light which is causing me a bit of a headache. The LVP kicks in really early, I have the right voltage dividers and I’ve tired getting the readings with TK’s firmware but they just don’t seem to be right. I suspect its down to the voltage drop when the light is pulling high currents. Is there anyway that I can get these readings while there is the voltage drop?
Thanks

Pastebin                                      &nbs

Mike C
Mike C's picture
Offline
Last seen: 2 months 1 week ago
Joined: 01/22/2014 - 08:03
Posts: 2486
Location: Sweden

pyro1son wrote:
I’m after a bit of help. I have a MTG2 light which is causing me a bit of a headache. The LVP kicks in really early, I have the right voltage dividers and I’ve tired getting the readings with TK’s firmware but they just don’t seem to be right. I suspect its down to the voltage drop when the light is pulling high currents. Is there anyway that I can get these readings while there is the voltage drop?
Thanks

Does the firmware you use have some sort of voltage readout ability?

I did some testing with storing the voltage value under load in the no init area and then retrieving it on readouts. It worked ok but I found it rather useless for my purposes. Now I have it so that when boost mode is active the LVP step down kicks in at critical voltage level, not low voltage level.

pyro1son
pyro1son's picture
Offline
Last seen: 2 months 1 week ago
Joined: 03/21/2013 - 08:18
Posts: 432
Location: UK

No I don’t have a readout on the firmware I’m using but willing to look into those that do as it is driving me mad. It makes the light unusable as it just steps down as soon as it get into a high mode.

Pastebin                                      &nbs

Mike C
Mike C's picture
Offline
Last seen: 2 months 1 week ago
Joined: 01/22/2014 - 08:03
Posts: 2486
Location: Sweden

What MCU are you using? If it’s 13a based I can’t help much with code, I haven’t touched that little thing in a long time and have no code for it left.

Another thing that might be affecting your readings: The internal 1.1v reference voltage is different on each MCU. Datasheet specifies it can be between 1.0v and 1.2v. Normally it’s very close to 1.1v and nothing needs to be done, but I have had the odd MCU where it has been at the very limits. This caused readings to be off enough that I wrote a calibration routine.

May I ask what driver you have, and what the values of the voltage divider resistors are?

pyro1son
pyro1son's picture
Offline
Last seen: 2 months 1 week ago
Joined: 03/21/2013 - 08:18
Posts: 432
Location: UK

I have some 85s that I can use. Currently using 13 on Wights 22mm DD+single

I can’t remember the values I’m using off the top of my head, I can look later.
Thanks

Pastebin                                      &nbs

Mike C
Mike C's picture
Offline
Last seen: 2 months 1 week ago
Joined: 01/22/2014 - 08:03
Posts: 2486
Location: Sweden

If you have a working 85 firmware that has some sort of readout function it could be modified to write the voltage value to EEPROM or no init area. I can give small tips on how to do that but I won’t make a whole flashable firmware as my hands are full with getting my own firmware ready.

I have no experience with Toykeepers firmware so I can’t really help with those readings that appear wrong either.

fixed it
Offline
Last seen: 6 months 1 week ago
Joined: 12/08/2015 - 14:27
Posts: 396
Location: Canada

pyro1son wrote:
I have the right voltage dividers and I’ve tired getting the readings with TK’s firmware but they just don’t seem to be right.
Did you actually measure the resistors of the divider? What are the values? If you’re unlucky and they’re both 5% off in the wrong direction, you’ll get a reading about 10% off. That’s over 0.3V.

Also, what is the LVP set to in the firmware? I mean the actual ADC value (something around 100-120), not what the comments claim the voltage to be.

Which firmware are you running?

pilotdog68
pilotdog68's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 05/30/2013 - 23:31
Posts: 6420
Location: Held against my will in IOWA, USA

I’ve always had trouble with LVP on my 2S lights, to the point I don’t even bother anymore. I figured out the correct resistors to use (don’t have those values in front of me right now), then hooked up my power supply (which works great for 1S LVP) at 6v and recorded the values to put in the FW. The values were were right in the middle of the usable range, but without fail as soon as I assembled the light, the LVP would kick in at like 8v instead of 6v.

I suspected my cheap power supply was causing me problems so I bought a 6v lantern battery which I slightly discharged till it was exactly 6v, and used that to calibrate the values. It made no difference at all. I had this problem with 3 different drivers, different pcb designs, different value resistors, it never worked.

My Favorite Modded Lights: X6R, S8 , X2R , M6, SP03

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

pyro1son
pyro1son's picture
Offline
Last seen: 2 months 1 week ago
Joined: 03/21/2013 - 08:18
Posts: 432
Location: UK

Its most frustrating. I don’t want to be running an MTG2 on a FET without LVP

Pastebin                                      &nbs

pyro1son
pyro1son's picture
Offline
Last seen: 2 months 1 week ago
Joined: 03/21/2013 - 08:18
Posts: 432
Location: UK

-OK so I haven’t used this torch for a while and last time I powered it with 2x NCR18650B for long run time. This time I’m using 2× 30Q and I’m not suffering LVP problems, managed a whole 120 seconds turbo time (never happened before). So I guess the high discharge batteries don’t voltage sag anywhere near as much and that was the cause of my issue. -

Scrap that. Its defiantly better but they just got to 7.9v and now LVP is cutting in. I think I’m just going to have to do this on by eye.

Using the 2× 30Q has caused me another issue, the springs aren’t long enough now.

P.S. My ADC critical is 120

Pastebin                                      &nbs

pilotdog68
pilotdog68's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 05/30/2013 - 23:31
Posts: 6420
Location: Held against my will in IOWA, USA

If I actually used those lights for any real purpose it’d be a major problem, but since most of my lights are just to show off from time to time, I rarely let the cells go below 3.8v anyways. Still frustrating though.

My Favorite Modded Lights: X6R, S8 , X2R , M6, SP03

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

ToyKeeper
ToyKeeper's picture
Online
Last seen: 5 min 21 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10349
Location: (469219) 2016 HO3

pyro1son wrote:
I’m after a bit of help. I have a MTG2 light which is causing me a bit of a headache. The LVP kicks in really early, I have the right voltage dividers and I’ve tired getting the readings with TK’s firmware but they just don’t seem to be right. I suspect its down to the voltage drop when the light is pulling high currents. Is there anyway that I can get these readings while there is the voltage drop?
Thanks

Yes, open up battcheck.c and look for this part near the bottom:
    while(1) {
        PWM_LVL = 0;

This sets the output level it uses during measurement. Change that 0 to something higher, and you should be able to measure voltage under load.

Or you could turn off LVP entirely.

Or perhaps add a battcheck mode to whatever firmware you’re using, so you can check voltage without opening the light. It’ll probably be a little awkward at higher voltage though, since all the code assumes a voltage range of 2.5V to 4.4V. The easiest method is probably using the “4bar” or “8bar” style, with voltages measured from the actual light but cut in half for what the code sees. Like, if you measure an ADC value of 200 at 8.4V, you’d need to tell it that 200 is actually 4.2V to make it fit into the expected range. The relative full-ness meter should still work though.

I just got a thing which can measure current and voltage simultaneously, and tested it with a 2.8A Convoy light. My 20R cell measured at about 3.9V on moon mode but on turbo it said the voltage had sagged to about 3.4V. I’d imagine that a low-amp cell probably sags even more, but at the moment I can’t test it. Need to build a custom kernel for the thing before it’s working again.

pyro1son
pyro1son's picture
Offline
Last seen: 2 months 1 week ago
Joined: 03/21/2013 - 08:18
Posts: 432
Location: UK

Thanks. I didn’t know Batt check worked at higher outputs. I will be giving this a go later

Pastebin                                      &nbs

ToyKeeper
ToyKeeper's picture
Online
Last seen: 5 min 21 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10349
Location: (469219) 2016 HO3

The drawback to calibrating under load is that it could potentially make LVP useless. I mean, let’s say it’s calibrated for a 0.5V sag, with step-down or shutoff at 2.8V. The turbo mode would step down at a real (sagged) voltage of 2.3V, which might be okay. But after it steps down all the way, it wouldn’t shut off until the voltage gets down to 2.3V again, too low to be useful. So, it’d step down at an appropriate time on turbo, but it might try to stay on low mode until long after the battery is drained.

I haven’t tried it though. I’m not really sure what to expect. Be sure to test it before depending on it. Smile

ToyKeeper
ToyKeeper's picture
Online
Last seen: 5 min 21 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10349
Location: (469219) 2016 HO3

I made a thing. Haven’t tried it yet; will have to wait until tonight.

It’s a “goodnight” mode on my CNQG brass 18650 light. The idea is that it’ll provide light for about an hour then shut itself off (as much as possible). It’s intended to be ceiling-bounced from a night stand while going to bed.

More specifically, it blinks out the voltage (whole volts then tenths), ramps up from moon mode to low over a couple seconds, then ramps back down over about an hour, then shuts itself off.

If my measurements and calculations are correct, it should last about a year per charge. It looks like it’ll use about 8mAh per night, or about 10mAh if I forget and leave it “on” all day. On a 3100mAh cell, that works out to very approximately a year of runtime. This mode bypasses LVP though, so I made it blink out the voltage first to let me know when it’s about ready to be charged.

At the moment I have it in the main mode sequence between moon and low. So, it’s moon, goodnight, low, med, high, turbo, then all the blinkies. On other lights I’d probably put it a bit later in the cycle though, like just after battcheck.

Does this sound like a thing anyone else might find useful?

Joat
Offline
Last seen: 7 months 3 weeks ago
Joined: 06/13/2013 - 23:43
Posts: 523
Location: Minnesota

I could see replacing battcheck with it.
I could also leave off the blinking the charge level every time and instead give a few warning blinks when it under 50% then go to low, and if the cell is under 25% give the warning blinks and stay in moon.

ToyKeeper
ToyKeeper's picture
Online
Last seen: 5 min 21 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10349
Location: (469219) 2016 HO3

Joat wrote:
I could see replacing battcheck with it.
I could also leave off the blinking the charge level every time and instead give a few warning blinks when it under 50% then go to low, and if the cell is under 25% give the warning blinks and stay in moon.

In “goodnight mode” it doesn’t actually enter the part of the code which checks the voltage. It also never goes above the “low” mode, since it ramps slowly from there to moon. Then it shuts down into the lowest-power mode it can, which uses a small fraction of what moon mode uses.

Warning blinks could be useful, but it’s likely they might not be seen since the user is presumably trying to sleep.

So, basically, it’s already executing the LVP procedure… just a bit slower and smoother, and without actually checking the voltage. With an estimated 300+ full nights worth of charge per cell, and a voltage reminder before starting, I’m not too worried about it.

Anyway, it’s kind of a quick kludge I added to one of my personal lights. I’m wondering if it’d be worth making it more robust for others to use.

FmC
FmC's picture
Offline
Last seen: 2 months 1 week ago
Joined: 03/31/2013 - 05:23
Posts: 2197
Location: Brisbane, AU
ToyKeeper wrote:
I made a thing.

This is pretty cool, & would be very useful in a lantern.

Configurable sleep time would be nice to have as well.

Beer

LightRider
LightRider's picture
Offline
Last seen: 2 years 2 months ago
Joined: 08/05/2015 - 09:52
Posts: 2007
Location: U.P. MI, USA

ToyKeeper wrote:
I made a thing. Haven’t tried it yet; will have to wait until tonight.

It’s a “goodnight” mode on my CNQG brass 18650 light. The idea is that it’ll provide light for about an hour then shut itself off (as much as possible). It’s intended to be ceiling-bounced from a night stand while going to bed.

More specifically, it blinks out the voltage (whole volts then tenths), ramps up from moon mode to low over a couple seconds, then ramps back down over about an hour, then shuts itself off.

If my measurements and calculations are correct, it should last about a year per charge. It looks like it’ll use about 8mAh per night, or about 10mAh if I forget and leave it “on” all day. On a 3100mAh cell, that works out to very approximately a year of runtime. This mode bypasses LVP though, so I made it blink out the voltage first to let me know when it’s about ready to be charged.

At the moment I have it in the main mode sequence between moon and low. So, it’s moon, goodnight, low, med, high, turbo, then all the blinkies. On other lights I’d probably put it a bit later in the cycle though, like just after battcheck.

Does this sound like a thing anyone else might find useful?


I am intrigued. I often use my flashlights for this purpose. However, I usually is lights with a magnetic tail and an eswitch. Right now I’m using an Olight s30. This way it sticks nice to the metal on my night stand and I can still asp access the button on the side. Idk if this feature would be useful enough to sacrifice the side switch or not? I think it’s cool though.

Prior to the s30 I used the candle mode on one of dr jones rgbw drivers. I no longer have this light, but this would be a nice feature on lights with a candle mode as well.

ToyKeeper
ToyKeeper's picture
Online
Last seen: 5 min 21 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10349
Location: (469219) 2016 HO3

FmC wrote:
Configurable sleep time would be nice to have as well.

Hah, so far the delay mechanism is designed to be small, not configurable. Smile
It just goes through each PWM level from ‘low’ to ‘moon’, in order, and delays at each step for 255 seconds. Then it shuts off. When I checked last night I think that ended up being 49 minutes total, but I’ll probably reflash it to get it closer to 60 minutes.
Joat
Offline
Last seen: 7 months 3 weeks ago
Joined: 06/13/2013 - 23:43
Posts: 523
Location: Minnesota

ToyKeeper wrote:
Joat wrote:
I could see replacing battcheck with it.
I could also leave off the blinking the charge level every time and instead give a few warning blinks when it under 50% then go to low, and if the cell is under 25% give the warning blinks and stay in moon.

In “goodnight mode” it doesn’t actually enter the part of the code which checks the voltage. It also never goes above the “low” mode, since it ramps slowly from there to moon. Then it shuts down into the lowest-power mode it can, which uses a small fraction of what moon mode uses.

Warning blinks could be useful, but it’s likely they might not be seen since the user is presumably trying to sleep.

So, basically, it’s already executing the LVP procedure… just a bit slower and smoother, and without actually checking the voltage. With an estimated 300+ full nights worth of charge per cell, and a voltage reminder before starting, I’m not too worried about it.

Anyway, it’s kind of a quick kludge I added to one of my personal lights. I’m wondering if it’d be worth making it more robust for others to use.

I didn’t mean warning blinks during the running, I was thinking of that instead of the voltage reminder at the start.

Tom E
Tom E's picture
Offline
Last seen: 7 hours 58 min ago
Joined: 08/19/2012 - 08:23
Posts: 13030
Location: LI NY

Latest updates to Narsil released and posted. Details in this 25/45/85 thread post: http://budgetlightforum.com/comment/972129#comment-972129.

Sorry, but still feel I got more to go, but this version has a few good bug fixes, and some improvement tweaks to ramping..

 

MRsDNF
MRsDNF's picture
Offline
Last seen: 10 hours 30 min ago
Joined: 12/22/2011 - 21:18
Posts: 13332
Location: A light beam away from the missus in the land of Aus.

Thanks Tom. I should be able to have a go at it this weekend. Theres still not enough hours in the day.

 

djozz quotes, "it came with chinese lettering that is chinese to me".

                      "My man mousehole needs one too"

old4570 said "I'm not an expert , so don't suffer from any such technical restrictions".

Old-Lumens. Highly admired and cherished member of Budget Light Forum. 11.5.2011 - 20.12.16. RIP.

 

Tom E
Tom E's picture
Offline
Last seen: 7 hours 58 min ago
Joined: 08/19/2012 - 08:23
Posts: 13030
Location: LI NY

MRsDNF wrote:
Thanks Tom. I should be able to have a go at it this weekend. Theres still not enough hours in the day.

No prob! I know what you mean -- work pressure, backyard garden is in full stride, reviews, support, software, mod'n madness.

I feel like pull'n a quote from another movie, but no time.. smile

MRsDNF
MRsDNF's picture
Offline
Last seen: 10 hours 30 min ago
Joined: 12/22/2011 - 21:18
Posts: 13332
Location: A light beam away from the missus in the land of Aus.

Still house reorganizing. Tired

 

djozz quotes, "it came with chinese lettering that is chinese to me".

                      "My man mousehole needs one too"

old4570 said "I'm not an expert , so don't suffer from any such technical restrictions".

Old-Lumens. Highly admired and cherished member of Budget Light Forum. 11.5.2011 - 20.12.16. RIP.

 

FmC
FmC's picture
Offline
Last seen: 2 months 1 week ago
Joined: 03/31/2013 - 05:23
Posts: 2197
Location: Brisbane, AU

Is there a ‘ready to go’ firmware available for;

Attiny13 / FET+1 / e-switch?

Just searching now, but thought I would post the question as well.

Cheers Beer

-edit;

Looks like STAR_momentary version 1.6 should do the trick. Been a while since I built a 13a driver!

pilotdog68
pilotdog68's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 05/30/2013 - 23:31
Posts: 6420
Location: Held against my will in IOWA, USA

Alright guys, I need some help. Talk to me like I’m a total noob.

I am still using 13a’s, but I have found a few bugs in my version of blf-a6 that was adapted for Triple channel. So I figure now is as good a time as any to try bistro on a 25. I haev not even used the new system of config files or whatever they are called, I just alter the c file for every build and have a library of the ones I have used in other lights.

So, step by step, how do I configure bistro and flash to a 25, assuming I am already setup to flash hex files to 13’s?

My Favorite Modded Lights: X6R, S8 , X2R , M6, SP03

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

Texas_Ace
Texas_Ace's picture
Offline
Last seen: 16 hours 45 min ago
Joined: 03/24/2016 - 07:44
Posts: 8690
Location: Everything is brighter in Texas

Do you use linux or Atmel studio to compile right now?

Flashing the hex file is easy, exactly the same as what you are doing now, just with a command line change to the 25 instead of the 13A and the associated fuses.

Compiling is a bit different due to the extremely tight space constraints.

I have a hex file for bistro tripledown in the Texas Avenger thread that is setup for a 19.1K R1 that you can try, just make sure you get the correct fuse settings and command, I can dig the one I use out if you need.

The weather is supposed to cool down this weekend, hopfully it won’t be 90f in the house with 80-90% humidity and I will be able to work on the drivers a bit more. Gonna calibrate one for a 22k R1.

The nice thing about bistro is that since it has so many user adjustable settings you don’t need to adjust much on a light by light basis. Simply select a different mode group.

Tom E
Tom E's picture
Offline
Last seen: 7 hours 58 min ago
Joined: 08/19/2012 - 08:23
Posts: 13030
Location: LI NY

I use Win w/ATMEL Studio 7. I copy all the header files (.h files) into the same folder where the main source code is - much easier to track and control, for me that is... I've built Bistro successfully. I believe I have it all working fin under 1 solution with 1 project. I could ZIP up the complete Studio 7 solution and post it on my google driver, with the proper AVRDude BAT files, if you want -- when I get home - @work now.

 

Pages