Problem with motor noise & Pololu motor driver

Hi,

I've got Arduino attached to Pololu motor driver:

Controlling this 12v DC motor at varying voltages between 4 and 12 with 3.5 peak Amps:

The motor/driver/Arduino combination is all working as expected, but the noise generated in the motor by the PWM frequency is piercing. If I wasn't using the Pololu driver, I would simply put a capacitor in line with the motor, but I can't do that here. When I tried, there is some kind of short that on small capacitors doesn't seem to have any effect but sparking, but larger ones cause noise in the Arduino. Neither have any affect on the motor noise. What I think the motor driver is doing is alternating the positive/negative output to create an average PWM flow in either of two directions. Any ideas of how I can loose the noise? I've been scouring the net for hours and can't seem to find a solution.

Thanks,

Joe

Try a different PWM frequency. It's common for motors to "sing" at the PWM frequency
being used.

The Pololu motor driver can handle a PWM frequency up to 40kHz (that is very high).
The Arduino analogWrite() uses about 450Hz (that is a low frequency).

This is about changing the registers, Arduino Playground - TimerPWMCheatsheet

This is a small function that sets the registers, Arduino Playground - HomePage

Some made a complete library, but I think that small code will do the trick.

The best PWM frequency does depend to some extent on the motor - larger motors like lower
frequencies (less iron losses). Too low a PWM frequency causes mechanical resonances which
are annoying, but can loosen the windings too which is not desirable! Typical frequencies used
are 4, 8, 16kHz.

The standard Arduino configuration has about 1kHz on pins 5 and 6
and about 500Hz on the other PWM pins. The clock prescaler for each of the timers can be
changed to control the PWM speed of the the relevant pins - but timer0 is used for millis() and
delay() and so you would normally not change that (it drives pins 5 and 6).

The Pololu driver seems to have sluggish switching/dead time of several us, so that could mean
high switching losses at 16kHz and above - you may want to experiment a bit.

Changing the PWM Frequency helped tremendously! I used this library:

and bumped up the frequency to 6.5kHz --> no noise whatsoever, and the motor is spinning smoother on lower rates than with the analogWrite function.

Thanks for the info, saved me a lot of time!

So the frequency change worked great for getting rid of the motor noise, however with the higher frequency, I loose motor torque. Any ideas?