AS5048A magnetic sensor with inconsistent values

Hello everyone.

I am using the AS5048A magnetic sensor with the simple FOC example code for magnetic sensors and I get values ​​that are continuously oscillating.

I have tested the sensor with another library and it works fine.

Has anyone used this sensor with simple FOC?

Thank you very much for your time.


How did you init your sensor ?

Some time ago i was also in trouble with AS5048A and SimpleFOC…

I use this initialisation for the AS5048 :
MagneticSensorSPI sensor = MagneticSensorSPI(PA4, 14, 0xFFFF);

And it work now.

Best regards

Hi Robin.
I start my sensor with
MagneticSensorSPI sensor = MagneticSensorSPI (10, 14, 0x3FFF);

I have tried the way you do and it does not give me any value.
The record 0xFFFF I think is not correct.

Thank you anyway.


What MCU are you using ?

This trick work with an stm32f103. I did that because i saw with an osciloscope that the SPI message sent by the stm32 was not compatible with the as5048A.

Best regards,

I use a STM32F446RE.
I have also tested it with arduino UNO.

@Francesc_Riera_Vidal Can you explain what you mean by oscillating?

Are you using one of the examples like this?

Also are you on v1.6.1? There may have been an SPI bug in earlier versions

Hey guys,

AS5048a was the first sensor tested with the library and it was the first one to be working with Magnetic sensor class. I unfortunately do not have an instance with me any more, but what you can try is running the library version 1.4 or even 1.3 and use MagneticSensor(10, 14, 0x3FFF).

@Francesc_Riera_Vidal: I guess I had the same problem and found a solution.
See: MagneticSensorSPI and MA730 sensor
It’s just the library version. I guess you are using 1.6

@Antun_Skuric: Probably you can check the issue. It is complete repeatable.

Hey @Juxo,

I see. Thanks!
I’ll definitely look into this one. have you maybe checked if 1.6.1 works well?
We have repaired one bug in the spi library, that might be it.

In any case, we’ll do extensive testing of sensor libraries for next release.

Hi @Antun_Skuric,

I did the tests.
The rotor position was left untouched while changing the library versions. Also the board stays powered all the time. Last time I posted the flaw I did the tests with an AS5048a and Nucleo F103RB and also with an Arduino as a reference.
Now I use a Nucleo F411RE and the same sensor.

1.6.1 reads 2PI

1.6.0 jumps up and down by 2PI starting at 4PI

1.5.0 also reads 2PI

Looks like everything is fine again with the 1.6.1
Thanks a lot.