PMSM电机无传感器FOC矢量控制_图文._第1页
PMSM电机无传感器FOC矢量控制_图文._第2页
免费预览已结束,剩余43页可下载查看

下载本文档

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

文档简介

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

2、静止坐标系(va, v 然后再经过矢量调制成 PWM 控制 电机。无传感器角度估算:由 Clarke 变换得到(ia,和由 Park 逆变换得到的(va, v 经, 过低通滤波器 PT1,再由直角坐标系变极坐标系得到磁链估算角无传感器开环启动 策略:在定子中加入幅值及频率都受控的电流,若 PLL 收敛,切换到 FOC 闭环控制。*w Clarke变换应用于定子电流:i迪ig心 -L、二4j/:rf*; x -/F/、/J-1: - f1f .k/ ; / - / b 二 GiZb; / fIL;,.Va.J!a.u.;;./a.aB. i ! / / E / /-、;z0 一斤 ”*- - -

3、 * 、!-#: .-Clarke Transform*/* / Function in t clarke_tra ns(i nt Phase_s, i nt Phase_t, i nt *ia;/*/* Clarke变换应用于定子电流:y:、jjf :X -arV -1-1:-t7 、J|:/k“ ,11I I .1. ! LF t-IBIJKIBIm % M LI L jf XJ fjB*si一+ 2L,cX/ -Z X J./.:. . /. d/-/ Descripti on ia=is/ ib = 1/sqrt(3*( (2 * it + is/-/ Returnvalue (ib

4、* 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 nmov MCW,#0200h ; set saturatio n nshl %2,#1 ; ( 2*Phase_t nadd %2,%1 ; + Phase_s nmov r13,#37837 nCoMULsu %2,r13 ;* 1/sqrt(

5、3 nCoSHL #4 ; default 2 * 4 nCoSTORE %0,MAS ; ib = result nshl %1,#2 nmov %3,%1 ; ia = Phase_s * 4 nmov 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 :.*:;hTvJr x:了 、一K*7

6、:亠:r.X-【71八G =cosg_韦 sing-:-!- -!- -* + P日k变换应用于定子电流门“臥r%.-:、:/- ZL . . JL4_ ., - . ., . _ _-.- . jT. .=. L./Q =/acos6r-sin./. .=.Ti1_.G =sin0r+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/-0

7、9.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( nmov r13,MCW nmov MCW,#0600h nshr %3,#6 nshl %3,#1 nEXTS #SEG (_si ncostab,#2 nmov r11,%3 + #SOF(_si ncostab+512 nmov r12,%3 + #SOF(_si ncostab nCoMUL %2,r12 nCoMAC %1,r11 nC

8、oSTORE %0,MAS nCoMUL %2,r11 n/ Date*CoMAC- %1,r12 nCoSTORE %4,MAS nmov MCW,r13 nn:=&w(retvalue /* 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 iF i - s 5 i i ibi /,-l _-反Pmrk变换

9、应用于定子电压:vqs/vds:- - :-8-Fx: :;、*-I V J 4 1! 4 1 R 1 RBI* B B B B1R!F Z A?:=q二83+%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/li Date/Il09.01.2005II Con diti on optimizati on of

10、f 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( nmov r13,MCW nmov MCW,#0600h nshr %3,#6 nshl %3,#1 nEXTS #SEG (_si ncostab,#2 nmov r12,%3 + #SOF(_sincostab+512 nmov r11,%3 + #SOF(_sincostab nCoMUL %1,r12 nCoMAC- %2,r11 nCoASHR #2 nCoSTORE %0,MAS nCoMUL %

11、1,r11 nCoMAC %2,r12 nCoASHR #2 nCoSTORE %4,MAS nmov MCW,r13 nn:=&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 representation (p,|V|). Thetransformat

12、ion 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 ( 1AB1* / Function int cart_polar_c on v(i nt x,i nt y, i nt *an gle;/ Descripti

13、on/IIII-II ParametersIIII-II 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( nmov MCW,#0200h ; en able saturatio n to +I-0 x7fff nmov r13,%1 ; r13 = x njmpr cc_nn ,kpw1co ; if (x = 0 goto kpwlco nneg r1

14、3 ; else r13 = -r13 nkpwlco: ; r13 = |x| nmov r12,%2 ; r12 = y n/Illi Returnvaluejmpr cc_nn ,kpw2co ; if (y = 0 goto kpw2co nneg r12 ; r12 = -r12 nkpw2co: ; r12 = |y| nmov r9,#1024 ncmp r13,r12 njmpr cc_c,kpw3co ; if( x sig ned nCoSTORE %0,MAS ; %0 = CoACC n nEXTS #SEG (_phitab,#1 nmov r10,r9+#SOF(_

15、phitab ; r10 = arcta n( y/x n cmp %1,#0 ; njmpr cc_n,kpw4co ; if ( x 0 goto kpw4co n cmp %2,#0 njmpr cc_n ,kpw5co ; if ( y 0 and y 0 nneg r10 nmov %3,r10 ; an gle = -arcta n( y/x njmpr cc_uc, en dco nnkpw4co: ; x 0 ncmp %2,#0 ; njmpr cc_n,kpw6co ; if ( y 0 goto kpw6co n mov r9,#8000h nsub r9,r10 nmo

16、v %3,r9 ; angle = 180? - arctan( y/x n jmpr cc_uc, endco nnkpw6co: ; x 0 and y 0 nadd r10,#8000h nmov %3,r10 ; angle = -180? + arcta n( y/x n jmpr cc_uc, endco nnkpw3co: ; |x| signed nCoSTORE %0,MAS ; %0 = CoACC nnEXTS #SEG (_phitab,#1 nmov r10,r9+#SOF(_phitab ; r10 = arctan( y/x ncmp %1,#0 njmpr cc

17、_n ,kpw7co ; if ( x 0 goto kpw7co ncmp %2,#0 njmpr cc_n ,kpw8co ; if ( y 0 and y 0 nadd r10,#0C000h nmov %3,r10 ; angle = -90? + arctan( x/y = -(90? - arccot( y/x = -arctan( y/x njmpr cc_uc, en dco nnkpw7co: ncmp %2,#0 ; x 0 njmpr cc_n ,kpw9co ; if ( y 0 goto kpw9co nadd r10,#4000h nmov %3,r10 ; ang

18、le = 90? + arctan( x/y = 180? - (90? - arccot( y/x = 180?-arcta n( y/x n jmpr cc_uc, en dco nnkpw9co: ; x 0 and y 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./ Parameter

19、s ubE nlntr:/ En able Source In terrupt : defi nes source 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(ub

20、yte ubExtTrg, ubyte ubE nlntr, ubyte ubRFill, ubyteubCha nn elNum uword uwVal = 0;if (ubExtTrg = 1uwVal = 0 x0080;if (ubE nlntr = 1uwVal = uwVal + 0 x0040;if (ubRFill = 1uwVal = uwVal + 0 x0020;uwVal = uwVal + (ubCha nn elNum & OxOOIf;ADC0_QINR0 = uwVal; / requested cha nnel / End of fun ctio n

21、ADC0_vStartSeq0ReqChNum* / Fun ction void ADC0_viSRN0(void/-/ 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

22、 ADC0_viSRN0(voidif(ADCO_EVINFR & 0 x0100 = 0 x0100 /ResultO event in terruptADC0_EVINCR = 0 x0100; / Clear Result。eve nt in terrupt/ USER CODE BEGIN (ADC0_viSRN0,20if( CCU60_TCTR0 & 0 x0040 / check cou nt direction of T12.ADC0_CHCTR8 |= 0 x1000; / 1: T12 cou nts dow n - assig n ADC-CH8 toRE

23、SREG1 elseADC0_CHCTR8 &= 0 xefff; / 0: T12 cou nts up - assig n ADC-CH8 to RESREG0if( !(svm0.Sector & 0 x0001CCU60_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_

24、13; / en able shadow tran sfer/ USER CODE END / End of fun ctio n ADC0_viSRN02.2.1Reference VectorThe reference vector I:represents the resulting magneticstator 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 a

25、pproximated by two active vectors (e g V1 and V2| and one zero vector (VO) The plane isdissected into six sectors and the angle 9 is transformed into the relative angle2.2.1Reference VectorThe referenee vectorrepresents the resulting magnetlc stator field (flux). It is defined by the following equat

26、ionIt is rotating in space with the speed :co =2K f(12The referenee vector can be approximated by two active vectors (eg V1 and V2) and one zero vector (VO). The plane Isdissected into six sectors and the angle p is transformed into the relative angle创.11i1_-j1IMn u(1】)0 0T?2TJ2TJ2gTJ274Figure 10 PW

27、M Pattern of a Seven Segment Switching SequenceThe output voltage of each leg to neutral is shown in Figure 11A B | C D | E | F4-1- -1I1_1Ip qliojn ii(1 02 OjT72TJ2TJ2T/2TJ2 TgFigure 10 PWM Pattern of a Seven Segment Switching SequenceThe output voltage of each leg to neutral is shown in Figure 112.

28、3PriQso Current MoasuFflmntFjf nu号号njtLH创irKdud iequtHmV Qc sbuM聖:twg 屮TE pba-K cuments can be reUMcurtenl ig血r忙露one PWM period (TTheIhinj piu currentQIbe cakuWed by t 4 * bus irs redundant fcw tte ccnifo-* FU1 JILJ1F1a ibcdefFkgijirt 12 FIUMCunnBnc liiKumnE Vilthm mt PWM Pantrn叽 rd商知知resize the mcf

29、od tnc ALL tnggcr pavtsi rust tc ndsusted Dccontagi io the PWMPODCTHLIWDdMeenl currentsun be meA&ufed)! PWM lune It and T2 Depending on 1he jfluAJ wclcr tiecurreints have a diterem fTWdnrxj The fcukwinq3 曲srews these fontwiaOM耳VHI:ifw clcuriKm for ph3H djinrent冬AndF.StcurBc0EFruVVWWuwpAuVVu如dfJ%

30、 :心dT _叫氐Z=Lj,+:Oj$ il r I AS/Aa/- 1= p(LJ. i+ 訂;一LJa/ .)q.j /J j rfjmqr1jr e used later in this application noteVoltage Equation:2.4.2Sensorless FOCThe costs for an encoder or other position sensor can be saved, when the exact position of the rotor is not required. The motors back EMFis utilized in

31、 order to calculate the rotation angle and rotor position. The back EMF is calculated in the flux estimator, which is based on thevoltage model of the system in the two phase reference frame. A single shunt is eno ugh to reconstruct the phase curre nts. Xml(5:Figure1G2.4.2Sensorless FOCThe costs for

32、 an encoder or other position sensor can be saved, when the exact position of the rotor is not required. The motorsback EMF is utilized in order to calculate the rotaton angle and rotor position The back EMF is calculated in the flux estimator,which is based on the voltage model of the system in the

33、 two phase reference frame. A single shunt is enough to reconstruct thephase currentsFigure 16 Block Diagram of Sensorless Field Oriented ControlFigure 16 shows the block diagram of the sensoriess FOC algorithmThe flux estimator s input signals are taken from theorthogonal two phase stator system wi

34、th the index u and |3. The output signal repcesents the rotor angle. The motor signals mthe two phase stator system (u-fsystem) are equivalent to the three phase system. As a result. an ideal two phase motor can beassumed in the a-p-system Then there are only two equations toThe flux of the stator (

35、Equation (25), Equation (26) contain the mutual inductance Lisand the flux oftheroto with thepermanent magnet屮.The stator voltage equations (Equation (27). Equation (28) contains the resistance of the coil Risand thninverse vector rotafton4peed cakuhtiorIIli Descripti onThis is the interrupt service

36、 routine for the CCU60 node 10. If the content of the corresponding compare timerII (con figurable equals the content of the capturelcompareII register or if a capture eve nt occurs at the associatedII port pin, the in terrupt request flag is set and an/in terrupt is triggered (only if en abled.II P

37、lease note that you have to add application specific codeII to this function.IIII- II ReturnvalueNoneIIII- II ParametersNoneIIII- II Date14.05.2010Il* /USERCODE BEGIN (Nodel0,1/ USER CODE END_in terrupt(CCU60_Nodel0_INT void CCU60_viNodel0(void/ USER CODE BEGIN (NodeI0,2/ USER CODE ENDif(CCU60_IS &a

38、mp; 0 x0040 / if CCU60_IS_T12OM/ Timer T12 one match detect ion/ USER CODE BEGIN (NodeI0,20CCU60_vE nableShadowTra nsfer(CCU60_TIMER_12;/ USER CODE ENDCCU60_ISR |= 0 x0040; / clear flag CCU60_IS_T12OMif(CCU60_IS & 0 x0080 / if CCU60_IS_T12PM/ Timer T12 period match detect ion/ USER CODE BEGIN (N

39、odeI0,19CCU60_TCTR2 = t13_triggersvmO.Sector;svmO.SectorStore = svmO.Sector;svmO.TIStore = svmO.TI;svm0.T2Store = svmO.T2;focO.A ngleStore = focO.A ngle;/ Flux Estimator*DSP_MAC(foc0.1 alpha, foc0.STATOR_R, focO.Valpha;DSP_MAC(foc0.lbeta, focO.STATOR_R, focO.Vbeta; focO.FluxAmplitude = cart_polar_co

40、nv( focO.Fluxalpha, focO.Fluxbeta,& focO.FluxA ngle;*if( statusO.c on trol = 0 focO.Vd = 0;if( focO.AngleSpeed 0focO.Vq = vf_co ntrol(focO.Vf_offset, focO.Vf_slew, focO.A ngleSpeed;elsefocO.Vq = vf_con trol(-focO.Vf_offset, focO.Vf_slew, focO.A ngleSpeed;elsecon trolO.Refere ncelq = pi_c on trol

41、ler32(&con trolO.Speed, con trolO.Refere nceSpeed, controlO.ActualSpeed;focO.Vd = pi_co ntroller32(&con trolO.Id, con trolO.Refere nceld, focO.Id;focO.Vq = pi_con troller32(&controlO.lq, con trolO.Refere ncelq, focOq;focO.Valpha = in v_park_tra ns( focO.Vd, focO.Vq, focO .An gle, & f

42、ocO.Vbeta ;/ Modulatorsvm( & svmO ;/ USER CODE ENDCCU60_ISR |= 0 x0080; / clear flag CCU60_IS_T12PM / End of fun ctio n CCU60_viNodel02.2Space Vector ModulationIn this section, tne modulation of a three leg voltage source inverter is describee rhis type of inverter conta ns si MOSFETs oriGBTs wf

43、iich act switches. Th switches connected to the po&ilive supply rail are called high创 來switches (h$) and theswitches connected to the negative rail of the power supply are called low side swilches Is In the fol lowing figure, a blockdiagram of a three leg voltage source Inverter can be seen:By s

44、Mtching the high side and如side ssvrtches on and off, there are eight states pc詳吧 Q,hich do notCMJSAcross cunentsinskie the leg itself, but allow a cunent flowing to and back from the irialor.2+2 Space Vector ModulationIn this section, the modulation of a three leg voltage source inverter Is describe

45、d This type of inverter contains si MOSFETsor IGBTs which act曲switches. The bitches connected to the positive supply rail are called high side Switches hy) and the$v/itche$ connected to the negative rail of th石pow审supply called low$ide switches (!$ In the following figure, a blockdiagram of a three

46、leg voltage source Inverter can be seen:Figure1Space Vector Diagrarn of a U-V-W SystemThe magnetic field (flux of a three pha&e PMSM can be represented iri a U-V-W space vector diagram. IrFigure 7.the flux issimplified by a magnetic Whereas the stator coils are fixed in their position, the flu?

47、rotates dependent on the sector of thehexagon I 一一 厶- - *. 1 一 _-一一 一 ”一 _|iLM - _ . . il- . _ _ J A i Jf -=3._JL* / Prototypes Of Local Fu nctions* unsigned int V_TA, V_TB;void svm( tSVM *svmun sig ned char gamma;un sig ned int tmp, T1_2;tmp = (un sig ned in tsvm-A ngle 4 * 6;gamma = (un sig ned char (tmp4;svm-Sector = tmp 12;svm-T1 = DSP_mi nMU

温馨提示

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

评论

0/150

提交评论