图4.6 磁链计算与位置检测模块
磁链计算与位置检测模块如上图所示。该模块由磁链计算和磁链位置检测两部分组成。
在PSIM仿真环境中,并没有直接可用的滞环比较器,因而利用C Block,通过C语言编程来实现滞环比较的功能。
磁链比较器的程序段如下:
g_nStepCount++;
// In case of error, uncomment next two lines. Set *pnError to 1 and copy Error message to szErrorMsg
//*pnError=1;
//strcpy(szErrorMsg, "Place Error description here.");
dellta_fi=in[0];
if(dellta_fi>0.15)
fi_k=1;
else if(dellta_fi<=-0.15)
fi_k=-1;
else fi_k=fi_k; //只在输入达到极值时才改变,其余时间保留前一刻的值
out[0]=fi_k;
4.3.5 转矩计算模块
图4.7 转矩计算模块
转矩计算模块如上图所示,功能是将平均转矩与给定值比较,并输入转矩滞环得到每个步长中的转矩控制值。
转矩比较器的程序段如下:
g_nStepCount++;
// In case of error, uncomment next two lines. Set *pnError to 1 and copy Error message to szErrorMsg0
//*pnError=1;
//strcpy(szErrorMsg, "Place Error description here.");
Er=in[0];
if (Er<=-10)
Cr1=-1;
else if (Er>=0)
Cr1=0;
else Cr1=Cr1;
if(Er<=0)
Cr2=0;
else if (Er>=10)
Cr2=1;
else Cr2=Cr2; //求出位于x轴以上的滞环输出
out[0]=Cr1+Cr2; //将两个小滞环的输出和作为整个三段滞环比较器的输出值
4.3.6 P/N给定转矩极性鉴别器模块