Agent skill

Motor Foc Control

by LeoYeAI in LeoYeAI/openclaw-master-skills

FOC磁场定向控制深度指南 | 深入讲解FOC原理、SVPWM、MTPA、弱磁控制、龙贝格观测器,配合实测案例、C代码和PI整定脚本

MITAuto-check passed

Install Motor Foc Control

skills CLI
$ npx skills add LeoYeAI/openclaw-master-skills --skill motor-foc-control -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install LeoYeAI/openclaw-master-skills motor-foc-control --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/LeoYeAI/openclaw-master-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/motor-foc-control .claude/skills/motor-foc-control && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
motor-foc-control
GitHub stars
2.2k
Token cost
~3.5k tokens
SKILL.md length
174 words
Files
4 (incl. scripts, references)
Skills in repo
1,235
Repo updated
First seen
Licence
MIT

At a glance

FOC磁场定向控制深度指南 | 深入讲解FOC原理、SVPWM、MTPA、弱磁控制、龙贝格观测器,配合实测案例、C代码和PI整定脚本

  • Works in 9 steps: FOC 基本原理 → SVPWM 原理与实现 → MTPA(最大转矩电流比)控制 → …
  • SKILL.md covers 目录, FOC 基本原理, SVPWM 原理与实现 and MTPA(最大转矩电流比)控制, plus 5 more sections
  • Runs Python scripts from its folder; calls python

What it does

Motor Foc Control is an agent skill from LeoYeAI/openclaw-master-skills. FOC磁场定向控制深度指南 | 深入讲解FOC原理、SVPWM、MTPA、弱磁控制、龙贝格观测器,配合实测案例、C代码和PI整定脚本

Its SKILL.md is about 3.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 5 other files, including scripts and reference files (for example `_meta.json`, `references/foc-quick-ref.md` and `scripts/foc_pi_tuner.py`).

The repository describes itself as: 🧠 Curated collection of 1209+ best OpenClaw skills — weekly updated by MyClaw.ai. The licence is MIT.

Example prompts

  • “/motor-foc-control”

Requirements

  • Python 3

Workflow steps

9 steps, taken from the first numbered list in SKILL.md.

  1. FOC 基本原理
  2. SVPWM 原理与实现
  3. MTPA(最大转矩电流比)控制
  4. 弱磁控制
  5. 磁链观测器
  6. PI 参数整定指南
  7. 工程参数速查
  8. 常见问题排查
  9. 参考资源

What it can do on your machine

Read from SKILL.md and the folder at commit e5199b5. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • python

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Motor Foc Control loads about 3.5k tokens when it runs, and up to ~4.5k if it reads all its reference files. Until then it costs about 21 tokens; SKILL.md has 174 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~21
When it runs · the whole SKILL.md, loaded when a task matches
~3.5k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from LeoYeAI/openclaw-master-skills at commit e5199b5, republished under its MIT licence (© LeoYeAI). 174 words, ~3,537 tokens.

Download SKILL.mdSave it as .claude/skills/motor-foc-control/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
motor-foc-control
description
FOC磁场定向控制深度指南 | 深入讲解FOC原理、SVPWM、MTPA、弱磁控制、龙贝格观测器,配合实测案例、C代码和PI整定脚本
version
2.1.0
tags
foc, motor-control, svpwm, mtpa, flux-weakening, smo, pmsm, pmsm-control
category
motor-engineering

FOC 磁场定向控制深度指南 v2.1

面向电机工程实践,系统讲解 FOC 磁场定向控制的原理、实现、调参要点。 新增:PI自动整定脚本、弱磁深度控制、故障诊断完整流程。

目录

  1. FOC 基本原理
  2. SVPWM 原理与实现
  3. MTPA(最大转矩电流比)控制
  4. 弱磁控制
  5. 磁链观测器
  6. PI 参数整定指南
  7. 工程参数速查
  8. 常见问题排查
  9. 参考资源

FOC 基本原理

坐标变换
三相静止坐标系 (ABC)
        ↓ Clarke 变换
两相静止坐标系 (α, β)
        ↓ Park 变换  
两相旋转坐标系 (d, q)

