Berkeley Humanoid Lite Docs
  • Home
  • Releases
  • Getting Started with Hardware
    • Materials and Parts (BOM)
    • Preparing the Tools
    • 3D Printing Instructions
    • Building the Actuator
    • Flashing the Motor Controllers
    • Building the Robot
  • Getting Started with Software
    • Software Development Environment Overview
    • Training Environment
    • Sim2sim Validation
    • The On-board Computer
    • Motion Capture System
  • lerobot Integration
  • In-depth Contents
    • Field Oriented Control (FOC) Operation
    • Motor Controller Firmware Execution Timing Information
    • Motor Characterization
    • Actuator Characterization
    • CAN Communication
    • Joint ID Mapping
    • Exporting Robot Description Files from Onshape
    • Domain Randomizations for Training Locomotion
  • Contribute
Powered by GitBook
On this page
  • 1. Brushless DC Motor
  • 2. A Simple Control Scheme: Six-Step Commutation
  • 3. Efficiency Improved: Vector Control
  • 4. Frame Transformation
  • Alpha Beta Transform
  • DQ Transform
  • Inverse DQ Transform
  • SVPWM
  • Theoratical Maximum RPM
  • 5. Current Loop
  • DC Motor Model
  • PI Controllers
  • System Model
  • 6. Torque Control
  • 7. Position Loop
  • 8. Conclusion
  1. In-depth Contents

Field Oriented Control (FOC) Operation

PreviousIn-depth ContentsNextMotor Controller Firmware Execution Timing Information

Last updated 1 month ago

1. Brushless DC Motor

A brushless direct-current (BLDC) motor consists of magnets and phase-winding coils. To illustrate its operating principle, consider a simplified model featuring one pair of magnetic poles and three coils.

In this model, the coils form the stator. When current flows through a coil, it generates a magnetic field that either attracts or repels the adjacent magnet on the rotor. This magnetic interaction causes the rotor to rotate.

2. A Simple Control Scheme: Six-Step Commutation

In a BLDC motor, the ends of the three coils are connected to form three external terminals that interface with the driving circuit. These coils can be connected either in a star (wye) configuration or a delta configuration. The star connection is more common: one end of each coil is accessible as an external lead, while the other ends are joined internally to form a neutral point.

To control the three wires, a three-phase inverter circuit is used. This inverter is composed of three half-bridge drivers, which can be viewed as six switches connecting between VDD and ground. Each half-bridge can operate in one of four states:

  • High-side ON, low-side OFF (1)

  • High-side OFF, low-side ON (0)

  • High-side ON, low-side ON (X)

  • High-side OFF, low-side OFF (N)

The X state is invalid because it directly connects VCC to ground, while the N state is not used because it leaves the phase coil in a floating condition, reducing the driver’s maximum output capability. This leaves only two valid states: state 1 connects the phase to VCC, and state 0 connects it to ground.

By combining these two valid states for the three phases, there are eight possible inverter states:

  • 000

  • 100

  • 110

  • 010

  • 011

  • 001

  • 101

  • 111

Out of these, the states 000 and 111 are non-driving because all phases are tied to the same voltage level (either VCC or ground), resulting in no voltage differential between them. The remaining six states are the driving states.

For example, consider the motor in state 100:

  • Phase A is connected to VCC.

  • Phases B and C are connected to ground.

In this configuration, current flows from phase A through the neutral point to phases B and C, and then to ground. This current generates a magnetic field oriented toward phase A (0°), which attracts the rotor's magnets and rotates the rotor to 0°.

Next, switching to state 110:

  • Phases A and B are connected to VCC.

  • Phase C is connected to ground.

This creates a magnetic field pointing between phases A and B (approximately 30°), which turns the rotor toward the 30° direction.

Similarly, the remaining driving states sequentially direct the rotor to 60°, 90°, 120°, 150°, and finally back to 0° when returning to state 100.

By switching through these states in order, the motor can be driven continuously and efficiently.

3. Efficiency Improved: Vector Control

4. Frame Transformation

Since the motor’s phase voltages are floating and lack a fixed reference point, it is impractical to use power resistors for sampling. A simpler approach is to add resistors under the low-side MOSFETs, which allows us to sample and obtain three approximate sine-wave phase currents. However, the resulting measurement would yield three sinusoidal signals that are correlated with each other. This makes designing the controller for it very challenging. Instead, with the use of a series of mathematical transformations, we can convert the three phase BLDC motor model into a two phase DC motor model.

