Change PWM frequency of DC motors Arduino Motor Carrier / MKRMotorCarrier library

Congratulations to @facchinm for his library MKRMotorCarrier.

I'm trying to change the PWM frecuency of the signals sent to the DC motor up to 16 or 20 kHz to obtain ultrasonic commutation, because the operation of the DC motors is quite noisy. I see that that function is not programmed:

void DCMotor::setFrequency(int frequency) {
// NB: not implemented at the moment!
//this->frequency = frequency;

Can we expect to get this feature soon? Or can we change the properties of timers TC1 and TC2 within the Motor Carrier ATSAMD11 in some way?


I will make a suggestion you check what the limits of the motor are. You have not posted any information on that. A link to the technical information on the motor will help. You can change the frequency by changing the timer settings.

Hi @gilshultz

I'm using MAXON RE-25-055-35 DC motors (20 W, 2.34 ohms).

I was able to change the frequency of motors M3 and M4 using with SAMD21turboPWM library., becuase the chips MC33926 of the Motor Carrier are they are directly connected to Arduino digital pins 2, 3, 4 and 4. However, motors M1 and M2 are connected to chip drivers DRV8871 and theses drivers are conneted to the ATSAMD11 controller of the Motor Carrier. As far as I know the Arduino Board communicates with this chip ATSAMD11 using a IC2 channel.

Default PWM was a bit less than 1 kHz. I've set motors M3 and M4 to 20 kHz which is the maximum frequency for drivers MC33926. The other two drivers DRV8871 also support 20 kHz frequency, but I don't know how to change it.

Thanks for yor interest.

A picture is worth a thousand words.
This is the actual scheme of my project:

I read the enoders using the FPGA of the Arduino (and not the Motor Carrier) because I can read their values much faster. I have to include a third motor-encoder. I'm considering to cut the physical connetion of Arduino's pin A3 (I don't need to read the current feedback of the motors), so I can introduce a third encoders using A2-A3 pins (or even a fourth encoder with A4-A5 pins). But the third motor (or the fourth) has to be connected to M1 or M2, and that's why I have to change the PWM frequency of the pins 3, 4, 5 or 6 of the chip ATSAMD11 that is inside the Motor Carrier (not the Arduino itself).

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.