坐标变换详解:Clarke 与 Park 变换

系列:电机控制系列 - 第 5 篇 阅读时间:25 分钟

前言

坐标变换是 FOC 的核心魔法

  • 3 相交流 → 2 相直流 → 像控制直流电机一样简单
  • 看似复杂,实则有规律可循

本篇目标

  • ✅ 理解变换的物理意义
  • ✅ 掌握推导过程
  • ✅ 优化代码实现(查表法)

一、Clarke 变换(3→2 相)

1.1 几何意义

 abc 三相 → αβ 两相
 
         b 轴           β 轴
          /\             |
         /  \            |
        /    \           |
       /______\          |________ α 轴
      a 轴   c 轴
 
 abc: 三相,120° 对称
 αβ: 两相,90° 正交

1.2 数学推导

投影法

 iα = ia + ib·cos(-120°) + ic·cos(120°)
    = ia - 0.5·ib - 0.5·ic
 
 iβ = ib·sin(-120°) + ic·sin(120°)
    = -√3/2·ib + √3/2·ic
    = √3/2·(ic - ib)

等幅值变换(系数 2/3):

 void Clarke_Transform(float ia, float ib, float ic,
                       float *i_alpha, float *i_beta) {
     *i_alpha = ia;
     *i_beta = (ia + 2.0f * ib) / 1.732050808f;
 }

等功率变换(系数 √(2/3)):

 *i_alpha = 0.81649658f * (ia - 0.5f * (ib + ic));
 *i_beta = 0.70710678f * (ib - ic);

区别

  • 等幅值:幅值不变,功率变化
  • 等功率:功率不变,幅值变化

FOC 常用:等幅值(方便理解)


二、Park 变换(静止→旋转)

2.1 几何意义

 αβ 静止 → dq 旋转
 
       q 轴(旋转)
        |
        |  θe
        | /
        |/____ d 轴(旋转)
        ─────────── α 轴(静止)
             β 轴(静止,向上)
 
 dq 坐标系随转子旋转
 θe:转子电角度

2.2 数学推导

旋转矩阵

 [id]   [  cosθe   sinθe ] [iα]
 [iq] = [ -sinθe   cosθe ] [iβ]

物理意义

  • 从"地面"(αβ)看电流矢量 → 旋转的
  • 从"转子"(dq)看电流矢量 → 静止的

代码实现

 void Park_Transform(float i_alpha, float i_beta, float theta,
                     float *id, float *iq) {
     float cos_theta = cosf(theta);
     float sin_theta = sinf(theta);
     
     *id =  i_alpha * cos_theta + i_beta * sin_theta;
     *iq = -i_alpha * sin_theta + i_beta * cos_theta;
 }

2.3 逆 Park 变换

 [iα]   [ cosθe  -sinθe ] [id]
 [iβ] = [ sinθe   cosθe ] [iq]
void Inv_Park_Transform(float vd, float vq, float theta,
                        float *v_alpha, float *v_beta) {
    float cos_theta = cosf(theta);
    float sin_theta = sinf(theta);

    *v_alpha = vd * cos_theta - vq * sin_theta;
    *v_beta  = vd * sin_theta + vq * cos_theta;
}

三、三角函数优化

3.1 问题

直接计算(太慢):

cosf(theta);  // 几百个时钟周期
sinf(theta);

3.2 查表法

#define SIN_TABLE_SIZE  1024
static float sin_table[SIN_TABLE_SIZE];
static float cos_table[SIN_TABLE_SIZE];

// 初始化(上电时执行一次)
void SinCosTable_Init(void) {
    for (int i = 0; i < SIN_TABLE_SIZE; i++) {
        float theta = 2.0f * M_PI * i / SIN_TABLE_SIZE;
        sin_table[i] = sinf(theta);
        cos_table[i] = cosf(theta);
    }
}

// 快速查表(线性插值)
void SinCos_Lookup(float theta, float *sin_val, float *cos_val) {
    // 归一化到 [0, 2π)
    theta = fmodf(theta, 2.0f * M_PI);
    if (theta < 0) theta += 2.0f * M_PI;

    // 计算索引
    float index_f = theta / (2.0f * M_PI) * SIN_TABLE_SIZE;
    int index = (int)index_f;
    float frac = index_f - index;

    // 线性插值
    int index_next = (index + 1) % SIN_TABLE_SIZE;
    *sin_val = sin_table[index] * (1.0f - frac) + sin_table[index_next] * frac;
    *cos_val = cos_table[index] * (1.0f - frac) + cos_table[index_next] * frac;
}

性能提升

  • 直接计算:\~200 周期
  • 查表法:\~20 周期
  • 提速 10 倍!

四、完整变换流程

// FOC 控制主循环
void FOC_Update(float ia, float ib, float ic, float theta_e,
                float id_ref, float iq_ref) {
    // 1. Clarke 变换
    float i_alpha, i_beta;
    Clarke_Transform(ia, ib, ic, &i_alpha, &i_beta);

    // 2. Park 变换
    float id, iq;
    Park_Transform(i_alpha, i_beta, theta_e, &id, &iq);

    // 3. 电流环 PID
    float vd = PID_Calculate(&pid_id, id_ref - id);
    float vq = PID_Calculate(&pid_iq, iq_ref - iq);

    // 4. 逆 Park 变换
    float v_alpha, v_beta;
    Inv_Park_Transform(vd, vq, theta_e, &v_alpha, &v_beta);

    // 5. SVPWM 调制
    SVPWM_Update(v_alpha, v_beta);
}

五、总结

Clarke 变换

  • 3 维 → 2 维
  • 三相对称 → 两相正交

Park 变换

  • 静止 → 旋转
  • 时变 → 时不变
  • FOC 的核心魔法

优化技巧

  • 查表法:提速 10 倍
  • CMSIS-DSP:硬件加速

下一篇SVPWM 空间矢量调制

最后修改:2026 年 03 月 14 日
如果觉得我的文章对你有用,请随意赞赏