Tracking the transformation between these two models can be particularly challenging due to differences in reference frames. In the three-phase BLDC motor model, physical quantities are defined relative to each individual phase, with the reference frame rotating along with the rotor. In contrast, the simplified two-phase DC motor model defines quantities with respect to the orthogonal D (direct) and Q (quadrature) axes within a stationary reference frame.

It's essential to pay close attention to the frame in which each variable is defined. In the following discussion, we will clearly state the reference frame along with the corresponding variables.

Alpha Beta Transform

Note

After magnitude scaling, we get the final Clarke transform equation:

or in matrix format:

DQ Transform

or in matrix format:

After converting the three phase currents into stationary DQ currents using the Clarke and Park transforms, we now have a simplified representation that is much easier to control. However, our control is limited to adjusting the applied voltages. To regulate the current, we employ a controller that modulates the input voltage. A detailed discussion of this controller will be provided in the next section. For now, let's explore how the DQ voltage is converted back into the three phase voltages.

Inverse DQ Transform

or in matrix format:

Note

SVPWM

Unlike the process of transforming current signals, converting voltage signals involves a different approach. This is because the applied voltage ultimately controls digital signals—either 0 or 1—that determine the switching of the MOSFETs in the upper and lower bridge arms, rather than influencing analog values from current measurements. Consequently, we must adopt an alternative method to discretize our desired voltage.

From the six-step commutation scheme, we know that the motor driver can generate voltage vectors (or forces) pointing in six distinct directions. These can be thought of as six fundamental vectors originating from the center and directed toward 0°, 30°, 60°, and so on. By controlling the motor driver to rapidly switch between two states and adjusting the proportion of time spent in each state, we can synthesize a resultant voltage vector that points in a direction between the two fundamental vectors. Furthermore, by incorporating the two non-driving states—which effectively act as zero vectors—we can also adjust the magnitude of the resultant vector.

As a result, we have:

or in matrix format:

Theoratical Maximum RPM

To control the motor correctly during high speed region, the FOC commutation frequency must be significantly higher than the electrical frequency of the motor. A general rule is that commutation frequency must be at least 10x the electrical frequency.

The motor’s mechanical frequency can then be calculated from the electrical frequency and pole pair:

For example, for a motor with 14 pole pair, if FOC commutation is set to 10 kHz. Then, the maximum supported electrical frequency is 1 kHz.

The maximum mechanical frequency would then be:

5. Current Loop

DC Motor Model

In the simplified DC motor model, the motor can be seen as a resistor and inductor in series. Therefore, the voltage across the motor can be written as:

Note

The resistance here is not the winding resistance. It is the equivalent resistance we get after performing the Clarke and Park transformation. Same applies for the inductance.

Since we are focusing on low-rpm scenario, the back-EMF term can be ignored, simplifying the equation to be:

Performing Laplace transform to the equation, we get:

As a result, the transfer function of the motor is:

PI Controllers

There are two configurations of PI controller, the parallel configuration (the most common one) and the series configuration.

Parallel PI Controller

For parallel configuration, we have

Serial PI Controller

For series configuration, we have

Since the subsequent calculations are more straightforward with a series PI controller, we will adopt this configuration.

Example C implementation of the serial PI controller

float kp, ki;
float target, measured;
float limit;  // integrator anti-windup value
float dt;     // loop execution time
float integrator;

float error = target - measured;
integrator = clampf(integrator + kp * ki * error * dt, -limit, limit);
float result = kp * error + integrator;

System Model

For open loop control, we have the transfer function as:

In order to simplify the equation, we want

which means

For closed-loop feedback control, we have the transfer function as

Therefore,

In other words, we have

Usually in practice, we want to ensure that the current bandwidth is less than 10% of the switching frequency, i.e. 20% of the Nyquist rate.

For example, if the switching frequency is 20kHz, the maximum bandwidth would be 2kHz.

6. Torque Control

However, for the drone BLDC motors, vendors typically only provide the KV rating, representing the revolution per minute per volt applied between the motor phases. A typical measurement process of this KV value is to rotate the motor at a specific rotation speed and measure the peak-to-peak voltage difference between two phases. Hence, this KV value equals to the line-to-line back EMF voltage of the motor.

Another aspect is that the measurement of KV is done between two phases of the motor, which the reference frame is different from the DQ frame the PI controller are situated at. To convert it to the correct DQ frame, the following equation establishes:

7. Position Loop

Similar to current control loop, we can build a PD controller to regulate the rotor position by controlling the target torque.

8. Conclusion

As a result, we get the following motor controller block diagram.

