Flashlight Firmware Repository

2227 posts / 0 new
Last post
ToyKeeper
ToyKeeper's picture
Offline
Last seen: 8 hours 20 min ago
Joined: 01/12/2013 - 14:40
Posts: 10301
Location: (469219) 2016 HO3

ImA4Wheelr wrote:
I just don’t trust my sense of timing.

That’s what the metronome is for. Smile
chouster
Offline
Last seen: 5 months 4 weeks ago
Joined: 02/20/2014 - 15:05
Posts: 690
Location: germany
ToyKeeper wrote:
To fix LVP, I think you’ll need to make it change the PWM level directly instead of changing the mode index. It kind of assumes that the modes go low to high, but that won’t matter if you cut the PWM in half each time it needs to step down.

Thanks ToyKeeper. Looks like I have to figure out how to do this. By the way, is it possible that the LVP inside star_noinit doesn’t work as it should when you change the mode direction to high->low? I just swapped the 1 and -1 of mode direction in line #194 and #196, but that should make no difference to soldering star 3.

ImA4Wheelr
Offline
Last seen: 1 day 13 hours ago
Joined: 02/03/2013 - 14:51
Posts: 7931
Location: SC

TK wrote:

ImA4Wheelr wrote:
I just don’t trust my sense of timing.


That’s what the metronome is for. Smile

Sounds like a tool for a professional.  My luck I would just get hypnotized and not realize my driver has a short.

 

EDIT:  Finished the 3rd driver.  Worked great.  Seems like measuring capacitance of the OTC is a decent way to get reliable results when the LVP resistors are kept stock.  By the way, I really love your BLF-A6 FW.  I'm big on momentary switch lights.  But I have to admit it, it feels like using a momentary switch.  And the UI is really great.  Who knew so much could be done with just one button.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 8 hours 20 min ago
Joined: 01/12/2013 - 14:40
Posts: 10301
Location: (469219) 2016 HO3
chouster wrote:
ToyKeeper wrote:
To fix LVP, I think you’ll need to make it change the PWM level directly instead of changing the mode index. It kind of assumes that the modes go low to high, but that won’t matter if you cut the PWM in half each time it needs to step down.

Thanks ToyKeeper. Looks like I have to figure out how to do this. By the way, is it possible that the LVP inside star_noinit doesn’t work as it should when you change the mode direction to high->low? I just swapped the 1 and -1 of mode direction in line #194 and #196, but that should make no difference to soldering star 3.


It’s definitely possible that LVP won’t work with a different mode order. I haven’t really tested the various flavors of STAR very much. I’ve been meaning to go through every project and LVP-test it then add the results to the meta files, but I only got through a few before I got distracted…

As for modifying the PWM level directly… it’s easy in solid modes, not so easy in blinky modes. Basically replace the stuff about mode_idx with something about PWM_LVL. Like, if (PWM_LVL > 10) { PWM_LVL = PWM_LVL >> 1; } else { PWM_LVL = 0; and the sleep_mode stuff }

That should make it cut power in half each time it needs to step down, then eventually shut the light off. The double angle brackets do a bitwise shift to the right, which has the same effect as dividing by two.

bugsy36
bugsy36's picture
Offline
Last seen: 1 week 4 days ago
Joined: 07/11/2014 - 18:15
Posts: 2475
Location: Florida USA

ImA4Wheelr wrote:

TK wrote:

ImA4Wheelr wrote:
I just don’t trust my sense of timing.


That’s what the metronome is for. Smile

Sounds like a tool for a professional.  My luck I would just get hypnotized and not realize my driver has a short.

 

EDIT:  Finished the 3rd driver.  Worked great.  Seems like measuring capacitance of the OTC is a decent way to get reliable results when the LVP resistors are kept stock.  By the way, I really love your BLF-A6 FW.  I'm big on momentary switch lights.  But I have to admit it, it feels like using a momentary switch.  And the UI is really great.  Who knew so much could be done with just one button.

NO KIDDING!! One hell of a job she did Smile

It's the simple things that we take for granted that cost us the most

Ευκαιρία λέει πιάσε με από το μέτωπο γιατί μόλις έχω περάσει δεν θα με πιάσειs

