Attiny25/45/85 FW Development Thread

More progress this eve on ramping support in Narsil:

  • got lock-out working with same sequence as in non-ramping mode: 2 quick clicks followed by hold
  • got battery voltage check working same way also: 1 quick click followed by hold
  • got both modes of configuration UI working, again same or similar way as non-ramping, but for the main configuration setting, simply hold the button for 5.5 seconds, which is a full 3.5 seconds longer than a ramping sequence
  • changed ramp down - it stops now on moon mode instead of stopping by turning the light OFF

Still to do:

  • would like to get the locator LED toggling ON/OFF supported in ramping. Right now I lost that capability
  • need to add selection of ramping vs. mode sets to the configuration UI settings
  • might be on small bug to fix: after exiting lock-out, looks like 1st click is ignored, then all works fine
  • might see if I can clean up the LED output when in these special sequences (lock-out, batt voltage, config UI, etc.)
  • would like to get the ramping a little smoother look'n - right now a flicker is noticeable because it's changing PWM levels at 20 times/sec, whcih is somewhat noticeable. Would be better to adjust it closer to 100 times/sec which is possible.
  • might want to add in ramping a direct method to Hi/Turbo - possibly a dbl-click or triple-click

Overall liking the smooth ramping. Operation:

From OFF:

  • click to last level it was on
  • hold ramps up from moon to hi/turbo in 3 seconds, smoothly (currently 64 levels)

From ON:

  • click turns it OFF (this level is restored on the click from OFF)
  • hold ramps up, accept if it is on hi. If on hi, hold ramps down all the way to moon in 3 seconds, and stops there

It's simple and predictable, least that's my think'n... All the other special stuff is accessible by special sequences.

Thanks to blueb8llz and ToyKeeper for guidance, inspiration and support:

Ramping UI, Defined by blueb8llz (Ray)

Posted here: https://budgetlightforum.com/t/-/72707/10

In this thread on the Meteor M43: https://budgetlightforum.com/t/-/72707

It would need to be single click to turn the light on and off.
Hold switch while light is on, and ramps levels.
Hold switch while light is off, turns on moonlight mode.
Single click turns on light in last used mode including turbo.

Give me this ui, I promise to purchase at least two more units.

I’d really like to test your firmware with my current XHP50 SRK (I blew the driver past weekend so I’ll rebuild it with an attiny25)
I have an indicator LED around the switch so I can test this too.
Is it available for download somewhere?

Wauw Tom!!
Looks great and logical thus intuitive!

Very nice Tom E!
I might want to go with the “old” Narsil for my DQG due to the thermal issues. Maybe a cut down High would be better for my u.i., but this is definately nice for lights with normal cooling abilities.

I’ve ran into a problem flashing the X6 driver:

“C:\AVRusb>avrdude -p t25 -c usbasp -n

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s
avrdude: Device signature = 0x1effff
avrdude: Expected signature for ATtiny25 is 1E 91 08
Double check chip, or use -F to override this check.

avrdude done. Thank you.”

Also with the -F function it doesn’t write firmware properly. I get the same signature error.

I don’t know how to use a .bat file yet, but I guess if a direct command doesn’t work, that won’t work either.

Am I missing something or could it be a faulty Attiny25? I’ve got another driver lying aroud, but before I brick both, I thought lets ask the BLF oracle in advance :smiley:

Narsil requires an 85 - won't run on a 25 because of program space requirements.

Yes, but not with the ramping features - still under development/test. Latest version posted is dated 2016-04-07, accessible here for the source code, AVRDude BAT files and manual:

https://drive.google.com/folderview - shared 25-45-85 projects

Dutcheee - Are you sure you have a properly wired USB dongle? I've posted this several times - there's bad info floating around on the dongle wiring, and it didn't really effect me til I started programming 25's, 45's, and 85's.

That messaging you are getting is probably related to a bad connection of the clip/dongle - I've gotten the same message many times. Sometime the clip position is off or the pins just aren't making good contact, but if you have the GND pin wired incorrectly, you can get similar inconsistent error messages.

Check detailed info and pics in my recent post #127 of this thread: https://budgetlightforum.com/t/-/30672

Ahaa, yes now I remember… That’s why I’ve got the coloured FT cable you recommended in my parts box… :+1:

Already thought I had missed something, thanks! Will rewire and try again.

That helped a lot, I just flashed your psw-te25 firmware to the X6 driver. I don’t have the 85s in yet, so I’ll try with the T25 first.

I had to bend the pins from my cheap ebay clip a little, but it works flawless!

Cool!

I'm always keeping a spare USB AVR complete w/cable and clip around now. The clips specially can start having problems with use. The first black cheaper one I used had pin problems - pins just loosened up and would back out on attempting to clip to the MCU. Became a real PIA fiddling with them all the time. Then a blue Pomona failed on me - one of the pins sprung out of the plastic tabs holding it in, and just couldn't get it to stay. This problem was probably my own fault though, abusing it to fit on MCU's in tight spaces.

I basically got the ramping mode operational in Narsil, accept for the To Do list below. There were a lot of little bugs along the way, but looks like it's operating pretty clean now, so far that is... Ramping can be chosen via the configuration settings, so you can still choose one of 12 mode sets, or ramping.

Code size is now 5496 bytes, 67.1% filled, so still lots of free space.

So the basic ops is fairly simple:

From OFF:

  • click to last level it was on
  • hold ramps up from moon to max level in 3 seconds, smoothly (currently 64 levels)
  • double-click to max level

From ON:

  • click turns it OFF (this level is restored on the click from OFF)
  • hold ramps up, accept if it is on the max level. If on max, hold ramps down all the way to moon in 3 seconds, and stops there