关键公式:
Clarke:  Iα = Ia
         Iβ = (Ia + 2Ib)/√3

Park:    Id = Iα·cos(θ) + Iβ·sin(θ)
         Iq = -Iα·sin(θ) + Iβ·cos(θ)

逆变换:
Iα = Id·cos(θ) - Iq·sin(θ)
Iβ = Id·sin(θ) + Iq·cos(θ)

三相重构:
Ia = Iα
Ib = -Iα/2 + Iβ·√3/2
Ic = -Iα/2 - Iβ·√3/2
FOC 控制框图
        ┌──────────────────────────────────────────┐
        │                                          │
Iq_ref ──→ ┌────┐    ┌────┐    ┌────┐    ┌─────┐ │
           │ PI │───→│ SVPWM │──→│ 逆变器 │──→│ 电机 │ │
           └────┘    └────┘    └─────┘    │     │ │
           ↑ PI      ↑            ↑             │     │
Id_ref ───→┌────┐    │            │             ↓     ↓
           │ PI │────┘            │        ┌────────┐ │
           └────┘                 │        │ 三相输出 │ │
           ↑                      │        └────────┘ │
        0 ───→┌────┐             │             ↑       │
           ┌─→│ −ωLqIq │←───────┘             │       │
           │  └────┘                          │       │
      ┌────┐│                                 │       │
 θe ←│ PLL│←─────────────────────────────────┘       │
      └────┘                                          │
      (磁链观测器)                                      │
                                                     │
     ←←←←←← 转速环 ←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←

SVPWM 原理与实现

空间矢量定义
c
// 8个基本空间矢量(6个非零 + 2个零矢量)
// U0(000): 000, U1(100): 100, U2(110): 110, ...
// U3(010): 010, U4(011): 011, U5(001): 001
// U6(101): 101, U7(111): 111

typedef struct {
    float alpha;
    float beta;
} SpaceVector;

// 合成任意方向电压矢量
SpaceVector sv_ref = {
    .alpha = Uref * cos(theta_e),
    .beta  = Uref * sin(theta_e)
};
SVPWM 扇区判断
c
// 判断参考电压矢量所在扇区
int sv_sector(SpaceVector *sv) {
    float a = sv->beta;
    float b = sv->alpha * 0.866 - sv->beta * 0.5;
    float c = -sv->alpha * 0.866 - sv->beta * 0.5;

    int N = 0;
    if (a > 0) N |= 1;
    if (b > 0) N |= 2;
    if (c > 0) N |= 4;

    // N → 扇区号 (1~6)
    const int sector_table[8] = {0, 2, 6, 1, 4, 3, 5, 0};
    return sector_table[N];
}
SVPWM 时间计算
c
// 在扇区 k 中,计算相邻矢量作用时间
// T0 = (T - Ta - Tb) / 2
// Ta, Tb 根据扇区查表

typedef struct {
    float Ualpha;
    float Ubeta;
    float T;        // PWM周期
    float Udc;      // 母线电压
} SVPWM_Handle;

void svpwm_calc(SVPWM_Handle *h, float *Ta, float *Tb) {
    float X = h->Ubeta;
    float Y = h->Ualpha * 0.866 + h->Ubeta * 0.5;
    float Z = -h->Ualpha * 0.866 + h->Ubeta * 0.5;

    int sector = sv_sector((SpaceVector*)h);

    switch(sector) {
        case 1: *Ta = Z; *Tb = Y; break;
        case 2: *Ta = Y; *Tb = -X; break;
        case 3: *Ta = -Z; *Tb = X; break;
        case 4: *Ta = -X; *Tb = Z; break;
        case 5: *Ta = X; *Tb = -Y; break;
        case 6: *Ta = -Y; *Tb = -Z; break;
    }

    // 过调制处理
    float T_sum = *Ta + *Tb;
    if (T_sum > h->T) {
        *Ta = *Ta * h->T / T_sum;
        *Tb = *Tb * h->T / T_sum;
    }

    // 零矢量分配(7段式对称PWM)
    float T0 = (h->T - *Ta - *Tb) / 2;
    float T7 = T0;

    // 计算三相占空比
    // DPA, DPB, DPC 存入比较寄存器
}
占空比计算(7段式对称SVPWM)
c
// 各扇区占空比计算
// Tcm1, Tcm2, Tcm3 → 对应 ABC 三相比较值

