# Torque control loop

SimpleFOClibrary gives you the choice of using 3 different torque control strategies:

In short voltage control mode is the simplest approximation of the motor torque control and it so basic that can be run on any motor+driver+mcu combination out there. DC current mode is teh next step of the motor’s torque approximation which is much more exact than the voltage mode but requires current sensing and much stronger microcontroller. FOC current mode is controls motor’s true torque and it is not an approximation, it also requires current sensor and even more processing power than the DC current mode. See in depth explanations in torque mode docs.

This motion control mode is enabled setting the controller parameter to:

// torque control loop
motor.controller = MotionControlType::torque;


If the voltage control mode is used and if the user does not provide the phase resistance parameter to the motor, the input to the torque control loop will be the target voltage Uq:

And if one of the current based torque control modes (DC current or FOC current) is used, the input in the control loop will be the target current iq. The same is true in the voltage mode if the user provides the phase resistance value to the motor class.

The torque control loop is used as a base for all other motion control loops. For more info about the content of the blue boxes check the torque mode docs.

## Configuration parameters

Depending on the torque control type you wish to use there are different parameters that you need to consider.

For more information about the source code implementation of the motion control strategies check the library source code documentation

## Comparison

Torque control typePROSCONS
Voltage✔️ Very simple and fast
✔️ Good performance with any MCU
✔️ Very smooth on low speeds
✔️ No current sense needed
❌ Not optimal on high speeds
❌ Cannot control true current draw
❌ Torque is approximated (low error on low speeds)
DC current✔️ Can control true current draw
✔️ Suitable for low performance MUCs
✔️ Current limiting
❌ More complex to execute (slower)
❌ Can achieve lower speeds than voltage mode
❌ Torque is approximated (low error on low speeds)
❌ Needs current sensing
FOC current✔️ True torque control (any velocity)
✔️ Can control true current draw
✔️ Very efficient on higher velocities
✔️ Current limiting
❌ The most complex to execute (slowest)
❌ Not suitable for low-performing MCUs (can become unstable)
❌ Needs current sensing

### Voltage mode - voltage

Torque control through voltage is the most basic torque control type, and it provides you an abstraction of the BLDC motor so that you can control it as a DC motor. It is based on the principle that the current is directly proportional to the voltage (it neglects the current dynamics) and therefore does not need any current sensing hardware. For more info about this approach, visit our digging deeper section. This torque control approach will be able to work on any BLDC driver board, regardless if it has current sensing or not.

### DC current mode - dc_current

DC current control mode enables you to control the current of the BLDC motor as if it was a DC motor. Current sensing is used to obtain a overall magnitude of the current the motor is drawing and its direction, and the assumption is that the torque is proportional to the overall current. The benefit of this approach is that the true current set to the BLDC motor can be controlled very precisely it is a bit faster and more stable to execute for less-performant microcontrollers (such as Atmega328 family).

### FOC current mode - foc_current

FOC current control is the only true torque control approach. It controls two components of the current vector q and d. The torque is assumed to be proportional to the q current component and the d component of the current is controlled to remain equal to 0.

## Project examples

Here is one very cool project example which uses torque control and describes the full hardware + software setup needed.

Find more projects in the example projects section.