Attiny25/45/85 FW Development Thread

Latest Narsil (requires an ATtiny85 with FET+1 driver) uploaded with a few new features:

  • expanded modes sets from 8 to 12, new mode set supports up to 8 mode levels (7 + moon)
  • An Indicator LED (SMD LED) is supported as a locator LED and low voltage indicator
  • Moonlight mode can be optionally added (enable/disable), and the moon output level custom set

Here's the summary of configuration settings:

Configuration UI Operation

The main Configuration UI settings is activated from OFF or ON by click& hold for at least 2.5 seconds. The light will display a strobe, but if you continue to hold, strobe will stop and the light will blink 2 times quickly, and once slowly to indicate the Configuration UI mode is active. There are 5 settings, listed in the table below. You can change or leave any of these settings – there’s no need to set each one. Clicks choose the value for each setting, and each click will blink the light to acknowledge the click. If no clicks are entered in 4 seconds, the light jumps to the next configuration setting indicated by 2 quick blinks and slow quicks of the number for what setting it is (ex: 3 slow blinks means the 3rd setting). You can bypass the timeout by doing a click&hold to skip to the next setting. If you continue to hold it, it will exit configuration UI settings mode altogether, indicated by 4 quick blinks.

Configuration Settings

Setting #

Function

Clicks

Defaults

1

Choose Mode Set

