目录
FOC框图
一、坐标变换
1、反Park变换
公式:
2、反Clark变换
公式:
3、Clark变换
公式:
4、Park变换
公式:
C代码如下:
#include <stdio.h>
#include <math.h>
typedef struct {
double Ualpha; double Ubeta; double Ud; double Uq;
double Ua; double Ub; double Uc;
double ia; double ib; double ic;
double iq; double id; double ialpha;
double ibeta; double id_pre; double iq_pre;
double angle;
}MOTOR_PARAM;
MOTOR_PARAM motor_param;
int Res_Upark();
int Res_Uclark();
int Ipark();
int Iclark();
int main(void) {
motor_param.Ud = 0.0;
motor_param.Uq = 10.0;
motor_param.angle = 30.0;
Res_Upark();
printf("alpha轴电压:%f beta轴电压:%f\n",motor_param.Ualpha,motor_param.Ubeta);
Res_Uclark();
printf("A相电压:%f B相电压:%f C相电压:%f\n",motor_param.Ua,motor_param.Ub,motor_param.Uc);
motor_param.ia = motor_param.Ua;
motor_param.ib = motor_param.Ub;
motor_param.ic = motor_param.Uc;
Iclark();
printf("alpha轴电流:%f beta轴电流:%f\n",motor_param.ialpha,motor_param.ibeta);
Ipark();
printf("D轴电流:%f Q轴电流:%f D轴电流(预):%f Q轴电流(预):%f\n",motor_param.id,motor_param.iq,motor_param.id_pre,motor_param.iq_pre);
return 0;
}
int Res_Upark(){
motor_param.Ualpha = motor_param.Ud * cos(motor_param.angle) - motor_param.Uq * sin(motor_param.angle);
motor_param.Ubeta = motor_param.Ud * sin(motor_param.angle) + motor_param.Uq * cos(motor_param.angle);
return 0;
}
int Res_Uclark(){
motor_param.Ua = motor_param.Ualpha;
motor_param.Ub = -0.5*motor_param.Ualpha + ((sqrt(3.0)/2.0) *motor_param.Ubeta);
motor_param.Uc = -0.5*motor_param.Ualpha - ((sqrt(3.0)/2.0) *motor_param.Ubeta);
return 0;
}
int Iclark(){
motor_param.ialpha = motor_param.ia;
motor_param.ibeta = (motor_param.ia + 2*motor_param.ib)/sqrt(3.0);
return 0;
}
int Ipark(){
motor_param.id = motor_param.ialpha * cos(motor_param.angle) +motor_param.ibeta * sin(motor_param.angle);
motor_param.iq = -motor_param.ialpha * sin(motor_param.angle) + motor_param.ibeta * cos(motor_param.angle);
motor_param.id_pre = motor_param.id *1.5;
motor_param.iq_pre = motor_param.iq *1.5;
return 0;
}
执行效果如下:
二、SVPWM
将坐标变换中的反Park变换得到的 Valpha 、Vbeta 转换六路PWM输出。
1、扇区判断
根据推导可得:
N = 4C + 2B + A;
扇区 | 一 | 二 | 三 | 四 | 五 | 六 |
N | 3 | 1 | 5 | 4 | 6 | 2 |
2、相邻矢量作用时长
推导可得:
Ts :定时器的频率,Vdc : 母线电压。
扇区与作用时长的关系:
1 | 2 | 3 | 4 | 5 | 6 | |
Tx | z | y | -z | -x | x | -y |
Ty | y | -x | x | z | -y | -z |
表中数字代表扇区判断中N的值,1对应的是第二扇区,以此类推。
Tx,Ty代表两个矢量的时长。可以理解为两个分量上的占空比输出。
3、每个扇区的作用时长
第一扇区: Sa = (Ts - Tx - Ty)/4, Sb = (Ts + Tx - Ty)/4, Sc = (Ts + Tx + Ty)/4;
第二扇区: Sa = (Ts + Tx - Ty)/4, Sb = (Ts - Tx - Ty)/4, Sc = (Ts + Tx + Ty)/4;
第三扇区: Sa = (Ts + Tx + Ty)/4, Sb = (Ts - Tx - Ty)/4, Sc = (Ts + Tx - Ty)/4;
第四扇区: Sa = (Ts + Tx + Ty)/4, Sb = (Ts + Tx - Ty)/4, Sc = (Ts - Tx - Ty)/4;
第五扇区: Sa = (Ts + Tx - Ty)/4, Sb = (Ts + Tx +Ty)/4, Sc = (Ts - Tx - Ty)/4;
第六扇区: Sa = (Ts - Tx - Ty)/4, Sb = (Ts + Tx + Ty)/4, Sc = (Ts + Tx - Ty)/4;
Sa、 Sb、 Sc 可以理解为U、V、W 三项的占空比输出。
以下为MATLAB svpwm仿真模块的代码:
function [Tpwm1,Tpwm2,Tpwm3,sector] = fcn(Valpha,Vbeta,Udc,Tpwm)
%#codegen
sector = single(0);
Tpwm1 = single(0);
Tpwm2 = single(0);
Tpwm3 = single(0);
Uref1 = Vbeta;
Uref2 = (sqrt(3)*Valpha - Vbeta)/2;
Uref3 = (-sqrt(3)*Valpha - Vbeta)/2;
if(Uref1 > 0)
sector = single(1);
end
if(Uref2 > 0)
sector = sector + single(2);
end
if(Uref3 > 0)
sector = sector + single(4);
end
X = (sqrt(3)*Tpwm*Vbeta)/Udc;
Y = Tpwm/Udc*(3/2*Valpha +sqrt(3)/2*Vbeta);
Z = Tpwm/Udc*(-3/2*Valpha +sqrt(3)/2*Vbeta);
switch(sector)
case 1
Tx = Z;Ty = Y;
case 2
Tx = Y;Ty = -X;
case 3
Tx = -Z;Ty = X;
case 4
Tx = -X;Ty = Z;
case 5
Tx = X;Ty = -Y;
otherwise
Tx = -Y;Ty = -Z;
end
if(Tx+Ty>Tpwm)
Tx = Tx/(Tx+Ty);
Ty = Ty/(Tx+Ty);
else
Tx = Tx;
Ty = Ty;
end
ta = (Tpwm-Tx-Ty)/4.0;
tb = ta+Tx/2;
tc = tb+Ty/2;
switch(sector)
case 1
Tpwm1 = tb;
Tpwm2 = ta;
Tpwm3 = tc;
case 2
Tpwm1 = ta;
Tpwm2 = tc;
Tpwm3 = tb;
case 3
Tpwm1 = ta;
Tpwm2 = tb;
Tpwm3 = tc;
case 4
Tpwm1 = tc;
Tpwm2 = tb;
Tpwm3 = ta;
case 5
Tpwm1 = tc;
Tpwm2 = ta;
Tpwm3 = tb;
case 6
Tpwm1 = tb;
Tpwm2 = tc;
Tpwm3 = ta;
end
end
执行的效果如下:标准的马鞍波