chouster
Offline
Last seen: 5 months 4 weeks ago
Joined: 02/20/2014 - 15:05
Posts: 690
Location: germany

Thanks again, ToyKeeper, I really appreciate your help. I’ll give it a try.

vestureofblood
vestureofblood's picture
Offline
Last seen: 17 hours 58 min ago
Joined: 08/17/2012 - 15:21
Posts: 1893
Location: Missouri

I am trying to use the start off time firmware for a 2 mode light with a twisty tail cap.   The problem is I cant hardly twist this cap fast enough to get the mode to change.   How would I edit the firmware to have the window where the mode changes be open longer?

In Him (Jesus Christ) was life; and the life was the light of men. And the light shineth in darkness; and the darkness comprehended it not.
http://asflashlights.com/ Everyday Carry Flashlights, plus Upgrades for Maglite.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 8 hours 20 min ago
Joined: 01/12/2013 - 14:40
Posts: 10301
Location: (469219) 2016 HO3

I think the value you’re looking for is CAP_THRESHOLD.

You can either guess what value to use, or measure it by flashing ToyKeeper/battcheck/offtime-cap.hex . Basically, turn it on, turn it off, wait the amount of time you want to measure, and turn it on again. It’ll blink out the value it read from the capacitor, which can then be plugged into other code.

bugsy36
bugsy36's picture
Offline
Last seen: 1 week 4 days ago
Joined: 07/11/2014 - 18:15
Posts: 2475
Location: Florida USA

Nice trick. Sneaky girl you are. Smile

It's the simple things that we take for granted that cost us the most

Ευκαιρία λέει πιάσε με από το μέτωπο γιατί μόλις έχω περάσει δεν θα με πιάσειs

vestureofblood
vestureofblood's picture
Offline
Last seen: 17 hours 58 min ago
Joined: 08/17/2012 - 15:21
Posts: 1893
Location: Missouri

Thanks TK Laughing

A lower number will give me a longer window right?

In Him (Jesus Christ) was life; and the life was the light of men. And the light shineth in darkness; and the darkness comprehended it not.
http://asflashlights.com/ Everyday Carry Flashlights, plus Upgrades for Maglite.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 8 hours 20 min ago
Joined: 01/12/2013 - 14:40
Posts: 10301
Location: (469219) 2016 HO3

Yes, a lower number is a longer amount of time. The capacitor drains while it’s off, following a curve similar to 1/x — quickly at first, then slower and slower and sloooooooower.

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

So we know that heat can affect OTC timing with certain divider resistors, can heat also affect the LVP itself?

I’m using blf-a6. I tested values with my power supply and battcheck, then rechecked with an actual battery when stuff started acting weird.

This is what’s happening:

If I keep the light out of turbo, LVP steps in at about 3.1v (where i set it). When the light is hot, LVP seems to step in at 3.6v. I turn the light on turbo, the timer steps it down after 60 seconds, and it will stay on medium with no problem. But if I immediately bump it back to turbo, it lasts 5 seconds, then drops to medium for 5 seconds, then drops to low and stays there. It never drops to moon or shuts off. When i take the battery out, it’s right at 3.6v. If I wait for the light to cool down and put the same battery back in, it will work fine as long as I don’t use turbo.

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

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 8 hours 20 min ago
Joined: 01/12/2013 - 14:40
Posts: 10301
Location: (469219) 2016 HO3

I think the temperature may affect some other things too, but I haven’t been able to get it to do anything weird on purpose except for the OTC timing differences.

Battery voltage sag might be a factor too, but I don’t think it explains the whole story. I wonder how I might be able to control temperature for some voltage+heat tests…

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 8 hours 20 min ago
Joined: 01/12/2013 - 14:40
Posts: 10301
Location: (469219) 2016 HO3

pilotdog68 wrote:
I turn the light on turbo, the timer steps it down after 60 seconds, and it will stay on medium with no problem. But if I immediately bump it back to turbo, it lasts 5 seconds, then drops to medium for 5 seconds, then drops to low and stays there. It never drops to moon or shuts off. When i take the battery out, it’s right at 3.6v. If I wait for the light to cool down and put the same battery back in, it will work fine as long as I don’t use turbo.

