Can i modify the control logic?

first of all, i’m not who uses English as a mother language,
so, it could be poor related with my English.

my goal is to make limitaion at accelation (torque) and jerk.
so, i want to modify the control function like below. (with Arduino)
so i wanna know whether it is possible before trying.

Then, if possible, i also wanna know how you made ‘trajectory control’ logic.
As far as i know, there is accelation/deceleration limit (saturation) function.
but, i know that it only can be used at position control.

the reason why i ask this 'trajectory control logic is
to use as a reference when i try to make torque limitaion (saturation) function.

There already is a configurable saturation there you can use:
https://docs.odriverobotics.com/v/latest/fibre_types/com_odriverobotics_ODrive.html#ODrive.Axis.Config.torque_soft_min

Thank you for your quick response.

Then, i have some questions, but it is messed up now, and i have no time right now.
so i’ll leave one more comment after organizing my questions neatly.

Thank you again.

Then, even-though the saturation function exists already,
i want to implement saturation function in my own hand with Arduino.

Then, my first question is that
whether is it possible to access to variables like V_d or V_alpha within control logic.

i think there would be some more questinos while i’m trying it,
then i’ll ask when i get questions.

Thanks a lot again.

Hi! Yes, you can read these values, but because they’re used by the internal FOC loop you cannot write to them.

Can you elaborate a bit more on what you mean by “saturation function”? You can always command a direct torque, and simply limit the torque commanded on the Arduino side.

Thnaks a lot.

i can explain what the “saturation function” i mean,
but i think it’s worthless because i already got an answer that you said “you can’t modify (access to) the values which is in FOC loop.”.

the purpose of my questions was that.
my premise was “i can access (modify) the values in FOC loop.”.

Then, my next step is to control the jerk (instead of torque becasue Odrive already has torque limit function)
so i’ll ask more questions if i got while trying.

Thanks again.

Well, I’d still be curious as to what you mean by saturation function – it may be something we have implemented.

There’s actually an torque ramp input mode as well as a current slew rate parameter – both of these will have the effect of limiting jerk.

Thank you for your reply.

the “saturation function” i said at first was actually same as soft_limit of Odrive function.
i didn’t know Odrive has a function like that.

then, though i can’t know (understand) what “torque input mode” is,
(because, i understood it as a function which changes the target torque value from current value to target value.
but, if so, i can’t understand the difference betweent using that function and inputting the target torque value directly.
so i thought that i don’t know what the “torque ramp input mode” function is.)

anyway, though i can’t know what “torque input mode” is,
i also didn’t know that Odraive offers the functions which can set even the current slew rate.


Until this is reply for your comment,
and i also have some questinos.

  1. i want to know the sampling time.
    (if current and velocity doesn’t have same sampling time, i want to know both of them.)
  2. whether it is possible that setting the target torque value while i’m using velocity control mode.
    (but, sadly, i think it can’t)

oh, i missed one question.

i also want to know whether it is possible to get live velocity and current (i_A, i_alpha, i_d, and etc…) data (via Arduino) when the state of Odrive is “idle”.

To answer your questions:

  • ODrive has three control modes – torque, velocity, and position
  • Each of those control modes has one or more associated “input modes” – which are like filters for your setpoint
  • For instance, the PASSTHROUGH input mode directly sets the internal ODrive setpoint (depending on if you’re in torque/vel/pos mode) to the given setpoint.
  • Another example, if you’re in position mode you can use the TRAP_TRAJ input mode which will automatically generate and execute a trapezoidal trajectory to move to the given setpoint.
  • In torque control, the TORQUE_RAMP input mode will increase/decrease the internal torque setpoint at the rate of torque_ramp_rate to the user’s given setpoint. This allows for limiting the jerk of movements.

I would recommend looking at the controller page in the documentation:
https://docs.odriverobotics.com/v/latest/manual/control.html#control-modes

i want to know the sampling time.

8kHz

whether it is possible that setting the target torque value while i’m using velocity control mode.

In velocity control, the closed-loop controller generates a torque setpoint. However, you can give an additional torque feed-forward value to be added to the output of the velocity closed-loop controller.

i also want to know whether it is possible to get live velocity and current (i_A, i_alpha, i_d, and etc…) data (via Arduino) when the state of Odrive is “idle”.

If the ODrive is idle, it’s not possible for current to be flowing, so the ODrive does not update these values in idle. However, position and velocity is always calculated and available.

Thank you for your detail and kind reply.

Then, i have more questions.

  1. you mentioned that i can set torque feed-forward value.
    Then, is it ok if i put the desired torque value diretly to torque feed-forward variable?
    (=is it ok if i put 0.01 to torque feed-forward varibale when i want 0.01 Nm as target torque?)
    or there sholud be put the calculated value?
  2. should i think that it is almost same between setting ‘torque input’ directly under torque control mode and setting ‘torque feed-forward’ value under velocity control mode except internal control logic?

Then, is it ok if i put the desired torque value diretly to torque feed-forward variable?

Yes, you can “assist” the velocity controller if you know the desired torque

  • should i think that it is almost same between setting ‘torque input’ directly under torque control mode and setting ‘torque feed-forward’ value under velocity control mode except internal control logic?

Correct.

Then, similarly, can i set “current” feed-forward value like i_d, i_q, i_alpha and etc instead of torque?
because the diagram above has current feed-forward term.

or is it just possible only for torque?

Torque is the same as i_q. There shouldn’t be any need to set feedforwards for those other values, why would you want to do that?

i don’t know FOC well.
Rather, it can be said that there is almost nothing that i know about FOC.

it means that i didn’t know that the torque is same as i_q,
and the situation was that (=this happening was happened because), i just wanted to handle the current variables like i_d or i_q or etc without any knowledge about them(FOC).

i wanted to research and study about FOC especially i_d, i_q via this motor experiment.
and that’s why i approached to (asked about) “current” control instead of “torque” control.
I_q and torque were independent parts for me.

then, may i accept your mention “torque is the same as i_q” as “relationship between torque and i_q can be written like [torque = k * i_q, where k is coefficient]” ?

apart from my question above, i’'ll study about FOC either.
sorry for my lack comprehension about FOC, and thank you for your reply.

Totally understood! On the ODrive, torque control is the same as current control – under a proper FOC implementation, all the current you put into the motor is converted to torque.

And yes, torque = k * i_q – in fact on the ODrive, it requires you to enter the torque_constant, which is that k there.

i_d is the non-torque-producing current – you can raise the current you put into i_d and no torque will be produced. However, it changes the motor parameters in other ways that can be helpful, though typically not in the context of what people use the ODrive for. So by default it’s set to zero.

We want people to learn! I’m glad you’re asking all these questions!

Thank you for your reply.

i’ll back here when i get other questions

Thanks!

Then, may i know the FOC calculation frequency?

i think i could be 80Hz, because i heard that it’s good to set the sampling rete as 100 times of PID calculation rate. (you said the sampling freq is 8kHz)
i heard it from my “friend” (of course, he is not an expert).

and i also heard that it is recommended to set the sampling frequency as “at least” 10 times of control calculation frequency from automatic control lecture. (= calculation for control requires at least 10 samples)

Both FOC and PID are running at 8kHz. The motor control PWM runs at 24kHz. That 10-100 factor is definitely useful in some cases, but less relevant here :slight_smile:

Thank you a lot!