Magnetic sensors protocols

I am planning on using the AS5047 magnetic position sensor for a project with an ESP32 board. I see the sensor supports several different communication protocols (SPI/ABI/PWM/UVW). Is there any advantage of choosing one method over another? Will it make a difference in accuracy or efficiency?

Yes, it can make a big difference…

PWM is poorly supported in SimpleFOC, very slow, and inaccurate. I would strongly advise against using it for motor control.

UVW is a mode where the sensor simulates the response of 3 hall sensors. Its intended, I believe, for use in situations where you want compatibility with existing hardware that expects such inputs. Its a lot lower resolution than the other modes, so I would not use it.

SPI is a fast digital protocol. The AS5047 is well supported, both by our generic MagneticSensorSPI driver, and a AS5047 specific driver in our drivers repository. You get the full accuracy of the sensor, and via the specific driver can also access its other registers to configure it or obtain diagnostic information. SPI needs 4 IO pins on your MCU: MOSI, MISO, SCLK and nCS (which can be any pin).

ABZ is a mode where the sensor simulates the output of a standard quadrature rotary encoder. It is very fast, accurate and simple to interface. It is supported by our Encoder driver, or on STM32 MCU by our STM32HardwareEncoder driver (drivers repository).

ABZ has the advantage of lower latency, while SPI has higher latency, but has the advantage of the additional functions and is always absolute. ABZ is relative until the index pin is found (which means moving the motor to find it) and unless using the hardware encoder class, it causes interrupt load on the MCU, which will limit the maximum speed you can achieve.

2 Likes