All the Narsil special/advanced features are now working in ramping mode:

  • lock-out works: From OFF, 2 quick clicks followed by hold (same as non-ramping)
  • battery voltage check: From OFF, 1 quick click followed by hold (same as non-ramping)
  • both modes of the configuration UI working - to access the main configuration setting, hold the button for 5.5 seconds, 2.5 secs longer than a ramping sequence
  • in ramping, locator LED is toggled by a triple click from OFF

Couple things still To Do:

  • turbo timeout (currently only works in normal mode sets, not ramping)
  • Low Voltage Protection - needs to be modified to lower levels (currently only steps down modes in a mode set)

Nice. :slight_smile:

This looks sweet Tom!
I have ordered the hardware to flash the AT85
And I already know which srk will be using the prototype Q8 driver
NICE!!!
So intuitive!

Does the voltage of the PWM signal from an Attiny chip vary with the battery voltage?

Sorry, I can't answer that in any certainty, but total guess is yes, because I don't think anything in the MCU is boosting or regulating voltage, but really dunno. Do you think it makes a difference to the FET or 7135's, because it just acts as a ON/OFF switch, not used directly as power out of the FET or 7135's?

I’m considering the limitation of the PWM signal being strong enough only to control ~32 7135 chips. I am thinking that if the PWM signal went to a fet whos output was connected to the PWM pins of the 7135’s, an unlimited number might be able to be switched.

Hhmm, don't think the waveform of the signals are the same - the gate input, and the FET output, but I could be wrong. I have a modded MtnE 7135 SRK driver with the full up 32 7135's, and 18 more piggybacked, total of 50. I got it in a Fing 5X, getting like 18A out of it, which is close or at the max. It works great, up to 8 PWM modes using PHASE PWM (I don't use FAST mode anymore), running on a 85. Not sure, but might not have tested it for LVP operation...

Nice. Yea, I was thinking a FET might be fast enough not to mess with the waveform too much but idk. Another option might be to use two MCU pins PWM’ing in parallel to a bank of 7135’s.

Got the final open issues for ramping done and pretty much tested now. I have the new Narsil installed in 3 lights:

  • Supfire M6 (Indicator LED, FET+1, 3 U3's, does about 5,000 lumens)
  • SupFire M2-Z (FET+1, C8 size side switch, modded with an XPL)
  • ZY-T11 clone (indicator LED, FET+1, XM-L2 T6 4C)

The timing for one full ramp was taking about 3.6 secs, so I reduced it now to ~2.8-3.0 secs, and looks much smoother now with no noticeable flicker. I increased the # of steps to 142 (was 64 steps).

I admire your skills Tom. It all sounds exciting.

Hi, sorry, I’ve been avoiding this thread until I had a day free. I’ll just put all my replies into one, for now:

No, it’s not expected to work correctly on smaller higher-powered lights. The code is configured for the BLF X5/X6 project. If you want to use it on something higher-powered in a host with less heat capacity, you’ll need to modify the code accordingly. The thermal code is pretty bad though, so don’t be surprised if it does weird things like bouncing back and forth across the place where it should settle.

Running it at 4MHz, you’ll probably need to change significantly more details to make it work correctly. Everything will run half as fast, including thermal regulation, blinky modes, ramp-up, etc. And you’ll likely get an audible whine on most of the output levels. You can fix a lot of the timing by cutting “BOGOMIPS” in half though.

Sorry, I’ve really procrastinated about that. I know better methods are possible, but I haven’t done it because I’ve been a bit overloaded lately. Also, thermal regulation is kind of a pain in the ass to test.

It can be pretty frustrating at times.

Wait, does your ramp automatically reverse at the end? It’s much more common to stop at the end, or at least stop temporarily before turning around. I personally prefer to just stop at each end instead of ping-ponging.

Er, nevermind. Just read your next post. It was turning off, not reversing, and you fixed it. :slight_smile:

I’m looking forward to trying this.

What about this instead?

“Hold” ramps in the same direction as it was ramping before, unless you release and hold again within 1 second, in which case the ramping direction will reverse. This way you can turn around quickly and easily to get to exactly the desired level, without having to go all the way up or all the way down first.

My Ferrero Rocher UI does that sometimes, and I consider it a bug. Holding from off should probably go to moon and stay there, requiring a release-and-hold-again to ramp up. I haven’t fixed it yet because I ran out of space, but was planning to fix it next time I mess with ramping.

I had the same happen on my first clip. I had some pins push back / recess themselves a few times before that, and was always able to pull them back out… but the sprung-out pin was harder to fix. It’s working again now, but it motivated me to buy a couple extra clips.

Those are two of the reasons why I made everything in bistro use the ramp instead of doing it with mode group levels like STAR or BLF-A6. It was kind of a pain refactoring everything, but afterward it made a lot of things easier.

Agreed, I don’t see much point using FAST on a 25/45/85. It would run at 31 kHz, which is faster than needed to avoid being audible, and fast enough to reduce PWM stability on low modes. Slower PWM is more stable and more consistent.

I’ve been using PHASE for moon mode even on tiny13, to make it less voltage-sensitive, but on the 25/45/85 it can use PHASE for everything. It’s nice.

I’m curious. Why 142 exactly?

Also, did you have to manually tweak the values at the point where the FET kicks in, and at the highest few modes? If I use the values my ramp calculator produces, I get less-smooth results at those two points. So I’ve been meaning to at least fade the 7135 out at the top instead of going directly from 255 to 0, to reduce the brightness “pop” between the two highest modes. Not sure exactly how to smooth out the channel transition in the middle though.