Attiny25/45/85 FW Development Thread

1901 posts / 0 new
Last post
Joat
Offline
Last seen: 1 week 2 days ago
Joined: 06/13/2013 - 23:43
Posts: 518
Location: Minnesota

It’s too bad you have to go up to the Attiny 24 to get more than 2 PWM outputs. I’d like to play with RGBW leds.

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

You can do RGBW on a tiny13, but at least two of the channels will be on/off only so if you want PWM you’ll have to do it manually. It’s generally not worthwhile except for low-power indicator lights, like for showing battery state through a translucent button.

Joat
Offline
Last seen: 1 week 2 days ago
Joined: 06/13/2013 - 23:43
Posts: 518
Location: Minnesota

I want PWM on red green and blue, I’d like to play with color mixing. I might buy a DIP package tiny 24 and build a test driver on perf board.

Tom E
Tom E's picture
Offline
Last seen: 1 hour 58 min ago
Joined: 08/19/2012 - 08:23
Posts: 10823
Location: LI NY

Oh boy, I ordered the 20 MHz probably because of my need-for-speed mentality I've had in this biz since 1980. I thought the speed was free, apparently not, I didn't fully research the consequences. At this point, there's no reason to play with the risk of that 2.7v cutoff with the 10 MHz chips. The 45's I received are the 8S2 package, and the legs do need to be bent or clipped to fit on a wight 17 FET+1 driver (http://budgetlightforum.com/node/36710) - it's way too darn close, but the wight 22 FET+1 driver (http://budgetlightforum.com/node/37231) is perfect for these packages with the extra set of extended pads, so it appears. I'll use the 22 mm board for development then.

I'll check around for 25's in the S8S1 package at 10 or 8 Mhz max - this seems to be the best option for using on existing 13A board designs.

This seems like the best in-stock option (ATtiny25V-10SSU):

http://www.mouser.com/ProductDetail/Atmel/ATTINY25V-10SSU/?qs=sGAEpiMZZMvqv2n3s2xjsY4e7hoSVIBakrXdKP3UXak%3d


 

 

 

SciFiFreak
Offline
Last seen: 1 week 3 days ago
Joined: 02/11/2015 - 21:43
Posts: 107
Location: Boise

So I realized that I had just received an attiny85-20SUR from Mouser the other day. I bent the legs and soldered it to a 105C to do some tests using TKs Cypreus2 firmware.

With the following fuses (2.7 Brownout Detection) I had the these results.
-U lfuse:w:0×62:m -U hfuse:w:0xdd:m -U efuse:w:0xff:m

3.11 works
3.07 erratic
3.05 more erratic
3.04 off
3.03 off
3.02 off

Then I flashed these fuses to disable brownout detection and got these results.
-U lfuse:w:0×62:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m

3.06 works
2.98 works
2.83 LVP

So on my test board the 2.7V brownout detection actually started kicking in just over 3V. With it disabled the programmed LVP correctly shutdown the light at 2.8V. Next I’ll disable the LVP in the firmware to see how low the attiny85 will go.

EDIT: I should note that the voltages were tested after disconnecting the battery so there may have been some sag involved. That said, if even the very low moonlight level wouldn’t light up there couldn’t have been that much sag.
EDIT2: While replicating my results I realized that I had wrongly attributed the LVP shutdown to the attiny85 when it was the attiny13a.

SciFiFreak
Offline
Last seen: 1 week 3 days ago
Joined: 02/11/2015 - 21:43
Posts: 107
Location: Boise

So my attiny85 works all the way down to 2.5V. That’s far lower than I wanted it to be able to go. It might go lower but that’s as far as I’m taking my battery.

ImA4Wheelr
Offline
Last seen: 1 day 1 hour ago
Joined: 02/03/2013 - 14:51
Posts: 7444
Location: SC

^ Great info SciFiFreak.  Thank you for sharing.  Looking forward to hearing about your next test.

Did you change the FW code at all?  I ask because I see it references memory code "WDTIE".  That isn't a valid code on the 85.  It's equivalent would be "WDIE".  You many want to also change F_CPU to 8000000 with the last fuse settings you listed.  You probably did all that, but I mention it just in case.

I didn't look at all the memory references.  Just the above because those were the only real changes I had to make to the version of Star Momentary I ported over.

EDIT:  Not sure I follow your "EDIT2:" above.  Can you elaborate on it?

SciFiFreak
Offline
Last seen: 1 week 3 days ago
Joined: 02/11/2015 - 21:43
Posts: 107
Location: Boise
ImA4Wheelr wrote:

^ Great info SciFiFreak.  Thank you for sharing.  Looking forward to hearing about your next test.

Did you change the FW code at all?  I ask because I see it references memory code “WDTIE”.  That isn’t a valid code on the 85.  It’s equivalent would be “WDIE”.  You many want to also change F_CPU to 8000000 with the last fuse settings you listed.  You probably did all that, but I mention it just in case.

I haven’t touched the firmware in any way yet but will start digging into that soon. Thanks for the tips. My primary goal was just to see if it ran and at what voltages it would run. My basic tests were only simple mode changes.

SciFiFreak
Offline
Last seen: 1 week 3 days ago
Joined: 02/11/2015 - 21:43
Posts: 107
Location: Boise
ImA4Wheelr wrote:
Not sure I follow your “EDIT2:” above.  Can you elaborate on it?

While testing the voltages I was bouncing the battery back and forth between a FET+1 attiny13a, to discharge it, a charger, and the 105C attiny85. I thought I saw the 85 do the LVP step-down and turn off. In reality it was the 13a and I had gotten them confused. So the LVP code in the Cypreus2 firmware doesn’t seem to work on the 85 (at least on the 105C). That’s OK, it’s a different chip/board after all.

ImA4Wheelr
Offline
Last seen: 1 day 1 hour ago
Joined: 02/03/2013 - 14:51
Posts: 7444
Location: SC

Thank you for the follow up SciFiFreak.   Smile

 

TK wrote:

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.

If going running faster can get rid of the whining in the medium to highish modes, that would be a a good point in favor of it.  I didn't notice any whining when testing at 8MHz, but I wasn't focused on that when I was doing the test.  I will listen for that this weekend and report back.

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

ImA4Wheelr wrote:

 

TK wrote:

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.

If going running faster can get rid of the whining in the medium to highish modes, that would be a a good point in favor of it.  I didn’t notice any whining when testing at 8MHz, but I wasn’t focused on that when I was doing the test.  I will listen for that this weekend and report back.


Oh, it shouldn’t whine with fast PWM (19 kHz), but you’ll probably hear whining with phase-correct PWM (~9 kHz).

I mean, unless you have extremely unusually good hearing, in which case 19 kHz might still be audible.

Also, I’m surprised to hear that the cypreus2 code compiles for the attiny85, much less actually works. I thought it had enough differences that it would require some rewriting. But if only the WDT stuff needed changes in STAR, that would explain why cypreus2 works… it doesn’t use the WDT.

ImA4Wheelr
Offline
Last seen: 1 day 1 hour ago
Joined: 02/03/2013 - 14:51
Posts: 7444
Location: SC

TK wrote:
Oh, it shouldn’t whine with fast PWM (19 kHz), but you’ll probably hear whining with phase-correct PWM (~9 kHz).

I mean, unless you have extremely unusually good hearing, in which case 19 kHz might still be audible. . . .

My wife says I have a terrible sense of hearing.  At least, I think that's what she says.  Wink

Seriously though, my sense of hearing really is pretty bad.  I have never heard fast (19k) PWM.  I do hear phase PWM as you mention.  My wife and dogs, on the other hand, regularly comment on the noise my lights make in the mid to highish modes.  That, in a sense, pretty much makes me sensitive to it too.  Since 19k is on the outer edge of human hearing, nudging up the frequency might add some peace in my household.  That would be a definite benefit of moving to the Attiny25, at least for me and my wife.  The dogs will probably still occasionally bark.

RMM
RMM's picture
Offline
Last seen: 5 hours 7 min ago
Joined: 07/23/2013 - 13:47
Posts: 3985
Location: USA

I can hear the 19KHz PWM in most lights in the middle modes, but that's because what I'm hearing isn't 19KHz anymore--it's the springs and MLCCs resonating at a lower frequency.  MLCCs are especially bad (piezoelectric effect).

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

led4power
led4power's picture
Offline
Last seen: 2 hours 44 min ago
Joined: 12/29/2012 - 09:48
Posts: 631
Location: Croatia,EU

Things (MLCCs,springs,glass...)can't "vibrate" at frequency different than source(driver in this case). So if current\voltage frequency is 19kHz,all other components are forced to vibrate at that frequency (+harmonics if source generates signal different than pure sine). Resonant frequency is frequency at which vibration reaches its maximum,but it doesn't influence system frequency forced by external source(driver).

dchomak
Offline
Last seen: 20 min 55 sec ago
Joined: 03/17/2012 - 20:10
Posts: 3876
Location: Connecticut
led4power wrote:

Things (MLCCs,springs,glass…)can’t “vibrate” at frequency different than source(driver in this case). So if current\voltage frequency is 19kHz,all other components are forced to vibrate at that frequency (+harmonics if source generates signal different than pure sine). Resonant frequency is frequency at which vibration reaches its maximum,but it doesn’t influence system frequency forced by external source(driver).

There is a thing called the heterodyne effect
https://en.wikipedia.org/wiki/Heterodyne

This could explain all of this

led4power
led4power's picture
Offline
Last seen: 2 hours 44 min ago
Joined: 12/29/2012 - 09:48
Posts: 631
Location: Croatia,EU

You must have two signals and mix it for that effect to occur.

For start it would be best to actually measure frequency of sound that comes from driver(with known pwm driver frequency). Microphone+PC or smartphone app is the simplest method.

dchomak
Offline
Last seen: 20 min 55 sec ago
Joined: 03/17/2012 - 20:10
Posts: 3876
Location: Connecticut

If anything is being heard, I’m pretty sure it wouldn’t be 19kHz. I am guessing that it is a frequency much lower than that.
When PWM is in place, there is a whole infinite spectrum of frequencies present in the output wave form, including frequencies low enough to beat against each other in the springs etc.

I can’t say exactly what is going on, just that if something is being heard, them something is going on.

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

PWM is a square wave, or pretty close to it, and square waves have more harmonics than almost anything else. I wouldn’t be surprised if it’s making other audible frequencies, especially on bigger lights or high-powered circuits.

ImA4Wheelr
Offline
Last seen: 1 day 1 hour ago
Joined: 02/03/2013 - 14:51
Posts: 7444
Location: SC

^ The problem does seem to manifest in my large high power buck lights.

Tom E wrote:

. . . but the wight 22 FET+1 driver (http://budgetlightforum.com/node/37231) is perfect for these packages with the extra set of extended pads, so it appears. I'll use the 22 mm board for development then.

Been trying to use this board, but I can't get the FW to work right on it.  It never goes to sleep mode and mode changes are a bit erratic.  When the driver is populated with components, but not connected to a cell or a LED, I read some continuity from Pin 2 and ground.  Maybe that is normal, but it seems the problem is related the momentary switch pin.  The board works fine with an Attiny13a and BLF-A6 loaded.

Gonna needed to change to a different driver board.

Tom E
Tom E's picture
Offline
Last seen: 1 hour 58 min ago
Joined: 08/19/2012 - 08:23
Posts: 10823
Location: LI NY

I just reflowed the 45 to that 22mm FET +1 driver, and pin #2 looks good - it connects to the OTC pad. If you have a grnd signal on pin #2, that could mean the OTC pad has some connection, as if the OTC cap is mounted - it can't be for the default e-switch setup. Could be a bad trace in that specific driver PCB, weird...

RMM
RMM's picture
Offline
Last seen: 5 hours 7 min ago
Joined: 07/23/2013 - 13:47
Posts: 3985
Location: USA

led4power wrote:

Things (MLCCs,springs,glass...)can't "vibrate" at frequency different than source(driver in this case). So if current\voltage frequency is 19kHz,all other components are forced to vibrate at that frequency (+harmonics if source generates signal different than pure sine). Resonant frequency is frequency at which vibration reaches its maximum,but it doesn't influence system frequency forced by external source(driver).

What happens when you hit a piece of metal and it rings after the initial impulse?  What do they call that, tambor?  I may have used the incorrect terminology, but that is what is happening here.  I can't even hear 17kHz sounds, and I've measured the PWM to be always at 18kHz+.  The frequency you're hearing isn't the PWM frequency.  

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

Tom E
Tom E's picture
Offline
Last seen: 1 hour 58 min ago
Joined: 08/19/2012 - 08:23
Posts: 10823
Location: LI NY

I flashed the 45 on the 22mm FET+1 driver, and so far it's look'n pretty good. I got 5 modes, first 3 are on the 7135, and the 4th on a combo of the FET and 7135, last is FET only. Looks like the 1st mode doesn't work at all, 2nd and 3rd modes are the same roughly, and the 4th and 5th look normal. Strongly suspect the 7135 PWM's aren't working/configuring correctly. I got the strobe looking pretty good though - it's frequency looks pretty good - it runs at a pretty high frequency, meant to be disorienting.

I'm using for fuses: low: 0xe2, hi: 0xdf, extra: 0xff. So, I'm setting clock/8, and disabling brown out detection.

Gotta research that PWM channel used for the 7135. Though Richard mentioned some differences, maybe PWM's...

ImA4Wheelr
Offline
Last seen: 1 day 1 hour ago
Joined: 02/03/2013 - 14:51
Posts: 7444
Location: SC

Tom E wrote: 

. . . Could be a bad trace in that specific driver PCB, weird

Thanks Tom.  When I depopulate the boards, I'll have to check for that.  The trace running over to the OTC pads is very close to the ground trace.  So maybe there is some leakage going on there.  When I do, I'll also transfer the MCU directly over to a 17DD and see if the problem disappears.

Tom E wrote

:I flashed the 45 on the 22mm FET+1 driver, and so far it's look'n pretty good. I got 5 modes, first 3 are on the 7135, and the 4th on a combo of the FET and 7135, last is FET only. Looks like the 1st mode doesn't work at all, 2nd and 3rd modes are the same roughly, and the 4th and 5th look normal. Strongly suspect the 7135 PWM's aren't working/configuring correctly. I got the strobe looking pretty good though - it's frequency looks pretty good - it runs at a pretty high frequency, meant to be disorienting.

I'm using for fuses: low: 0xe2, hi: 0xdf, extra: 0xff. So, I'm setting clock/8, and disabling brown out detection.

Gotta research that PWM channel used for the 7135. Though Richard mentioned some differences, maybe PWM's...

The 2 channels of PWM changes some stuff.  I think I read that one of the channels is only for phase and the other only for fast.  So maybe that is it.  I did have one 17mm board that would not work on the FET channel (using Attiny13a).  I swapped mcu's, 7135's, etc and it just wouldn't work.

I don't think the fuse setting above would effect dividing your clock by 8.  Strobe would be pretty slow if they did.

 

 

 

 

 

Tom E
Tom E's picture
Offline
Last seen: 1 hour 58 min ago
Joined: 08/19/2012 - 08:23
Posts: 10823
Location: LI NY

All I changed was the low fuse, from 0x62 to 0xe2, and then the strobe sped up significantly. Dunno - strobe depends on the _delay_ms() function.

I'll have to dig more into the PWM stuff then - that would be a limitation with these MCU's - surprised they are less functional than the 13A.

These are the modes/PWM options I'm using:

#define MODES     0,    0,    0,    0,   80,  255  // Must be low to high, and must start with 0
#define ALT_MODES 0,    5,   30,  255,  255,    0  // for secondary (7135) output. Comment out if no secondary output
#define MODE_PWM  0,PHASE, FAST,PHASE, FAST,PHASE  // Define one per mode above. 0 tells the light to go to sleep

So, looks like modes 1 and 3 are the flaky ones both are on the 7135 in PHASE mode... Interesting. Look'n thru the data sheets, it sure is confusing, but I see possible differences in PWM's for the two pins (PB1 is the FET, and PB0 is the alternate PWM output 7135).

 

ImA4Wheelr
Offline
Last seen: 1 day 1 hour ago
Joined: 02/03/2013 - 14:51
Posts: 7444
Location: SC

^ Same here.  Much to learn about this mcu.  You may be right, but I think we will find it has more functionality.  Even if one channel is only phase and the other fast, they both can be feed to Pins 5 and 6.  OCO is one of the PWM channels.  OC1 is the other PWM channel.  Notice both Pins 5 and 6 can be feed from both PWM channels.  I think we just need to learn how to get them to work for us.

led4power
led4power's picture
Offline
Last seen: 2 hours 44 min ago
Joined: 12/29/2012 - 09:48
Posts: 631
Location: Croatia,EU

RMM wrote:

What happens when you hit a piece of metal and it rings after the initial impulse?  What do they  call that, tambor?  I may have used the incorrect terminology, but that is what is happening here.  I can't even hear 17kHz sounds, and I've measured the PWM to be always at 18kHz+.  The frequency you're hearing isn't the PWM frequency.  

That's "free response" and in that case you'll hear resonant frequency. But important thing is that mlcc capacitor have resonant frequency of several hundreds kHz,so there is no chance that capacitor produces lower than pwm sound,which leaves spring as only possible source of sound lower than pwm frequency. Is there a noise when driver is connected with wires without spring?

Tom E
Tom E's picture
Offline
Last seen: 1 hour 58 min ago
Joined: 08/19/2012 - 08:23
Posts: 10823
Location: LI NY

Seems like I bricked the 45, may be those fuse settings I used, in post #52 above, not sure yet. AVRDude connects fine, then can't verify at address 0x0000 (1st address), so acts like it's bricked. Tried several times, so seems permanent. I'll have to reflow another - dunno if just something flaky, or are they really bad fuse settings.

This looks like a great tool for fuse settings btw: http://www.engbedded.com/cgi-bin/fcx.cgi?P_PREV=ATtiny13A&P=ATtiny45&M_LOW_0x0F=0x09&M_LOW_0x80=0x00&M_HIGH_0x06=0x04&M_HIGH_0x10=0x00&B_SPIEN=P&B_SELFPRGEN=P&B_SUT0=P&B_CKSEL1=P&B_BODLEVEL0=P&V_LOW=79&V_HIGH=ED

This is the Fuse resetter design: http://homepage.hispeed.ch/peterfleury/avr-hvsp-fuse-restore.html

 

RMM
RMM's picture
Offline
Last seen: 5 hours 7 min ago
Joined: 07/23/2013 - 13:47
Posts: 3985
Location: USA

led4power wrote:

RMM wrote:

What happens when you hit a piece of metal and it rings after the initial impulse?  What do they  call that, tambor?  I may have used the incorrect terminology, but that is what is happening here.  I can't even hear 17kHz sounds, and I've measured the PWM to be always at 18kHz+.  The frequency you're hearing isn't the PWM frequency.  

That's "free response" and in that case you'll hear resonant frequency. But important thing is that mlcc capacitor have resonant frequency of several hundreds kHz,so there is no chance that capacitor produces lower than pwm sound,which leaves spring as only possible source of sound lower than pwm frequency. Is there a noise when driver is connected with wires without spring?

Yes, it is possibly the spring, but that's my point--once you get it installed in a light, you can hear it.  Much of the MLCC noise comes from the MLCC vibrating against the PCB. 

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

ImA4Wheelr
Offline
Last seen: 1 day 1 hour ago
Joined: 02/03/2013 - 14:51
Posts: 7444
Location: SC

Tom E wrote:

Seems like I bricked the 45, may be those fuse settings I used, in post #52 above, not sure yet. AVRDude connects fine, then can't verify at address 0x0000 (1st address), so acts like it's bricked. Tried several times, so seems permanent. I'll have to reflow another - dunno if just something flaky, or are they really bad fuse settings.

This looks like a great tool for fuse settings btw: http://www.engbedded.com/cgi-bin/fcx.cgi?P_PREV=ATtiny13A&P=ATtiny45&M_LOW_0x0F=0x09&M_LOW_0x80=0x00&M_HIGH_0x06=0x04&M_HIGH_0x10=0x00&B_SPIEN=P&B_SELFPRGEN=P&B_SUT0=P&B_CKSEL1=P&B_BODLEVEL0=P&V_LOW=79&V_HIGH=ED

This is the Fuse resetter design: http://homepage.hispeed.ch/peterfleury/avr-hvsp-fuse-restore.html

That fuse resetter looks like the simplest design out there.  Thanks for sharing that.

I think that is the same fuse tool Halo linked to in Post 2.  It can be used in reverse.  Just plug in your fuse values in the bottom and see what settings they would give you above.  It seems your  fuse values in 52 are valid.  Is your programmer set to 5 volts?

What specific FW are you using for the DD+7135?  I'd like to check it out.

Diode663
Offline
Last seen: 1 year 1 week ago
Joined: 05/26/2015 - 22:24
Posts: 27
Location: United States

I can hear the PWM whine as well. This is what I got from a smart phone app that seems to be in line with what we are all hearing.

Pages