# SVPWM生成流程

U r e f = m U d c 3 U_{ref} = \frac{mU_{dc}}{\sqrt{3}}

U a ( θ ) = { 3 2 U r e f cos ⁡ ( θ − π 6 ) , 0 ≤ θ < π 3 , π ≤ θ < 4 π 3 3 2 U r e f cos ⁡ ( θ ) , π 3 ≤ θ < 2 π 3 , 4 π 3 ≤ θ < 5 π 3 3 2 U r e f cos ⁡ ( θ + π 6 ) , 2 π 3 ≤ θ < π , 5 π 3 ≤ θ < 2 π U_{a}(\theta)=\begin{cases}\dfrac{\sqrt{3}}{2}U_{ref}\cos(\theta-\dfrac{\pi}{6}),& 0\leq\theta<\dfrac{\pi}{3},\pi\leq\theta<\dfrac{4\pi}{3} \cr\cr \dfrac{3}{2}U_{ref}\cos\left(\theta\right),& \dfrac{\pi}{3}\leq\theta<\dfrac{2\pi}{3},\dfrac{4\pi}{3}\leq\theta<\dfrac{5\pi}{3} \cr\cr \dfrac{\sqrt{3}}{2}U_{ref}\cos(\theta+\dfrac{\pi}{6}), &\dfrac{2\pi}{3}\leq\theta<\pi,\dfrac{5\pi}{3}\leq\theta<2\pi\end{cases}
U a b ( θ ) = U a ( θ ) − U b ( θ ) = 3 U r e f sin ⁡ ( θ + π 3 ) U_{ab}(\theta)=U_{a}(\theta)-U_{b}(\theta)=\sqrt{3}U_{ref}\sin\left(\theta+\dfrac{\pi}{3}\right)

# 判断扇区

I U α > 0 U_\alpha>0 , U β > 0 U_\beta>0 U β U α < 3 \dfrac{U_{\beta}}{U_\alpha}<\sqrt{3}
II U β > 0 U_\beta>0 U β ∣ U α ∣ > 3 \dfrac{U_{\beta}}{\vert U_\alpha\vert}>\sqrt{3}
III U α < 0 U_\alpha<0 , U β > 0 U_\beta>0 − U β U α < 3 \dfrac{-U_{\beta}}{U_\alpha}<\sqrt{3}
IV U α < 0 U_\alpha<0 , U β < 0 U_\beta<0 U β U α < 3 \dfrac{U_{\beta}}{U_\alpha}<\sqrt{3}
V U β < 0 U_\beta<0 − U β ∣ U α ∣ > 3 \dfrac{-U_{\beta}}{\vert U_\alpha\vert}>\sqrt{3}
VI U α > 0 U_\alpha>0 , U β < 0 U_\beta<0 − U β U α < 3 \dfrac{-U_{\beta}}{U_\alpha}<\sqrt{3}

U 1>0, A=1 , 否则 A=0;
U 2>0, B=1 , 否则 B=0;
U 3>0, C=1 , 否则 C=0;

N123456

C语言实现：

#define Sqrt3 1.732050808f
void JudgeArea(svpwm_variables * svpwm_v)
{
//看不清楚可以删掉所有代码段中的'svpwm_v->'
char A,B,C,T;
A = (svpwm_v->Ub)>0? 1:0;
B = (Sqrt3*svpwm_v->Ua - svpwm_v->Ub)>0? 1:0;
C = (-Sqrt3*svpwm_v->Ua - svpwm_v->Ub)>0? 1:0;
T = A + 2*B +4*C;

switch (T)
{
case 1: svpwm_v->N=2;break;
case 2: svpwm_v->N=6;break;
case 3: svpwm_v->N=1;break;
case 4: svpwm_v->N=4;break;
case 5: svpwm_v->N=3;break;
case 6: svpwm_v->N=5;break;
default: svpwm_v->N=1;break;
}
}


# 计算占空比

## 计算每个扇区中基本矢量的持续时间

{ X = 3 U β Y = 3 U α + 3 U β 2 Z = − 3 U α + 3 U β 2 \begin{cases}X=\sqrt{3}U_{\beta}\cr Y=\dfrac{3U_{\alpha}+\sqrt{3}U_{\beta}}{2}\cr Z=\dfrac{-3U_{\alpha}+\sqrt{3}U_{\beta}}{2}\end{cases}

TX-ZYXZ-Y-X
TYXZ-Y-X-ZY

C语言实现：

//已经定义过Sqrt3了
void CacuTime(svpwm_variables * svpwm_v)
{
float x,y,z;
float Dx,Dy,Dz;//Tz是零矢量持续时间比

//你看我x y z的表达式里边已经把开关周期除了，实际上这是持续时间占开关周期的比例
x = Sqrt3*svpwm_v->Ub;
y = (3*svpwm_v->Ua +Sqrt3*svpwm_v->Ub)/2;
z = (-3*svpwm_v->Ua +Sqrt3*svpwm_v->Ub)/2;

switch(svpwm_v->N)
{
case 1: Dx = -z;Dy = x;break;
case 2: Dx = y;Dy = z;break;
case 3: Dx = x;Dy = -y;break;
case 4: Dx = z;Dy = -x;break;
case 5: Dx = -y;Dy = -z;break;
case 6: Dx = -x;Dy = y;break;
default:Dx = -z;Dy = x;break;
}
Dz = 1-(Dx+Dy);
}


## 计算三路占空比

DutyBDy+Dz/2Dx+Dy+Dz/2Dx+Dy+Dz/2Dx+Dz/2Dz/2Dz/2
DutyCDz/2Dz/2Dy+Dz/2Dx+Dy+Dz/2Dx+Dy+Dz/2Dx+Dz/2

C语言实现：

void CacuPWMDuty(svpwm_variables * svpwm_v)
{
//Dx Dy Dz 已经由上一个函数计算得出
switch(svpwm_v->N)
{
case 1:
svpwm_v->DutyA = Dx+Dy+Dz/2;
svpwm_v->DutyB = Dy+Dz/2;
svpwm_v->DutyC = Dz/2;
break;
case 2:
svpwm_v->DutyA = Dx+Dz/2;
svpwm_v->DutyB = Dx+Dy+Dz/2;
svpwm_v->DutyC = Dz/2;
break;
case 3:
svpwm_v->DutyA = Dz/2;
svpwm_v->DutyB = Dx+Dy+Dz/2;
svpwm_v->DutyC = Dy+Dz/2;
break;
case 4:
svpwm_v->DutyA = Dz/2;
svpwm_v->DutyB = Dx+Dz/2;
svpwm_v->DutyC = Dx+Dy+Dz/2;
break;
case 5:
svpwm_v->DutyA = Dy+Dz/2;
svpwm_v->DutyB = Dz/2;
svpwm_v->DutyC = Dx +Dy +Dz/2;
break;
case 6:
svpwm_v->DutyA = Dx+Dy+Dz/2;
svpwm_v->DutyB = Dz/2;
svpwm_v->DutyC = Dx+Dz/2;
break;
default:svpwm_v->DutyA = Dx+Dy+Dz/2;svpwm_v->DutyB = Dy+Dz/2;svpwm_v->DutyC=Dz/2;break;
}
}



12-10 1403
03-21 1136
06-18
11-22 1264
05-27 2764
10-19 1万+
06-28 3万+
07-09 5万+
01-23 1748