Attiny25/45/85 FW Development Thread

Thanks Tk ,
I couldn’t find this file you mentioned . :slight_smile:

Ive finally made some sort of firmware for my drivers available: Mike C drivers and X85 firmware.

Very nice. May I include it in the firmware repository? If so, what kind of license should I list for it?

Each project has a key/value-list metadata file used for description and indexing, but I can probably figure out what to fill in for the rest of that. :slight_smile:

Sure you can add it, but managing version releases on the repository is something I won’t do. If I release a new version I’ll just switch out the zip file in my link.

What kind of license? I don’t know much about those things… as it’s for my own specific drivers I’d hope no one edits it and sends it off… But if someone actually builds any of my drivers they might want to change the code so they should. To be honest, with all the other cool driver projects floating around I don’t expect must interest in mine. I’m mainly releasing this stuff because I promised I would a long time ago :slight_smile:

Key/value-list metadata file?? Sounds good to me :blush:

Already found a bug… I’ve replaced the zip file in my download.

It might be useful if I can replace firmware versions in the firmware repository after all.

Awesome.

I wouldn’t expect you to manage the copy in the repository. I’m going with a model similar to Linux distros, where independent authors do their own thing and someone else pulls it all together into a curated collection.

Oh, the licensing thing can unfortunately be complicated. Most of that doesn’t really matter or apply unless it gets really popular though.

Copyrightable works default to all rights reserved. So, nobody can really do anything with it except personal stuff covered by fair use. Making it open requires at least a minimal license statement.

The opposite is public domain, when someone disclaims their copyright so that absolutely anyone can do anything with it. Although normally simple, this can be weirdly complicated in Europe.

The next simplest is a BSD-style license, which basically says anyone can do almost anything, as long as they preserve the copyright, license, and attribution. That’s the bare minimum required for it to really count as a license. Some argue this makes it the most free of all licenses. In practice, however, BSD code tends to get eaten by companies like Microsoft and Apple, who keep taking what the community provides but never give anything back.

I usually go for a GPL-style license, which adds the additional requirement that people must share alike. I.e. anyone who distributes the work (or derivative works) in binary form must also provide the sources. It keeps people from taking without giving back — they can use it, but they have to share their improvements. It also adds protections against a few abuses seen in the wild, such as Tivo-ization and patent trolling (see SCO vs IBM).

There are also quite a few others, each with their own quirks.

I know it’s a thing people don’t generally want to deal with (and it can be done later), but people can’t really use or share it without something giving them permission to do so.

Well, I don’t really consider it open for anyone to do what they want with it and send it on the others, but the people here seem to respect this no matter what license, and the ones that don’t respect it don’t really care about licenses anyway. I guess GPL sounds fair. Do I need to write something in the firmware for that?

I can just tag it with “GPL” in the metadata file for now, but to be fully legit the code needs a comment somewhere in the header. This explains how:

https://www.gnu.org/licenses/gpl-3.0.en.html#howto

… and since the license itself is written by lawyers, this explains it in more plain language:

https://www.gnu.org/licenses/quick-guide-gplv3.en.html

Meanwhile, the BSD license could fit on a napkin. :slight_smile:

Oh, and since you own the copyright, you can change or cancel the license any time you want.

I’ll grab the updated version before adding it.

You’re also welcome to change a branch of the repository and propose merges if you want. It’s extra effort and overhead though, so I normally do that part. And I’m still considering moving it from Launchpad (bzr) to Github (git), since git is more popular. Any preference?

If you are offering to do that part I certainly don’t mind not doing it… I can spend that time on firmware… or writing instructions for it (more work than one would think).

No preference. I’ve never used any of those.

Just posted the latest smooth ramping version of Narsil up on my google docs share, with the updated manual in docx and PDF format.

The share is: Google Doc 254585 Support Shared Drive

Just to make it clear, it's configured for a FET+1 driver, with a 350 mA 7135 (not 380 mA). This is an important detail for the ramping to work properly. Other ramping tables can be built and used easy enough to support 380 mA chips, or only FET, using TK's utility. In fact I need to modify it myself to work well on one of RMM's SRK 7135 drivers. Also moon mode would need to be changed/tweaked based on what you can use as the lowest PWM value, depending on the driver (FET, 7135 350 or 7135 380).

