Attiny25/45/85 FW Development Thread

I don’t have hardware yet, but the plan I’m going with is to let the user calibrate the temperature cutoff. Basically, run in turbo and save the temperature value every second or so, until the user turns the light off or presses the e-switch. From then on, that value will be what it uses as a maximum temperature. I think this will be an easy and effective way to make it work for different lights and different preferences.

As for the switch, I’ve also been planning to ditch the switch interrupt, because it takes a bunch of extra room and seems to make the code very fragile. We don’t exactly have a proper threading library on the attiny… so, I had also planned to go the WDT route.

But I’m starting with clicky-switch code and a small attiny25. E-switch stuff will have to happen later.

Ooh, nice! I’ll probably want one. :slight_smile:

It’d be a lot nicer than drilling holes through a 17mm driver… please update with progress as events unfold!

Here is my 85 driver board I got home while I was away. The rather radical changes I made are that I’ve put the OTC, voltage divider and E-switch all on the same pin. The idea is that the voltage divider resistors will be of large enough values so that R2 also acts as a bleed resistor for the OTC, and as the OTC is on the same pin it will be constantly charged by the BAT+ input. Voltage readings should be normal except when the E-switch is pressed. I don’t know if I can get this to work, but I just have to try. Why? Because I want to use my smooth adjustable output level of any amount of AMC7135s on up to 7 on constant current with an additional single AMC7135 for PWM between, and also have a FET for turbo/boost mode. I’m doing this on the 84 and love it, so this is an experiment to see if it can be done on the limited amount of pins that the 85 has.

I actually managed to squeeze in a total of 10 x AMC7135s, but don’t know if it will be too tight to be able to flash the MCU, so I put those two additional ones next to the pins of the MCU so they are the ones to go if it’s too tight with 10.

No spring as I will bridge with stiff copper wire with vias on each end of the MCU, and the MCU needs folded legs. Resistors and caps are 0603 size. Ground tabs on the AMC7135s need to be cut off a little, as does the PSMN3R0-30YLD FET, and made custom Eagle parts for these cut parts. No other way to fit all this stuff on a 17mm board otherwise.

No idea if this will work at all. It’s just an idea I have to try… It is a hobby after all…

Edit: Removed images, new version in the pipeline…

Mad science, I tell you. Mad!

Wight tried something similar, and it was pretty cool. It seems like a simple FET+1 covers most of the functionality though, without the need for extra 7135 channels. Beyond that it’s kind of diminishing returns, with the extra 7135 channels getting used only for like one mode each. On the BLF A6, here is how the two channels are powered for evenly-spaced modes:

The modes are:
|. Group 1 |. 7135 power |_. FET power |
| Moon | 0.8% | 0 |
| Low | 8% | 0 |
| Med 1 | 43% | 0 |
| Med 2 | 100% | 2.7% |
| High 1 | 100% | 22% |
| High 2 | 100% | 54% |
| Turbo | 0 | 100% |
|. Group 2 |. 7135 power |_. FET power |
| Low | 8% | 0 |
| Med | 90% | 0 |
| High | 100% | 35% |
| Turbo | 0 | 100% |

Extra channels would improve the modes labelled “High”, and maybe “Med 2”, but aren’t really needed for the rest.

I’m very curious to see if you can get the combined voltage/otc/e-switch pin to work though. Combining any two of those would help quite a bit with opening pins for other purposes.

IIRC, Mike had said in an earlier thread that he didn’t really like un-regulated output, so all the low-mid-high-whatever modes will have regulation and the FET is only used for Turbo mode. I can appreciate his reasoning, and I’m looking forward to seeing the finished (final tested version) driver.

I'm more interested in driving 3-4 outputs with this sort of setup. Is that what this 85 driver does? I know only 2 I/O pins can be used with PWM's, but a 3rd or 4th could be driven with fixed 7135's at full power I suppose - pretty cool, great for multi-color lights. That whacko nut zoomie light (on TMART and GB) with it's 3 XP LED's would be an interesting host for this.

^ I believe the 25/45/85 have 4 pins that can have PWM output. Pins 2, 3, 5, & 6.

13a has one PWM channel that can output to 2 pins (OC0A,OC0B). The 25 et al have 2 PWM channels that can output to 4 pins (OC0A,OC0B,OC1A,OC1B).

Ohhh?? Didn't realize that! I thought the 13A had 2 independent PWM's on max of 2 I/O pins it could support. Hhmm, didn't realize that was what T_K's firmware was limited to when combining the FET and 7135 - thought her dual mode tables were controlling 2 PWM values at the same time. Also thought the 25/45/85 had the same restrictions... I gotta go back into the specs.

