PMSM电机无传感器FOC矢量控制_图文._第1页
PMSM电机无传感器FOC矢量控制_图文._第2页
PMSM电机无传感器FOC矢量控制_图文._第3页
PMSM电机无传感器FOC矢量控制_图文._第4页
PMSM电机无传感器FOC矢量控制_图文._第5页
已阅读5页,还剩40页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、说明:下面程序取自IFX 16位机无传感器PMSM电机矢量控制程序。程序架构 是C语言嵌套汇编。其中坐标系变换是汇编编写。有插图说明,便于更好的理解。其中包括坐标系变换,磁链角估算,PI速度环电流环调节。(单片机XC2236N,Tasking 编译器Cavin整理坐标系变换说明:双电阻采样得到两相电流(ia, ib,由abc120°静止坐标系Clarke 变换到直角坐标系(i a,由® ,静止直角坐标系Park变换到直角旋转坐标系(iq, id。直流id不变,通过PI速度环电流环得到期望直流iq,进行限幅控制。由旋转坐标 系(vq, vd经过Park逆变换到静止坐标系(v

2、a , v然后再经过矢量调制成PWM控制 电机。无传感器角度估算:由Clarke变换得到(i a,和由Park逆变换得到的(v a , v经, 过低通滤波器PT1,再由直角坐标系变极坐标系得到磁链估算角无传感器开环启动 策略:在定子中加入幅值及频率都受控的电流,若PLL收敛,切换到FOC闭环控制。*/* Clarke变换应用于定子电流: y:、jjf :X '-arV -1-1:-t7 、J|:/k“ ,"11I I .1. ! L'F t-IBIJKIBIm % M LI L «jf XJ f jB * si 一 + 2L,c X/ -Z X J./.:.

3、 . /. 'd*w Clarke变换应用于定子电流:i迪ig心 -L、二4j/:rf*'; x -/ F /、/J-1: - f1f .k/ ; / - / b 二 GiZb; / fIl ;,Va.«J!a.u.;;./a.»aB . i > ! / / E / /-、;z、一”.、=# LhL0 一斤 ”*- - "- *" 、!-»-#: .Clarke Transform*/* / Function in t clarke_tra ns(i nt Phase_s, i nt Phase_t, i nt *ia;/

4、 Descripti on ia=is/ ib = 1/sqrt(3*( (2 * it + is/ Returnvalue (ib * 16 , "(ia * 16"/ Parameters/ Date09.01.2005/ Con diti on optimizati on off / one/* inline int clarke_tra ns(i nt Phase_s, int Phase_t, int *iaint retvalue;_asm("mov r12,MCW n""mov MCW,#0200h ; set saturatio

5、 n n""shl %2,#1 ; ( 2*Phase_t n""add %2,%1 ; + Phase_s n""mov r13,#37837 n""CoMULsu %2,r13 ;* 1/sqrt(3 n""CoSHL #4 ; default 2 * 4 n""CoSTORE %0,MAS ; ib = result n""shl %1,#2 n""mov %3,%1 ; ia = Phase_s * 4 n""

6、;mov MCW,r12 n":"=&w"(retvalue /* output registers */:"w"(Phase_s,"w"(Phase_t,"w"(ia /* in put registers */:"r13","r12"/*scratch registers */return retvalue; Pak变换应用于定子电流:i0Jp:、 - - - - i :*:; hTv Jr x:了 、一 K*7:亠:r.X-【71八KX : .'

7、;-/ :G =cosg_韦 sing:!* + P日k变换应用于定子电流门“臥r'%.-':、:/- ZL . . JL 4_ ., - . ., . _ _- . jT. .<=. L./Q =/acos6r-sin./. =.Ti1'_.G = sin 0r + cos*/* / Function int park_tra ns(i nt e_a,i nt e_b,i nt phi,i nt *a_b/ Descripti onpark tran sformati on/ Returnvalueld_comp , Iq_comp/ Parameters/ D

8、ate/09.01.2005/ Con diti on optimizati on off / onein li ne int park_tra ns(i nt i_a,i nt i_b,i nt phi,i nt *o_qint retvalue;_asm( "n""mov r13,MCW n""mov MCW,#0600h n""shr %3,#6 n""shl %3,#1 n""EXTS #SEG (_si ncostab,#2 n""mov r11,%3 +

9、 #SOF(_si ncostab+512 n""mov r12,%3 + #SOF(_si ncostab 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""mov MCW,r13 n""n":"=&w"(retvalue

10、 /* output registers */:"w"(i_a,"w"(i_b,"w"(phi,"w"(o_q /* in put registers */:"r13","r12","r11"/*scratch registers */Jreturn retvalue;/*反Pmrk变换应用于定子电压:vqs/ :.Efiiiiijiiaaiiii ii I i i f i - s 5 i i i bi "/,-l _"-反Pmrk变换

11、应用于定子电压:vqs/vds: :8 Fx : :; 、 *"-I V J 4 1! 4 1 R 1 RBI*« B B B B1 R! F' Z A?:= q 二8£3+%winq*/* / Function int in v_park_tra ns(i nt e_a,i nt e_b,i nt phi,i nt *a_b/ Descripti onin verse park tran sformati on/ Returnvaluel_alpha , I_beta/ Parameters/Illi Date09.01.2005II Con diti

12、on optimizati on off I oneII* inline int in v_park_tra ns(i nt i_d,i nt i_q,i nt phi,i nt *o_bint retvalue;_asm( "n""mov r13,MCW n""mov MCW,#0600h n""shr %3,#6 n""shl %3,#1 n""EXTS #SEG (_si ncostab,#2 n""mov r12,%3 + #SOF(_sincostab+5

13、12 n""mov r11,%3 + #SOF(_sincostab n""CoMUL %1,r12 n""CoMAC- %2,r11 n""CoASHR #2 n""CoSTORE %0,MAS n""CoMUL %1,r11 n""CoMAC %2,r12 n""CoASHR #2 n""CoSTORE %4,MAS n""mov MCW,r13 n""n":&q

14、uot;=&w"(retvalue /* output registers */:"w"(i_d,"w"(i_q,"w"(phi,"w"(o_b /* in put registers */ : "r13","r12","r11"/*scratchregisters */return retvalue;Now, the voltage space vector i (小)is transformed into a polar repres

15、entation (<p,|V|). The transformation is calculated in the CORDIC:CORDIC configurationCircular vectoring mode K 七 1.64676_- rAfinalMPSIM 一 Xnalflnal = 0Zfigi _ #十訂【汕| y)° 厶wl6Y -z - 0Now. the voltage space vector / 厂屮 怎)is transformed into a polar representation (<p,|V|). The transformati

16、on is calculated in the CORDIC:CORDIC configurationCircular vectoring mode K 直 1.64676finalMPSIM =几鼻仏=ofinal = Z十帀怡剳屮=final%r = y1 %Z = 0rl /I n o 一 nH* j"klL*i-1A14 ja hit hnl nji L*> 1 Ab "1* / Function int cart_polar_c on v(i nt x,i nt y, i nt *an gle;/ Descripti on/Illi ReturnvalueI

17、IIIII ParametersIIIIII Date09.01.2005II Con diti on optimizati on off I oneII* un sig ned int cart_polar_c on v(i nt x,i nt y, i nt *an gleun sig ned int retvalue;_asm( "n""mov MCW,#0200h ; en able saturatio n to +I-0x7fff n""mov r13,%1 ; r13 = x n""jmpr cc_nn ,kpw

18、1co ; if (x >= 0 goto kpwlco n""neg r13 ; else r13 = -r13 n""kpwlco: ; r13 = |x| n"mov r12,%2 ; r12 = y n""jmpr cc_nn ,kpw2co ; if (y >= 0 goto kpw2co n""neg r12 ; r12 = -r12 n""kpw2co: ; r12 = |y| n""mov r9,#1024 n""cm

19、p r13,r12 n""jmpr cc_c,kpw3co ; if( x < y goto kpw3co n""mulu r12,r9 ; MD = y * 1024 n""divlu r13 ; MDL = MD / x n""mov r9,MDL ; r9 = MDL = (y/x * 1024 n""shl r9,#1 ; prepare for word address n""EXTS #SEG (_betab,#1 n""mov r10,

20、r9+#SOF(_betab ; r10 = sqrt( 1 + (r9A2 n" " CoMULu r13,r10 ;CoACC = x * sqrt( 1 + (y/xA2 n" " CoSHL #1 ; un sig ned -> sig ned n""CoSTORE %0,MAS ; %0 = CoACC n" "n""EXTS #SEG (_phitab,#1 n""mov r10,r9+#SOF(_phitab ; r10 = arcta n( y/x n&

21、quot; " cmp %1,#0 ; n""jmpr cc_n,kpw4co ; if ( x < 0 goto kpw4co n" " cmp %2,#0 n""jmpr cc_n ,kpw5co ; if ( y < 0 goto kpw5co n" " mov %3,r10 ; an gle = arcta n( y/x n" " jmpr cc_uc, en dco n""n""kpw5co: ; x > 0 and

22、y < 0 n""neg r10 n""mov %3,r10 ; an gle = -arcta n( y/x n""jmpr cc_uc, en dco n""n""kpw4co: ; x < 0 n""cmp %2,#0 ; n""jmpr cc_n,kpw6co ; if ( y < 0 goto kpw6co n" " mov r9,#8000h n""sub r9,r10 n"&

23、quot;mov %3,r9 ; angle = 180? - arctan( y/x n" " jmpr cc_uc, endco n""n""kpw6co: ; x < 0 and y < 0 n""add r10,#8000h n""mov %3,r10 ; angle = -180? + arcta n( y/x n" " jmpr cc_uc, endco n""n""kpw3co: ; |x| < |y|

24、n""mulu r13,r9 ; MD = |x| * 1024 n""divlu r12 ; MDL = MD / |y| n""mov r9,MDL ; r9 = MDL = (y/x * 1024 n""shl r9,#1 ; prepare for word address n""n""EXTS #SEG (_betab,#1 n""mov r10,r9+#SOF(_betab ; r10 = sqrt( 1 + (r9A2 n"&quo

25、t;CoMULu r12,r10 ; CoACC = x * sqrt( 1 + 两2 n""CoSHL #1 ; unsigned -> signed n""CoSTORE %0,MAS ; %0 = CoACC n""n""EXTS #SEG (_phitab,#1 n""mov r10,r9+#SOF(_phitab ; r10 = arctan( y/x n""cmp %1,#0 n""jmpr cc_n ,kpw7co ; if ( x &

26、lt; 0 goto kpw7co n""cmp %2,#0 n""jmpr cc_n ,kpw8co ; if ( y < 0 goto kpw8co n""mov r9,#4000h n""sub r9,r10 n""mov %3,r9 ; angle = 90? - arctan( x/y = 90? - arccot( y/x = arctan( y/x n"jmpr cc_uc, en dco n""n""kpw8co: ; x

27、> 0 and y < 0 n""add r10,#0C000h n""mov %3,r10 ; angle = -90? + arctan( x/y = -(90? - arccot( y/x = -arctan( y/x n""jmpr cc_uc, en dco n""n""kpw7co: n""cmp %2,#0 ; x < 0 n""jmpr cc_n ,kpw9co ; if ( y < 0 goto kpw9co n&

28、quot;"add r10,#4000h n""mov %3,r10 ; angle = 90? + arctan( x/y = 180? - (90? - arccot( y/x = 180?-arcta n( y/x n" "jmpr cc_uc, en dco n""n""kpw9co: ; x < 0 and y < 0 n""mov r9,#0C000h n""sub r9,r10 ; angle = -90? - arctan( x/y =

29、-180? + (90? - arccot( y/x = -180? +arcta n( y/x n""mov %3,r9 n""n""en dco: n":"=&w"(retvalue /* output registers */:"w"(x,"w"(y,"w"(a ngle /* in put registers */:"r13","r12","r11","r10&

30、quot;,"r9"/*scratch registers */return retvalue;PT1The differential equation ol a PT 1 is defined as folkiws:T - v(l) + y(l) = Kr (39:drWhen Equation 39) is divided by T. the term * 、(门 can be neglected for large values of 11(40:The remaining equation can be integrated:yd)Input Valuestored

31、valueThe sampling time is st. The time constant for the filter is T.The PT1 controller is calculated by the MDU, The implementation provides two gaii factors G王 selected by global flag fO. F0 = 0: Z(k) = Ztk) / 256 r Gz = 256* FO = 1: Z闖=Z(k t Gz= 1zi):stwdXk: Input Valuevalue of 片歸The sampling time

32、 is At. The time constant for the filter is TThe PT1 controller is calculated by the MDU, The implementation provides two gair factors Gz selected by global flag FO. FO = 0: Z(h) = Zk) / 256 ( Gz = 256* = 1: Z(k = Zk), Gz = 1The integration of the induced voltage during the calculation of the flux 屮

33、 is calculates by a low pass filter of first order which is realized by a PT1 con troller. See following figure for dAtails*/* / Fun ctio n: a low pass filter 2012-9-13 17:58:43/ C calling format:/ int inline int pt1_controller32( int *pt1_parameter, int X/ Description/ PT1-Co ntroller/ derived from

34、 tran sfer fun cti on/ / Y_(k = Y_(k-1 + Z1_(k * X_(k - Z2_(k * Y_(k-1/ Computi ng time/42 CPU-cycle/ Returnvalue/ i nt "3" Output of pt1_co ntroller/ Parameters/ Con diti onoptimizatio n off / one*inline in t pt1_con troller32( PT1_array *pt1_parameter, i nt X /inline int pt1_c on troller

35、32( int *pt1_parameter, i nt Xint retvalue;_asm( "n""mov r10,MCW ;Save MCW register n"mov MCW,#0400h ;Set shift left n""mov %0,%1+ n""CoLOAD %0,%1 ;Load Y(k-1 in accumulator n""mov r13,%1 ;Save parameters addres in %1 n""add r13,#2 n"&

36、quot;mov r12,r13+ ;Load Z1 in R5 n""mov r11,r13+ ;Load Z2 in R6 n""CoMAC r12,%2 ;CoACC = Y(k-1 + Z1 * X n""CoMAC- r11,%1 ;CoACC = Y(k-1 + Z1 * X - Z2 * Y(k-1 n""n""n""mov r11,r13+ ;Load ynmax (limit value max n""mov r12,r13+ ;Load

37、 yn min (limit value min n""mov %0,ZEROS ;Load zero in %0 n""CoMIN %0,r11 ;Limit max yn n""CoMAX %0,r12 ;Limit min yn n""CoSTORE %0,MAS ;Store Y(k-high in R4 n""CoSTORE r13,MAL ;Store Y(k-low in R3 n""mov %1,%0 ;Store in Y buffer(High n&quo

38、t;mov -%1,r13 ;Store in Y buffer(Low n""n" "mov MCW,r10 ;Restore MCW register n""n":"=&w"(retvalue /* output registers */:"w"(pt1_parameter,"w"(X /* in put registers */:"r13","r12","r11","r10"

39、;/*scratch registers */Jreturn retvalue;/*/ Fu nction void ADC0_vStartSeq0ReqChNum(ubyte ubExtTrg, ubyte/ ubE nlntr, ubyte ubRFill, ubyte ubCha nn elNum/ Descripti on This fun ctio n starts the con versi on of the requested/ cha nn el./ NOTE - / Before passing ubEnlntr argument as 1,make sure that S

40、eq 0/ source in terrupt is en abled./ External Trigger -> 0,1 ndicates software trigger/ (Conv ersi on starts once this fun ctio n is executed/ Returnvalue No ne/ Parameters ubExtTrg:/ External Trigger : defines external trigger./ Parameters ubE nlntr:/ En able Source In terrupt : defi nes source

41、 in terrupt/ Parameters ubRFill:/ Refill : defi nes the refill/ Parameters ubCha nn elNum:/ Channel nu mber : Name of the Request Channel Number (0 -/ 15- see macros defined in the header file/ Date 14.05.2010 /*void ADC0_vStartSeq0ReqChNum(ubyte ubExtTrg, ubyte ubE nlntr, ubyte ubRFill, ubyte ubCha

42、 nn elNum uword uwVal = 0;if (ubExtTrg = 1uwVal = 0x0080;if (ubE nlntr = 1uwVal = uwVal + 0x0040;if (ubRFill = 1uwVal = uwVal + 0x0020;uwVal = uwVal + (ubCha nn elNum & OxOOIf;ADC0_QINR0 = uwVal; / requested cha nnel / End of fun ctio n ADC0_vStartSeq0ReqChNum* / Fun ction void ADC0_viSRN0(void/

43、 Descripti onThis is the in terrupt service rout ine for the Service/ Request Node 0 of the ADC0 module./ ReturnvalueNone/ ParametersNone/ Date14.05.2010/* / USER CODE BEGIN (ADC0_viSRN0,0/ USER CODE END _in terrupt(ADCO_SRNOINT void ADC0_viSRN0(voidif(ADCO_EVINFR & 0x0100 = 0x0100 /ResultO even

44、t in terruptADC0_EVINCR = 0x0100; / Clear Result。eve nt in terrupt/ USER CODE BEGIN (ADC0_viSRN0,20if( CCU60_TCTR0 & 0x0040 / check cou nt direction of T12.ADC0_CHCTR8 |= 0x1000; / 1: T12 cou nts dow n -> assig n ADC-CH8 toRESREG1 elseADC0_CHCTR8 &= 0xefff; / 0: T12 cou nts up -> assig

45、 n ADC-CH8 to RESREG0 if( !(svm0.Sector & 0x0001CCU60_T13PR = svm0.T2Store/2 + svm0.ADCDELAY; / set T13 Period value elseCCU60_T13PR = svm0.T1Store/2 + svm0.ADCDELAY; / set T13 Period valueCCU60_vE nableShadowTra nsfer(CCU60_TIMER_13; / en able shadow tran sfer/ USER CODE END / End of fun ctio n

46、 ADC0_viSRN02.2.1 Reference VectorThe reference vector I : represents the resulting magnetic stator field (flux). It is defined by the following equation:(11)It is rotating in space with the speed 他:(o = f(12)The reference vector can be approximated by two active vectors (e g V1 and V2| and one zero

47、 vector (VO) The plane is dissected into six sectors and the angle 9 is transformed into the relative angle2.2.1 Reference VectorThe referenee vectorrepresents the resulting magnetlc stator field (flux). It is defined by the following equationIt is rotating in space with the speed ®:co = 2k f(1

48、2The referenee vector can be approximated by two active vectors (eg V1 and V2) and one zero vector (VO). The plane Is dissected into six sectors and the angle <p is transformed into the relative angle 创.11i1_j1IMn u(1 °】)0 0"T?2TJ2TJ2gTJ2 74Figure 10 PWM Pattern of a Seven Segment Switc

49、hing SequenceThe output voltage of each leg to neutral is shown in Figure 11A B | C D | E | F411I1_1Ip qliojn ii(1 02 Oj"T72TJ2TJ2T/2TJ2 TgFigure 10 PWM Pattern of a Seven Segment Switching SequenceThe output voltage of each leg to neutral is shown in Figure 112.3PriQso Current MoasuFflmntF

50、1;jf nu 号 n<jtL< QjiiI dl 更叩屯、11輕 plkig lui ivihb d 兰rqu ieJ 曲 ilpulA ll>H创 irKdud iequ>tHmV Q°c sbuM 聖:tw g屮 TE pba-K cuments can be re<oiifSlTvdi&d fwi 廿岳 l>UM curtenl ig血r忙露 one PWM period (TThe Ihinj piu« current q«i be cakuWed by t 4 *® bus irs redundan

51、t fcw tte ccnifo-J&Or* F¥U1 JILJ1F1a ibcdefFkgijirt 12 FIum CunnBnc li»iKu«m»nE Vilthm mt PWM Pantrn叽 £rd商 知 resize the mcfod tnc ALL tnggcr pavtsi rust tc ndsusted Dccontagi io the PWM poDcthl Iwd dMe<enl currents un be meA&ufed)«! PWM lune It and T2 Dependi

52、ng on 1he jfluAJ wclcr tiecurreints have a diterem fTWdnrxj The fcukwinq 3曲 srews these fontwiaOM耳 vhI :ifw clcuriKm for ph3H djinrent 冬 And F.StcurBc0EFruVVWWuwpAuVVu<卜则' V44J)J4J*"#) wu耳一占(W uVV(U) *(¥)4 V)* / Fun ction void ADC0_viSRN1(void/ DescriptionThis is the interrupt servi

53、ce routine for the Service/ Request Node 1 of the ADC0 module./ ReturnvalueNone/ Parameters None/ Date 14.05.2010/*/ USER CODE BEGIN (ADC0_viSRN1,0/ USER CODE END_in terrupt(ADC0_SRN1INT void ADC0_viSRN1(voidif(ADC0_EVINFR & 0x0200 = 0x0200 Result1 eve nt in terruptADC0_EVINCR = 0x0200; / Clear

54、Result1 eve nt in terrupt/ USER CODE BEGIN (ADC0_viSRN1,21ADC0_CHCTR8 &= 0xefff; / assig n ADC-CH8 to RESREG0 if( !(svm0.Sector &0x0001CCU60_T13PR = svm0.T1Store/2 + svm0.ADCDELAY; / set T13 Period value elseCCU60_T13PR = svmO.T2Store/2 + svmO.ADCDELAY; / set T13 Period value CCU60_vE nableS

55、hadowTra nsfer(CCU60_TIMER_13; / en able shadow tran sfer/ calculate Ialpha and Ibeta from single shunt measurementswitch( svm0.SectorStorecase 0:svm0.lphaseA = (ADC0_RESR0 & 0x0fff - svm0.ADCOFFSET;svm0.lphaseB = (ADC0_RESR1 & 0x0fff - (ADC0_RESR0 & 0x0fff;break;case 1:svm0.lphaseA = (ADC0_RES

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论