Go Down

Topic: ATTiny85 PWM frequency selection (Read 4933 times) previous topic - next topic

Bobnova

A bit of background:
I'm looking to control PWM computer cooling fans directly from an ATTiny85, the fans want a ~15-25khz PWM signal.  The currant involved in minimal.

At default settings with Coding Badly's excellent arduino port I got 500hz from pin0 and 1khz from pin1.
If I use " TCCR0B = TCCR0B & 0b11111101 | 0x01;" from the Arduino PWM frequency howto, I can get 1khz from pin0 and 2khz from pin1.

However from reading about AVRs in general it appears that far higher is possible, just not doable through the arduino environment.
Is this correct?  Am I totally out to lunch?

Any help/advice would be greatly appreciated.
(Sidenote:  The 328p's ~32khz output works, but is horrendously inefficient in controlling fans, they don't like it much)

Coding Badly

I'm looking to control PWM computer cooling fans directly from an ATTiny85, the fans want a ~15-25khz PWM signal.


Sounds good.

Quote
The currant involved in minimal.


How minimal?  It's extremely rare to find a motor that can be driven directly from a microprocessor.  Or do the cooling fans have a "control line" separate from the power?

Quote
At default settings with Coding Badly's excellent arduino port


Thanks!   :D

Quote
I got 500hz from pin0 and 1khz from pin1.


Are you running the processor at 16 MHz?

Quote
However from reading about AVRs in general it appears that far higher is possible


The ATtiny85 is capable of generating a 64 MHz PWM signal.  So "far higher" is a good description.

Quote
just not doable through the arduino environment.


The Tiny Core includes a "veneer" that makes changing the timers a bit easier.  Confirm the processor speed and I'll try to help.

MarkT

Quote
If I use " TCCR0B = TCCR0B & 0b11111101 | 0x01;" from the Arduino PWM frequency howto, I can get 1khz from pin0 and 2khz from pin1.


I don't know if the ATTiny85 is similar to the 328, but if so that line needs to be:
TCCR0B = TCCR0B & 0b11111000 | 0b001 ; // set to divide-by-1 prescale
(The 328 timer prescaler fields are 3 bits wide)
[ I won't respond to messages, use the forum please ]

Bobnova

#3
May 13, 2011, 03:54 pm Last Edit: May 13, 2011, 04:14 pm by Bobnova Reason: 1
Minimal currant like <=15ma, the fans are four pin type things: +12v, ground, tach output (you pull it high, it grounds that wire twice per revolution) and PWM input.
The PWM input goes to a controller on the fan circuitboard that figures out when to switch the mosfets to get the fan to run at the speed you selected via PWM.  It's a pretty cool setup, though they cost more than the three pin non-PWM fans.

Processor speed wise I've tried both 1mhz and 8mhz, I don't have any spare 16mhz crystals/resonators.  I should get some.

I'll try that line in my attiny85 and report back in with what happens.

Thanks for the input!


(Sidenote: I got 15.4khz PWM out of a 328p by using the internal oscillator at 8mhz and running the timer at full speed, but attiny85's are cheaper and easier to find)



EDIT:
That worked beautifully!  I now have a pair of 15.6khz PWM outputs from my attiny85.
Thank you very much!

putyn



EDIT:
That worked beautifully!  I now have a pair of 15.6khz PWM outputs from my attiny85.
Thank you very much!


how did you get it to work ? :)

Go Up