Hi, I connected the AS5048A magnetic sensor to an Arduino Mega board (SPI). I used the example program to test it.
MagneticSensorSPI sensor = MagneticSensorSPI(10, 14, 0x3FFF);
No compiling errors, but only 0.0 readouts. When I change the Mega with an Uno (same sketch, same pins), I get normal readouts.
Any solution? Is it a software bug?
- Check pin selection
Arduino Mega SPI pins: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS).
Arduino Nano SPI pins: 10 (SS) Chip Select or any pin, 11 (MOSI), 12 (MISO), 13 (SCK)
Arduino Uno SPI pins: 10 (SS) Chip Select or any pin, 11 (MOSI), 12 (MISO), 13 (SCK)
Check wiring, crossed wires, wrong wires go to the wrong pins.
Check bad / cold connections (pins connected but wire connector is bad).
Check code for separate boards is using the correct pin assignment in the code.
Check target MCU in Arduino IDE/GUI is building for correct target MCU.
Check AS5048A sensor is using correct voltage (3v vs 5v), nano and mega use 5v, but if you select 3v for the sensor, sometimes it works intermittently even though it should not, so you get funny half-assed readings.
Most of the times it’s a combination of some of the aforementioned problems so you got to have extreme patience and trace the problem. Most importantly, the problem is simple so don’t get frustrated and throw the board on the floor and jump on top if it. It doesn’t help. I’ve tried.
Thx, that did the trick. I knew this…
Hi, I connected the AS5047P magnetic sensor to an Arduino UNO (SPI). It is no problem. The BLDC can work well.
But I changed to Arduino Mega 2560 (SPI). Why the BLDC cannot work? Please refer to the picture. Thanks.