void svpwm_duty(SVPWM_Handle *h, float *Tcm) {
    float Ta, Tb;
    svpwm_calc(h, &Ta, &Tb);
    float T0 = (h->T - Ta - Tb) / 2;

    int sector = sv_sector((SpaceVector*)h);

    switch(sector) {
        case 1:  // U4(100), U6(110), U0(000)
            Tcm[0] = (h->T + Ta + Tb) / 2;  // A: 先断后通
            Tcm[1] = (h->T - Ta + Tb) / 2;  // B
            Tcm[2] = (h->T - Ta - Tb) / 2;  // C
            break;
        case 2:  // U6(110), U2(010), U0(000)
            Tcm[0] = (h->T - Ta + Tb) / 2;
            Tcm[1] = (h->T + Ta + Tb) / 2;
            Tcm[2] = (h->T - Ta - Tb) / 2;
            break;
        case 3:  // U2(010), U3(011), U0(000)
            Tcm[0] = (h->T - Ta - Tb) / 2;
            Tcm[1] = (h->T + Ta + Tb) / 2;
            Tcm[2] = (h->T + Ta - Tb) / 2;
            break;
        case 4:  // U3(011), U1(001), U0(000)
            Tcm[0] = (h->T - Ta - Tb) / 2;
            Tcm[1] = (h->T - Ta + Tb) / 2;
            Tcm[2] = (h->T + Ta + Tb) / 2;
            break;
        case 5:  // U1(001), U5(101), U0(000)
            Tcm[0] = (h->T + Ta - Tb) / 2;
            Tcm[1] = (h->T - Ta - Tb) / 2;
            Tcm[2] = (h->T + Ta + Tb) / 2;
            break;
        case 6:  // U5(101), U4(100), U0(000)
            Tcm[0] = (h->T + Ta + Tb) / 2;
            Tcm[1] = (h->T - Ta - Tb) / 2;
            Tcm[2] = (h->T + Ta - Tb) / 2;
            break;
    }
}

MTPA(最大转矩电流比)控制

原理

对于内嵌式 PMSM(IPMSM),存在 d轴磁阻转矩,利用 MTPA 可在相同电流下获得更大转矩。

电磁转矩方程:
T = 1.5 × np × [Ψm × Iq + (Ld - Lq) × Id × Iq]

定义电流幅值:
|I| = √(Id² + Iq²)

MTPA 轨迹:固定 |I|,寻找使 T 最大的 (Id, Iq) 组合
MTPA 数学推导
令 ∂T/∂Id = 0,约束条件 |I| = constant

拉格朗日函数:L = T - λ(√(Id²+Iq²) - I_ref)

∂L/∂Id = 1.5×np×[(Ld-Lq)×Iq] - λ×Id/|I| = 0
∂L/∂Iq = 1.5×np×[Ψm + (Ld-Lq)×Id] - λ×Iq/|I| = 0

联立求解(化简后):

Id_MTPA = -(Ψm / (2×ΔL)) + √[(Ψm/(2ΔL))² + Iq²]

其中 ΔL = Lq - Ld > 0

当 ΔL 很小时(表贴式),Id_MTPA ≈ 0 → 退化为 Id=0 控制
MTPA 实现
c
// MTPA 查表法(实时性最好)
// 预计算 MTPA 曲线,运行时查表 + 线性插值

static const float mtpa_table_Iq[] = {
    0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 15.0, 18.0, 20.0
};
static const float mtpa_table_Id[] = {
    0.0, -0.5, -1.1, -1.8, -2.5, -3.2, -4.0, -5.3, -6.6, -7.8
};

