I’m using an ESP32S3 and AS5047 (using SPI) with the “Closing the loop test” ( Closing the Loop Test | Arduino-FOC ) and finding that the motor makes a grinding noise in torque control mode. It’s a 20 ohm drone gimbal motor.
Anyone know how to solve this? The motor also slightly wobbles.
I’ve tried playing around with the PID values to no avail.
Here is some monitor data that shows the current angle vs the loop output voltage:
I’ve measured the noise in the angle measurement and it is within expected limits for the AS5047P. The velocity is clearly affected by the angular noise.
I’ve found that if I set
motor.LPF_velocity.Tf = 0.02;
the noise and wobble much reduces. The problem now is I have a less reactive gimbal motor since filtering is done across 1/50 second of samples.
Why does SimpleFOC not do filtering on position samples? This would reduce noise in velocity which is currently amplified due to the differentiation between adjacent noisy position samples.
It does, with motor.LPF_angle.Tf .
I found this cheat sheet very useful
Thanks I totally missed that variable. 
By the way, I increased motor.LPF_angle.Tf all the way to 1.0 where the motor is really unstable, wobbling back and forth, and it still did not fix the motor noise issue.
I am thinking perhaps that variable only filters the angle once it comes back integrated from the velocity.
Yeah, only the angle PID sees the filtered angle result. Velocity comes straight from the sensor class and then is filtered by LPF_velocity.
Have you tried increasing sensor.min_elapsed_time?
You could also use pseudo-velocity angle mode. Set controller to angle or angle_nocascade and increment the target by your desired velocity the way velocity_openloop does. Smoother at low speed than velocity control mode, and guarantees the correct amount of movement over time.
I got it working okay in the end by using a combination of:
- sensor.min_elapsed_time
- motor.LPF_velocity.Tf
- motor.PID_velocity.P
- motor.PID_velocity.I
I only found out about the last two from this link: Tuning Velocity Loop | Arduino-FOC which I found made things pretty good.
The SimpleFOC documentation is extensive and a really useful/impressive level of detail, but I find it really hard to follow as a whole since there is duplication and it jumps around the place.
I’m going to do the current sensing next by following the Getting Started Guide and try to resist the temptation to follow links to yet more documentation!