Hi guys so Ive read that the standard pwm frequency on(UNO) pin 5 and 6 are close to 980hz which is 0.98khz.
Most pages Ive googled say the best frequency to run dc motors are around 16khz .
Now my motor drive is a Pololu daul VNH5019 driver which has the capability of up to 20 khz but im not using it as a shield im using it as a stand alone driver and just using analogWrite to pwm the motors so if i understand correctly my motors are running on 0.98khz which is way to low? (I dont know!)
Ive also read that you can increase the frequency on the arduino pins.
So now how would I increase it to close to 16khz ?
Note that Im using Virtual wire library Im not sure if changing the pwm frequency will effect the library in anyway because of the timers and all.
Thanks in advance for the help guys.
Ok so I found this page http://playground.arduino.cc/Main/TimerPWMCheatsheet
I then added this to my setup:
TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM00);
TCCR0B = _BV(CS00);
I was supposed to add this:(which is 31khz)
And modify the line in the wiring.c function in the Arduino program files
#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(1 * 510))
But I added this:
#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(1 * 1020))
It seems to be working alright but Im guessing my frequency is now 15.6khz is this correct?
I would say 1/(.000510 + .001020) = 654 Hz ? Or maybe .0000000625 needs to be worked in there also? (1/16,000,000)
Do you have a multimeter with a frequency selection on it?
Or a small speaker and a 150 ohm resistor? Can listen to the output. 654 Hz is around E above middle A on a piano. 15-16K will be annoyingly high.