DRV8302 + Tarot motor -> Control type: Voltage : Magnet polarization problem

I (possibly) had a problem similar to this.


  • Works: When I completely remove power from STM + circuitry . Then re-power on - I’m able to upload and sensor ‘works’.
  • Doesn’t work: However, my second and subsequent uploads fail (unless I power off/on).

What I tracked it down to was that the i2c sensor itself needed to be ‘powered off’ otherwise it was holding SDA low. Essentially if the sensor is in the middle of transmitting data when you upload sketch it won’t release SDA until it is sent a bunch of SCLKs or powered down. This only happened on some stm32, didn’t see it on esp32.

If you are seeing this behavioud then there are a few workarounds.

Hi @Owen_Williams,

Thank you for tinking along with me! Great suggestion.

I tried turning everything (including AS5600) off, and after that reuploading the sketch. Also resetting the system after everything is uploaded. I also tried different combinations of turning on the power: everything in one time, first drv8302, then STM etc, but that does not seem to work.

So even when everything is turned off, it will not work. I am also not able to recreate the situation when it worked…

When the motor works in open loop mode, does it automatically mean that all the connections of the driver are ok? Or are extra pins used in closed loop for the driver?



If it works in open loop then your driver pins are ok.

Can I summarise where you’ve got to?

  • openloop works fine. nice and smooth
  • you can run a ‘sensor test’. If you rotate exactly 360 deg then sensor prints out 6.24 radians. You have 11 pole_pairs defined

Can you let us know what happens when you try the following:

  • what happens when you call initFOC()? does it move 6 steps right then left? It should definitely do this if open_loop is running smoothly.
  • are you calling motor.useMonitoring(Serial); ? This will give some debug messages during initFOC which can be helpful.
  • have you called linkSensor(&sensor)?
  • as a rule - you should try motor.controller = ControlType::voltage; before motor.controller = ControlType::velocity;. It is a little easier to get working. Be careful with how much you pass to motor.move(target_voltage);. Start low.

Hi @Owen_Williams!

Thanks for all the suggestions! This morning I was checking all the connections with the multimeter, and saw that the DIR port of the AS5600 was not well connected. I changed the cable for making the right correction and finally voltage control closed loop worked!!! :slight_smile:

So for everyone having the same problem that sensor gives correct data but the motor is not turning in FOC mode: Check your magnet and the direction port.

Thank you all for helping me! I can go on to the velocity/position control now :slight_smile:




DIR? Where you connected it?

Hi @Rem666

I made this image for you:


I hoped that I have helped you further, otherwise just ask a follow up question!

Good luck and greetings,


No, I know what DIR is and who needs it. But where did you connect it? GND? VDD? I tried to connect this sensor via I2C, but I didn’t connect DIR anywhere and it works. The direction does not matter, there is calibration for that. Antun, I am right?

The library should detect direction during initFOC(). I guess if it was floating and toggling high and low then it would mess things up. You’d expect it to have a light pullup/down to avoid that

Hi @Rem666,

Sorry I interpreted your question wrong! I connected it to the ground.