Attiny25/45/85 FW Development Thread

1911 posts / 0 new
Last post
Tom E
Tom E's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 08/19/2012 - 08:23
Posts: 12912
Location: LI NY

Ohhh, ok. I’m not a fan of OTC’s use for short/long presses. Just don’t see enough consistency. e-switch’s solve all of that.

Mike C
Mike C's picture
Offline
Last seen: 1 month 4 days ago
Joined: 01/22/2014 - 08:03
Posts: 2486
Location: Sweden

fixed it wrote:
Maybe I’m being slow this morning but with both higher voltage and higher R1, shouldn’t you end up with roughly the same current and charge time?

That’s what I thought when I decided to go with 2M7 R1 resistors… but it gave me issues. Maybe because 2M7 is a little more than double 1M2? Issues are solved anyway, and now I don’t have to have a stock of separate R1 resistors.

Tom E wrote:
Ohhh, ok. I’m not a fan of OTC’s use for short/long presses. Just don’t see enough consistency. e-switch’s solve all of that.

Short and long are fine for me. Perhaps more stable because I have calibrated the voltage readings and use actual voltage levels as short/long off times? I don’t know, but I have consistency with both fully charged and almost depleted cells, and heat doesn’t have much of an impact on the components I have used.

E-switches don’t solve anything if the light doesn’t have an E-switch.

Dutcheee
Offline
Last seen: 1 day 6 hours ago
Joined: 12/19/2015 - 21:40
Posts: 476
Location: Netherlands

Another question, can I reflow this one
Attiny85

onto and replace the original mcu on
BLF X6 driver
Or
BLF A6 driver

And then flash Narsil onto it?

Is there any difference on the two drivers after the mcu reflow, besides lighted tailcap options on the X6?

Halo...
Halo...'s picture
Offline
Last seen: 3 years 9 months ago
Joined: 12/15/2011 - 02:39
Posts: 3304
Location: Halo island

Dutcheee wrote:
Another question, can I reflow this one
Attiny85

onto and replace the original mcu on
BLF X6 driver
Or
BLF A6 driver

No. That version of the tiny85 is physically too large, won’t fit.
Tom E
Tom E's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 08/19/2012 - 08:23
Posts: 12912
Location: LI NY

Halo... wrote:
Dutcheee wrote:
Another question, can I reflow this one "Attiny85":http://www.ebay.com/itm/222067143441?_trksid=p2057872.m2749.l2649&ssPage... onto and replace the original mcu on "BLF X6 driver":http://www.banggood.com/BLF-X6X5-Driver-ATTiny25V-Based-and-FET7135-Powe... Or "BLF A6 driver":http://www.banggood.com/BLF-A6-A17DD-L-FET1-2_8-4_35v-74-Modes-Flashligh...
No. That version of the tiny85 is physically too large, won't fit.

That eBay one is a thru-hole, you need a surface mount, and specific size like this one: http://www.mtnelectronics.com/index.php?route=product/product&path=25_104&product_id=601, and note Richard's instructions about bending the pins.

Page 206 here: http://www.atmel.com/images/atmel-2586-avr-8-bit-microcontroller-attiny25-attiny45-attiny85_datasheet.pdf, you want the 8S2 package, and then have to bend the pins to fit.

 I've used those from Richard, and these: ATTINY85V-10SU

Unfortunately you may have problems upgrading the BLF A6 with it's inferior components - might have to piggyback another 10 uF cap onto C1, or add a 0.1 uF cap across the grnd and Vcc pins of the MCU. The BLF X6/X5 driver is better, but not great. The BLF X6/X5 driver uses a 12 uF C1 cap, not 10 uF, so in theory should work with a 85 without adding anything else.

Dutcheee
Offline
Last seen: 1 day 6 hours ago
Joined: 12/19/2015 - 21:40
Posts: 476
Location: Netherlands

Thanks for the quick replies!
If I cut the trough-hole paws on the 85 and bend them over, maybe it can work?
Yes, I already ordered them before I posted Facepalm

So X6 would be best for upgrade compared to the A6.
Do you guys build these drivers from scratch, using Oshpark boards? Even mtnelectronics or 3tronics doesn’t sell anything close..

Tom E
Tom E's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 08/19/2012 - 08:23
Posts: 12912
Location: LI NY

Yes - I usually build from scratch with OSHPark. Sometimes though I've used Richard's boards that he sells bare. However I've also upgraded boards, such as Richard's fully populated SRK 7135 based drive. I swapped the two voltage divider resistors out to 220K and 47K (to lower parasitic drain), and swapped out the MCU. I didn't need to touch caps or add one - it just worked fine as-is. Here's some pics:

 

MRsDNF
MRsDNF's picture
Online
Last seen: 9 min 5 sec ago
Joined: 12/22/2011 - 21:18
Posts: 13307
Location: A light beam away from the missus in the land of Aus.