That sounds a lot like battery voltage sag. The repeated step-down is probably LVP, but then the voltage recovers far enough that it won’t reach its shut-off point for a long long time. I suspect that it would stay on medium if bumped back up after low has been running for a while. It may also depend on changes made to the code, but it’s hard to say for sure.
pilotdog68
pilotdog68's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 05/30/2013 - 23:31
Posts: 6420
Location: Held against my will in IOWA, USA

You think it’s sagging half a volt? This is with a Samsung 25R at about 6amps. I’ve had some other funny stuff happen with blf-a6, but since nobody else reported it I just assumed it was hardware related. Just for the sake of more information I’ll try repeating tests with other firmwares.

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

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 8 hours 20 min ago
Joined: 01/12/2013 - 14:40
Posts: 10301
Location: (469219) 2016 HO3

pilotdog68 wrote:
You think it’s sagging half a volt? This is with a Samsung 25R at about 6amps. I’ve had some other funny stuff happen with blf-a6, but since nobody else reported it I just assumed it was hardware related. Just for the sake of more information I’ll try repeating tests with other firmwares.

I have a Roche F6 with a real-time green/orange/red voltage indicator, and when I run it at the highest mode (25R cell) I’ve seen it sag by half a volt. A full charge can sag into the orange range within seconds on turbo, but it recovers soon after I turn the level down.

If you’re taking the cell out before measuring its voltage, it has probably already recovered quite a bit during the seconds it takes to get the cell out. And if it’s a high-amp cell, there isn’t a lot of capacity left at 3.6V. It will sag really easily at that level, much more than it would sag when full.

During normal use, I see the indicator flicker quickly from green to orange when it’s about half full, even with a lowpass filter on the ADC readings. I can actually tell the voltage pretty well by the relative time spent at each color, since at first it blinks orange only a little but it gradually gets more orange and less green. The results tend to be pretty noisy, so on the battcheck firmware it averages quite a few samples for each readout. I wonder if you might be seeing step-down too soon due to noise instead of actual sag.

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

Hmm very interesting. I guess I didn’t realize it would sag that much.

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

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

pyro1son
pyro1son's picture
Offline
Last seen: 3 weeks 5 days ago
Joined: 03/21/2013 - 08:18
Posts: 432
Location: UK

Just a quite question. How difficult would it be to change BLF-A6 to work with momentary switch?

Pastebin                                      &nbs

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 8 hours 20 min ago
Joined: 01/12/2013 - 14:40
Posts: 10301
Location: (469219) 2016 HO3

pyro1son wrote:
Just a quite question. How difficult would it be to change BLF-A6 to work with momentary switch?

It would require a complete rewrite. Clicky switch code is structured very differently than e-switch code, and has very different requirements and techniques to make things work.

However, I’m hoping to get some bigger MCUs soon and start on a combined clicky-switch / e-switch firmware based on blf-a6.c and Ferrero_Rocher/Ramping_UI_table.c .

pyro1son
pyro1son's picture
Offline
Last seen: 3 weeks 5 days ago
Joined: 03/21/2013 - 08:18
Posts: 432
Location: UK

Ooo now that sounds interesting.

Pastebin                                      &nbs

jack-bkk
Offline
Last seen: 1 month 1 week ago
Joined: 04/15/2015 - 01:29
Posts: 436
Location: Bangkok

this BLF A6 driver is it possible to copy or flash it to any attiny13 IC or to any nangj 105 driver like 8*7135 or the likes ???

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

Yes, but you’ll need an off-time capacitor, and it won’t work properly without the second PWM channel. You’ll need to move the modes to all be on the same channel if you want to put it on a Qlite or Nanjg (it is very simple to do)

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

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 8 hours 20 min ago
Joined: 01/12/2013 - 14:40
Posts: 10301
Location: (469219) 2016 HO3

What pilotdog68 said.

Yes, sort of. BLF-A6 expects to have an offtime capacitor (which nanjg drivers don’t have), and it also would need all its modes adjusted in order to work with only one power channel. You would also have to calibrate a bunch of hardcoded values for things like voltage and button timing and PWM levels, but I include calibration tools in the firmware repository.

