侧边栏壁纸
  • 累计撰写 35 篇文章
  • 累计创建 9 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

PLL锁相环-SOGI变换推导

Hollies
2023-11-30 / 0 评论 / 0 点赞 / 36 阅读 / 9495 字 / 正在检测是否收录...
温馨提示:
本文最后更新于 2024-06-08,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

1. 理论

原式

D\left( s \right) =\frac{k\omega _0s}{s^2+k\omega _0s+\omega _{0}^{2}}
Q\left( s \right) =\frac{k\omega _{0}^{2}}{s^2+k\omega _ns+\omega _{0}^{2}}

离散化公式

s=\frac{2}{T_s}\frac{z-1}{z+1}

离散化推导

D\left( z \right) =b_0\cdot \frac{1-z^{-2}}{1-a_1z^{-1}-a_2z^{-2}}
Y\left( z \right) =X\left( z \right) D\left( z \right) =b_0\cdot \frac{X\left( z \right) -z^{-2}X\left( z \right)}{1-a_1z^{-1}-a_2z^{-2}}
\Rightarrow Y\left( z \right) -a_1z^{-1}Y\left( z \right) -a_2z^{-2}Y\left( z \right) =b_0X\left( z \right) -b_0z^{-2}X\left( z \right)
\Rightarrow Y\left( z \right) =b_0X\left( z \right) -b_0z^{-2}X\left( z \right) +a_1z^{-1}Y\left( z \right) +a_2z^{-2}Y\left( z \right)
\Rightarrow y\left( k \right) =b_0x\left( k \right) -b_0x\left( k-2 \right) +a_1y\left( k-1 \right) +a_2y\left( k-2 \right)

Q\left( z \right) =\lambda b_0\cdot \frac{1+2z^{-1}+z^{-2}}{1-a_1z^{-1}-a_2z^{-2}}
Y\left( z \right) =X\left( z \right) Q\left( z \right) =\lambda b_0\cdot \frac{X\left( z \right) +2z^{-1}X\left( z \right) +z^{-2}X\left( z \right)}{1-a_1z^{-1}-a_2z^{-2}}
\Rightarrow Y\left( z \right) -a_1z^{-1}Y\left( z \right) -a_2z^{-2}Y\left( z \right) =\lambda b_0X\left( z \right) +2\lambda b_0z^{-1}X\left( z \right) +\lambda b_0z^{-2}X\left( z \right)
\Rightarrow Y\left( z \right) =\lambda b_0X\left( z \right) +2\lambda b_0z^{-1}X\left( z \right) +\lambda b_0z^{-2}X\left( z \right) +a_1z^{-1}Y\left( z \right) +a_2z^{-2}Y\left( z \right)
\Rightarrow y\left( k \right) =\lambda b_0x\left( k \right) +2\lambda b_0x\left( k-1 \right) +\lambda b_0x\left( k-2 \right) +a_1y\left( k-1 \right) +a_2y\left( k-2 \right)
\Rightarrow y\left( k \right) =\lambda b_0\left( x\left( k \right) +2x\left( k-1 \right) +x\left( k-2 \right) \right) +a_1y\left( k-1 \right) +a_2y\left( k-2 \right)

b_0=\frac{x}{x+y+4},a_1=\frac{8-2y}{x+y+4},a_2=\frac{x-y-4}{x+y+4}
\lambda =0.5\omega _0T_s,x=2k\omega _0T_s,y=\left( \omega _0T_s \right) ^2
\omega _0为无阻尼自然频率,即输入信号频率;k为阻尼比,是设定值

2. 代码验证

main.c