Those double stacked chips look like a work of art. For that matter the whole driver does. Beer

 

djozz quotes, "it came with chinese lettering that is chinese to me".

                      "My man mousehole needs one too"

old4570 said "I'm not an expert , so don't suffer from any such technical restrictions".

Old-Lumens. Highly admired and cherished member of Budget Light Forum. 11.5.2011 - 20.12.16. RIP.

 

FmC
FmC's picture
Offline
Last seen: 1 month 1 week ago
Joined: 03/31/2013 - 05:23
Posts: 2197
Location: Brisbane, AU
MRsDNF wrote:
Those double stacked chips look like a work of art. For that matter the whole driver does. Beer

I know, right? …I bet Ouchyfoot cried when he saw that Tired Smile

MRsDNF
MRsDNF's picture
Online
Last seen: 9 min 5 sec ago
Joined: 12/22/2011 - 21:18
Posts: 13307
Location: A light beam away from the missus in the land of Aus.

I thought of Of at the time and thought to myself dont go there. Smile

 

djozz quotes, "it came with chinese lettering that is chinese to me".

                      "My man mousehole needs one too"

old4570 said "I'm not an expert , so don't suffer from any such technical restrictions".

Old-Lumens. Highly admired and cherished member of Budget Light Forum. 11.5.2011 - 20.12.16. RIP.

 

Tom E
Tom E's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 08/19/2012 - 08:23
Posts: 12912
Location: LI NY

Almost worth it - I got bout 15A out of it now, but not the 17-18A I was expecting. Still, I got 5300 lumens in mostly a 3D tint. Adding a UCLp gave it a nice bump cool.

Flashy Mike
Flashy Mike's picture
Offline
Last seen: 5 days 15 hours ago
Joined: 01/14/2016 - 16:38
Posts: 1221
Location: Germany

Is this the right thread for comments regarding Bistro firmware?
If yes: please forgive if I am asking dumb questions which have been answered before, the thread is far to long to read completly in reasonable time.
I am currently testing a bistro driver with cpu clock lowered to 4 Mhz, built into a S2+ triple, and so I also checked temperature control. It didn’t work as suspected, first I assumed a dependency to the clock change, but there was another reason in code: when over temperature is detected, the output level is ramped down 1 step each 8 seconds!
This means, coming from highest level it lasts 80 seconds to reach a FET output of 50% and even 160 seconds for 25%. My triple will be melted then.
Is this solution really expected to work with any smaller light pulling more than 3 amps?

Tom E
Tom E's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 08/19/2012 - 08:23
Posts: 12912
Location: LI NY

Mike - this might be the correct thread. As far as I know, Bistro has no dedicated thread, so it's either this thread or the firmware thread: http://budgetlightforum.com/node/38364.

The bottom line would be asking the author - ToyKeeper, and her firmware thread would be the better of the two since she created the other one.

I just looked the code over and it seems you are right - 1/2 second delay in the main loop, then the "overheat_count", incremented by 1, has to be greater than 15 to do an adjustment, and when it does an adjustment, "overheat_count" is reset to zero.

So it doesn't adjust for 8 secs, then only will adjust every 8 secs or so thereafter.

Also be aware it adjusts one "level" per drop-down adjustment, and there are 64 levels defined for the full range of brightness/output.

All I can offer for my explanation is that Bistro was written for single LED DD lights in mind, for the BLF SS/Cu X6 or Cu X5 class running at 4-5A. Also I can say others have seen this problem and tweaked the algorithm. You can bump up the decrement factor or bump up the frequency of checks, and/or add intelligence to do it smarter. Dr Jones got his own PID algorithm implemented for temp monitoring, but has not released it to the public. I heard Atmel has a sample PID in source code as well, but will probably not fit in to a 25's 2K.

Yes - you are right about the 80 seconds. Here's the top 11 levels for FET PWM values:

129,137,146,155,164,174,184,194,205,216,255

I agree, a triple in a thin tube light is a crazy design when it's fully max'ed out. I would never put one in the hands of someone who is in-experienced with these sort of things. Bistro is just the firmware, and not designed for this intended use, accept for the fact it's given out open and freely in source code, so the designer of a flashlight can mod it as they like.

You also might want to consider a turbo timeout - set the timeout to 30 secs, and it drops one full mode, which could be down to 35-40%, depending on you mode definitions, but of course temp monitoring has advantages for more circumstances.

Flashy Mike
Flashy Mike's picture
Offline
Last seen: 5 days 15 hours ago
Joined: 01/14/2016 - 16:38
Posts: 1221
Location: Germany

In my lights I’m using my own driver software anyway but this driver is used in mass production lights meanwhile, and perhaps it might be safer to implement a configurable turbotimer than a temperature regulation which won’t work with many lights.

