Skip to main content
Associate III
September 1, 2024
Solved

AS5047u SPI Driver

  • September 1, 2024
  • 1 reply
  • 3139 views

So i started to learn stm32cubeide recently i decided to write a driver for AS5047u magnetic sensor using SPI and i can communicate with the IC with SPI. On reading the data i get a 16 bit value from it the first two bits are don't care bits and i have now 14 bits of data. How do i convert them into angles ? should i convert the 14bit Binary vaue into something else ??? This is the datasheet of the IC
https://look.ams-osram.com/m/48d90c982e0879e8/original/AS5047U-DS000637.pdf
 Any help would be appreciated. Thank you 

Best answer by Tesla DeLorean

Which part, the one where the document explains you're sending data out, and getting it back later?

That each 16-bit frame has a CS around it, the bus is symmetrical, so you send the read command in one burst, but get the response in the next, and send a new command or NOP.

as5047u_rd_000.jpg

So Read ADD[ANGLEUNC] then Read ADD[NOP], the data you get back when clocking out the NOP will be the ANGLEUNC value.

1 reply

Tesla DeLorean
Guru
September 1, 2024
Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Associate III
September 1, 2024

Why should i divide it by 16384?

Also the SPI data will be in binary right? what should i divide it with?

Tesla DeLorean
Guru
September 1, 2024

Why would you think?  2**14 = 16384

0 ..16383 relates to 0 to 359.99

You're trying to scale the full range 14-bit value into 360 degrees, or 2PI radians

Binary value, multiplied by 0.02197 to scale to degrees

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..