Optimal PWM frequency to control a DC motor?

Hi all,

for our project, we control two Fischertechnik DC motors via an Ardumoto shield on top of an Arduino Uno. To control speed, we use PWM on pins 3 and 11.

Today, a friend pointed out that, if the PWM frequency was too low, the permanent magnets of the motor might slowly get demagnetized; thus their performance will drop over time. According to the reference, the default frequency of the PWM signal is about 490 Hz. My friend recommended to set the PWM frequency to about 2 to 4 kHz.

I am aware that one can set the Arduino's PWM frequency, but the code's comment also says that

Changes on pins 3, 5, 6, or 11 may cause the delay() and millis() functions to stop working.

a thing I definitely want to avoid.

Has anyone any hint what I should do?

Thanks, Roland

timer0 does millis() etc and it only controls pins 5 and 6. timer1 controls pins 9 and 10, timer2 controls 3 and 11.

By default timers 1&2 are only used for PWM only unless you use a library that employs one of them (the Servo library for instance).

As for optimal frequency that depends on the various losses in the system - iron losses in the motor increase with both frequency and current-ripple, switching losses in the H-bridge/controller increase with frequency. Too low a frequency causes higher current-ripple leading to increased winding (copper) losses and can cause annoying mechanical vibration and whining... Many RC motor controllers use 8 or 16kHz PWM BTW