-
Notifications
You must be signed in to change notification settings - Fork 659
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
On a Nucleo L476RG initialization of the AS5048 does not work as expected.
The sensor works using:
MagneticSensorSPI as5048 = MagneticSensorSPI(10, 14, 0x3FFF);
But it does not work using:
MagneticSensorSPI as5048 = MagneticSensorSPI(AS5048_SPI, 10);
Inspection with GDB reveals that in the latter case the config struct AS5048_SPI is not properly initialized:
>>> p AS5147_SPI
$13 = {
spi_mode = 1,
clock_speed = 1000000,
bit_resolution = 14,
angle_register = 16383,
data_start_bit = 13,
command_rw_bit = 14,
command_parity_bit = 15
}
>>> p AS5048_SPI
$14 = {
spi_mode = 0,
clock_speed = 0,
bit_resolution = 0,
angle_register = 0,
data_start_bit = 0,
command_rw_bit = 0,
command_parity_bit = 0
}
I believe the issue to be on line 15 in MagneticSensorSPI.cpp, i.e.:
// AS5048 and AS5047 are the same as AS5147
MagneticSensorSPIConfig_s AS5048_SPI = AS5147_SPI;
MagneticSensorSPIConfig_s AS5047_SPI = AS5147_SPI;
By changing the code to the following (and also update the external declaration in the header) it seams to be working:
// AS5048 and AS5047 are the same as AS5147
MagneticSensorSPIConfig_s &AS5048_SPI = AS5147_SPI;
MagneticSensorSPIConfig_s &AS5047_SPI = AS5147_SPI;
The original assignment seems to be working in Arduino UNO though, although I have not connected GDB to the Arduino and looked into it in detail.
Describe the hardware setup
- Which motor
GM3506 - Which driver
SimpleFOCShield V3.2 - Which microcontroller
STM32L476RG - Which position sensor
AS5048 with SPI communication
IDE you are using
- Platformio
runger1101001
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working