Set control mode from arduino

Hi I am having trouble setting the control mode. I can set it and save it from the terminal using odrive tool. but i need to set it via serial from my arduino. I am able to write lots of other config parameters via serial from arduino (actually a teensy 4.1). but the control_mode doesnt write for some reason :

for (int axis = 0; axis < 2; ++axis) {
Serial2 << “w axis” << axis << ".controller.config.control_mode " << 2.0f << ‘\n’;

is what i have tried, to get it into velocity control mode… but no luck. anyone have any suggestions? Is it because the value is actually an int not a float? I have tried removing the “.0f” after the 2 and read through the arduino.cpp to see if there is a way to write an int, but am not quite advanced enough to understand if that is the issue or not.


I think i may have found the issue.
when i call the command later :

odrive2.SetPosition(1, (S2 / 100));

does that set the axis into control mode 3? and leave it there until say i call odrive2.SetVelocity(1, (S2 / 100));



You’re setting the control mode to a float, which isn’t going to work properly. Use 2 instead of 2.0f

1 Like