float mtpa_interpolate(float Iq) {
    int n = sizeof(mtpa_table_Iq) / sizeof(mtpa_table_Iq[0]);
    // 边界
    if (Iq <= mtpa_table_Iq[0]) return mtpa_table_Id[0];
    if (Iq >= mtpa_table_Iq[n-1]) return mtpa_table_Id[n-1];
    // 查表
    for (int i = 0; i < n-1; i++) {
        if (Iq >= mtpa_table_Iq[i] && Iq < mtpa_table_Iq[i+1]) {
            float t = (Iq - mtpa_table_Iq[i]) /
                       (mtpa_table_Iq[i+1] - mtpa_table_Iq[i]);
            return mtpa_table_Id[i] + t * (mtpa_table_Id[i+1] - mtpa_table_Id[i]);
        }
    }
    return 0;
}

// MTPA 解析公式法(适合在线计算)
float mtpa_Id_formula(float Iq, float Psi_m, float Ld, float Lq) {
    float delta_L = Lq - Ld;
    if (delta_L < 1e-6) return 0;  // 表贴式,无 MTPA 效益

    float k = Psi_m / (2.0f * delta_L);
    float Id = -k + sqrtf(k * k + Iq * Iq);
    return -Id;  // Id 必须为负(去磁)
}

弱磁控制

原理

当转速超过基速时,反电动势 E > Vdc,电压饱和。弱磁通过增加 Id(去磁电流)来降低有效磁链,从而在恒功率区扩展转速。

电压极限椭圆(d-q 平面):
Vd² + Vq² ≤ Vdc² / 2   (SVPWM线性调制区最大输出)

反电动势约束:
V = ω_e × (Ψm - Ld×Id)  ≈ ω_e × Ψm_eff

弱磁的本质:在电压极限椭圆内重新分配 Id、Iq
弱磁深度等级
等级Id 比例适用转速范围特性
轻度弱磁-0.3×Imax1~1.5× 基速转矩下降少
中度弱磁-0.5×Imax1.5~2× 基速恒功率区主力
深度弱磁-0.7×Imax2~3× 基速转矩大幅下降
六步方波全部去磁>3× 基速最大转速,扭矩波动大
弱磁控制器实现
c
typedef enum {
    MTPA_MODE,         // 最大转矩电流比
    FW_MODE,            // 弱磁模式
    SIXSTEP_MODE        // 六步方波
} FluxMode;

typedef struct {
    float Vdc;          // 母线电压
    float V_lim;        // 电压极限(Vdc/sqrt(2))
    float V_th;         // 弱磁启动阈值(建议 0.9×V_lim)
    float Id_fw_min;    // 最大去磁电流(负值)
    float gamma;         // 弱磁PI积分系数
    float Kp_fw;        // 弱磁比例增益
    float Ki_fw;        // 弱磁积分增益
} FluxWeaken_Handle;

void flux_weaken_update(FluxWeaken_Handle *h,
                        float V_mag, float Id_ref,
                        float *Id_fw_out) {
    // V_mag = sqrt(Vd² + Vq²)
    // Id_ref = MTPA 给定的 Id

    static float integral = 0;
    float error = V_mag - h->V_lim * 0.95;  // 提前 5% 介入

    if (error > 0) {
        // 电压饱和,启动弱磁
        integral += h->gamma * error;
        integral = fminf(integral, 0);  // Id_fw 为负,积分限幅
        *Id_fw_out = h->Id_fw_min;       // 直接给最大去磁
    } else {
        // 电压裕量足够,逐渐减小弱磁
        integral *= 0.95;  // 缓慢衰减
        *Id_fw_out = Id_ref + integral;
    }

    // 与 MTPA 叠加
    *Id_fw_out = fmaxf(*Id_fw_out, h->Id_fw_min);
}
弱磁调度逻辑
c
float select_Id_ref(float Id_MTPA, float Id_FW, float V_mag,
                    float V_lim, float speed) {
    float Id_ref;

    if (V_mag < V_lim * 0.85) {
        // 电压充裕,MTPA 控制
        Id_ref = Id_MTPA;
    } else if (V_mag < V_lim * 0.95) {
        // 电压接近饱和,过渡区
        float alpha = (V_mag - V_lim * 0.85) / (V_lim * 0.1);
        Id_ref = Id_MTPA + alpha * (Id_FW - Id_MTPA);
    } else {
        // 深度弱磁
        Id_ref = Id_FW;
    }

    return Id_ref;
}