We can inject user control targets at different stage to achieve control of each quantity (e.g. position, velocity, torque, current, or voltage control).

Reference:

By analyzing the magnetic forces generated from the stator winding acting on the rotor, we can decompose the overall force into two orthogonal components: one aligned with the rotor’s magnetic field (the d-axis component, FdF_dFd​) and one perpendicular to it (the q-axis component, FqF_qFq​). In vector control, only the perpendicular component, FqF_qFq​, contributes to generating torque. The component FdF_dFd​, which is parallel to the rotor magnet, does not aid in rotation and is essentially wasted energy.

To drive the motor efficiently, the control strategy aims to minimize FdF_dFd​ while maximizing FqF_qFq​, thereby ensuring that most of the electrical energy is converted into useful rotational force.

The three phase currents IaI_aIa​, IbI_bIb​, and IcI_cIc​ are three sinusoidal, rotating vectors, each offset by 120° relative to the others. Since they all lie in the same plane, the (also named ) can be used to reduce them into two orthogonal components, IαI_\alphaIα​ and IβI_\betaIβ​.

First, we can express IαI_\alphaIα​ and IβI_\betaIβ​ in terms of IaI_aIa​, IbI_bIb​, and IcI_cIc​:

Iα=Ia+cos⁡(23π)Ib+cos⁡(43π)IcIβ=sin⁡(23π)Ib+sin⁡(43π)Ic\begin{aligned} I_\alpha &= I_a + \cos(\frac{2}{3}\pi)I_b + \cos(\frac{4}{3}\pi)I_c \\ I_\beta &= \sin(\frac{2}{3}\pi) I_b + \sin(\frac{4}{3}\pi)I_c \end{aligned}Iα​Iβ​​=Ia​+cos(32​π)Ib​+cos(34​π)Ic​=sin(32​π)Ib​+sin(34​π)Ic​​

Using Kirchhoff Circuit Laws, Ic=Ia+IbI_c = I_a + I_bIc​=Ia​+Ib​, we can further simplify the equation to be the following

Iα=Ia+cos⁡(23π)Ib+cos⁡(43π)Ic=Ia+cos⁡(23π)Ib−cos⁡(43π)Ia−cos⁡(43π)Ib=Ia−12Ib+12Ia+12Ib=32Ia\begin{aligned} I_\alpha &= I_a + \cos(\frac{2}{3}\pi)I_b + \cos(\frac{4}{3}\pi)I_c \\ &= I_a + \cos(\frac{2}{3}\pi)I_b - \cos(\frac{4}{3}\pi)I_a - \cos(\frac{4}{3}\pi)I_b \\ &= I_a - \frac{1}{2}I_b + \frac{1}{2}I_a + \frac{1}{2}I_b \\ &= \frac{3}{2}I_a \end{aligned}Iα​​=Ia​+cos(32​π)Ib​+cos(34​π)Ic​=Ia​+cos(32​π)Ib​−cos(34​π)Ia​−cos(34​π)Ib​=Ia​−21​Ib​+21​Ia​+21​Ib​=23​Ia​​
Iβ=sin⁡(23π)Ib+sin⁡(43π)Ic=sin⁡(23π)Ib−sin⁡(43π)Ia−sin⁡(43π)Ib=32Ib+32Ia+32Ib=32Ia+3Ib\begin{aligned} I_\beta &= \sin(\frac{2}{3}\pi) I_b + \sin(\frac{4}{3}\pi)I_c \\ &= \sin(\frac{2}{3}\pi) I_b - \sin(\frac{4}{3}\pi)I_a - \sin(\frac{4}{3}\pi)I_b \\ &= \frac{\sqrt{3}}{2}I_b + \frac{\sqrt{3}}{2}I_a + \frac{\sqrt{3}}{2}I_b \\ &= \frac{\sqrt{3}}{2}I_a + \sqrt{3}I_b \end{aligned}Iβ​​=sin(32​π)Ib​+sin(34​π)Ic​=sin(32​π)Ib​−sin(34​π)Ia​−sin(34​π)Ib​=23​​Ib​+23​​Ia​+23​​Ib​=23​​Ia​+3​Ib​​

However, we also need to ensure that the magnitude of the signal should match. Therefore, we need to scale the result by factor of NNN.

In an amplitude-invariant transformation, the normalization factor NNN should be set to 2/32 / 32/3, while a power-invariant transformation requires N=2/3N = \sqrt{2/3}N=2/3​.