1-12 (1-7 is # of modes) – see Mode Sets

4

2

Moon Mode

1=disable, 2=enable

2

3

Mode ordering

1= sets lo->hi, 2=sets hi->lo

1

4

Mode Memory

1=disable, 2=enable

1

5

Turbo Timeout

1=disable, 2=30 secs, 3=60 secs, 4=90 secs, 5=2 mins, 6=3 mins, 7=5 mins, 8=10 mins

1

Mode Sets

Mode Set Order

Mode Count

Mode Percentages

Notes

1

1

full only

(full is always max FET, no 7135)

2

2

10-full

max 7135, max FET

3

3

5-35-full

5=1/2 7135, 35=mixed

4

4

2-10-40-full

10=max 7135, 40=mixed

5

5

2-5-10-40-full

10=max 7135, 40=mixed

6

6

TK BLF A6 7 mode

6 well evenly spread

7

7

1-2.5-6-10-35-65-max

10=max 7135, 35=mixed

8

3

2-20-full

2=1/5 7135, 20=mixed

9

3

2-40-full

2=1/5 7135, 40=mixed

10

3

10-35-full

10=max 7135, 35=mixed

11

3

10-50-full

10=max 7135, 50=mixed

12

4

TK BLF A6 4 mode

4 well evenly spread

Advanced Configuration UI Operation

The Advanced Configuration UI settings is activated from Battery Check mode by doing a click& hold for at least 1.1 seconds. The battery voltage reading will be interrupted, then the light will blink 2 times quickly, and once slowly to indicate the Adv. Configuration UI mode is active. There are 5 settings summarized below.

Advanced Configuration Settings

Setting #

Function

Clicks

Defaults

1

Locator LED feature

1=disable, 2=enable

1

2

Set Moonlight Level

1 - 7 (PWM value)

3

4

Battery level Indicator LED Only

1=disable, 2=enable

1

3

Indicator LED Enable

1=disable, 2=enable

2

5

Power switch modes w/mem

1=disable, 2=enable

1

Full Atmel Studio project source code, ZIP'ed, manual in docx and PDF format, and .BAT files for downloading and setting fuses posted on a google share drive here: google drive - Narsil share

Some mods running Narsil w/Indicator LED support (BLF SD10, UF-T18, ZY-T11 clone, SWM C20C):

You can do anything the included GPLv3 license allows. Mostly, it means “pretty much anything, as long as you share the code”.

Awesome. It’s now (finally) merged into the repository.

U 2 contribute alot here, admiration :star:

Thanks TomE :beer:

Thanks All! Notice the brightness of those LEDs? Wayy too low resistance used. On the UF-T18 there was a resistor already mounted on the switch PCB, but must be low. Probably only used for blinking in stock driver - looks ok when blinked, super bright when on steady.

Actually the UF-T18's switch LED is the ultimate low moon mode. It actually throws a pretty good amt of light ().

So Tom what’s the difference between indicator LED and locator LED?

Ok - I’m calling the physical SMD LED wired to pin #3 the “Indicator LED”, but the “locator LED” is the functionality of it being ON when the main LED is OFF. Thought this might be confusing, so no prob, ask away.

Thanks. Another thing to put on the ever growing pile of things to look at. I’ll keep it in mind when I return to temp control coding.

I took only a brief look at PID before deciding on something simpler. The atmel example code I found for it compiled to like 5500 bytes and the MCU only had 2048, so I put it aside and tried to come up with something tiny instead. However, I hear PID can be implemented in far less space than what I found…

wight linked to one that was supposed to compile in 534 bytes. I’ll start there. Space is certainly an issue, I don’t know how much I will be able to afford. My “development” firmware is getting full, but some of that stuff can be stripped out for “user” firmware.

I was just looking at Mountain Electronics and I saw that the DRJones H17F driver with lucidrv2 uses PID. And from reading about his UI, it seems fairly rich as well. That driver is using ATtiny25.

DrJones is making some money off his drivers though, so I presume he justify putting more than just free time into them.

Yeah, I’m sure he has spent loads of time on his drivers. I was only remarking that PID is definitely possible in a small(ish) space. Hoping to encourage some of these talented people working on drivers and firmware, confirming that it can be done. It wasn’t long ago that TK didn’t know it could be.

Doc Jones is famous for getting the most of every single bit in every single byte. He’s probably got the world’s most efficient PID algorithm in terms of memory usage. Also, 2KB code space in a 25 is a nice bump… I’m amazed what he’s done is so little space of the 13A’s.

Is it the time it take the heat to get from the LED to the sensor that you are compensating for?
The LED won’t get any hotter after you reduce the current.

Just modded my SupFire M6 to add the indicator LED and light pipe, then upgraded the 85 to the latest Narsil. I used this light pipe: mouser-LPCM050CTP, only $0.56 each. Came out nice! The 3 LED's will work on a PWM setting of 2 for moon mode, and I measured a true 0.1 lumens on fresh SAM 30Q BT's. On hi, measured lumens: 5202 @start, 4991 @30 secs. It's got U3 2A XM-L2's on 20 mm Noctigons, 20 AWG wires.

I think the brightness of the indicator came out really nice using a 1K resistor with an orange LED, mounted tombstone style on a ground pad, directly in front of the light pipe (had to align the old driver/contact board up). It's bright enough to see in a well lit room, but not too bright, and mounted next to the button makes it easy to find the button in the dark. Here's some pics:

The 1K resistor, also tombstone style mounted on a pad from pin #3. The blue wire is for the switch (pin #2):

The light pipe is about 11mm long, while the M6 thickness is about 8 mm, but because I could set the LED position a bit back on the board, it matched up pretty well:

Regular office light:

Here's the 0.1 lumens 2 PWM setting:

Err, it won’t? The LED’s temperature doesn’t simply “track” with input current. Think about it - this is just like an electric oven. Reducing the input current may or may not reduce the temperature - it depends on ambient temp, what’s around the oven, and whether you reduced the current from 100% to 80% or maybe 50% to 30%. Somewhere in there exists a “steady state” break point - above that point temperature will rise and below it temperature will fall.

For this application using lookup tables is tricky: they only fully function when they are created with knowledge of the many variables (LED, battery, light mass, external mass, ambient temp). Holding or not holding the flashlight makes a huge difference, but how do we know which lookup table to use (hand vs. no-hand) at any given time?

PID lets us dodge almost everything, I think. You brought up slow/laggy measurements - that may be an issue, I’m not really certain. My immediate take is that whether it’s an issue depends on your goal: I think most of us are ignoring the LED temp and are only interested in maintaining flashlight usability with very high power setups. (someone please let me know if I’m wrong!) In the case of maintaining usability, getting laggy temp measurements isn’t really a big deal - they’ll be reasonably close to “flashlight surface” temps and we should be able to tune the PID settings to achieve the right performance. To re-iterate - for me the “right” performance is a flashlight which I can continue to grip without burning myself, but also a flashlight that will not become scalding hot if I set it down on a table for 60s.

Very slick Tom E, good work. What type of wire are you using for your little hookup wires? The sheathing on the green wire which goes to the LED caught my eye as odd…

Soo, the tiny25/45/85 includes a useful extra feature which I should point out over here. They can measure vcc internally. No pin or voltage divider resistors needed. See my post here: Flashlight Firmware Repository - #790 by Halo

wight - that green wire is really old stuff I had laying around, not sure from where. It's maybe 3-4" with a large amt of the ends stripped - that's why a good amt is bare, it was partially used already. Guess'n it's bout 30 AWG single strand. Think'n it was wire wrap wire? Looks like this wire wrap pre-cut here.

Halo - that sounds interesting! I'm surprised the 1.1v ref would drop same as a direct batt readings, but I don't claim to understand these MCU's for sure.