Controlling Odrive via Microcontrollers

Hi I’m going to use Odrive with Arduino UNO.
I can set position and state but i need to configure it aswell.
Is there is a way to set vel_gain, pos_gain, vel_limit etc. via Arduino?

Are you needing to configure it through the Arduino in particular for some reason?

For my application I configured the gains with Odrivetool, then used odrv0.save_configuration() to save them on the Odrive before hooking it up to the Arduino.

That said, although I didn’t see any function in the Arduino library for it, you can write to a property over serial with w [property] [value]. For instance, in the example scketch, the following code in the setup function sets velocity and current limits for both motors:

for (int axis = 0; axis < 2; ++axis) {
    odrive_serial << "w axis" << axis << ".controller.config.vel_limit " << 22000.0f << '\n';
    odrive_serial << "w axis" << axis << ".motor.config.current_lim " << 11.0f << '\n';
    // This ends up writing something like "w axis0.motor.config.current_lim 10.0\n"
  }

Hope that helps!

1 Like

Thank you for your help.

I’m designing an gui for easy use first I created one with directly using odrivetool on the background.

But now I’m using it directly via microcontroller. Trying to recreate this via arduino.

Looks cool! I would try:

odrive_serial << "w axis" << axis << ".controller.config.pos_gain " << 20 << '\n';

See if that does the trick.

1 Like

Hi I’m created the gui for arduino control

But now I’m stuck at adding button for saving the configurations or reboot is there is a way to do these at arduino?