在逆变设计中经常会遇见傅里叶分析,尤其计算基波的傅里叶系数,这里值给出基波50Hz的算法,对于150Hz、250Hz等高次谐波算法相同。
根据直流为0的周期波形的傅里叶级数表达式f(t)=Σ(ai*sin(wit)+bi*cos(wit))
当i=1时,即为基波,i=3时,为3次谐波。
基波的幅值、幅角算法如下框图实现(基波傅里叶系数计算)
傅里叶模块Fourier参数
锁相环傅里叶Fundamental(PLL-Driven)模块参数
傅里叶模块与锁相环傅里叶模块内部算法完全一样,只是输入和参数略有不同(一个固定参数,一个可变参数),这里讲解相环傅里叶模块。
模块算法框图
In 为函数f(t)采用输入波形
wt为频率,可以是基波的 1、3、5、7、.... 的倍数,在PLL中wt是基频,这里是50Hz。
Freq 是频率,这里是 1/50 。
是一个周期内积分和,这个模块内部结构和算可以参考我的另一篇文章《Simulink 的单相锁相环PLL模块分析与Matlab代码实现》
是将两个数合称为复数(实部+虚部)
计算复数的模和幅角。
采用傅里叶分解方式计算基波(50Hz)的幅值和角度,算法原理如下:
根据傅里叶级数,任意周期波形可以用函数f(t)=Σ(a*sin(wit)+b*cos(wit))来表示,其中i=1,3,5,7,9...
f(t)*2*sin(w1t) = 2*Σ(a*sin(wit)*sin(w1t) + b*cos(wit)*sin(w1t))
f(t)*2*cos(w1t) = 2*Σ(a*sin(wit)*cos(w1t) + b*cos(wit)*cos(w1t))
w1 是wi 中i=1 时的波形,即基波,PLL中为50Hz
此外对上式进行一个周期内积分(和),由于当 i = 3, 5, 7... 时,函数的积分(和)都为0 ,因此上式为:
f(t)*2*sin(w1t))
=2(a*sin(w1t)*sin(w1t)+b*cos(w1t)*sin(w1t))
=2(a*sin(w1t)^2+b*cos(w1t)*sin(w1t))
f(t)*2*cos(w1t) =
=2(a*sin(w1t)*cos(w1t)+b*cos(w1t)*cos(w1t))
=2(a*sin(w1t)*cos(w1t)+b*cos(w1t)^2)
=2(b*cos(w1t)^2+a*cos(w1t)*sin(w1t))
根据倍角公式
cos(a)^2=(1+cos(2a))/2, sin(a)^2=(1-cos(2a))/2, sin(2a)=2sin(a)*cos(b)
带入倍角公式
f(t)*2*sin(w1t)
=2(a*sin(w1t)^2 + b*cos(w1t)*sin(w1t))
=2(a*(1-cos(2w1t))/2 + b*cos(w1t)*sin(w1t))
=a*(1-cos(2w1t) + 2*b*cos(w1t)*sin(w1t)
=a - a*cos(2w1t) + 2*b*cos(w1t)*sin(w1t)
=a - a*cos(2w1t) + b*sin(2w1t) ----------- (1)
f(t)*2*cos(w1t)
=2(b*(1+cos(2w1t))/2 + a*cos(w1t)*sin(w1t))
=b*(1+cos(2w1t)) + 2*a*cos(w1t)*sin(w1t)
=b + b*cos(2w1t) + 2*a*cos(w1t)*sin(w1t)
=b + b*cos(2w1t) + a*sin(2w1t) ----------- (2)
表达式(1)(2)中cos(2w1t)、sin(2w1t) 周期T1的积分均为0,因此有
一个周期内求和 Σf(t)*2*sin(w1t) = a
一个周期内求和 Σf(t)*2*cos(w1t) = b
则 f(t)的模 = sqrt(a^2 + b^2) = sqrt((Σf(t)*2*sin(w1t))^2 + (Σf(t)*2*cos(w1t))^2)
也就是前面模块中的算法得到了模和角度
傅里叶系数算法Matlab代码
function [Mag,Phase] = Fundamental(Freq,wt,Vin)
Gain1_Gain = 2.0;
RadDeg_Gain = 180.0/pi;
Gain3_Gain = 2.0;
persistent in_1 in_2;
if isempty(in_1)
in_1 = struct('in_data',zeros(1,300), 'Integ4',0, 'Integ4_DSTATE',0, 'Integ4_SYSTEM_ENABLE',0, 'UnitDelay_DSTATE',0, 'UnitDelay1_DSTATE',0, 'Timing',0 );
in_2 = struct('in_data',zeros(1,300), 'Integ4',0, 'Integ4_DSTATE',0, 'Integ4_SYSTEM_ENABLE',0, 'UnitDelay_DSTATE',0, 'UnitDelay1_DSTATE',0, 'Timing',0 );
end
%/* MATLAB Function: '<S2>/MATLAB Function1' 处理正弦通道 */
[sin_Mean,in_1] = Mean_X( Vin * (Gain1_Gain * sin(wt)), Freq ,in_1);
%/* MATLAB Function: '<S3>/MATLAB Function1' 处理余弦通道 */
[cos_Mean,in_2] = Mean_X( Vin * (Gain3_Gain * cos(wt)), Freq ,in_2 );
%/* 计算幅值:通过正交分量的均方根 */
Mag = sqrt( sin_Mean*sin_Mean + cos_Mean*cos_Mean );
%Mag = rt_hypotd_snf(sin_Mean,cos_Mean);
%/* 计算相位:通过反正切,并转为角度制 */
Phase = 0;%RadDeg_Gain * rt_atan2d_snf( sin_Mean, cos_Mean );
end