⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nofeedback.asm

📁 无feedevb的异步电机vf控制的dsp调试程序
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;;      SPACE VECTOR PULSE WIDTH MODULATION   

   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   ;            Sector calculation
   ; reference voltage for sector
   ; Vref1=usbeta
   ; Vref2=(-usbeta+sqrt(3)*usalfa)/2 
   ; Vref3=(-usbeta-sqrt(3)*usalfa)/2 
        ;lacc #0800h
        ;sacl ualpfa
        ;lacc #0000h
        ;sacl ubeta
SVPWM:       
       lt    ualpfa    ;Q12
        mpy   #sqrt32   ;sqrt32= 0ddbh sqrt(3)/2, 4.12
        pac             ;sqrt(3)*usalfa/2
        sub   ubeta,11 ;-vsbeta/2,so left-shift 11 
        sach  Vref2,4   ;Q12
        pac
        neg             ;-sqrt(3)*usalfa/2
        sub   ubeta,11 ;-vsbeta/2,so left-shift 11
        sach  Vref3,4   ;Q12
        lacl  ubeta
        sacl  Vref1     ;Vref1=usbeta,Q12
   ; End reference voltage for sector calculation        
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   ; Time quality X,Y,Z Calculation
   ; VDCinvT=PWMPRD/Vdc
   ; X=sqrt(3)*VDCinvT*usbeta  
   ; Y=(sqrt(3)*VDCinvT*usbeta + 3*VDCinvT*usalfa)/2
   ; Z=(sqrt(3)*VDCinvT*usbeta - 3*VDCinvT*usalfa)/2
            lt    vdcinvt
            mpy   #sqrt32
            pac
            sach  tmp,4  ;tmp=sqrt(3)*VDCinvT/2,Q12
            lt    tmp
            mpy   ubeta
            pac
            sach  X,4    ;X=sqrt(3)*VDCinvT*usbeta/2,Q0
            lacc  X
            sacl  tmp1   ;tmp1=sqrt(3)*VDCinvT*usbeta/2,Q0
            sacl  X,1    ;X=sqrt(3)*VDCinvT*usbeta,Q0
            
            
            lt    vdcinvt
            splk  #1800h,tmp ;3/2=1800h(Q12)
            mpy   tmp        ;3*VDCinvT/2
            pac
            sach  tmp,4      ;tmp=3*VDCinvT/2 , Q12
            lt    tmp
            mpy   ualpfa     ;3*VDCinvT/2*usalfa , Q12
            pac
            sach  tmp,4   ;tmp=3/2*VDCinvT*usalfa, Q12
            lacc  tmp
            add   tmp1    ;tmp1=sqrt(3)*VDCinvT/2,Q12                     
            sacl  Y 
           
             ;Y=3/2*VDCinvT*usalfa+sqrt(3)*VDCinvT*usbeta/2,Q12
            sub   tmp,1   ;acc-tmp*2
            sacl  Z 
                        
             ;Z=3/2*VDCinvT*usalfa-sqrt(3)*VDCinvT*usbeta/2,Q12 
   ;  End X,Y,Z calculation      
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;          
   ;;  60 degrees sector determinnation
            lacl  #0
            sacl  sector
            lacc  Vref1
            bcnd  Vref1_neg,LEQ 
             ;if Vref1<=0,do not set bit1 of sector
            lacc  sector
            or    #1
            sacl  sector         
Vref1_neg:  
            lacc  Vref2
            bcnd  Vref2_neg,LEQ 
             ;if Vref2<=0,do not set bit1 of sector
            lacc  sector
            or    #2
            sacl  sector                                    
Vref2_neg:  
            lacc  Vref3
            bcnd  Vref3_neg,LEQ 
             ;if Vref3<=0,do not set bit1 of sector
            lacc  sector
            or    #4
            sacl  sector                                    
Vref3_neg:              
   ;;  End 60 degrees sector determinnation             
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;          
   ;;  t1 and t2 calculation depending on the sector number
         ;sector=1   t1=Z t2=Y
            lacl  sector
            sub   #1          
            bcnd  no2,NEQ
            lacc  Z
            sacl  t1          
            lacc  Y
            sacl  t2
            b     t1t2out
no2:    ;sector=2   t1=Y t2=-X
            lacl  sector
            sub   #2          
            bcnd  no3,NEQ
            lacc  Y           
            sacl  t1
            lacc  X
            neg
            sacl  t2
            b     t1t2out
no3:    ;sector=3   t1=-Z t2=X            
            lacl  sector
            sub   #3
            bcnd  no4,NEQ
            lacc  Z
            neg
            sacl  t1
            lacc  X
            sacl  t2
            b     t1t2out
no4:    ;sector=4   t1=-X t2=Z          
            lacl  sector
            sub   #4
            bcnd  no5,NEQ
            lacc  X
            neg
            sacl  t1
            lacc  Z
            sacl  t2
            b     t1t2out
no5:    ;sector=5   t1=X t2=-Y
            lacl  sector
            sub   #5
            bcnd  no6,NEQ
            lacc  X
            sacl  t1
            lacc  Y
            neg
            sacl  t2
            b     t1t2out
