A2212/13t BLDC motor and problems

Can I summarise where you are at.

  • You can run open loop code. The motor spins forwards and backwards (depending on +-=0.001)
  • you can manually spin the motor a whole turn and it correctly says 6.3 rads when you ask what the angle is
  • when you run find_pole_pairs it barely moves and/or moves erratically left to right

This is odd as pole_pairs is more or less the same as open loop.

Can you check that your
BLDCMotor motor = BLDCMotor(9, 5, 6, 0, 8); is the same between pole_pairs and open loop.
@Antun_Skuric asked about which pins you use. I guess you are using 9,5,6,8 for motor and 10 for chip select for SPI. SPI will also be using 3 other pins (11, 12 and 13 is common for Uno I think). Uno is also using 0 and 1 for serial port. Does that sound right?
I’d get a fresh copy of pole_pairs especially if you’ve made changes e.g. to pp_search_angle