Mod - GarryBunk's SecurityIng HD-016 (It's Finally Done!) - Pic Heavy

I'm totally fine with this. I don't need all three lit, just some indication that the battery pack is getting low. Would be nice if indication was in two steps: 1) 10% battery (or whatever is most appropriate) and 2) flashing indicator LEDs and either dropping output to low or shutting off. I would plan to change battery at the first indication so the light cutting off during a ride probably wouldn't happen.

-Garry

^ Thank you for the idea wight. I'll have to think on that.

I trust you on the theory (goes over my head), but I'm initially concerned about more components/complexity. It increases the risk for problems and future failures. Do you have any rough guess how much power this circuit would consume?

Fair enough. It’s not like I’ve built and tested one. There’s a lot of “I think” and “should” in my suggestion. :wink:

As far as how much power would be consumed… I think sub 1mA, maybe waaaay below 1mA, but I don’t know and I’m not super confident. (I think that the IC cannot supply more than 75mA, so it should be safe to say that it would consume less than 100mA or something no matter how wrong I was about the rest.) In any case it should not be enough to affect battery life and in the most likely case the big drain will be keeping a 10-20mA LED lit.

Would it be easier to convert the power bank to parallel, bypass the stock MCU entirely (don’t even power it up, or the other stock components), and use only two of the three power indicators? That way, there’s no need to buck the voltage, no need to sync anything with the original MCU, and most common firmwares should “just work”.

At that point your longest regulated runtime likely comes from switching to a linear driver as well (eg Nanjg-105c).

EDIT: switching the battery config doesn’t free up any MCU pins anyway.

I need/want to keep this light working with a standard 2S2P battery pack.

-Garry

Switching the battery config doesn’t free up any pins, but it does make most of the complexities disappear. I’m not a fan of complexity. However, I’m not doing the hardware so it’s not my call. :slight_smile:

The same battery capacity and runtime should still be available; it would just be four cells in parallel instead of 2S2P.

I'm with ToyKeeper regarding complexity. I think we are on the verge of making a really nice light, but there is something much bigger than that I think we are creating. So far, we don't have a viable DIY driver/FW solution that provides true thermal and series cell voltage protection. It seems this build will provide a blue print for our board designers to add these much sought after protections with buck. Modern emitters are more voltage hungry and series seems needed for the foreseeable future. The thermal and voltage divider circuits on this driver are simple and elegant and can be used for DD too. We, however, can not pull this off without assistance from ToyKeeper. I'm more than happy to do all the measuring and tuning to make the hardware and software merry.

So my preference is to ditch the stock MCU and pursue using only the Attiny and ToyKeeper's FW. If she is able to a squeeze in using the indicator LED's in some fashion, we should consider that icing on the cake.

From a firmware point of view, voltage monitoring is easy. The hard part is dividing it to a usable range and then calibrating the actual values needed on the internal 8-bit or 10-bit scale. Er, and the other hard part is fitting more than one battery into a flashlight. It’s all about the physical build and circuitry.

Thermal step-down shouldn’t be too difficult (again, after build concerns and calibration), but we start to run into limitations on the attiny13 in terms of ROM space and switching the ADC channel. Especially on e-switch lights, since handling that takes a lot of room. As is, only 174 bytes are left.

JonnyC has been trying to put together a solid firmware with both voltage and temperature monitoring, and last I heard he is seriously considering requiring an attiny25 instead so there will be enough ROM to hold the code. Everything is do-able, just very hard to fit into 1024 bytes.

It’s also a bit difficult for me to ensure anything works without having the relevant hardware. You may have to do a lot of tweaking and calibration.

I'll do the best I can if you are game. I certainly don't want your time to be wasted and you seem to appreciate the same for me. We just need Garry's agreement to proceed.

Garry,

I'd like to say that pulling off thermal protection (not faux turbo timeout) and voltage monitoring with series cells is not a small feat. Adding another MCU to the mix creates more potential problems and potential failure points. I recommend making the indicator lights optional (hopefully, they can be worked in some hobbled form) and ditching the stock MCU.

To me, FW is the critical factor as there is very limited space in the Attiny13a. So I will do my best to work with whatever you and ToyKeeper want to do.

I'm fine with ditching the stock MCU. I'm also okay if you can't get the thermal protection to work and just keep the turbo timeout. I'm also okay if the voltage monitoring is hobbled down to just one of those LEDs flashing or something like that. I'm at your and TK's mercy as to what you all can pull off.

-Garry

Sounds good. Thanks Garry.

TK,

Sure you know, but just in case. The Thermistor circuit drops voltage to the MCU as it warms up. So I'm getting assuming it decreases resistance with heat as it is between ground and the "R1" of the voltage divider. It makes sense that is should work about like voltage monitoring from a FW point of view. Not sure if you can use the existing voltage monitoring and use an "Or" type clause. I think step down reading will likely be in the 60's.