If you can’t modify the driver hardware, you might want to look at other firmwares tagged with “ontime” or “mem decay”. Check the INDEX file to find these tags.

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

This discussion originally started in the X6R thread if you want to read or respond there: http://budgetlightforum.com/node/38998
TomE was helping a ton but maybe some other people can chime in so I don’t feel like I’m pestering him too much. Smile

The the X6R is a rechargeable clicky+eswitch light with the charging circuit separate but stacked on the driver, so a driver swap is possible. The tail clicky has to be ‘on’ to complete the circuit while charging.

I am going to use STAR dual-switch, but I would like the driver to know when the charger is connected and set PWM to 0 while charging, then turn the light back on when the charger is disconnected. I figured I could use the unused pin (#3?) for this. What can the I/O pins on a 13a measure? Can I just airwire that pin to the 5v power input? I assume the actual code for this would be very simple, but I dont know how to do it.

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

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 8 hours 20 min ago
Joined: 01/12/2013 - 14:40
Posts: 10301
Location: (469219) 2016 HO3

pilotdog68 wrote:
I am going to use STAR dual-switch, but I would like the driver to know when the charger is connected and set PWM to 0 while charging, then turn the light back on when the charger is disconnected. I figured I could use the unused pin (#3?) for this. What can the I/O pins on a 13a measure? Can I just airwire that pin to the 5v power input? I assume the actual code for this would be very simple, but I dont know how to do it.

Interesting question. I don’t have a verified answer yet, but I expect it should be easy if you find the right part to connect a wire to. Smile

I hope it can be detected as a simple “open” or “closed” circuit like the e-switch, but I’m not sure if the charging circuit will have a part which behaves that way. And it’ll be a while before I have the hardware to poke at.

At the very least, I’ll have to make sure the light can be turned off via e-switch in order to allow charging to work correctly. Or ignore the charger entirely. I had otherwise been counting on the tail switch as a power on/off control.

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

So i’m trying to “add memory” to STAR momentary for my X6R. I looked at STAR dual-switch and STAR momentary side-by-side in diffchecker, and I found this at the end of the DS FW that was not in the momentary FW

Quote:

if (mode_idx != last_mode_idx) {
// Save the new mode
last_mode_idx = mode_idx;

I tried putting that in the same place in momentary and now the firmware literally just does nothing.

Any ideas as to what I should try next?

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

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 8 hours 20 min ago
Joined: 01/12/2013 - 14:40
Posts: 10301
Location: (469219) 2016 HO3

Are you trying to make it remember after power has been disconnected, or remember after the e-switch has turned the light to “off” mode?

In the former case, adding memory will involve making it read/write the mode in eeprom. Check the “store_mode_idx” and “read_mode_idx” functions in the base STAR code. Calling store_mode_idx is the only thing which will allow it to remember the mode across power disconnects.

In the latter case, it may be a little more complicated. There’s a lot happening in parallel through interrupts, and the UI logic there is a bit fragile. The main loop isn’t likely the right place to add e-switch memory.

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

I was speaking of the former. Thanks, very helpful

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

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

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

TK, is BLF A6 LVP configured around 19.1k and 4.7k resistors?

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

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 8 hours 20 min ago
Joined: 01/12/2013 - 14:40
Posts: 10301
Location: (469219) 2016 HO3

pilotdog68 wrote:
TK, is BLF A6 LVP configured around 19.1k and 4.7k resistors?

It is calibrated for the last driver sample from Manker. The resistor values alone don’t seem to be a reliable way to get the right LVP values. You’ll probably need to actually calibrate to your individual driver with battcheck.hex (and an adjustable power supply or some math).

If you use battcheck to get a reading at a low voltage (near 3.0V) and a high voltage (near 4.2V), I can send you the hardcoded voltage values to plug in to other firmwares. I made a script to calculate those, called battcheck.py, here. To use it, edit voltage-example.txt with your measurements (only two are needed, one high and one low), then run “battcheck.py voltage-example.txt”.

Pages