AS5048 SPI Communication trouble
- April 18, 2017
- 5 replies
- 2878 views
Hi All,
Have just moved over to the STM32 (have the Nucleo-F103RB!) device from 8bit devices, and am finding the STM32 device to be pretty cool
Currently working on a personal project, to build a robotic arm and have decided to use the AS5048A (SPI interface) as a way to measure the angular position of each joint. I've configured the STM32 to use the SPI1 interface configured with CPHA = 1, and CPOL = 0; so the clock is idle low, and the trailing edge is used to capture data, which aligns with the AS5048A datasheet. It is also setup to only send 8bits at a time, I am aware that the device requires 16bits, so I've set up the transmit to take this into account, 2 bytes are transmitted between slave selections.
When I read from the device, it seems to work.....sometimes, most of the time, I get weird data that doesn't make sense:
I am unable to clear the error flag with each package (even when reading from the 'Clear Error Flag' register; when reading data from the 'Clear Error Flag' register I get 0xC000 or 0xC001, the last one makes the least amount of sense as the data should be EVEN parity (note I have read this register multiple times, and still get this).
Even with a magnet over the chip, I seem to get sporadic data, telling me that the angle is 0/1, even when rotating the magnet in multiple directions (the magnet I have used is the one provided in the AS5048A Development board)
So, I'm a little lost as to what I've not done wrong, I've attached a copy of my code to interface to the device to this post.
The function within called 'AS5048_CompleteRead' has been able to get some good data, but as I have stated above, it works very intermittently, and the angles I get are not consistent; one minute it says it's at angle 150deg, move it around a bit and then return, and I get a completely different number
Any help that can be provided will be most appreciated.
Regards,
Thomas
