Flashlight Firmware Repository

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.

I got some DD+7135 boards from OSH Park. So I ditched the old DD boards I modded but was having troubles with. The new boards are working, but I need to fine tune the OTC a little more. Boy TK, I totally see why you recommend tuning the OTC because it totally makes a difference in the UI's performance. Once I got it close, the program was a joy to use. Before that, it was frustrating. I probably would not have had to tune at all if I had known the my supposed 1uF caps were not actually 1uF. They are around .7uF. So I used 2 parallel caps and things got much better. I would not have discovered my caps were underrated were it not for this FW.

I'm curious. This may have already been discussed and I apologize if it has. 1uF seems a tad too big a cap. The stock FW threshold is pretty high at 190. I'm hoping to try like a cap that is about 2/3rds the capacitance and change the FW threshold down to around 140 (just throwing out a guess). Maybe will even try .5uF and then change the FW threshold down to around 95 (another guess). Has anyone done any work in that regard yet? If yes, what did they find out?

The cap isn’t the only thing which affects that. The voltage divider resistors seem to have a pretty big effect too. Ideally, you should try to tune the hardware so that the OTC decays to under 100 within 3 seconds or so, but that’s easier said than done.

In any case, I have to calibrate the OTC for every driver I use, because I’ve gotten them from a variety of sources and each one is a little different. The method I ended up using for best results is to use a metronome at 120bpm and take the average of several samples.

http://toykeeper.net/torches/blf-a6/offtime/

To save time and avoid shipping delays, I also had to teach Manker how to run these tests… which was interesting since we don’t speak any of the same languages. So, I ended up making a wordless video to demonstrate the process.

^ That sounds like quite and effort and challenge.

Tonight, I used just one cap that is measuring about .688uf on a DMM. Set the FW to 140 (from 190). It works so good and reliable that I am going to pass on running the off-time FW. I have 2 more to tune. I may not be as lucky and will run the off-time FW on them if needed. I just don't trust my sense of timing. I will measure and match the capacitors to help ensure success.

Maybe someone can make a spread sheet to see if a pattern develops. Something like this:

Capacitor Diode FW UI Performance

Measurement in LVP R1 R2 Threshold & Reliability

.688uF ? 19K 4.7K 140 Excellent

1.37uF ? 19K 4.7K 190 OK

That’s what the metronome is for. :slight_smile:

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.

TK wrote:

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


That’s what the metronome is for.

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.

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.

NO KIDDING!! One hell of a job she did :)

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

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?

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.

Nice trick. Sneaky girl you are. :)

Thanks TK

A lower number will give me a longer window right?

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.

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.

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…

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.

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.