LowPowerLab Forum

Hardware support => Moteino => Topic started by: sntlewis on January 02, 2014, 04:48:54 PM

Title: Changing PWM Frequency (running PWM Fan)
Post by: sntlewis on January 02, 2014, 04:48:54 PM
Now that I have the RFM69 working with the Mega2560...  Thanks for all the help...

I'm onto to the next level of the project which is a PWM fan controlled by the Moteino (ulitmately temp will be monitored by the 2560 and fan speed up/down sent to the Moteino).  I've got the fan working but the PWM frequency creates "audible" noise (I expected this so this isn't new).  Solution is to shift the PWM frequency higher to above 20KHz.

And I don't want to break things before I get started (too much).

I realize that if I diddle with Timer0 and its PWM pins (5,6) I could break/hinder the delay() and millis() functions..  I think this will cause timing problems for the Moteino and RFM69 library.

Now what if I messed with the PWM frequency of Timer1 or Timer2.  How does that mess with the SPI interface portion of the RFM69/Mega328 interface?

Anyone else done this?
Title: Re: Changing PWM Frequency (running PWM Fan)
Post by: sntlewis on January 03, 2014, 10:39:39 AM
Ok a bit more clarification...

If I set OC2A/OC2B to some other frequency than the "default" will the RFM69 continue to work?
Title: Re: Changing PWM Frequency (running PWM Fan)
Post by: Felix on January 03, 2014, 12:13:36 PM
I'm not intimately familiar with the OC2A/OC2B timer interrupts. A good way to know quickly is to try... I don't really see a reason why it should not, the SPI should work at most frequencies and I believe that's not affected.
Title: Re: Changing PWM Frequency (running PWM Fan)
Post by: sntlewis on January 04, 2014, 03:24:03 PM
worked just fine with D3/D11 and OCR2A/OCR2B...

Yeah, moteino running PC pwm fan...

onto next level of project..
Title: Re: Changing PWM Frequency (running PWM Fan)
Post by: john k2ox on January 04, 2014, 09:52:14 PM
Glad to see you got this working.  I did the same thing a few years ago. It controls the acceleration of a 50V 22A motor that rotates a 200 lb antenna 120 ft in the air.  Arduinos - Rule!!

If I remember correctly Atmegas have two internal pwm's and changing the wrong one scales the delay functions.
Title: Re: Changing PWM Frequency (running PWM Fan)
Post by: sntlewis on January 05, 2014, 01:00:41 PM
Yep, stay away from Timer0, if at all possible.