Flashlight Firmware Repository

Both. Your voltage divider must also read directly from the input source, since reading after the zener diode will always give you the zener diode's voltage.

@TK i hope this question fits here if not, please someone direct me where this is more appropriate :slight_smile:

I have been thinking about if you only want a nice low moon/max of one 7135 chip/and full blast DD in a driver, do we even need an FET for this?

Couldn’t the attiny13a simply connect the battery to the led & and shut down the 7135, similar like what DrJones did in his “Glow” driver

But instead of a glow mode from “An additional 100k resistor bypassing MCU and AMC7135s, while the MCU switches the 7135s off” you do the same but without the resistor to get full DD on one channel & a nice regulated 7135 on the other.

And another idea :slight_smile: if you don’t want/need the max possible output from the FET driver PWM level 255 for max amps, could you lets say start at a lower percentage, for example PWM level 128 and then pseudo regulate this so that when the volt drops & amp drops it automatically raises the PWM level to get a stable regulated output from a FET driver?

I’m trying to get LVP working on an MTG2 build.

I am using 22kohm as R1 and 2.2kohm for R2. I ran TK’s battcheck with my power supply at 6.2v and it spat out a value of 136, and 130 for 5.9v.

I plugged those into STAR offtime, flashed the driver, and reconnected my PS.

I started at 6.4v and slowly lowered the voltage and…… nothing happened. I let it run at 5.5v volts for about 5 minutes and LVP never kicked in.

I reflashed and retested again with the same results.

I gave up and put batteries in the light to use it that night, and immediately LVP kicked in. I removed the batteries and checked them, they’re both at 4v.

Any ideas what’s going on? Do I need to set my PS to a higher current?

DD directly through the attiny would blow it in no time. Remember: V=IR (think of the attiny13a as a VERY high resistance switch).

To fully regulate current you need a sense resistor (with additional losses), but you could alter PWM based on battery voltage as well (I think that someone has already tried this).

Were you measuring the power supply output with a multimeter? If the current is set low, then the voltage will automatically drop down to the voltage needed to maintain that maximum current.

I think that's beside the point though, since your values are in the ballpark. Your batteries might be sagging down to the LVP level.

I have checked it’s accuracy with a DMM, but not at the time I was doing this. The ‘Constant Voltage’ light was on at the time. I don’t think it’s battery sag, because it kicked in on low mode ~350ma.

I was using a FW that previously had LVP disabled, so maybe I messed with it more than just commenting it out and don’t remember now. I’ll retry but starting with a stock FW this time.

edit: just redid the battcheck with dmm this time, and got the same values.

So I started over completely, and it still isn’t working correctly.

I decided to disable LVP, I’ll just be careful with this light.

Hey there.

I’m using TK’s BLF-A6 firmware wherever I can so I can get familiar with at least one program. It worked great with Wight’s FET + 1 (using both channels). I fine-tuned it with Battcheck. Offtime didn’t need any tinkering as it was right on even though it doesn’t have a pull-down resistor. I found where it checks for memory, and set it to on. I gassed everything in the hidden mode, save for battcheck. I didn’t test parasitic drain after LVP shutdown.

Then I installed it on Wight’s 22mm 16X1735 single-channel driver. The only thing I had to change was to put battcheck on the first PWM channel and put values on the lower main levels as they were zeroes. It was reassuring that the battcheck firmware blinked out values within 1 of the FET + 1 driver from 4.2 down to 2.7 volts on the Fluke.

I have a couple questions:

I had a hell of a time with offtime medium presses on the 22mm 16X driver. I started at 470K on the pulldown resistor. I ended up using 910K, and medium presses were still too quick. So I loaded TKs Offtime_Cap firmware. A fast press gave me the expected 255, and medium presses gave me values of 156, 144, 148 and 140. The firmware was set to 190, so I changed it to 140, and everything is working. Given the values I got, was 140 the correct value to enter? Should I have entered a lower number to capture longer presses? How low can I go and still recognize the 156 press?

Next, I tested the LVP. Everything went fine, with the light throttling at 2.8 volts and going dark at ~2.75 volts. With the light dark (but still on), I put the Fluke on amps, and measured 270uA coming from the battery. That seems high, as the 13A’s datasheet shows the draw at 190uA when active, and 24uA when idle. Is there a way to get this 270uA down? Maybe the unused second PWM channel is doing something?

Thanks

I tried the medium press thing, including several different OTC values, and just can't get into it. If it's not on a momentary switch I don't want medium presses because I can't consistently do it without some sort of feedback. It's also a pain to get things consistent between different drivers and parts. I can see someone doing it for that "one light" they use a lot and become really accustomed to, but for lots of lights it's a huge pain in the butt. It's a cool idea, but just not one that in practice I really like. Of course, that's just my opinion, and everyone else is entitled to theirs.

~200uA is about par for the course if the attiny isn't sleeping, plus you've got the voltage divider draining a few uA no matter what, and probably the pulldown resistor putting a drain on things if the MCU isn't going to sleep.

