Attiny25/45/85 FW Development Thread

1901 posts / 0 new
Last post

Pages

ImA4Wheelr
Offline
Last seen: 16 hours 5 min ago
Joined: 02/03/2013 - 14:51
Posts: 7412
Location: SC
Attiny25/45/85 FW Development Thread

This thread way over my head.  So here are links to "Status" posts of members that are developing and sharing code for the Attiny 25/45/85.  They are talented folks that we all appreciate.  Alphabetical order on screen name:

 

Flintrock:

Mike C:

Tom E (Primarily focusing on Momentary Switch FW):

ToyKeeper (Primarily focusing on Clicky Switch FW):

 

Original Post:

Decided to pursue the Attiny 25/45/85 ("25") because I want the following:

  • Thermal protection that is based on actual temperature and not a make shift solution like turbo time out.
  • Ability to use the widely available Attiny 13a driver boards without having to modify the pcb.
  • Not having to use one of the valuable remaining 3 or 4 pins of the mcu for an external thermal protection circuit.
  • Not having to sacrifice valuable existing code to make room for new thermal protection code due to the Attiny13a's 1k flashable program space limit.

Status:

  • Thanks to Tom E's skill and efforts, modified JohnnyC's Star Momentary modified for strobe, dual PWM modes, and Alt PWM by Tom E is working on the 25.  He has published his first working version in Post 71This is big news!  BLF drivers will be jumping up to a whole new level of functionality soon.  Probably not tterev3 levels, but we should hopefully be able to better address heat safety issues and gain whatever fun new features programmers can imagine with the extra programming space, PWM outputs, etc.

To Do:

  • Create OSH Park boards that can be used to piggy back this MCU on to any driver (making it a slave) using air wires. The wire solder points will be far enough out to still enable flashing the MCU. It will also have a ground plane that can be used to both provide ground and a thermal path to the slave drivers ground ring.  Will include pads to have an optional LVP voltage divider to the board too.
  • Begin creating thermal protection code

Some Notes:

Pinout:

The 25/45/85 have 2 PWM channels (Attiny13a has 1) that can put put to pins 2, 3, 5, and 6.

A direct match would be 8S1 which is only available in the 25.  For the 45 and 85, the 8S2 appears to the best match.  The pins of the 8S2 package need to be bent down to fit the Attiny13a SSU (8S1) package footprint.  It's easy to do and I am still able to attach clip for flashing.  The modified chip still fits in the original protective sleeve (Chip on far right).

 

Original Post (8/3/2015, changed on 8/4/15):

The question of why we don't use the 25/45/85 pops up from time to time with no real conclusions.  I'm not a programer, but had to try it out to satisfy my curiosity.

Ordered some cheap Attiny45's because I didn't know how things would turn out.  Went for the 10 Mhz version.   If I understand the data sheets correctly, the 20 Mhz version only operates at 20 above 4.5 volts (just like the Attiny13a).

Grabbed JohnnyC's Star Momentary modified for strobe by Tom E.  For every memory reference, I compared the the Attiny13a data sheet to the 25,45,85 data sheet.  To my surprise, only one change was needed in the end.

Fuses, I know nothing about.  Tried to flash with 0x75/0xff and got an error which basically bricked the chip.  I will need to make one of those 12v jobbers to reset it and make it usable again.

Tried a 0x75/0xfd with the same result.

Finally tried to learn a bit about Attiny25/45/85 fuses and got overwhelmed.  Queried a chip and saw that it had 0x62/0xdf/0xff (l,h,e) fuses.  Decide that seemed good enough for now until I learned more.

Hooked up the chip to a HX-1175b1 driver and lit her up.  Worked good.  Fast clicks when up through the 7 modes I programed.  Medium clicks went down and a real long click went into strobe.  Strobe was pretty slow with long flashes.  Thinking setting the proper fuses will fix that.  After a second or so in any mode with button activity, a fast click would turn off the light.  In short, the FW appears to be working fine.

I have more to learn some more to get it running right, but it seems pretty close already.  Why are we still not using the 25/45/85 when we could have the following for just slightly more cost?:

  • Internal temp sensor
  • 2 PWM channels
  • 2/4/8K Bytes of In-System Programmable Program Memory Flash
    • Endurance: 10,000 Write/Erase Cycles
  •  128/256/512 Bytes In-System Programmable EEPROM
    • Endurance: 100,000 Write/Erase Cycles
  • 128/256/512 Bytes Internal SRAM
  • etc, etc.