TK - if you get a chance, you can post it in the repository - your same GPL license that you use is fine. Think it's just an update anyways.

Very nice, thank you very much for sharing Tom E! :beer:

I just adjusted the code for modes and turbo step-down timings for my DQG mod.
.hex file got compiled just fine.

As soon as I have more time, I’ll swap the R1 & R2 resistors and flash the new firmware.

Anybody knows which 7135 (350 or 380 mA) is on the X6 driver? How can this be determined?

I think it's a 350 but not sure. Easy test is in Narsil, set a fixed mode (there are many sets with a max 7135 mode), then measure amps. Of the 350's and 380's we use (most bought from FastTech), the 380 is clearly labeled as 380 while the 350 is not.

I just flashed the new Narsil with ramp and replaced R1 & R2 with 220K & 47K resistors. Those 0805’s are some little pieces to solder!

Firmware is great. Ramping is a really nice feature!

I have a few issues though…
On battery check mode, I now get 1-1 blink (1.1V?). On the “old” Narsil before the resistor mod, it worked really accurate.

Also the parasitic drain still reads 0.01A on my UT210E.

Maybe some resistor has got a bad solder joint? Or won’t the driver work at all in that case?

Edit: On 100% 7135 the tailcap measures 350mA, so that should be O.K.

The 1.1V blink means an error happened and it couldn’t measure voltage. If you flash battcheck.c onto it, it’ll probably blink out 255 every time. It’s almost certainly a physical problem somewhere on the driver, but I’m not sure where exactly.

Did you remove the bleeder resistor?
And I don’t know if we can trust clamp readings at this little currrents.

Not that I’m aware of … Thanks, I guess I kinda missed that… How do I recognize the bleeder resistor?

It also sporadically jumps modes now, for example from moon to a high mode…

At the banggood X6 driver it goes from the LED+ pad to ground, labelled 471 which means 470 Ohms.
How many amps does your mod pull at turbo?

Thanks for the info TK & Flashymike! Does removing this resistor remove any functionality? Like mode memory or something? Sorry for the noob question :wink:

Just did a quick tailcap check, on a full 30Q it pulls just short of 13Amp.

It is only needed for a lighted tail cap on lights with tail cap clickies - which you don’t have, I assume.

With that high currents I wouldn’t recommend the Banggood X6 driver. At currents above 9 Amps it tends to reset the mcu due to inductive spikes. I’ve read the Mountain Electronics drivers are better.

Yea, for 17's, I'm using the MtnE drivers exclusively now - got all the parts in, including the 0402 resistor - talk bout small... On the MtnE boards, I use 191K resistors for R1 because the resistors are after the diode, not before, opposite of wight's drivers.

Dutcheee - I hpoe you don't mean in that order as you said: I just flashed the new Narsil with ramp and replaced R1 & R2 with 47K & 220K resistors

R1 should be the 220K, and R2 the 47K. I haven't used the bleed resistor in any of my driver builds, 85 or otherwise.

Here's a pic of a working MtnE driver, the MTN17DDm, v1.1:

This evening, I'll double-check battery level checks on these MtnE boards. Every 85/Narsil I've built with the new ramping support battery check and LVP work fine - I've tested I'd say about 6 working lights so far w/latest Narsil, 3 of which are in SRK style lights, doing 15A to 20A each (3X modded M6, 4X clone, 5X clone).

Last night I just updated my SWM C20C with the ramping version. It blinks out 3.9v and with the cell removed, it measures 4.007v on a Fluke DMM. I consider that close enough, but the driver is a wight driver, so I'm using the 220K/221K resistor for R1.

Important Note: To properly measure parasitic drain, you must hold the probes across the batt- to the housing for several seconds, I think it's about 6-8 seconds. I added this delay to the firmware intentionally - it's a delay before going into sleep mode. I just did this on my C20C light, and measured 0.02 mA, whichs is 0.016 mA rounded to 2 decimal digits. Looks like this Fluke I'm using at work (175 - true RMS DMM) is limited to 2 decimal digits.

I measured 4.85 mA for those first few secs before it drops. The 4.85 mA is probably the MCU's draw in normal running.