That’s me and moon mode and/or a bazillion levels. Just give me 3-4 well-spaced levels—like mode2 in the A6 firmware.

I didn’t care about medium presses either until TK came out with on-board battcheck, which is accessed with a medium press. Battcheck is a really nice feature IMHO.

Edit:

I sure can see where setting up drivers for medium presses in a production environment would suck. Get the OTC/pull-down resistor (if applicable) close, flash offtime-cap, get the right number, program it in, flash battcheck, verify the numbers, modify the c file, compile the hex file, flash, test. Tedious to be sure, but what you end up with is a means to access hidden modes and useful features like battcheck, bike strobe, etc.

Do you suppose there is a need out there that I can fill?

Sorry, I don’t really do hardware. :slight_smile:
(and this was already answered above)

Yes.

I actually did this already in my “cypreus” firmware, only it uses the technique to pseudo-regulate moon mode instead of turbo… and it uses PFM instead of PWM. But the basic method is still roughly the same. Feel free to try it, modify it, etc.

I haven’t actually tested STAR much, only the derivatives I’ve made. It sounds like the MCU is getting useful voltage readings, but either the power supply or the firmware is doing something unexpected.

It was already mentioned, but for LVP tests I have to leave the amps cranked up to force CV mode instead of CC mode. I’ve never had any issues getting results this way, so I get the impression it’s more likely the firmware… especially since the batteries behaved strangely.

Also, it was brought to my attention today that I forgot to tag projects with LVP to make them easier to find. So, in the near future I’m hoping to go through each project and actually test the LVP so I can tag the ones where it works. It might take a little while though…

I also had the amps high enough to be in constant voltage. On my second try I used blf-a6 instead of STAR and ended up with the same result: LVP kicks in at 8v, but not 6v.

This is a strange one... Some backgrond first. The battcheck numbers look good but a little low, are you measuring voltage at the power supply or at the driver? Does the LVP ever kick in? Do different modes affect the LVP? Is this a zener mod? Is there a cap across the zener (Vcc to GND)?

Gotta run be back tonight.

It is a zener mod. The LVP never activates when it is running off the power supply. I have measured voltage both at the driver and the power supply. No cap on the zener.

What do you mean by kicks in at 8V but not at 6V?! That seems counter-intuitive.

Do I also understand that the LVP always kicks in on batteries, but never on the power supply?

What the heck is going on?

Have you tried running battcheck with the batteries rather than the supply?

To me it seems there may be a bad connection that causes the LVP to see a low voltage, perhaps only during heavy load. (I'm grasping at straws here...)

I’m away for the weekend so I can’t do more tests right now, but yes.

I ran it off the power supply, and slowly decreased voltage from 6.5v down to 5.5v and let it run there for a couple minutes. LVP never kicked in.

I put in 2 batteries, at 4v each, and within seconds it started ramping.

Those OTC values look totally fine… it’s actually in the desired range, while the BLF A6 driver I have is unusually high. It sounds like 140 should work if that gives you the timing you want, but I’d probably go lower. The way I measure it is to half-press for about half a second, check the value, and use that for CAP_SHORT. Then I’ll half-press for about 1.5 to 2.0 seconds, check the value, and use that for CAP_MED. This gives me a reasonably wide window for medium presses so I can count “one one-thousand” in my head and let go and reliably get the medium press action.

The CAP_* #defines are the edge boundaries, not the center of the target. Any value above CAP_SHORT is a short press. Any value between CAP_SHORT and CAP_MED is a medium press. Anything below CAP_MED is a long press. So, if I understand correctly you might want to set CAP_SHORT to ~180 and CAP_MED to ~120 to increase the error margin. On a nanjg with OTC, I use 200 and 100. Your values of 140 to 156 fall right in the middle, which is a good thing.

As for post-LVP power usage, I’m not sure. I thought it would be lower than that since the code invokes power-down mode, but it sounds like RMM knows more about this and you should listen to him. :slight_smile:

Ok nice, interesting i might do that if i ever get around to start flashing my own attiny’s that is :slight_smile:

Yes 270uA does seem high, make sure you're testing it with your Fluke correctly. Connect ammeter to measure current. Set the Fluke to uA scale but place a jumper across the meter inputs (this shunts all the current around the meter), turn power supply ON and reduce voltage to the point where LVP kicks in. When the light goes out remove the jumper from the meter input (do this carefully so as not to open the circuit) and you will be reading "OFF state" current.

The ATtiny should be in 'power down' sleep and drawing only 1 or 2 uA, the ADC voltage divider however will still be drawing 103 uA. (2.75V / (22,000ohms+4,700ohms) = 103uA) If you're still reading 270uA look for another problem. Perhaps the ATtiny isn't sleeping.

For zener mods OFF state current can be 6,000uA! (assuming 6.2V battery, 5V zener and 200 ohm resistor).