I think inertia is keeping us from starting to use them.  I guess I'm not really concerned with why we aren't using them, but more I'm urging us to start using it.  It could help address a major safety issue with some of our hot rods and will also help with some other challenges the 13a poses.

Edited by: ImA4Wheelr on 02/17/2017 - 15:14
mash.m
Offline
Last seen: 1 year 1 month ago
Joined: 07/29/2011 - 00:39
Posts: 17
Location: germany

Hi,

i think it´s not a question about hardware specs, it´s cause the tiny13 is already mounted on most drivers. it´s easy to reprogram without desolder. shure, the bigger tiny´s are nice and have some features, but you also need software the use them.

markus

Halo...
Halo...'s picture
Offline
Last seen: 1 year 2 months ago
Joined: 12/15/2011 - 02:39
Posts: 3304
Location: Halo island

Skip the attiny45 and go straight for tiny85!

AVR Fuse Calculator Be sure “Serial program downloading (SPI) enabled; [SPIEN=0]” is always checked.

You can also use the calculator backwards. Enter the fuses and you can see what it would do. With an attiny45, the fuses 0×75 0xFF or 0×75 0xFD disables SPI. Which does indeed brick your chip unless you have a high voltage programmer or fuse resetter.

ImA4Wheelr
Offline
Last seen: 16 hours 5 min ago
Joined: 02/03/2013 - 14:51
Posts: 7412
Location: SC

mash.m,

I agree with your logic.  For those reasons and others, the 13a will not be going out of use for a long, long time.  It's a decent chip and is a good choice.  My biggest concern is that we have to use make shift thermal protection schemes with it.  I know manufactures use it because they make thousands of boards and the 13a is cheaper.

I reworded my question because using the 13a is fine.  I also added the following to the end of the OP: 

"I think inertia is keeping us from starting to use the 25.  I guess I'm not really concerned with why we aren't using it, but more I'm urging us to start using it.  It could help address a major safety issue with some of our hot rods and will also help with some other challenges the 13a poses."

Halo...,