#include "sogi.h"
#include <math.h>
#include <stdio.h>
int main()
{
    float s = 0;
    signal_PLL si;
    si = signal_PLL_Init(si);
    FILE *f = fopen("f.txt", "w");
    FILE *d = fopen("d.txt", "w");
    FILE *q = fopen("q.txt", "w");
    for (int i = 0; i < 1440; i++)
    {
        s = (float)sin(i * 3.1415926 / 180.f);
        si.u_0 = s;
        si = sogi(si);
        fprintf(f, "%f\n", si.u_0);
        fprintf(d, "%f\n", si.d_0);
        fprintf(q, "%f\n", si.q_0);
    }
    fclose(f);
    fclose(d);
    fclose(q);
    return 0;
}

signal_PLL.h

//存储信号内部过程量
struct signal_PLL_Temp
{
    float lamda;
    float x;
    float y;
    float b0;
    float a1;
    float a2;
};
typedef struct signal_PLL
{
    float omiga;    //无阻尼自然频率,2*pi*频率
    float Ts;   //采样周期
    float d_0, d_1, d_2;
    float q_0, q_1, q_2;
    float u_0, u_1, u_2;
    struct signal_PLL_Temp temp;
}signal_PLL;

signal_PLL signal_PLL_Init(signal_PLL pll);

signal_PLL.c

#include "signal_PLL.h"
//初始化结构体
signal_PLL signal_PLL_Init(signal_PLL pll)
{
    signal_PLL temp = pll;
    temp.d_1 = 0.f;
    temp.d_2 = 0.f;
    temp.q_1 = 0.f;
    temp.q_2 = 0.f;
    temp.omiga = 2 * 3.14f * 50;
    temp.Ts = 1 / 20000.f;
    return temp;
}

sogi.h

#include "signal_PLL.h"
signal_PLL sogi(signal_PLL signal);

sogi.c

#include "sogi.h"
/*
SOGI变换
调用频繁,使用内联函数可增加效率
具体公式见博文
*/
float k = 1.41f;    //阻尼比
signal_PLL sogi(signal_PLL signal)
{
    signal_PLL temp = signal;
    temp.temp.lamda = 0.5f * temp.omiga * temp.Ts;
    temp.temp.x = 2 * k * temp.omiga * temp.Ts;
    temp.temp.y = temp.omiga * temp.Ts * temp.omiga * temp.Ts;

    temp.temp.b0 = temp.temp.x / (temp.temp.x + temp.temp.y +4);
    temp.temp.a1 = (8-2 * temp.temp.y) / (temp.temp.x + temp.temp.y + 4);
    temp.temp.a2 = (temp.temp.x - temp.temp.y - 4) / (temp.temp.x + temp.temp.y + 4);

    temp.d_0 = temp.temp.b0 * temp.u_0 - temp.temp.b0 * temp.u_2 + temp.temp.a1 * temp.d_1 + temp.temp.a2 * temp.d_2;
    temp.q_0 = temp.temp.b0 * temp.u_0 +2 * temp.temp.b0 * temp.u_1 + temp.temp.b0 * temp.u_2 + temp.temp.a1 * temp.q_1 + temp.temp.a2 * temp.q_2;

    temp.u_2 = temp.u_1;
    temp.u_1 = temp.u_0;
    temp.d_2 = temp.d_1;
    temp.d_1 = temp.d_0;
    temp.q_2 = temp.q_1;
    temp.q_1 = temp.q_0;
    return temp;
}

3. 结果查看

将结果导入Excel进行绘图

PLL锁相环_SOGI变换_图1.png

PLL锁相环_SOGI变换_图2.png

可以看到经过SOGI变换后,输出了一个与原函数相同的d函数,以及一个滞后于原函数90°的q函数。

参考

2023年电赛电源题代码开源——(含SOGI、锁相环、电压电流双环控制的STM32实现)_单同步单相锁相环.c实现-CSDN博客

单相锁相环(一)基于二阶广义积分器的单相锁相环(SOGI-PLL)的matlab/simulink仿真 - 知乎 (zhihu.com)

q轴分量实测是d轴分量的\frac{382}{3}倍,在进行park变换前需要统一幅值。

事实上是上面推导出错所导致,公式推导已修正,代码部分需要自行修改。

0

评论区