Set Gain in Torque mode (PI)

Hi guys,

I’m curently controlling my motor via an Arduino using other sensors. Hence, I would like to know how to set the internal settings of the controler (PI) gains to P=1 and I=0. So that only the PID inside my Arduino is driving the show. I’m asking because from what I read, those settings are automatically adjusted when changing current_bandwidth ?! How can I make sure P=1 and I=0 ?

Thanks

Which PI controller on the ODrive do you mean?

In torque mode, all the PIs are disabled except the current controller.

@grahameth When using torque_mode, there’s a PI controller where the gains are automatically set according to the value of the current_bandwidth.
.

How exacly can I manually set the gains for the current controller ?

You can’t. You can only control it with the bandwidth setting.

But you shouldn’t be changing that, what are you actually trying to do?

Here’s a picture of what I want to do.

I have a motor connected to a pendulum. I want to control it in torque mode using sensors that the Arduino will read and send a certain command to the controller. The reason I want the P=1 and I=0 on the Odrive is to set the values of the gains only on my Arduino program.

Another option would be to set the P gain =1 on the Arduino and adjust the gains on the controller. But if I shouldn’t be changing that, how am I supposed to tune my system?

Thanks

What sensors? Position? Gyroscope? Torque? Current? Temperature?

What command? Torque?

Which P gain? position, velocity, or torque loop?

Have you read through the ODrive control documentation? It might help answer your questions. Control Structure and Tuning — ODrive Pro Documentation 0.6.4 documentation

  • I’m using MPU6050, I just want to get the angle difference and then send a command (already processed with a PID controller in the Arduino) to the Odrive.

  • The command sent by the Arduino to the Odrive will be to commande the torque applied by the motor, yes.

  • By controlling in torque mode, it implies that position controller and velocity controller aren’t used as you said before and that’s perfect for me. However, the current controller is still active. It is the current controller gains that I would like to set manually. (Kp = 1 and Ki = 0 and there’s no Kd apparently)

  • Finally, yes I’ve read the doc again and again and tried many things, but never worked out. That’s why I’m grateful for your help !

You can modify the v3 firmware to do this, but your motor will likely become uncontrollable. You need the current controller to be active and well tuned if you want the commanded torque to equal the output torque.

If you change the current controller tuning to Kp = 1 and Ki = 0, this is no longer true - you will command 1N-m of torque, but get something else out (actually since it’s an FOC current controller in the dq frame, it’ll probably just lose control immediately and either not move or spin up to maximum speed).

Set control_mode to torque mode, and use input_torque. That’s it, all you gotta do :slight_smile:

Of course, that assumes your inverted pendulum code is right… feel free to share that if you want us to review it. Better yet, draw up a little control block diagram of it

Note that if you want to do this with torque control, your control loop frequency should be quite high (100Hz or so). The Stanford Doggo guys did something similar, and they had to hack the firmware communication protocol to make it fast enough.
I’d recommend to use velocity control for a single pendulum. It’ll be much easier.

2 Likes