no6:    ;sector=2   t1=-Y t2=-Z
            lacc  Y
            neg
            sacl  t1
            lacc  Z
            neg
            sacl  t2  
            
           clrc  c
		   lacc  taontemp
		   sub #0cc8h
		   bgez t1t2out
	       lar ar1,tbon
	       lar ar2,taontemp  
	       mar *,ar2
	       sar ar1,*+
	       sar ar2,taontemp  
	       
	       
	       lacc t1
	       sacl t1tmp    
t1t2out:
   ;; End t1 and t2 calculation
   ;; if t1+t2>PWMPRD, we have to saturate t1 and t2
   ;; t1=PWMPRD*t1/(t1+t2)
   ;; t2=PWMPRD*t2/(t1+t2)         
            lacc  t1
            add   t2
            sacl  tmp      ;tmp=t1+t2
            sub   #pwmprd
            bcnd  nosaturation,LT,EQ 
         ;; t1 and t2 saturation
            lacc  #pwmprd,15
            rpt   #15
            subc  tmp    ;divide PWMPRD by t1+t2
            sacl  tmp    ;tmp=PWMPRD/(t1+t2)
            lt    tmp  
            mpy   t1            
            pac   
            sach  t1,1   ;t1=PWMPRD*t1/(t1+t2)
            mpy   t2            
            pac   
            sach  t2,1   ;t2=PWMPRD*t2/(t1+t2)
         ;; End t1 and t2 saturation   
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
         
nosaturation:
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   ;; each phase working time taon,tbon,tcon calculation                     
   ;; calculating the PWM commutation instants of 3 channels
   ;;   taon=(PWMPRD-t1-t2)/2
   ;;   tbon=taon+t1
   ;;   tcon=tbon+t2        
            lacc  #pwmprd
            sub   t1       
            sub   t2
            sfr          ;right shift 1 bit       
            sacl  taon   ;taon=(PWMPRD-t1-t2)/2
            add   t1     ;tbon=taon+t1    
            sacl  tbon       
            add   t2     ;tcon=tbon+t2 
            sacl  tcon
   ;; End taon,tbon,tcon calculation               
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;                
                   
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   ;;   Sector  switching
   ;;   Depending on the sector of number we have to switch
   ;;   the calculated taon,tbon,tcon to the correct channel
         
;sect1 ;sector 1
            lacl  sector
            sub   #1
            bcnd  sect2,NEQ

             bldd  tbon,#CMPR4        
             bldd  taon,#CMPR5          
             bldd  tcon,#CMPR6
            b     endPWM
sect2:  ;sector 2             
            lacl  sector
            sub   #2
            bcnd  sect3,NEQ
            bldd  taon,#CMPR4        
            bldd  tcon,#CMPR5          
            bldd  tbon,#CMPR6
            b     endPWM
sect3:  ;sector 3             
            lacl  sector
            sub   #3
            bcnd  sect4,NEQ
            bldd  taon,#CMPR4        
            bldd  tbon,#CMPR5          
            bldd  tcon,#CMPR6
            b     endPWM
sect4:  ;sector 4
            lacl  sector
            sub   #4
            bcnd  sect5,NEQ
            bldd  tcon,#CMPR4        
            bldd  tbon,#CMPR5          
            bldd  taon,#CMPR6
            b     endPWM
sect5:  ;sector 5             
            lacl  sector
            sub   #5
            bcnd  sect6,NEQ
            bldd  tcon,#CMPR4        
            bldd  taon,#CMPR5          
            bldd  tbon,#CMPR6
            b     endPWM
sect6:  ;sector 6             
            bldd  tbon,#CMPR4        
            bldd  tcon,#CMPR5          
            bldd  taon,#CMPR6   
	       
;	       clrc  c
;		   lacc  taontemp
;		   sub #0dc8h
;		   bgez endPWM
;	       lar ar1,tbon 
;	       lar ar2,taontemp  
;	       mar *,ar2
;	       sar ar1,*+
;	       sar ar2,taontemp          
            
   ;;   END Sector  switching 
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;                

***     END SPACE VECTOR PWM
*************************************************************     

endPWM:     
		

	 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
*************************************************************  
***    clear all flags, which maybe change with only T1 
***    underflow int
            ldp   #DP_EVB
            splk  #200h,EVBIFRA      
  
            ldp   #0
            lacc  #0ffh
            sacl  IFR  ;reset IFR, write into 1 to clear                                             
              

***     Context restore and return
***      SEE following context saving
;            larp  ar4    ;ar4=74h
            mar *,ar4
            mar   *+     ;ar4=75h
            lacl  *+     ;Acc low restored from 75h
            add   *+,16  ;Acc high restored from 76h
            lst   #0,*+  ;ST0 restored from 77h           
            lst   #1,*+  ;ST1 restored from 78h
            clrc INTM
		RET
		
GISR1:
		LDP	#GPTCONB>>7h
         	SPLK	#0000h,COMCONB
    	        SPLK	#0000h,ACTRB
    	        KICK_DOG
    	        B	GISR1
                ret		
		
GISR3:
		RET
		
GISR4:
		RET
		
GISR5:
		RET
		
GISR6:
		RET
		
PHANTOM:
		RET
		
		.end																		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -