PMSM电机无传感器FOC矢量控制图文文档格式.docx
《PMSM电机无传感器FOC矢量控制图文文档格式.docx》由会员分享,可在线阅读,更多相关《PMSM电机无传感器FOC矢量控制图文文档格式.docx(25页珍藏版)》请在冰豆网上搜索。
//@Returnvalue(ib*16,"
(ia*16"
//----------------------------------------------------------------------------//@Parameters
//----------------------------------------------------------------------------//@Date09.01.2005
//Conditionoptimizationoff/one
//****************************************************************************inlineintclarke_trans(intPhase_s,intPhase_t,int*ia
{
intretvalue;
__asm(
"
movr12,MCW\n"
movMCW,#0200h;
setsaturation\n"
shl%2,#1;
(2*Phase_t\n"
add%2,%1;
+Phase_s\n"
movr13,#37837\n"
CoMULsu%2,r13;
*1/sqrt(3\n"
CoSHL#4;
default2*4\n"
CoSTORE%0,MAS;
ib=result\n"
shl%1,#2\n"
mov[%3],%1;
ia=Phase_s*4\n"
movMCW,r12\n"
:
"
=&
w"
(retvalue/*outputregisters*/
(Phase_s,"
(Phase_t,"
(ia/*inputregisters*/
r13"
"
r12"
/*scratchregisters*/
;
returnretvalue;
}
//****************************************************************************//@Functionintpark_trans(inte_a,inte_b,intphi,int*a_b
//----------------------------------------------------------------------------//@Descriptionparktransformation
//----------------------------------------------------------------------------//@ReturnvalueId_comp,Iq_comp
inlineintpark_trans(inti_a,inti_b,intphi,int*o_q
__asm("
\n"
movr13,MCW\n"
movMCW,#0600h\n"
shr%3,#6\n"
shl%3,#1\n"
EXTS#SEG(_sincostab,#2\n"
movr11,[%3+#SOF(_sincostab+512]\n"
movr12,[%3+#SOF(_sincostab]\n"
CoMUL%2,r12\n"
CoMAC%1,r11\n"
CoSTORE%0,MAS\n"
CoMUL%2,r11\n"
CoMAC-%1,r12\n"
CoSTORE[%4],MAS\n"
movMCW,r13\n"
(i_a,"
(i_b,"
(phi,"
(o_q/*inputregisters*/
r11"
/****************************************************************************
****************************************************************************///****************************************************************************//@Functionintinv_park_trans(inte_a,inte_b,intphi,int*a_b
//----------------------------------------------------------------------------//@Descriptioninverseparktransformation
//----------------------------------------------------------------------------//@ReturnvalueI_alpha,I_beta
//****************************************************************************inlineintinv_park_trans(inti_d,inti_q,intphi,int*o_b
movr12,[%3+#SOF(_sincostab+512]\n"
movr11,[%3+#SOF(_sincostab]\n"
CoMUL%1,r12\n"
CoMAC-%2,r11\n"
CoASHR#2\n"
CoMUL%1,r11\n"
CoMAC%2,r12\n"
(i_d,"
(i_q,"
(o_b/*inputregisters*/:
//****************************************************************************//@Functionintcart_polar_conv(intx,inty,int*angle;
//----------------------------------------------------------------------------//@Description
//----------------------------------------------------------------------------//@Returnvalue
//****************************************************************************unsignedintcart_polar_conv(intx,inty,int*angle
unsignedintretvalue;
enablesaturationto+/-0x7fff\n"
movr13,%1;
r13=x\n"
jmprcc_nn,kpw1co;
if(x>
=0gotokpw1co\n"
negr13;
elser13=-r13\n"
kpw1co:
;
r13=|x|\n"
movr12,%2;
r12=y\n"
jmprcc_nn,kpw2co;
if(y>
=0gotokpw2co\n"
negr12;
r12=-r12\n"
kpw2co:
r12=|y|\n"
movr9,#1024\n"
cmpr13,r12\n"
jmprcc_c,kpw3co;
if(x<
ygotokpw3co\n"
mulur12,r9;
MD=y*1024\n"
divlur13;
MDL=MD/x\n"
movr9,MDL;
r9=MDL=(y/x*1024\n"
shlr9,#1;
prepareforwordaddress\n"
EXTS#SEG(_betab,#1\n"
movr10,[r9+#SOF(_betab];
r10=sqrt(1+(r9^2\n"
CoMULur13,r10;
CoACC=x*sqrt(1+(y/x^2\n"
CoSHL#1;
unsigned->
signed\n"
%0=CoACC\n"
EXTS#SEG(_phitab,#1\n"
movr10,[r9+#SOF(_phitab];
r10=arctan(y/x\n"
cmp%1,#0;
\n"
jmprcc_n,kpw4co;
if(x<
0gotokpw4co\n"
cmp%2,#0\n"
jmprcc_n,kpw5co;
if(y<
0gotokpw5co\n"
mov[%3],r10;
angle=arctan(y/x\n"
jmprcc_uc,endco\n"
kpw5co:
x>
0andy<
0\n"
negr10\n"
angle=-arctan(y/x\n"
kpw4co:
x<
cmp%2,#0;
jmprcc_n,kpw6co;
0gotokpw6co\n"
movr9,#8000h\n"
subr9,r10\n"
mov[%3],r9;
angle=180�-arctan(y/x\n"
kpw6co:
addr10,#8000h\n"
angle=-180�+arctan(y/x\n"
kpw3co:
|x|<
|y|\n"
mulur13,r9;
MD=|x|*1024\n"
divlur12;
MDL=MD/|y|\n"
CoMULur12,r10;
cmp%1,#0\n"
jmprcc_n,kpw7co;
0gotokpw7co\n"
jmprcc_n,kpw8co;
0gotokpw8co\n"
movr9,#4000h\n"
angle=90�-arctan(x/y=90�-arccot(y/x=arctan(y/x\n"
kpw8co:
addr10,#0C000h\n"
angle=-90�+arctan(x/y=-(90�-arccot(y/x=-arctan(y/x\n"
kpw7co:
jmprcc_n,kpw9co;
0gotokpw9co\n"
addr10,#4000h\n"
angle=90�+arctan(x/y=180�-(90�-arccot(y/x=180�-arctan(y/x\n"
kpw9co:
movr9,#0C000h\n"
subr9,r10;
angle=-90�-arctan(x/y=-180�+(90�-arccot(y/x=-180�+arctan(y/x\n"
mov[%3],r9\n"
endco:
(x,"
(y,"
(angle/*inputregisters*/
r10"
r9"
//****************************************************************************//@Function:
alowpassfilter2012-9-1317:
58:
43
//Ccallingformat:
//intinlineintpt1_controller32(int*pt1_parameter,intX
//PT1-Controller
//derivedfromtransferfunction
//Y_(k=Y_(k-1+Z1_(k*X_(k-Z2_(k*Y_(k-1
//----------------------------------------------------------------------------//Computingtime42CPU-cycle
//int"
@3"
Outputofpt1_controller
//----------------------------------------------------------------------------//Conditionoptimizationoff/one
//****************************************************************************
inlineintpt1_controller32(PT1_array*pt1_parameter,intX
//inlineintpt1_controller32(int*pt1_parameter,intX
movr10,MCW;
SaveMCWregister\n"
movMCW,#0400h;
Setshiftleft\n"
mov%0,[%1+]\n"
CoLOAD%0,[%1];
LoadY(k-1inaccumulator\n"
Saveparametersaddresin%1\n"
addr13,#2\n"