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.

4 Likes

Hi just out of curiosity, were you able to validate this ?

Validate what, matt? Runger has extensive experience experimenting with these things, yes.

I would say that I tried using PWM and although I agree it is kind of crummy, if you get the update frequency up to 920 hz and use the smoothingsensor thing, it seems like a reasonable approach for some applications. There is that dead spot at top dead center.

To be honest I even tried analog because it is fairly noise-proof and I wanted that, which does actually work ok in my case, it just has the bothersome tendency to make it look like everything suddenly started turning backwards at high speed once per rotation. The voltage rises but it has to drop at some point and it cannot do that instantly. When it does it looks like everything is turning really fast the wrong way :stuck_out_tongue: . of course I was able to filter that out but it was bother.