磁链观测器

滑模观测器(SMO)估测转子位置
c
typedef struct {
    float I_alpha;
    float I_beta;
    float Ia;
    float Ib;
    float Ic;
    float R;
    float L;
    float emf_alpha;
    float emf_beta;
    float angle;
    float speed;
    float prev_angle;
    float k_gain;       // 滑模增益
    float filter_bw;     // 低通截止频率 rad/s
} SMO_Handle;

// sign 函数(连续近似,避免抖振)
float sign_f(float x, float delta) {
    if (x > delta)  return 1.0f;
    if (x < -delta) return -1.0f;
    return x / delta;  // |x|<delta: 线性近似
}

#define K_SMO 0.5f    // 滑模增益(过大=抖振,过小=延迟)

void smo_update(SMO_Handle *smo, float V_alpha, float V_beta,
               float Ia, float Ib, float Ic, float dt) {

    float e_alpha = smo->I_alpha - Ia;
    float e_beta  = smo->I_beta  - Ib;

    // 滑模控制量
    float z_alpha = smo->k_gain * sign_f(e_alpha, 0.05f);
    float z_beta  = smo->k_gain * sign_f(e_beta,  0.05f);

    // 电流更新(欧拉法)
    smo->I_alpha += dt * (-smo->R * Ia + V_alpha - z_alpha) / smo->L;
    smo->I_beta  += dt * (-smo->R * Ib + V_beta  - z_beta ) / smo->L;

    // 反电动势提取(低通滤波)
    float alpha_lpf = 2.0f * M_PI * smo->filter_bw;
    smo->emf_alpha += dt * alpha_lpf * (z_alpha - smo->emf_alpha);
    smo->emf_beta  += dt * alpha_lpf * (z_beta  - smo->emf_beta);

    // 角度提取
    smo->angle = atan2f(smo->emf_alpha, -smo->emf_beta);

    // 速度计算(微分)
    float d_angle = smo->angle - smo->prev_angle;
    // 角度归一化(处理 -π 到 +π 跳变)
    if (d_angle > M_PI)  d_angle -= 2.0f * M_PI;
    if (d_angle < -M_PI) d_angle += 2.0f * M_PI;
    smo->speed = d_angle / dt;
    smo->prev_angle = smo->angle;
}
PLL(锁相环)角度提取
c
// 对 SMO 估算的反电动势做 PLL
// emf_d = -ω_e × Ψm × sin(Δθ) ≈ -ω_e × Ψm × Δθ(小角度时)
// emf_q =  ω_e × Ψm × cos(Δθ) ≈  ω_e × Ψm

typedef struct {
    float Kp;
    float Ki;
    float integral;
    float angle;
    float speed;
    float lock_threshold;  // 锁定阈值 rad/s
    int   locked;         // 锁定标志
} PLL_Handle;

void pll_update(PLL_Handle *pll, float emf_d, float emf_q, float dt) {
    // d轴反电动势应接近0(正确对齐时)
    // q轴反电动势 = ω_e × Ψm

    float error = emf_d;  // PLL 误差

    // PI 积分
    pll->integral += pll->Ki * error * dt;
    // 积分限幅
    pll->integral = fmaxf(fminf(pll->integral, 1000.0f), -1000.0f);

    pll->speed = pll->Kp * error + pll->integral;
    pll->angle += pll->speed * dt;

    // 角度归一化 0~2π
    while (pll->angle < 0)      pll->angle += 2.0f * M_PI;
    while (pll->angle > 2.0f*M_PI) pll->angle -= 2.0f * M_PI;

    // 锁定判断
    if (fabsf(error) < pll->lock_threshold && fabsf(pll->speed) > 10.0f) {
        pll->locked = 1;
    }
}

PI 参数整定指南

自动整定脚本
bash
# 自动计算 PI 参数
python scripts/foc_pi_tuner.py --R 1.23 --L 5.6e-3 --J 1e-3 --Kt 0.15

# 交互模式(引导输入)
python scripts/foc_pi_tuner.py --mode interactive

# 指定目标带宽
python scripts/foc_pi_tuner.py --R 2.1 --L 8e-3 --target_bw 150

# 指定采样周期 + 生成Bode图
python scripts/foc_pi_tuner.py --R 1.23 --L 5.6e-3 --Ts_us 62.5 --plot
电流环整定
目标:带宽 ωbw = R/L × 0.5(典型因子 0.3~0.6)

Kp = L × ωbw
Ki = R / L

示例:
R = 1.23Ω, L = 5.6mH, ωbw = 1.23/0.0056 × 0.5 ≈ 110 rad/s
Kp = 0.0056 × 110 ≈ 0.616
Ki = 1.23/0.0056 ≈ 220 (需根据 Ts 离散化修正)
速度环整定
目标:带宽 ≈ 电流环带宽 / 10

Kp_speed ≈ J × ωbw_speed
Ki_speed ≈ Kp_speed / Tm

示例:
J = 0.001 kg·m²
ωbw_speed = 11 rad/s (电流环1/10)
Kp_speed = 0.001 × 11 = 0.011
Tm = J × R / Kt² = 0.001 × 1.23 / 0.15² ≈ 0.055 s
Ki_speed = 0.011 / 0.055 ≈ 0.2
离散化修正(Tustin 方法)
给定采样周期 Ts:
Kp_d = Kp
Ki_d = Ki × Ts / 2

示例:Ts = 62.5μs (16kHz)
Ki_d = 220 × 31.25e-6 = 0.006875

实现(位置式):
  integral += Ki_d × error
  output   = Kp_d × error + integral
  限幅:output ∈ [-Vmax, Vmax]

工程参数速查

详见 references/foc-quick-ref.md

参数典型值说明
电流环带宽100~500 Hz转速决定上限
速度环带宽10~50 Hz电流环的1/5~1/10
开关频率8~25 kHz载波比 >100
死区时间200~800 ns电压越高,死区越大
电流采样延迟≤1×Ts影响带宽
编码器分辨率≥2500线直接影响角度精度
PWM分辨率≥11-bit决定电流精度

常见问题排查

现象原因解决
启动抖动初始角度错误/Hall错位检查初始角校准程序
高速失步弱磁不足/电压裕量不足增强弱磁,提高Vdc
低速蠕动编码器分辨率低/速度环带宽低提高速度环带宽,更换编码器
电流振荡电流环带宽过高/采样延迟大减小 Kp,减小 Ts
温升快铜损过高/换向重叠角小检查开关死区,降低电流
振动噪音PWM载波比低/共振频率激发提高PWM频率,加陷波滤波
反电动势波形畸变磁钢充磁不均/磁饱和Maxwell仿真确认
启动转速超调速度环积分Windup加积分清零/抗积分饱和
换向时有台阶Hall传感器滞后/角度误差检查Hall安装相位
调试流程图
启动抖动?
├─ 初始角度问题 → 重新做初始角辨识(脉冲法/预定位)
├─ Hall错位 → 校正Hall安装位置
└─ 电流环带宽不足 → 提高电流环 Kp

高速失步?
├─ 弱磁不足 → 增强 Id_fw,验证 V_mag > 0.95×V_lim
├─ 母线电压不足 → 提高 Vdc 或加升压
└─ 反电动势估算错误 → 检查速度观测器

振动噪音?
├─ 开关频率共振 → 提高PWM频率或加RC吸收
├─ 机械共振 → 加陷波滤波器
└─ 电流纹波大 → 提高开关频率或加电感

参考资源

  • scripts/foc_pi_tuner.py - PI参数自动整定脚本(推荐优先使用)
  • references/foc-quick-ref.md - FOC工程参数速查卡(典型值、阈值速查)
  • references/pm-materials.md - 永磁体牌号参数表(可选扩展)
快速使用 PI 整定
bash
# 完整参数计算(自动输出离散PI参数)
python scripts/foc_pi_tuner.py --R 1.23 --L 5.6e-3 --poles 8 --J 1e-3 --Kt 0.15 --Ts_us 62.5

# 绘制 Bode 图(验证稳定性)
python scripts/foc_pi_tuner.py --R 1.23 --L 5.6e-3 --plot

# 对比不同带宽参数
python scripts/foc_pi_tuner.py --R 2.1 --L 8e-3 --target_bw 80
python scripts/foc_pi_tuner.py --R 2.1 --L 8e-3 --target_bw 200

注意:脚本输出为理论初始值,实际需在电机上微调。调试顺序:电流环→速度环→位置环,逐级验证带宽和稳定性。

© LeoYeAI, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (scripts, references) in skills/motor-foc-control of LeoYeAI/openclaw-master-skills.

  • SKILL.md
  • _meta.json
  • references/foc-quick-ref.md
  • scripts/foc_pi_tuner.py

Open the folder on GitHubat commit e5199b5

Compare with similar skills

Motor Foc Control next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Motor Foc Control compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Motor Foc Control this skillLeoYeAI/openclaw-master-skills2.2k—~3.5kAutomated safety check: PassMIT
Simulink Control Motorsmatlab/simulink-agentic-toolkit1.2k—~2.8kAutomated safety check: PassCustom licence
Motor Model Dynamicsbenchflow-ai/skillsbench1.8k—~845Automated safety check: PassApache-2.0
Focs Experimentsbrycewang-stanford/Awesome-Journal-Skills1.2k—~1.6kAutomated safety check: PassMIT
Focs Reproducibilitybrycewang-stanford/Awesome-Journal-Skills1.2k—~1.4kAutomated safety check: PassMIT
Focs Supplementarybrycewang-stanford/Awesome-Journal-Skills1.2k—~1.6kAutomated safety check: PassMIT

Similar skills

  • Simulink Control Motors

    matlab/simulink-agentic-toolkit

    Build motor control solutions using Motor Control Blockset for PMSM, induction motors, BLDC, and SynRM.

    1.2k GitHub stars~2.8k tokensUpdated 3 days ago
    Auto-check passed
  • Motor Model Dynamics

    benchflow-ai/skillsbench

    A skill your agent uses when simulating quadrotor physical dynamics — mapping desired thrust/moments to individual motor RPMs via a propeller allocation matrix, applying first-order motor lag, and…

    1.8k GitHub stars~845 tokensUpdated 2 mo ago
    Auto-check passed
  • Focs Experiments

    brycewang-stanford/Awesome-Journal-Skills

    A skill your agent uses when deciding whether and how computation appears in a FOCS (IEEE Symposium on Foundations of Computer Science) paper — a venue that accepts on theorems with no evaluation…

    1.2k GitHub stars~1.6k tokensUpdated 14 days ago
    Auto-check passed
  • Focs Reproducibility

    brycewang-stanford/Awesome-Journal-Skills

    A skill your agent uses when hardening a FOCS (IEEE Symposium on Foundations of Computer Science) paper's checkability — the theory analogue of reproducibility — via hypothesis ledgers…

    1.2k GitHub stars~1.4k tokensUpdated 14 days ago
    Research & ScienceAuto-check passed
  • Focs Supplementary

    brycewang-stanford/Awesome-Journal-Skills

    A skill your agent uses when architecting everything after page ten of a FOCS (IEEE Symposium on Foundations of Computer Science) submission — a venue with no separate supplement channel where the…

    1.2k GitHub stars~1.6k tokensUpdated 14 days ago
    Auto-check passed
  • Focs Submission

    brycewang-stanford/Awesome-Journal-Skills

    A skill your agent uses when running the final pre-upload audit of a FOCS (IEEE Symposium on Foundations of Computer Science) submission — the April HotCRP deadline clock, the…

    1.2k GitHub stars~1.5k tokensUpdated 14 days ago
    Documents & OfficeAuto-check passed

More from LeoYeAI/openclaw-master-skills

All 1,200 skills in this repo
  • DevOps Pipeline Management

    LeoYeAI/openclaw-master-skills

    Manages pipelines on a DevOps quality and efficiency platform through its OpenAPI: list workspaces and templates, create, update, run and cancel pipelines, and read run records.

    2.2k GitHub stars~4.2k tokensUpdated 2 mo ago
    Auto-check: notes
  • Feishu Document Collaboration

    LeoYeAI/openclaw-master-skills

    Patches OpenClaw's Feishu extension so an edited document triggers an isolated agent session that reads the doc and replies inline, turning it into a live chat space.

    2.2k GitHub stars~2k tokensUpdated 2 mo ago
    Auto-check passed
  • Files Memory System

    LeoYeAI/openclaw-master-skills

    Multi-context memory management system for OpenClaw agents with group-isolated storage, global shared memory, workspace organization, and group-specific skills isolation.

    2.2k GitHub stars~3.8k tokensUpdated 2 mo ago
    Auto-check passed
  • GEO-Claw AI Visibility Agent

    LeoYeAI/openclaw-master-skills

    Runs a brand's AI-search visibility work end to end: diagnosing how AI platforms represent it, repositioning it, producing AI-optimized content and monitoring ongoing mentions.

    2.2k GitHub stars~4.7k tokensUpdated 2 mo ago
    Auto-check passed
  • Google Workspace CLI

    LeoYeAI/openclaw-master-skills

    Installs and authenticates the gws CLI, then automates Gmail, Drive, Sheets, Calendar, Docs, Chat and Tasks with ready-made recipes, persona bundles and security audits.

    2.2k GitHub stars~2.6k tokensUpdated 2 mo ago
    Auto-check: notes
  • HealthFit Health Advisors

    LeoYeAI/openclaw-master-skills

    Runs four advisor roles, a fitness coach, nutritionist, data analyst and TCM practitioner, to build a health profile and track workouts, diet and wellness over time.

    2.2k GitHub stars~4.4k tokensUpdated 2 mo ago
    Auto-check passed

Questions about Motor Foc Control

What does Motor Foc Control do?

FOC磁场定向控制深度指南 | 深入讲解FOC原理、SVPWM、MTPA、弱磁控制、龙贝格观测器,配合实测案例、C代码和PI整定脚本. Motor Foc Control is an agent skill from LeoYeAI/openclaw-master-skills.

How do I install Motor Foc Control in Claude Code?

Run `npx skills add LeoYeAI/openclaw-master-skills --skill motor-foc-control -a claude-code`. Or copy the skill folder (skills/motor-foc-control in LeoYeAI/openclaw-master-skills) into .claude/skills/motor-foc-control in your project. Claude Code loads it when a task matches its description.

How do I install Motor Foc Control in Codex?

Run `npx skills add LeoYeAI/openclaw-master-skills --skill motor-foc-control -a codex`. Or copy the skill folder (skills/motor-foc-control in LeoYeAI/openclaw-master-skills) into .agents/skills/motor-foc-control in your project. Codex loads it when a task matches its description.

Can I use Motor Foc Control in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add LeoYeAI/openclaw-master-skills --skill motor-foc-control -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/motor-foc-control, .gemini/skills/motor-foc-control, .github/skills/motor-foc-control and .opencode/skills/motor-foc-control in your project.

What does Motor Foc Control need to run?

Going by SKILL.md and its folder, Motor Foc Control needs Python for the scripts in its folder and the command-line tools its instructions call (python). Our summary lists: Python 3.

Does Motor Foc Control access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Motor Foc Control safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Motor Foc Control use?

Motor Foc Control is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Motor Foc Control use?

About 3.5k tokens (SKILL.md is roughly 14k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1k tokens, read only when the agent opens those files.

What are the alternatives to Motor Foc Control?

Skills that share tags, products or a category with Motor Foc Control: Simulink Control Motors (matlab/simulink-agentic-toolkit, 1.2k stars), Motor Model Dynamics (benchflow-ai/skillsbench, 1.8k stars), Focs Experiments (brycewang-stanford/Awesome-Journal-Skills, 1.2k stars) and Focs Reproducibility (brycewang-stanford/Awesome-Journal-Skills, 1.2k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Motor Foc Control?

LeoYeAI (a GitHub user) maintains it in LeoYeAI/openclaw-master-skills, which has 2,161 GitHub stars. The repository holds 1,235 skills in this directory. The repository was last updated on July 20, 2026.

Source: LeoYeAI/openclaw-master-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.