STM32 increase PWM frequency to minimize audible noise

I am using MA730 absolute encoder with Nucleo L432KC - STM32L476KC, 2 pole BLDC motor without mechanical gear, SpaceVectorPWM modulation and angle (position) control.
After calibrating the control loop gains while keeping the ā€œPā€ gains as small as possible, I still have audible some noise at standstill when keeping the position.
How can I increase the PWM frequency to minimize the audible noise?


Hey @Geronimo,

I am not sure what kind of audible noise you have, maybe some video would give us a better idea.
STM32 devices (with simplefoc) should have the PWM frequency by defaulter of 25kHz which should not be audible.
You might have issues with your PIDs which amplify the noise of your sensors maybe.

So to change the pwm frequency just this line before driver.init().

driver.pwm_frequency = 30000;

And if the issue is the PID then you can try to increase the velocity LPF connstant

motor.LPF_velocity.Tf = 0.01: //defualt 0.005 s
1 Like

thanks! great answer