Sudden Motor reverse Direction (0.5.1post0)

Good evening all,

i am having some issues with using the odrive. I have an arduino nano connected to the 5v and GND port of the odrive, and am sending information to odrive from arduino nano using GPIO 1 and 2 on the odrive.

The system works as intended, however there are sometimes the motor reverse direction and messes with the system. Now every time on startup it is still in the “reversed” direction. I need to recalibrate the motor, in order for the system to function again.
i am using the standard AMT102 encoder. I’m curious if the encoder is causing this issue.
i have unplugged the encoder while power is on, and it seems to reverse direction.

is it because the encoder is weak? or gets rattled?

Please let me know if theres any more information you need or if you all may know whats wrong.

arduino code

If the encoder is loose (slipping on the shaft of the motor), this can happen, yes. It can also happen with electrical noise but that’s less likely.