I think any FW that works in the 25 will work in the 45 and 85 (I'm sure there are exceptions).  But not the other way around if it is too large.  So programming for the 25 leaves the option for all 3 chips to be used.  That could be handy if prices go up for one or supplies get tight for one.

Thanks for the info on fuses.  Last night, I tried that calculator you linked to along with several others.  But to be honest, some of the options go over my head.  I have some studying to do.

ImA4Wheelr
Offline
Last seen: 16 hours 5 min ago
Joined: 02/03/2013 - 14:51
Posts: 7412
Location: SC

Although I am still not fully up to speed with regards to fuses and the Attiny25/45/85 commands need to get various PWM results (such as fast,phase,frequency), I selected some new fuses and tried to flash them last night.  Problem is I'm getting a error message in AVRDUDE that says something like, "Command "avrdude" is not recognized . . .".

I tried the following, but still got the same message after each change:

  • Different USB ports,
  • New programmer,
  • Installed the latest WinAVR

Maybe my programmer's drivers are corrupted or maybe the USB ports are screwed up (seems doubtful).  Any one have this problem before and what did the problem turn out to be?

EDIT:  Also tried with an Attiny13a in the clip.  I'm using Windows XP (64bit version, I think) and the programmer is the standard ASPUSB 2.0.

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

I got the tools installed on Win 7, believe 64 bit (not sure), and works fine with 13A's. Are you trying on 13A's to sanity test it?

The message is implying it can't locate the avrdude.exe file, as if it's gone, or in another folder that's not in the search path.

 

Ohh btw - way cool you like my e-switch implementation. I think it's real nice, has me hooked on e-switch lights in fact. In other firmware goings ons, I modded a STAR_OFFTIME base (power clicky switch) to switch modes like luxdrv - where it initially changes mode to lowest, then mode toggles up from there. Always liked how luxdrv behaved like that. My luxdrv/STAR_OFFTIME has these features:

  • removed support for STAR jumpers (I know - STAR in the name is meaningless)
  • has simple support for FET+1 drivers with low modes using the 7135
  • a mode "locks in" in about a second, once locked in, the next quick power OFF cycle will switch to 1st mode, then following quick clicks go to next mode, etc.

 This will allow me to add battery tests, strobe modes, etc. after turbo high, and you never have to click through those extra flashy modes Smile. I also like the fact if you are working on a low or medium mode, you don't have to get blinded by hi or turbo to switch to a lower mode.

 I'm looking fwd to getting this new power clicky switch firmware ported to the 25/45/85 as well so I can take advantage of adding temp monitoring and a whole bunch of extra modes with the extra available memory. I always run out of space when I try to add some cool things...

ImA4Wheelr
Offline
Last seen: 16 hours 5 min ago
Joined: 02/03/2013 - 14:51
Posts: 7412
Location: SC

^ Thanks Tom.  I did try Attiny13 too with same result.  Forgot to list that in my post above.  I see what you mean that it may not be finding avrdude.exe.  I'll check into that tonight.

That modded program of yours sounds sweet. Like the way you think when it comes to features and UI.

 

ImA4Wheelr
Offline
Last seen: 16 hours 5 min ago
Joined: 02/03/2013 - 14:51
Posts: 7412
Location: SC

Good news.  Finally got new fuses flashed and the program appears to work flawlessly.  Next is to turn on LVP protection and see how that goes.  After that, it's time to start drafting thermal protection code that uses the 25/45/85 internal temperature sensor.  Starting to get excited.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 6 hours 42 min ago
Joined: 01/12/2013 - 14:40
Posts: 6212
Location: (469219) 2016 HO3

Awesome. I’d like to include code when you have some working. Smile

Even better if you’re already using a version control system I could import from.

FmC
FmC's picture
Offline
Last seen: 1 hour 1 min ago
Joined: 03/31/2013 - 05:23
Posts: 1934
Location: AU

Nice work - BLF marching forward once again Beer

ImA4Wheelr
Offline
Last seen: 16 hours 5 min ago
Joined: 02/03/2013 - 14:51
Posts: 7412
Location: SC

Hi TK,

You're certainly welcome to any code I create.  I've provided Tom E the details of my changes to "his" FW so far.  Since I'm just a hack when it comes to programming, I'm hoping a real programmer will eventually pick up whatever I get done and turn it into real code.  I figure I will probably be creating as many problems (if not more) as solutions.  Just trying to be a catalyst of change here.  If I have to develop it all on my own, so be it.  It just will take way more time and probably not be optimal code.

 

Thank you FmC.:)

bugsy36
bugsy36's picture
Offline
Last seen: 4 days 22 hours ago
Joined: 07/11/2014 - 18:15
Posts: 2475
Location: Florida USA

ImA4Wheelr wrote:

Good news.  Finally got new fuses flashed and the program appears to work flawlessly.  Next is to turn on LVP protection and see how that goes.  After that, it's time to start drafting thermal protection code that uses the 25/45/85 internal temperature sensor.  Starting to get excited.

Fantastic!!!!

It's the simple things that we take for granted that cost us the most

Ευκαιρία λέει πιάσε με από το μέτωπο γιατί μόλις έχω περάσει δεν θα με πιάσειs

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

This is sounding better and better! Hope to join you in the efforts soon. I did just get in a ASUS 15.6" touch screen laptop i7 (great deal at TigerDirect btw at the time), and installed Win 10 and Atmel Studio 6.2 so far, then will be installing and copying over the rest of my development tools so I can finally work on the firmware and do downloads in the same room where I do the modding, rather that running upstairs/dnstairs every time - was a major hassle. Also was a major hassle not having a good online access for pic uploading, BLF'ing, etc., in the same room as the modding...

 

Diode663
Offline
Last seen: 11 months 2 weeks ago
Joined: 05/26/2015 - 22:24
Posts: 27
Location: United States

I was thinking of switching over to the 85 so i could use the arduino ide. I think moving to that would make this alot more accessable to alot more people. Although maybe im just a wimp.

ImA4Wheelr
Offline
Last seen: 16 hours 5 min ago
Joined: 02/03/2013 - 14:51
Posts: 7412
Location: SC

Diode663,

