米多0036 发表于 2025-4-29 01:01

HC32F334如何用单次缓存解决LLC变频丢波连波问题?

HC32F334如何用单次缓存解决LLC变频丢波连波问题?


控制器输出频率先缓存
假设你每次环路计算出一个新的目标频率 f_target,不要直接设置到 PWM,而是:

c
复制
编辑
static uint32_t f_current; // 当前PWM频率
static uint32_t f_target;// 控制器输出的新目标频率
static uint32_t f_step;    // 每次调整的步进量
static uint8_tupdating;// 是否正在逐步更新
比如:

c
复制
编辑
void LLC_UpdateFrequency(uint32_t new_target)
{
    f_target = new_target;
    f_step = abs(f_target - f_current) / N_DIVISION; // N_DIVISION可设4~10,分成几步走
    updating = 1; // 开启平滑更新
}
Step 2. 定时在 PWM 更新中间插值过渡
在你的 PWM 更新(比如同步到中断回调,或者每次换向前):

c
复制
编辑
void LLC_PWM_Update()
{
    if (updating)
    {
      if (abs(f_current - f_target) <= f_step)
      {
            f_current = f_target;
            updating = 0; // 更新完成
      }
      else
      {
            if (f_current < f_target)
                f_current += f_step;
            else
                f_current -= f_step;
      }
      PWM_SetFrequency(f_current);
    }
}
这样频率变化被“缓冲”了,避免了突然跳变。

页: [1]
查看完整版本: HC32F334如何用单次缓存解决LLC变频丢波连波问题?