No sure if turbo timeout takes up much space. If it does, real thermal protection seems like a better safety measure. Ideally, I'm guessing Garry would like to have both in place.

Finally, if you are able to include code for a voltage indicator output pin, the indicator LED's are hardwired to 5.19volts positive. The MCU appears to provide ground via a 470 ohm resistor. I could rewire them if you need them set up the other way around.

For some reason, I can't get the indicator emitters to light up when I take them to ground directly. They test fine with a DMM. I don't know what to make of that.

Cool. I can just invert the value then.

What I was thinking is to do something roughly like setting the maximum PWM level to 255 minus the difference between some hardcoded value and the actual thermistor value. This way, it would ramp down smoothly and gradually above a certain temperature, and step back up just as gradually when it cools off. The scale might need to be multiplied or curved or something, but it seems like the concept should work.

The goal is something similar to ZL’s “PID” thermal controls, which behave like this (but less advanced):

Low voltage, though, should just use the standard approach found in STAR. When low, step down. If it’s already at the bottom level, warn and shut off.

Not really. The attiny can only measure one at a time, and it’s asynchronous, so it needs a bunch of extra logic just for switching back and forth between the two ADC channels. Plus, low voltage logic never steps back up.

I agree, both would be redundant. Thermal protection will use more ROM space than turbo timeout though. We’ll have to see what will fit.

It’d be nice if we could just replace the standard attiny13 with attiny25 chips in all the common drivers. Twice the ROM space, and since half the space gets used for overhead it means like 1500 bytes to play with instead of 500.

I have no idea. I’ve only done voltage indicators once, and the circuitry side of things was already fully taken care of. I just had to do the measurement and logic in the firmware.

This is just a guess, but I would assume that the attiny’s output pins run at the same voltage as its power source, so whatever the buck is feeding the attiny. It can run at up to 5.5V though, I think, which should be enough. And to control how much power is fed to those indicator LEDs you’d have to insert appropriate resistors along that path; the attiny can only turn it on or off. I don’t recall off-hand what the default attiny output pin current is, but you’ll almost certainly need to reduce it for indicator light use.

Guys, don't want to break out your brainstorming flow to much, but I have an idea for my usage only leaving stock MCU in place as is. First to resume what we have in stock form. As I understand it (I might be wrong) we have three circuits parts: 1 controling/user interface and 2 power controling for each led.

Now, my idea is to put both leds in parallel on both power controling circuits parts. Leaving everything else as is I'm assuming we can get modes like 50%, 50% 100%, strobe. This of course is not very usable, but if I change sense resistance in the circuits to get: first 1/3 and in second 2/3 of desired power. Then I think we can get modes 33%,66%,100%, strobe.

This would be just fine for my usage leaving all other features (voltage indicators, thermal protection) in place. Not the best as would rather have strobe hidden and bit different mode spacing, but it's usable.

Can someone look if this mode is possible? Resistor mod is trivial to me, but putting leds in parallel is in question electricaly. Phisicaly I can just connect two black wires and we are done .

What do you think?

TK,

All that sounds good to me. I have no problem if you wish to go with a Attiny25. I believe I could use the same equipment I already have. I would just need to specify Attiny25 in Atmel Studio when first setting up your FW. I would need to order some 25's.

I will play indicator leds to see what gets them to work. It sounds like they must have some internal protection that blocks current when voltage is too high.

ledoman,

Interesting idea. I don't know enough about electronics to answer your question. It sounds like it would work. I have paralleled drivers before to increase current. I didn't have any of the drivers off though. So I don't know if there would be any kind of back flow issue. On this driver, I think you would have to connect both the positive leads and both the negative leads to each other to make it work.

Thanks, will wait what others have to say. Since hopefuly there is no PWM, just on/off, I expect no intereference between power circuits. Hopefuly!

I should mention that I don’t actually have any attiny25s or the tools needed to swap one out on an existing driver. I’m just basing my guesses on the usual difficulty getting everything to fit, plus JonnyC’s comments that he is having trouble with exactly the same features. I know I’ve had to pull some dirty tricks to make things fit into 1024 bytes in the past…

I can probably use a lot of what JonnyC already wrote, but I haven’t looked at the details yet.

^ I can only imagine how creative one has to get squeeze code into such a small space. Just let me know if you do decide to go with the 25. I would need to place an order for some. I'd do my best to test code since you wouldn't be able to do the same with actual hardware.

I wonder if I should just get a hot air gun.

Or I found a BLF member selling nanjg drivers with the MCU replaced, but they’re $15 each plus $5.50 shipping. For the price of three, I could probably get a hot air gun and a few attiny25s and be able to upgrade arbitrary drivers.

Hot air guns are great to have for all kinds of things. I find that even the cheapest ones work fine for reflowing.

Not sure if you would be interested in the conversation that I trying to start here.