Nucleo 64 F401RE + NEMA17 + AS5600: Problems with the magnetic encoder

Dear community,

I have some problems, getting the AS5600 to work for me on the Nucleo 64 (F401RE) platform. On a Arduino Uno everthing works fine.

The first thing I learned was, to move the SDA and the SCL from A4 & A5 (arduino) to D14 & D15 (Nucleo 64). Using the Seeedstudio AS5600 library, I get plausible values ( So I imagine, it has nothing to do with the still missing pull-ups.

But the angle control sketch results in the following serial output:

MOT: Monitor enabled!
MOT: Init
MOT: Enable driver.
MOT: Align sensor.
MOT: Failed to notice movement
MOT: Init FOC failed.
Motor ready.
Set the target angle using serial terminal:

Sniplet of my code:

#include <Wire.h>
#include <SimpleFOC.h>

//MagneticSensorI2C(chip_address,bit_resolution, angle_register_msb, bits_used_msb)
MagneticSensorI2C sensor = MagneticSensorI2C(0x36, 12, 0x0E, 4);

StepperMotor motor = StepperMotor(50);

// Stepper driver instance (IN1, IN2, IN3, IN4, ENA, ENB)
StepperDriver4PWM driver = StepperDriver4PWM(5, 6, 9, 10, 8, 7);

// angle set point variable
float target_angle = 0;

// instantiate the commander
Commander command = Commander(Serial);
void doTarget(char* cmd) { command.scalar(&target_angle, cmd); }

void setup() {

// initialise magnetic sensor hardware

// link the motor to the sensor
</ code>

Has anybody any ideas what else I could try to make this work?

Hey Bill,

Have you tried the sketch in the library examples that tests the sensor?
Does it work with that example?

Also, when you use the motor, the level of noise is much much higher in the I2C lines and I really do not think you’ll be able to avoid using the pull-ups :smiley:
At least for the 3.3V stm boards, I was not able to make it work without them :smiley:

Thank you very much for your reply. I checked the megnetic sensor example with the motor unpluged. And it worked like a charm. Copying the lines from the example into the previous sketch and adding 10kOhm pull up resistors to SDA and SCL … and it worked! Thank you very much!!!