Update: I have now shared the driver in post #135 of the X6R thread.

Correct. Not using PWM on the FET at all. It’s just full on for turbo.

I’ll be driving 5 outputs. 3 outputs for AMC groups of 1, 2 and 4 for any number of 1 to 7 on in constant current, another output for driving a single AMC7135 with PWM, and the last is for the FET. I do this so I can seamlessly adjust the output from moonlight to all 8 AMCs full on, using PWM with the single AMC to fill in the gap between each constant current AMCs. I did it on my ZY-T08 project and just loved how it worked so now I want to try it on a 17mm driver for a triple XP-L HI light with dual switch setup and a FET for turbo mode.

I haven’t thought about the 85 having PWM on four pins as I only use it on one, except on my dual LED headlight project where I use two (but it uses the 84, not the 85).

I guess I should clarify that this particular driver won’t suitable for multiple LED outputs (such as different color LEDS) as there is only one LED- and all AMCs and the FET are connected to it.

Multi-LED lights would be very interesting, especially after hearing that the 25/45/85 have four usable PWM channels. :slight_smile:

Regulated output (with no PWM or very limited PWM) from zero to 3.04A also sounds really nice, and brings the driver up to par with high-end brands. I’d still put the FET on a PWM-capable channel though, to allow it to vary its output instead of jumping directly from 3A to 6A+ with nothing between.

On the attiny13a, there is one PWM counter, and it can optionally have two outputs with two different stopping points. Or it can have a single counter with a configurable ceiling. So, it has a couple different modes:

  • One channel: Counts from 0 to N each cycle and uses a duty cycle from 0 to X where 0 <= X <= N. N defaults to 255. This provides both pulse width modulation and pulse frequency modulation; the latter can be useful for fine-tuning output between individual PWM levels, and is used by Ferrero_Rocher/Ramping_UI_table.c .
  • Two channels: Counts from 0 to 255 each cycle, with one channel stopping at X and the other channel stopping at Y. The two channels are basically independent except for sharing a clock. This is what the BLF A6 does.

… and both can be configured for either a sawtooth wave (fast PWM) or a triangle wave (phase-correct PWM).

It sounds like the 25/45/85 doubles this, though the second set of PWM channels appears to have a slightly different feature set.

You guys already knew (or should have known) that the 85 could do 4 PWM outputs. Did you not remember DrJones' RGBW driver?

Oh, I thought that used the 84, not 85. And I made the mistake (for months!) of believing wikipedia’s page comparing atmel chips, which appears to be wrong or at least a bit misleading. But the 25/45/85 data sheet confirms four PWM outputs, and the differences between them.

The design I had in mind for running OTC, VDV and Esw on the same pin won’t work. Giving it another go by adding a MCU supervisor that has a built in 150ms delay. Thinking of the ADM1818 (from Analog Devices) because the RST (output) is low untill voltage level has been above a certain voltage threshold for 150ms (turning on the light). Then after the 150ms delay the + is let through to the VDV and OTC. The 150ms delay should give me enough time to read the OTC before the + voltage reaches it.

I’m no electronics guy, I just found this component by searching for a small delaying component with about the right delay. So does anyone with some knowledge about this stuff have any input? Even if it might work, are there better choices out there around the same size or smaller?

Didn't know Dr Jones driver was 85 based - actually totally forgot bout it. Soo hard following his stuff - I always seem to have a broken link to his sites. Think it's mentioned here: https://budgetlightforum.com/t/-/23510.

Edit: If he reads what we go thru, he's probably sitting back laughing - he knows all this stuff: been there, done that... Smile We are breaking ground in making it public I suppose. Others, maybe many others, have gone through all this already. Remember the polish driver? 25 based I think.

The wikipedia article is definitely mis-leading. It shows no difference in PWM support between the 13 and 25/45/85's... Wow.

I wonder why it uses software PWM at 2kHz instead of the hardware’s built-in PWM at 20kHz.

You think DJ used Pin 1 for the momentary switch? No real board traces visible and very limited info seems to be provided.

You can use pin 1 as an I/O, even on the 13, but after you do that you can't reprogram it without an HVSP programmer. That's another reason I bought a Dragon.

I’m about to place a mouser order, so I figured I would pick up a few of the 25’s for future use.

Will the ATTINY25-20SSU work, or do I need the ATTINY25V-10SSU?