Tom E
Tom E's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 08/19/2012 - 08:23
Posts: 12912
Location: LI NY

Oops, was still editing, repeatedly.... Again I put responsibility squarely on the manufacturers. TK has not made a penny on the use of Bistro by the Chinese manufacturers. The BLF group buys are one thing - buyers know or should know, but when the manufacturers turn that into a commercial light, it's all on them.

Flashy Mike
Flashy Mike's picture
Offline
Last seen: 5 days 15 hours ago
Joined: 01/14/2016 - 16:38
Posts: 1221
Location: Germany

I agree regarding the responsibility of the manufacturers but often I doubt they know what they are doing …

Tom E
Tom E's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 08/19/2012 - 08:23
Posts: 12912
Location: LI NY

Made some progress over the weekend on implementing/adding a ramping mode to Narsil. Testing it in a SupFire M6. The ramping is pretty much fully implemented, but it breaks all the other UI stuff for now, til I work it all out, like the lock-out, entering configuration modes, displaying battery voltage, toggling the locator LED, etc.

I used posts on BLF by ToyKeeper and blueb8llz as a guide for implementing how it works. I'll be providing more details.

One note is I'm currently using 64 levels spread over 3 seconds to fully ramp the range. I tried 2 seconds at first, but could not stop at moon mode. With 3 secs, it's fairly easy now, but just not sure if 3 secs is too slow. Maybe 2.5 or so is bout ideal -- not sure. Certainly it's all touchy/feely issues, probably a lot of personal preferences thrown in.

MRsDNF
MRsDNF's picture
Online
Last seen: 9 min 5 sec ago
Joined: 12/22/2011 - 21:18
Posts: 13307
Location: A light beam away from the missus in the land of Aus.

Nice work with the black magic Tom. You be careful now. Smile

 

djozz quotes, "it came with chinese lettering that is chinese to me".

                      "My man mousehole needs one too"

old4570 said "I'm not an expert , so don't suffer from any such technical restrictions".

Old-Lumens. Highly admired and cherished member of Budget Light Forum. 11.5.2011 - 20.12.16. RIP.

 

Tom E
Tom E's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 08/19/2012 - 08:23
Posts: 12912
Location: LI NY

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... smile 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: http://budgetlightforum.com/comment/822785#comment-822785

In this thread on the Meteor M43: http://budgetlightforum.com/node/42048

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.

 

KoekieMonster
KoekieMonster's picture
Offline
Last seen: 1 week 4 days ago
Joined: 03/28/2014 - 08:05
Posts: 41
Location: The Netherlands

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?

The Miller
The Miller's picture
Offline
Last seen: 6 months 1 week ago
Joined: 12/14/2015 - 12:08
Posts: 9908
Location: Charente France

Wauw Tom!!
Looks great and logical thus intuitive!

Dutcheee
Offline
Last seen: 1 day 6 hours ago
Joined: 12/19/2015 - 21:40
Posts: 476
Location: Netherlands

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 = 0×1effff
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 Big Smile

Tom E
Tom E's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 08/19/2012 - 08:23
Posts: 12912
Location: LI NY

KoekieMonster wrote:
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?

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

 

Tom E
Tom E's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 08/19/2012 - 08:23
Posts: 12912
Location: LI NY

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: http://budgetlightforum.com/node/36216

 

Dutcheee
Offline
Last seen: 1 day 6 hours ago
Joined: 12/19/2015 - 21:40
Posts: 476
Location: Netherlands

Ahaa, yes now I remember.. That’s why I’ve got the coloured FT cable you recommended in my parts box… Thumbs Up

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

Dutcheee
Offline
Last seen: 1 day 6 hours ago
Joined: 12/19/2015 - 21:40
Posts: 476
Location: Netherlands

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!

Tom E
Tom E's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 08/19/2012 - 08:23
Posts: 12912
Location: LI NY

Cool! wink

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.

Tom E
Tom E's picture
Offline
Last seen: 7 hours 45 min ago
Joined: 08/19/2012 - 08:23
Posts: 12912
Location: LI NY

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)
MRsDNF
MRsDNF's picture
Online
Last seen: 9 min 5 sec ago
Joined: 12/22/2011 - 21:18
Posts: 13307
Location: A light beam away from the missus in the land of Aus.

Nice. Smile

 

djozz quotes, "it came with chinese lettering that is chinese to me".

                      "My man mousehole needs one too"

old4570 said "I'm not an expert , so don't suffer from any such technical restrictions".

Old-Lumens. Highly admired and cherished member of Budget Light Forum. 11.5.2011 - 20.12.16. RIP.

 

The Miller
The Miller's picture
Offline
Last seen: 6 months 1 week ago
Joined: 12/14/2015 - 12:08
Posts: 9908
Location: Charente France

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!

Pages