Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

Change pmw frequency DRV8835?



I have problems driving a lego PF motor 8883 as discussed here.

Now please tell me how can I change the raspberry library to operate at 125khz PWM, asynchronous current recycling default 20khz?



Hello, Martin.

You can change the PWM frequency used in the Python library for the DRV8835 Dual Motor Driver Kit for Raspberry Pi by modifying the values for _max_speed and the pwm clock speed (wiringpi.pwmSetClock()) in pololu_drv8835_rpi.py. The Raspberry Pi PWM clock has a base frequency of 19.2 MHz. You can use the following formula to figure out the values for the clock divisor and range counter to get your specific frequency:

PWM\ frequency = {19.2\ Mhz \over (clock\ divider \times range)}

- Amanda


Thanks for the support!
Ok so it was like that and I tried with 1 and 150 which should then result in 128kHz, however it wouldn’t drive the motor. I switched back to the old L298N which got it running. Too bad I can’t use the DRV8835 as it’s better in soo many ways than L298N, however if the motor won’t run due to OCP is engaging I have not much use for it.

Not any ways to disable OCP?



No; there is no way to disable the DRV8835’s over-current protection feature.

We looked at your thread on the Electrical Engineering Stack Exchange forum again and realized that the extra capacitors on the DRV8835’s VM and VCC lines could be causing the issue. In our experience with the DRV8835, we’ve noticed that the motor driver is sensitive to extra capacitance, so you might consider removing those capacitors to see if that helps the problem.

- Amanda


Thanks for the support!

I guess you mean the capacitator on the motor lego 8883? Or how would i disable the capacitator on the driver DRV8835?


I’m referring to the capacitors that you mentioned adding in your Stack Exchange post.

- Amanda


oh sorry that’s not mine, I was only referring to it as I’m having the same problem. I’m using your Drv8835 kit for Raspberry pi ootb.
However, the post suggests that the Lego motor has additional capacitators to reduce noise, maybe I can disable those.