DRV8841 +AS5048a + ESP32-S3 stepper motor closed loop issues

Hi! I have been trying getting closed loop to work with my custom DRV8841 + ESP32-s3 board for a nema17 stepper.


This is the velocity behaviour in closed loop.


This is with a higher target velocity.


Here is what the stepper looks like during.


Behaviour in torque closed loop

Higher target torque

Debuging the AS5048a with the drivers library I get the following information

Does this seem like a reasonable amount of noise? This is during no movement and while the driver is not activated.

I have tried increasing the velocity LPF without much improvement.
Setting sensor.min_elapsed_time = 0.001; did not improve the closed loop behaviour, but did drastically reduce the noise in the velocity readings from the magnetic sensor.


This is using 1ms as min_elapsed_time

This is 0.1ms as min_elapsed_time

The magnet should be good, from supermagnete.de. There is also has a plastic space between the magnet and the metal shaft. The distance between the magnet and the sensor is very low, about 1mm, this gave a decent AGC-value of ~50. Increasing the distance does not improve the performance.
PP check and all the diagnostics seem good.

Any clue as to what could be causing these issues? Thanks :slight_smile:

Fine-tuning the zero_electric_angle seemed to help quite a bit