1、三相交流电动机 SVPWM 开环调速控制程序.equ _30F6010, 1.include “C:Program FilesMicrochipMPLAB ASM30 SuiteSupportincp30f6010.inc“.global _reset.global _PWMInterrupt.global _DefaultInterruptconfig _FOSC, CSW_FSCM_OFF mov #3,w1 mov #theta_90,w2ww:tblrdl w0+,w2+ dec w1,w1 btss w1,#15 goto ww mov #29335,w0mov w0,theta_i
2、 mov #31291,w0mov w0,theta_s main_loop:mov f_omega ,w0 mov set_f,w4 mul.uu w4,w0,w2 mov w3,omega mov max_v,w0mul.uu w4,w0,w2 mov w3,set_v bra main_loop _PWMInterrupt: push.d W0 push.d W2push.d W4push.d W6 mov omega,w0 mov t_sample,w4 mul.uu w4,w0,w2 lac w2,A sftac a,#16 push ACCAL lac w3,A clr ACCAU
3、 pop ACCAL sftac a,#1 mov theta_h,w0 add w0,amov theta_l,w1 lac w1,bsftac b,#16 clr ACCBHclr ACCBU add a sac a,w0mov w0,theta_h push ACCAH push ACCALsftac a,#-16clr ACCAUsac a,w0mov w0,theta_l pop ACCALpop ACCAHbtss ACCAH,#15 goto chk_uplim mov theta_360,w0 add w0,asac a,w0mov w0,theta_h bra rnd_the
4、tachk_uplim:mov theta_360,w0 lac w0,bsub abtsc ACCAH,#15 goto rest_thetasac a,w0 mov w0,theta_hgoto rnd_thetarest_theta:add a rnd_theta:mov #1,w0lac w0,bsftac b,#1add asac a,w0 mov w0,theta_r mov #1,w0mov w0,ss mov w0,sc mov theta_r,w0mov w0,theta_m mov theta_90,w2sub w2,w0,w6 btss w6,#15 goto e_qmo
5、v #-1,w2mov w2,sc mov theta_180,w2mov theta_r,w0sub w2,w0,w6mov w6,theta_m btss w6,#15goto e_q mov #-1,w2mov w2,ss mov theta_r,w2mov theta_180,w0sub w2,w0,w6mov w6,theta_m mov theta_270,w2mov theta_r,w0sub w2,w0,w6btss w6,#15goto e_q mov #1,w2mov w2,sc mov theta_360,w2mov theta_r,w0sub w2,w0,w6mov w
6、6,theta_m e_q:mov theta_m,w0 mov theta_i,w4 mul.UU W4,W0,W2lac w2,Asftac a,#16push ACCALlac w3,Aclr ACCAUpop ACCALsftac a,#5 sac a,w0mov w0,sin_indx mov #tblpage(sin_entry),W0 mov W0,TBLPAGmov #tbloffset(sin_entry),W0mov sin_indx,w1sl W1,#1,W1 add w0,w1,w2tblrdl W2,w5 mov w5,sin_theta mov #180,w4add
7、 w0,w4,w2sub w2,w1,w6tblrdl W6,w5 mov w5,cos_theta mov ss,w4mov sin_theta,w5mpy W4*W5, Asftac a,#-16sac a ,#0,w0mov w0, sin_theta mov sc,w4mov cos_theta,w5mpy W4*W5, Asftac a,#-16sac a ,#0,w0mov w0,cos_theta mov set_v,w4 mov cos_theta,w5mpy W4*W5, A sac a ,w0mov w0,ua mov sin_theta,w5mpy W4*W5, A sa
8、c a ,w0mov w0,ubmov theta_r,w0 mov theta_s,w4 mul.UU W4,W0,W2lac w2,Asftac a,#16push ACCALlac w3,A clr ACCAUpop ACCALsftac a,#11 sac a,w0mov w0,sectormov #tblpage(dec_ms),W0mov W0,TBLPAGmov #tbloffset(dec_ms),W0 mov sector,w1sl W1,#3,W1add w0,w1,w2tblrdl W2,w5 mov ua,w4mpy W4*W5, Aadd w2,#2,w2tblrdl
9、 W2,w5 mov ub,w4mpy W4*W5, B add a;0.5*C1,Q26btsc ACCAH,#15clr a cmp1big0:sac a,w0 mov w0,temp mov t1_period,w4 mul.UU W4,W0,W6lac w6,Asftac a,#16push ACCALlac w7,Aclr ACCAUpop ACCALsftac a,#-1sac.r a,w0mov w0,cmp_1 add w2,#2,w2tblrdl W2,w5 mov ua,w4mpy W4*W5, A add w2,#2,w2tblrdl W2,w5mov ub,w4mpy
10、W4*W5, B add a btsc ACCAH,#15 clr a cmp2big0:sac a,w0 mov w0,temp mov t1_period,w4mul.UU W4,W0,W2 lac w2,Asftac a,#16push ACCALlac w3,Aclr ACCAUpop ACCALsftac a,#-1sac.r a,w0mov w0,cmp_2 mov #183,w2 mov cmp_1,w0sub w2,w0,w6mov cmp_2,w1sub w6,w1,w2btsc ACCAH,#15 clr w2 cmp0big0:asr w2,#1,w0 mov w0,cm
11、p_0 mov #tblpage(first),W0mov W0,TBLPAGmov #tbloffset(first),W0 mov sector,w1sl w1,#1,w1add w0,w1,w2 tblrdl W2,w5 mov w5,first_togmov #183,w3mov cmp_0,w4sub w3,w4,w6sl w6,#1,w6mov w6,w5 mov #tblpage(second),W0 mov W0,TBLPAGmov #tbloffset(second),W0mov sector,w1sl w1,#1,w1add w0,w1,w2 tblrdl W2,w5 mo
12、v w5,sec_togmov cmp_0,w0mov cmp_1,w2add w0,w2,w3mov #183,w0sub w0,w3,w0sl w0,#1,w0mov w0,w5 mov #PDC3,w2 mov first_tog,w4 mov #PDC1,w5mov #PDC2,w1mov sec_tog,w3 sub w2,w4,w6add w6,w1,w7sub w7,w3,w8add w8,w5,w9mov w9,w10mov w10,tempmov cmp_0,w0mov cmp_1,w1add w0,w1,w3mov cmp_2,w2add w3,w2,w4mov #183,
13、w0sub w0,w4,w0sl W0,#1,W0mov w0,w10pop.d W6pop.d W4pop.d W2pop.d W0 bclr IFS2,#7 bset PTCON,#PTENretfie_DefaultInterrupt:bclr TRISA,#9 bset PORTA,#9 nopnopnopretfie_wreg_init:clr W0 mov W0, W14repeat #12mov W0, +W14clr W14return .section .sin_entry, code.section .angles, code.section .first, code.se
14、ction .dec_ms, code.section .second, code.palign 2sin_entry: .hword 0 .hword 286,572,857,1143,1428.hword 1713,1997,2280,2563,2845.hword 3126,3406,3686,3964,4240.hword 4516,4790,5063,5334,5604.hword 5872,6138,6402,6664,6924.hword 7182,7438,7692,7943,8192.hword 8438,8682,8932,9162,9397.hword 9630,9860
15、,10087,10311,10531.hword 10749,10963,11174,11381,11585.hword 11786,11982,12176,12365,12551.hword 12733,12911,13085,13255,13421.hword 13583,13741,13894,14044,14189.hword 14330,14466,14598,14726,14849.hword 14968,15082,15191,15296,15396.hword 15491,15582,15668,15749,15826.hword 15897,15964,16026,16083
16、,16135.hword 16182,16225,16262,16294,16322.hword 16344,16362,16374,16382,16384 angles_: .hword 0x1922 .hword 0x3244 .hword 0x4b66 .hword 0x6488 dec_ms: .hword 20066 .hword -11585 .hword 0.hword 23170.hword -20066.hword 11585.hword 20066.hword 11585.hword 0.hword 23170.hword -20066.hword -11585.hword 0.hword -23170.hword -20066.hword 11585.hword -20066.hword -11585.hword 20066.hword -11585.hword 20066.hword 11585.hword 0.hword -23170first: .hword PDC1 .hword PDC2 .hword PDC2.hword PDC3.hword PDC3.hword PDC1second: .hword PDC2 .hword PDC1 .hword PDC3.hword PDC2.hword PDC1.hword PDC3.end