Does the arduino ide require a specific package of the Attiny85?

I ask because it appears that package 8S2 would be the best match for our typical driver boards that use the SSU footprint.

I've never use arduino.  What would be the benefit of what your talking about?  High level and pretend I'm a 5 year old (I almost said 5th grader, but they probably know alot about this stuff).

RMM
RMM's picture
Offline
Last seen: 1 week 4 days ago
Joined: 07/23/2013 - 13:47
Posts: 3985
Location: USA

Thanks for working on this.  I have been working on it on and off for a while now, but keep getting sidetracked.  JonnyC posted some code 7-8 months ago that does work, but no temperature sensor added yet.  I was surprised that nobody except me tried it out.

I have some code that I started that has temperature sensor implementation and builds, but I have no idea if it actually works or not since I haven't even flashed it yet. Too busy.

You ought to get in touch with MikeC.  I think he has the temperature code already figured out.  

Mountain Electronics : batteries, Noctigon, and much more! What's new? 

ImA4Wheelr
Offline
Last seen: 16 hours 5 min ago
Joined: 02/03/2013 - 14:51
Posts: 7412
Location: SC

Thank RMM.  Need to find where JohnnyC posted that.  I think MikeC is working with much bigger chips, but maybe the his code could save some time. 

RMM
RMM's picture
Offline
Last seen: 1 week 4 days ago
Joined: 07/23/2013 - 13:47
Posts: 3985
Location: USA

ImA4Wheelr wrote:

Thank RMM.  Need to find where JohnnyC posted that.  I think MikeC is working with much bigger chips, but maybe the his code could save some time. 

It's in his github repository and was on his site before he started that.  He shared that code with me last August, but it sounds like you've already made it that far.  

Mountain Electronics : batteries, Noctigon, and much more! What's new? 

Diode663
Offline
Last seen: 11 months 2 weeks ago
Joined: 05/26/2015 - 22:24
Posts: 27
Location: United States

As far as i know it shouldnt matter what package it uses as the architechture is the same. And the main advantage i see is the aurdino ide seems much more integrated and user friendly then winavr. Also alot of the low level programing is taken care of for you, the only time you would need to write registers is to set the fast pwm. You can have all the code down below with a few variables up at the top of the code that the user modifies to get the desried modes and features and just click upload. At any point someone can step in and tell me im wrong because i dont have very much time in winavr and im not well versed in programing.

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

Diode663 wrote:
As far as i know it shouldnt matter what package it uses as the architechture is the same....

True, but I do care about the package because I would lke to use the 45 (or 25 or 85) on existing 13A boards we have on OSHPark. Besides new board orders, I got a little stock on the wight designed OSHPark boards, as well as RMM OSHPark boards. I don't have the time or expertise to Eagle CAD new board layouts, maybe someone else could, that would be great, but dunno. It's a chicken and egg thing -- no sense in doin board designs because no working firmware, no motivation to develop firmware without any board designs...

ImA4Wheelr
Offline
Last seen: 16 hours 5 min ago
Joined: 02/03/2013 - 14:51
Posts: 7412
Location: SC

^ I agree.  My understanding is that if the FW is written for the 25, it will work on the other 2.  The nice thing about the 25 is it comes in a 8S1 package which is the same package used for the Attiny13a SSU.

The 45 and 85 come in 8S2 which is the same as the Attiny13a SU.  I purchased some SU's once and they fit all my boards fine without bending the legs.  So I would think those would be fine for our purposes too.

That is why I'm confused about what size I got.  The 10SU I purchased should be in the 8S2 package, but mine appear to the the 8X TSSOP package (See picture in OP).  I will measure them tonight and report back.

 

Diode663,

Thanks for that info.  Sounds pretty interesting.  If you ever do that, please create a thread on it.  It seems like the 25 and 45 should work too as they are pretty much identical except for amount of memory.

RMM
RMM's picture
Offline
Last seen: 1 week 4 days ago
Joined: 07/23/2013 - 13:47
Posts: 3985
Location: USA

The 25/45/85 all run the same software and have the same features with the main difference being the 2KB/4KB/8KB software limitations.  2KB is actually a huge upgrade from 1KB in terms of potential functionality.  The 25 comes in the same small footprint SOIC 8 as our current 13a, but the 45/85 aren't that much bigger and the legs can be folded or cut to make it fit on the same pads.  

