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

^ 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.

Have you optimized the code enough? If you have based your code on Star there is a lot you can do. I’ve cut memory usage almost in half but still have the same functionality. Star is written for easy use and changing of modes and such, but can be optimized a whole lot to save space without changing functionality.

It depends. I’ve definitely squeezed a lot of extra features into the available space before, on other firmwares… There is a lot in STAR that I don’t need or care about, which helps. But in this case I don’t actually have hardware so I haven’t written much code.

I was surprised at how much memory could be saved from a few changes. Saved me from having to dig into ATtiny25 programming… for now at least.

I managed to fit 15 modes into 1024 bytes on an off-time based light, including a battery check mode and a bunch of different styles of blinkies and a pulse frequency modulated moon mode which smoothly self-adjusts its speed to compensate for decreasing voltage over time. And 2-level turbo stepdown and low-voltage protection. And a short/med/long button press UI.

So I might be able to fit everything into 1024 bytes for the light in this thread… I’m just not totally sure, and it’s hard to know until I have hardware to test on.

If there was more RAM, I could compress the code and fit even more… but attiny chips have nowhere near enough RAM to run a decompression engine and then store a larger program in memory.

Seems like you’ve done a lot of optimizing :slight_smile: I’ve got two individually controlled PWM channels with separate output pins, 8 individual modes per channel (each channel with it’s own mode memory), turbo timeout, low and critical voltage step down, short and long press UI (off time)… and still have room to spare… Not finished with it yet though, don’t need a total of 16 modes so I’ve got more space to work with if needed.

You don’t need any hardware to see if it fits, AVR Studio tells you how large the end result is after compiling.

Oh, I have the size calculation built into my build script. The question is whether the code actually works. I can easily make it small enough if it doesn’t have to work. :slight_smile:

In theory, practice and theory are the same. But in practice… well, not so much. Code is all theory until it’s running in its intended environment.

Yeah, I couldn’t get anything done without the hardware. It’s just that wrote you where not sure if it would fit, guess I misunderstood that a bit. Of coarse you can’t be sure of the size until it’s all been tried and tested, I know that all too well :slight_smile:

Regarding Attiny 13a vs 25, I'm not sure what all in involved with converting the FW over, but part of my thought process if I was a programmer would include the following:

  • The Attiny13 has been a challenge memory wise for quite some time. It probably has hobbled more than one programer.
  • The 25 is superior to the 13 and uses the same foot print.
  • Programing time will be needed to squeeze into the 13. This same time could be used to convert to 25. This time could be thought of as an investment into taking drivers to a new level going forward.

I’ve got a few of the 25s at home, and also a few 85s, but I wasn’t forced to use them as I just finished my head light project code (as described above) and it weighed in at exactly 1024 bytes! :bigsmile:

However, I’ve been looking at the datasheets for them both and comparing. I think it could be done rather easily. I just don’t have one of those component layout test boards (or whatever they are called) to test them. My 13a programming has been tested on Qlite boards, and I’m not that keen on attempting to replace the MCU on any of them. I’ll be getting one of those test boards though, and might dig into it then.

Has anything been decided about the hardware, like which MCU will drive the indicators? Where is the voltage coming in, and is it getting divided to a standard range? In general, how is the hardware turning out?

I think the decision was:

  • Remove the stock MCU entirely.
  • Attempt voltage monitoring AND temp monitoring.
  • Drive one or more of the stock indicators using the final remaining pin on the ATtiny. (EDIT: together, as unit. So just make them operate together and maybe turn on solid for low, then blink for critical… or something.)

Hardware is the stock driver (pictures in Post 16) with the MCU pulled. Here is a schematic of everything but the 2 build-in buck drivers. I will adjust the voltage divider resistors initially and again after testing, if needed. I can also adjust the FW to fine tune LVP.

LED's 3, 4 & 5 are voltage indicator LED's. There are 2 buck drivers in the driver. Both will be provided the same PWM feed.

wight is correct. I sent you (TK) a PM earlier that I am willing to give up the temp. monitoring if that is holding things up or too difficult. And like wight said, getting voltage indicators to work in some fashion to provide low voltage indication (and I like wight's idea to just light / flash all 3 together).

-Garry

I think that’s actually ImA4Wheelr’s idea! Hopefully I recall that correctly.

I was under the impression that the code JonnyC had on Github for temp & voltage was functioning, but who knows. I could definitely be wrong about that, I have not tried it.

You are correct wight. That was my idea if we used a pin for temperature monitoring. Although 2 emitters at 2.6 amps does not sound like much, the light is very small and the bike may not always be moving. Also, Garry could decide to increase current in the future. So it seemed true thermal protection would be worth pursuing and that it should trump voltage indicator lights (but that is Garry's decision).

Hi all,
Have just discovered this forum and have been hooked on it for the past few evenings. I am an apprentice electronics engineer and find it all very fascinating. I have one of these lights and am planning on resistor modding then having a stab at an mcu. I’ve only ever used PIC mcu before and the attiny is completely new to me but when you come up with something that works I will most definitely be attempting to reproduce it. Thanks very much for all the work that you guys have shared thus far and please please see this project through to completion.
Regards Jacob

Welcome to BLF Jacob! We might be scrapping the idea of the custom driver and instead utilizing the newly available KD2 10 Step programmable driver. Well it will still be custom work as the KD driver is not a direct fit.

-Garry