For this FOC application, it is important to preserve the magnitude of the signals (i.e. phase current readings) during transformation, so we choose, so we set N=2/3N = 2/3N=2/3.

{Iα=IaIβ=33Ia+233Iβ\begin{cases} I_\alpha = I_a \\ I_\beta = \frac{\sqrt{3}}{3}I_a + \frac{2\sqrt{3}}{3}I_\beta \end{cases}{Iα​=Ia​Iβ​=33​​Ia​+323​​Iβ​​
[IαIβ]=[100332330][IaIbIc]\begin{bmatrix} I_\alpha \\ I_\beta \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 \\ \frac{\sqrt{3}}{3} & \frac{2\sqrt{3}}{3} & 0 \end{bmatrix} \begin{bmatrix} I_a \\ I_b \\ I_c \end{bmatrix}[Iα​Iβ​​]=[133​​​0323​​​00​]​Ia​Ib​Ic​​​

Next, incorporating the information on rotor position θ\thetaθ, the can be used to convert the IαI_\alphaIα​ and IβI_\betaIβ​ components from the rotor reference frame to a stationary frame. This yields two stationary components, typically denoted as IdI_dId​ (the direct axis component) and IqI_qIq​ (the quadrature axis component). These stationary components simplify the motor control strategy by decoupling the torque and flux control.

{Id=cos⁡(θ)Iα+sin⁡(θ)IβIq=−sin⁡(θ)Iα+cos⁡(θ)Iβ\begin{cases} I_d = \cos(\theta)I_\alpha + \sin(\theta)I_\beta \\ I_q = -\sin(\theta)I_\alpha + \cos(\theta)I_\beta \end{cases}{Id​=cos(θ)Iα​+sin(θ)Iβ​Iq​=−sin(θ)Iα​+cos(θ)Iβ​​
[IdIq]=[cos⁡(θ)sin⁡(θ)−sin⁡(θ)cos⁡(θ)][IαIβ]\begin{bmatrix} I_d \\ I_q \end{bmatrix} = \begin{bmatrix} \cos(\theta) & \sin(\theta) \\ -\sin(\theta) & \cos(\theta) \end{bmatrix} \begin{bmatrix} I_\alpha \\ I_\beta \end{bmatrix}[Id​Iq​​]=[cos(θ)−sin(θ)​sin(θ)cos(θ)​][Iα​Iβ​​]

Similarly, we can take the desired voltages VdV_dVd​ and VqV_qVq​ and use the inverse Park transform to convert them into signals VαV_\alphaVα​ and VβV_\betaVβ​ that rotate together with the rotor.

{Vα=cos⁡(θ)Vd−sin⁡(θ)VqVd=sin⁡(θ)Vd+cos⁡(θ)Vq\begin{cases} V_\alpha = \cos(\theta)V_d -\sin(\theta)V_q \\ V_d = \sin(\theta)V_d + \cos(\theta)V_q \end{cases}{Vα​=cos(θ)Vd​−sin(θ)Vq​Vd​=sin(θ)Vd​+cos(θ)Vq​​
[VαVβ]=[cos⁡(θ)−sin⁡(θ)sin⁡(θ)cos⁡(θ)][VqVd]\begin{bmatrix} V_\alpha \\ V_\beta \end{bmatrix} = \begin{bmatrix} \cos(\theta) & -\sin(\theta) \\ \sin(\theta) & \cos(\theta) \end{bmatrix} \begin{bmatrix} V_q \\ V_d \end{bmatrix}[Vα​Vβ​​]=[cos(θ)sin(θ)​−sin(θ)cos(θ)​][Vq​Vd​​]

Since rotation matrices are orthogonal, A−1=ATA^{-1} = A^TA−1=AT.

Va=cos⁡(0)Vα+sin⁡(0)Vβ=VαV_a = \cos(0)V_\alpha + \sin(0) V_\beta = V_\alphaVa​=cos(0)Vα​+sin(0)Vβ​=Vα​
Vb=cos⁡(23π)Vα+sin⁡(23π)Vβ=−12Vα+32VβV_b = \cos(\frac{2}{3}\pi)V_\alpha + \sin(\frac{2}{3}\pi) V_\beta = -\frac{1}{2} V_\alpha + \frac{\sqrt{3}}{2} V_\betaVb​=cos(32​π)Vα​+sin(32​π)Vβ​=−21​Vα​+23​​Vβ​
Vc=cos⁡(43π)Vα+sin⁡(43π)Vβ=−12Vα−32VβV_c = \cos(\frac{4}{3}\pi)V_\alpha + \sin(\frac{4}{3}\pi) V_\beta = -\frac{1}{2} V_\alpha - \frac{\sqrt{3}}{2} V_\betaVc​=cos(34​π)Vα​+sin(34​π)Vβ​=−21​Vα​−23​​Vβ​
{Va=VαVb=−12Vα+32VβVb=−12Vα−32Vβ\begin{cases} V_a = V_\alpha \\ V_b = -\frac{1}{2}V_\alpha + \frac{\sqrt{3}}{2}V_\beta \\ V_b = -\frac{1}{2}V_\alpha - \frac{\sqrt{3}}{2}V_\beta \end{cases}⎩⎨⎧​Va​=Vα​Vb​=−21​Vα​+23​​Vβ​Vb​=−21​Vα​−23​​Vβ​​
[VaVbVc]=[10−1232−12−32][VαVβ]\begin{bmatrix} V_a \\ V_b \\ V_c \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ -\frac{1}{2} & \frac{\sqrt{3}}{2} \\ -\frac{1}{2} & -\frac{\sqrt{3}}{2} \end{bmatrix} \begin{bmatrix} V_\alpha \\ V_\beta \end{bmatrix}​Va​Vb​Vc​​​=​1−21​−21​​023​​−23​​​​[Vα​Vβ​​]
fmech=felecNppf_{mech} = \frac{f_{elec}}{N_{pp}}fmech​=Npp​felec​​

NppN_{pp}Npp​ is the number of pole pairs.

fmech=1 kHz14=71 rad/s=678 RPMf_{mech} = \frac{1 \text{ kHz}}{14} = 71 \text{ rad/s} = 678 \text{ RPM}fmech​=141 kHz​=71 rad/s=678 RPM

As mentioned above, our objective is to regulate the currents IdI_dId​ and IqI_qIq​. To accomplish this, we control the voltages VdV_dVd​ and VqV_qVq​ applied to the motor. A straightforward method to map these voltage inputs to the desired current outputs is by using a proportional-integral (PI) controller.

V=IR+LdIdt+kemfωV = IR + L\frac{dI}{dt} + k_{emf}\omegaV=IR+LdtdI​+kemf​ω

where III is the current flowing through the motor winding, RRR is the resistance of the motor winding, LLL is the inductance of the motor winding, kemfk_{emf}kemf​ is the back-EMF coefficient, and ω\omegaω is the rotation speed.

V=IR+LdIdtV = IR + L\frac{dI}{dt}V=IR+LdtdI​
V(s)=I(s)R+LsI(s)−LI(0)V(s) = I(s)R + LsI(s) - LI(0)V(s)=I(s)R+LsI(s)−LI(0)

We can assume the initial condition to be I(0)=0I(0) = 0I(0)=0, hence getting:

V(s)=I(s)R+LsI(s)V(s) = I(s)R + LsI(s)V(s)=I(s)R+LsI(s)
M(s)=I(s)V(s)=1R+Ls=1R1+LRsM(s) = \frac{I(s)}{V(s)} = \frac{1}{R + Ls} = \frac{\frac{1}{R}}{1 + \frac{L}{R}s}M(s)=V(s)I(s)​=R+Ls1​=1+RL​sR1​​
c(t)=kpe(t)+ki∫e(t)dtC(s)=kp+kis=kps+kis\begin{aligned} c(t) &= k_p e(t) + k_i \int e(t) dt \\ C(s) &= k_p + \frac{k_i}{s} = \frac{k_p s + k_i}{s} \end{aligned}c(t)C(s)​=kp​e(t)+ki​∫e(t)dt=kp​+ski​​=skp​s+ki​​​
c(t)=kp′e(t)+kp′ki′∫e(t)dtC(s)=kp′(1+kis)=kp′s+kp′ki′s\begin{aligned} c(t) &= k_p' e(t) + k_p' k_i' \int e(t) dt \\ C(s) &= k_p' (1 + \frac{k_i}{s}) = \frac{k_p's + k_p'k_i'}{s} \end{aligned}c(t)C(s)​=kp′​e(t)+kp′​ki′​∫e(t)dt=kp′​(1+ski​​)=skp′​s+kp′​ki′​​​
Gopen(s)=M(s)C(s)=1R1+LRskp′s+kp′ki′s=1R1+LRskp′ki′ski′+1s\begin{aligned} G_{open}(s) &= M(s)C(s) \\ &= \frac{\frac{1}{R}}{1 + \frac{L}{R}s} \frac{k_p's + k_p'k_i'}{s} \\ &= \frac{\frac{1}{R}}{1 + \frac{L}{R}s} k_p'k_i' \frac{\frac{s}{k_i'} + 1}{s} \end{aligned}Gopen​(s)​=M(s)C(s)=1+RL​sR1​​skp′​s+kp′​ki′​​=1+RL​sR1​​kp′​ki′​ski′​s​+1​​
1+LRs=ski′+11 + \frac{L}{R}s = \frac{s}{k_i'} + 1 1+RL​s=ki′​s​+1
ki′=RLk_i' = \frac{R}{L}ki′​=LR​

Setting ki′=RLk_i' = \frac{R}{L}ki′​=LR​, we can simplify the equation as

Gopen(s)=kp′ki′1RsG_{open}(s) = k_p'k_i' \frac{\frac{1}{R}}{s}Gopen​(s)=kp′​ki′​sR1​​
Gclosed(s)=Gopen(s)1+Gopen(s)G_{closed}(s) = \frac{G_{open}(s)}{1 + G_{open}(s)}Gclosed​(s)=1+Gopen​(s)Gopen​(s)​
Gclosed=kp′ki′1Rs1+kp′ki′1RsG_{closed} = \frac{k_p'k_i' \frac{\frac{1}{R}}{s}}{1 + k_p'k_i' \frac{\frac{1}{R}}{s}}Gclosed​=1+kp′​ki′​sR1​​kp′​ki′​sR1​​​

Substituting ki′=RLk_i' = \frac{R}{L}ki′​=LR​, into the equation, we get:

Gclosed=kp′RL1Rs1+kp′RL1Rs=kp′1Ls+kp′1L=1skp′L+1G_{closed} = \frac{k_p'\frac{R}{L} \frac{\frac{1}{R}}{s}}{1 + k_p'\frac{R}{L} \frac{\frac{1}{R}}{s}} = \frac{k_p' \frac{1}{L}}{s + k_p '\frac{1}{L}} = \frac{1}{\frac{s}{\frac{k_p'}{L}} + 1}Gclosed​=1+kp′​LR​sR1​​kp′​LR​sR1​​​=s+kp′​L1​kp′​L1​​=Lkp′​​s​+11​

The coefficient kp′L\frac{k_p'}{L}Lkp′​​ determines the frequency where the system response decreases by 3dB, or, the response cutoff bandwidth ω. The unit is rad / s.

kp′=L∗ωcutoffk_p' = L * \omega_{cutoff}kp′​=L∗ωcutoff​
ωcutoff=kp′L\omega_{cutoff} = \frac{k_p'}{L}ωcutoff​=Lkp′​​

with ω=2πf\omega = 2\pi fω=2πf,

fcutoff=12πkp′Lf_{cutoff} = \frac{1}{2\pi}\frac{k_p'}{L}fcutoff​=2π1​Lkp′​​
{kp′=2πfsampleLki′=RL\begin{cases} k_{p}' = 2\pi f_{sample} L \\ k_i' = \frac{R}{L} \end{cases}{kp′​=2πfsample​Lki′​=LR​​
{kp,2kHz′=2πL∗2∗103ki′=RL\begin{cases} k_{p, 2kHz}' = 2 \pi L * 2*10^3 \\ k_i' = \frac{R}{L} \end{cases}{kp,2kHz′​=2πL∗2∗103ki′​=LR​​

Reference:

Usually, we want to control the motor's output torque, instead of the current. Therefore, we must establish the relation between current IqI_qIq​ and the output torque τ\tauτ.

The torque is proportional to the phase current, with a factor of motor torque constant KτK_\tauKτ​.

τ=Kτ×Iphase\tau = K_\tau \times I_{phase}τ=Kτ​×Iphase​

To convert the KV rating to motor torque constant, two caveats need to be paied attention for. The first thing is the unit conversion. KV is given in revolution per minute. To convert it to the SI unit radius per second per volt, we need to use KV,SI=2π60KVK_{V,SI} = \frac{2\pi}{60}K_VKV,SI​=602π​KV​.

Kτ=12KV,SI=122π60KV≈0.0740KVK_\tau = \frac{1}{\sqrt{2}} K_{V,SI} = \frac{1}{\sqrt{2}}\frac{2\pi}{60} K_V \approx 0.0740 K_{V}Kτ​=2​1​KV,SI​=2​1​602π​KV​≈0.0740KV​
Six Step Commutation - MathWorks
reference
Digital PI Controller Equations
Clarke transform
alpha-beta transform
Park transform