# Low speed torque control - dropping torque

**URL:** <https://discourse.odriverobotics.com/t/low-speed-torque-control-dropping-torque/5637>\
**Category:** Support\
**Created:** [October 7, 2020, 1:15pm UTC](https://discourse.odriverobotics.com/t/low-speed-torque-control-dropping-torque/5637 "2020-10-07T13:15:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![thezida](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/thezida/32/3151_2.png) [@thezida](https://discourse.odriverobotics.com/u/thezida)\
**Post date:** [October 7, 2020, 1:15pm UTC](https://discourse.odriverobotics.com/t/low-speed-torque-control-dropping-torque/5637/1 "2020-10-07T13:15:43Z")

</div>

Hi everyone! I’m trying to use odrive for torque control when speed is zero. I need constant resistance.

I’m using herlea x8311s kv140 motor, as5048a encoder and odrive3.6 56V board. Firmware I’m running is latest 0.5.1 version. My power supply is laboratory power supply able to give voltage and current up to 30V and 30A.

In torque control mode i set `input_torque` to some value and `torque_setpoint` follows that value but the current doesn’t match the desired torque. I measure current from `odrv0.axis0.motor.current_control.Iq_measured` and it is completely different from the torque reference. Also `odrv0.axis0.motor.current_control.Iq_setpoint` matches the measured current but not desired torque and it is dropping. Current into Odrive is also dropping. My `vel_limit= 20` and `enable_current_mode_vel_limit = True` and motor is barely moving. Cranck is connected to motor shaft and it is driven into a board as shown on the picture.

 ![121014579_360339228713377_118327346933403965_n](https://discourse.odriverobotics.com/uploads/default/original/2X/8/87ef4073f5f969c8b9326659f3a0ae83be858ae9.jpeg)  
I also wrote a script to measure input torque and torque given by current. On next graphs  
`estimated torque = 8.27 * odrv0.axis0.motor.current_control.Iq_measured / 140`  
`reference torque = 8.27 * odrv0.axis0.motor.current_control.Iq_setpoint / 140` and  
`input_torque` and `torque_setpoint` are self explanatory.  
 ![estimiran_moment](https://discourse.odriverobotics.com/uploads/default/original/2X/9/90b806bb6a3baf5c97c35f8cf0239969a4992579.png)  
 ![estimiran_moment](https://discourse.odriverobotics.com/uploads/default/original/2X/d/d015e1c57f276c03b59e8e01c57ad52dad6a535f.png)

Can anybody tell me if this can be done and if I’m doing something wrong or expecting it to work in a way it doesn’t work. And why…

---

<div class="post-metadata">

**Author:** ![towen](https://discourse.odriverobotics.com/letter_avatar_proxy/v4/letter/t/bcef8e/32.png) [@towen](https://discourse.odriverobotics.com/u/towen)\
**Post date:** [October 7, 2020, 3:43pm UTC](https://discourse.odriverobotics.com/t/low-speed-torque-control-dropping-torque/5637/2 "2020-10-07T15:43:25Z")

</div>

That’s some strange behaviour I must say. Where did you get your constant 8.27/140 ~= 0.06 from? Was that trial and error to try to get the plots to line up? Or is that the motor’s torque constant?

Check motor.config.phase\_resistance and see if it matches the phase-to-phase resistance (or half or it) as measured by a multimeter. (if you don’t have a meter handy that can measure low resistances, you can use your bench power supply in constant current mode and record the voltage)

Did the calibration run properly? i.e. the motor turns both ways and there are no errors?  
What input\_mode are you running? It should be INPUT\_MODE\_PASSTHROUGH.  
Obviously controller.config.control\_mode should be CONTROL\_MODE\_TORQUE\_CONTROL

Can you post the output of odrv0.axis0.motor.config and odrv0.axis0.controller.config?

What current does your power supply show? (I’d expect this to be very low, less than 500mA if set to 30V)

---

<div class="post-metadata">

**Author:** ![thezida](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/thezida/32/3151_2.png) [@thezida](https://discourse.odriverobotics.com/u/thezida)\
**Post date:** [October 8, 2020, 9:35am UTC](https://discourse.odriverobotics.com/t/low-speed-torque-control-dropping-torque/5637/3 "2020-10-08T09:35:03Z")

</div>

Hey man, thanks! I feel stupid. I was convinced I was in CONTROL\_MODE\_TORQUE\_CONTROL but I was in CONTROL\_MODE\_POSITION\_CONTROL. Very stupid of me but still interesting behaviour. Would still be interested in explaination.

> That’s some strange behaviour I must say. Where did you get your constant 8.27/140 ~= 0.06 from? Was that trial and error to try to get the plots to line up? Or is that the motor’s torque constant?

That is the formula from this page: [https://docs.odriverobotics.com/commands](https://docs.odriverobotics.com/commands) under Motor current and torque estimation. Explaination of the formula is given here: [Where does the formula for calculating torque come from? - #2 by madcowswe](https://discourse.odriverobotics.com/t/where-does-the-formula-for-calculating-torque-come-from/1169/2) . But still after I reversed before mentioned mistake I got that torque from current is larger than setpoint value and always with the ratio 1.4767858081772214. So i guess formula still needs to be calibratated for given motor.

> [@towen](#):
>
> What current does your power supply show? (I’d expect this to be very low, less than 500mA if set to 30V)

No, for largest torques (around 2Nm) my current is 5-6A.

---

<div class="post-metadata">

**Author:** ![towen](https://discourse.odriverobotics.com/letter_avatar_proxy/v4/letter/t/bcef8e/32.png) [@towen](https://discourse.odriverobotics.com/u/towen)\
**Post date:** [October 8, 2020, 9:46am UTC](https://discourse.odriverobotics.com/t/low-speed-torque-control-dropping-torque/5637/4 "2020-10-08T09:46:54Z")

</div>

> [@thezida](#):
>
> No, for largest torques (around 2Nm) my current is 5-6A.

Yes, 5-6A when pushing 30A through the motor is about right, but I’d have expected something in the hundreds of milliamps range for your earlier post when the motor wasn’t producing any actual torque. 🙂  
I asked just in case something might have been about to let out the magic smoke. 😛

> [@thezida](#):
>
> Would still be interested in _an explanation_.

By setting a current input when you are in position control, maybe it applies a non-zero current demand for an instant (due to feedforward terms?), and then immediately returns to the zero demand from the position controller.  
The current controller is a PI controller, so having an ‘impulse’ demand like that might produce a very small ‘saw tooth’ like in your earlier plots.  
That’s just my guess anyway

---

<div class="post-metadata">

**Author:** ![PJohnson](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/pjohnson/32/3571_2.png) [@PJohnson](https://discourse.odriverobotics.com/u/PJohnson)\
**Post date:** [October 8, 2020, 7:48pm UTC](https://discourse.odriverobotics.com/t/low-speed-torque-control-dropping-torque/5637/5 "2020-10-08T19:48:16Z")

</div>

Hi thezida,

For the ODrive firmware that supports torque control, you must set `odrvX.axisX.motor.config.torque_constant` to your 8.27/KV value for the torque output to be correct. The stock value is 0.04, which explains the roughly 1.5x error between your calculated torque and current. Sorry for any confusion, we’re in the process of updating the documentation pages and that will be included.

---

<div class="post-metadata">

**Author:** ![Wetmelon](https://discourse.odriverobotics.com/user_avatar/discourse.odriverobotics.com/wetmelon/32/10_2.png) [@Wetmelon](https://discourse.odriverobotics.com/u/Wetmelon)\
**Post date:** [October 8, 2020, 11:04pm UTC](https://discourse.odriverobotics.com/t/low-speed-torque-control-dropping-torque/5637/6 "2020-10-08T23:04:06Z")

</div>

> [@thezida](#):
>
> Would still be interested in explaination.

This is normal behavior based on the way the control loop works. It’s trying to drive it to the position, velocity, and torque commanded. But the velocity has “priority” over the torque feedforward term, and the position has priority over the velocity feedforward (roughly speaking).

So when you’re in position mode and you pass in a torque command, it will apply that torque, but the feedback loops of the velocity & position are still running, so they detect movement and reduce the torque to try to bring it back to 0 speed and the desired position.
