In torque mode, the controller will control the motor torque by regulating the motor current. The motor current will be regulated by adjusting the motor PWM voltage.


Motor current trajectory


When the user sends a current command, the motor current will not be adjusted immediately, but the controller will drive the motor to the desired point by following a trajectory. This trajectory is configured by the acceleration and deceleration parameters. 



In torque mode, acceleration and deceleration are expressed in mA*10/sec.


In the below example is visible the difference in the current trajectory (Ramped command) by using different acceleration and deceleration parameters. The motor command is the current command given by the user.



FOC response


How fast the actual curent of the motor will follow the current trajectory is defined by the FOC PI gains. By using higher values of FOC gains, the current of the motor will be adjusted quicker.


In the below example you can see the difference in the current response by having different sets of FOC PI gains. 


The Motor command is the command given by the user, Ramped command reflects the current trajectory and Feedback is the actual value of the current.



FOC PI regulator


Note that there are two FOC PI regulators, one for the Torque current and one for the Flux current of the motor. 


When conifguring the FOC gains, Proportional terms of both regulators should have the same value and integral terms of the two regulators should have the same value as well.



Current command


The set current can be given with the G or the GIQ command. The G command has a range from -1000 to 1000, so the value configured to the amp limit parameter will be mapped on that range. For example, by having 10 A configured to amp limit parameter and giving a !G 1 1000 command, the motor will be driven to 10 A rms current. When giving a !G 1 -1000 command, the motor will be driven to -10 A.



Notice that by giving a G command, the motor command will take a different value. This is because in Torque mode, the motor command is given in the peak value and not in RMS. The peak value will be 10/0.707 = 14.14 A      



With the GIQ command, the given value will be the exact peak current. 



Again here the motor amps will be rms, so 5.8*0.707 = 4.1 A


Setting the FOC gains


The tuning of the torque PID (FOC) is an easy task because the FOC gains will derive by following a standard formula, knowing the motor R-L parameters: 


    FOC P = motor phase inductance*2*3.14* BW

    FOC I = motor phase resistance*2*3.14*BW 


The motor phase values can be obtained by the motor datasheet and are the p-p values divided by 2


e.g. motor p-p resistance = 0.1 Ohm = > motor phase resistance = 0.05 Ohm

       motor p-p inductance = 84uH => motor phase inductance = 43 uH


FOC calculation example



FOC P = (0.00043/2) H * 2 * 3.14 * 50 Hz = 0.0675

FOC I =  (0.08/2) Ohm * 2 * 3.14 * 50 Hz = 12.56


We used a bandwidth of 50 Hz which is the common value for F3 products. Different values between 10 to 100 Hz can be used and the current response will be increased accordingly 


Pay attention to the R-L units. All the values must be transformed to Henry and Ohm, and not their divisions. 


Alternatively, the motor/characterization tool can be used. The tool will estimate the motor R-L parameters and the bandwidth can be chosen by the user. The estimation tool should be used if the motor datasheet are not available, otherwise the manufacturer values should be used preferably.



Testing the FOC performance



In the next figures, is visible the difference in the current response, when 10 and 100 Hz bandwidth is used. Higher bandwidth will lead to more responsive but more aggressive current control.