Also, be aware that there is a 25 and a 25V.  The regular 25 will die and turn off before you ever hit a 2.8V LVP warning.  

Mountain Electronics : batteries, Noctigon, and much more! What's new? 

ImA4Wheelr
Offline
Last seen: 16 hours 5 min ago
Joined: 02/03/2013 - 14:51
Posts: 7412
Location: SC

The memory part is great, but I'm really wanting to exploit the internal temperature sensor.

I think Tom E has some non "V"'s on the way.  His are the 20Mhz variety.  I image they would be fine in a buck situation.

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

K, got my 45's. Think they will have problems. I ordered ATtiny45-20SHR, which in the 25/45/85 datasheet, is 20 MHz, and 2.7-5.5 volts, which will have the problem Richard described - dying before hitting LVP. These are in the 8S2 package. Didn't size them up yet, but hopefully I can use these for development/testing.

It looks like all the 20 Mhz rated parts are all 2.7v min, while the 10 Mhz parts are 1.8v min.

 

ImA4Wheelr
Offline
Last seen: 16 hours 5 min ago
Joined: 02/03/2013 - 14:51
Posts: 7412
Location: SC

I will probably get the dumb question of the year award for this, but I gotta learn sometime.  2.7v doesn't sound like a half bad cut-off point.  Some cells should only go down to 3v, others 2.5v.  Of course, they bounce back up some after the load is removed.  I tend to replace cells when the get down into the mid to high 3's because they seem boring at that point.  Won't your MCU's have automatic LVP and not need LVP coding?

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 6 hours 42 min ago
Joined: 01/12/2013 - 14:40
Posts: 6212
Location: (469219) 2016 HO3

I’m not sure what it’d do if the MCU shuts off due to voltage. It could “fail open”, so to speak, with the power channel fully connected. Maybe. I’d prefer letting it shut itself (and the light) down properly.

SciFiFreak
Offline
Last seen: 2 days 19 hours ago
Joined: 02/11/2015 - 21:43
Posts: 107
Location: Boise

I would love to see the 2.7v cutoff tested. To be safe an LVP could be programmed for 2.8-2.9V but having a hard cutoff at 2.7 would be good in my opinion. It’d be yet another way to protect us.

Halo...
Halo...'s picture
Offline
Last seen: 1 year 2 months ago
Joined: 12/15/2011 - 02:39
Posts: 3304
Location: Halo island

This isn’t LVP, it’s the voltage range where the chip is expected to behave properly. Some individual attiny25 chips may work just fine outside of the range but it is not guaranteed. The attiny25 and others have a Brown-out Detector that would be better to try as a backup LVP. Brown-out Detection can conveniently be set to 2.7v. Fuses 0×62 0xdd will set Brown-out Detection to 2.7v

RMM
RMM's picture
Offline
Last seen: 1 week 4 days ago
Joined: 07/23/2013 - 13:47
Posts: 3985
Location: USA

Is there any real point in running either chip past 10 MHz?  The chip uses more power at higher MHz.  

Mountain Electronics : batteries, Noctigon, and much more! What's new? 

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 6 hours 42 min ago
Joined: 01/12/2013 - 14:40
Posts: 6212
Location: (469219) 2016 HO3

As far as I can tell, there’s no point running faster than ~5 MHz, since that’s fast enough to make imperceptible 19kHz PWM. It’s not like it’s processing a lot of data.

ImA4Wheelr
Offline
Last seen: 16 hours 5 min ago
Joined: 02/03/2013 - 14:51
Posts: 7412
Location: SC

For the "V" chips, I believe the choices are 6.4 and 8Mhz unless you use an external oscillator.   I opted for 8 just because it is the default and doesn't seem that much higher than 6.4.  I will flash for the lower speed next time.  I chose 1.8v brown out because that is what TK used for BLF-A6.

I tried to add dual PWM Modes (fast/phase) and Alternative PWM output (like for +7135) to Tom E's version of Star Mom.  I have build errors that need to be fixed.  So no progress on LVP testing yet.

I just measured my chip at about .21" square not counting the legs.  So the chip pictured in the OP is the S82 package.

Pages