Attiny25/45/85 FW Development Thread

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.

Thank you for the follow up SciFiFreak. :)

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.

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.

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.

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).

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

This could explain all of this

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.

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.

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.

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

Tom E wrote:

. . . but the wight 22 FET+1 driver (https://budgetlightforum.com/t/-/31559) 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.

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...

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.

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...

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.

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).

^ 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.

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?

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

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.