Arduino Closed-Loop Current Control Issues

Trying to control 2 pieces of Odrive by ascii commands through UART with Arduino. I am aware that there is some Arduino Library for Odrive on Github but it didn’t work on my project until I made plenty of changes to it.

(Like, Odrive seems to ignore the commands randomly, so I had to repeat each of the write/read commands for a couple of times to achieve stability. )

Now I need to read the encoder positions/velocities continuously under the closed-loop control state. However, when I tried to, the encoder feedback became frozen and doesn’t change anymore, even when I twisted the motors manually. What’s worse, the Odrive would enter some kind of unknown status and I was not able to idle the motors anymore. It would be stuck and the only thing to do is to reboot the power source.

But if it’s under the idle state, the encoder feedback would work normally.
if I don’t try to read the velocities or positions, the odrive would be able to fall back to idle state when requested.
What can I do about this situation?

The 2nd problem is about current-control mode. As the documentation said,under the closed-loop state I need to send the command “w axis.controller.config.control_mode 1” to corresponding serial port, but it’s not working, neither. Actually the "w axis.controller.current_setpoint " command would still cause some movements on the motors even without the current mode requested. It’s really confusing and I really can’t solve the problems on myself anymore. Could anyone be so kind to give some tips on these?

Thank you bros in advance :cry:

Which Arduino do you use?
I ran a few days ago into massiv unreliable serial communication with an Arduino Uno, which has official not the capability to fullfill the official demands to 115200 baud. Then I tested an Arduino Mega which works stable with the ODrive.
Anyhow, finally I ended up with using an ESP32 (coded with the Arduino IDE) , and anything works stable and as expected.
If I’d know how to post a *. zip file I’ll share my code…

regards, Dirk

Mega 2560, that’s what I’m using…

Thank you so much for the information, it’s really nice of you to share the codes :smile: