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

📄 nofeedback.asm

📁 无feedevb的异步电机vf控制的dsp调试程序
💻 ASM
📖 第 1 页 / 共 2 页
字号:
*** This program is used to control the induction motor at 5Hz***
		.include	"f2407.h"
		.include	"vector.h"
		
KICK_DOG	.macro
		LDP	#00E0h
		SPLK	#05555h,WDKEY
		SPLK	#0AAAAh,WDKEY
		LDP	#0h
		.endm
		
		.sect ".table" 
sintab      .include   sin200.tab ; sine wave for 3-phase voltage input  

		 .data
*** axis transformation constants
sqrt3inv .set 093dh 		;1/sqrt(3) 4.12 format
sqrt32 	 .set 0ddbh 		;sqrt(3)/2 4.12 format 

*** pwm modulation constants
	
pwmprd 	.set 1500	;pwm period=2*1500 -> tc=2*1500*33ns=100us (33ns resolution)


*** vqr and vdr limitations
vbase 	.set 01000h 		;bemf at base speed=87V
vdc     .set  0cdfh             ;Vdc_ref=70V,pu=0.8046,Q12=0cdfh
		.bss tmp,1 	;temporary variable 
		.bss tmp1,1
		.bss tmptmp,1
		.bss tmpA,1
		.bss indexA,1
        .bss indexB,1 ;sine wave ub table
        .bss indextemp,1 
		.bss ua,1 	; uao=44*sqrt(2)*cos(theta)
		.bss ub,1 	; ubo=44*sqrt(2)*cos(theta-120)
		.bss uc,1 	; uao=44*sqrt(2)*cos(theta-240)
		.bss ualpfa,1 	;alfa-axis voltage
		.bss ubeta,1 	;beta-axis voltage
		.bss um,1     ;the max of the phase voltage
		.bss theta,1 	;rotor electrical position in the range [0;10000]
		.bss sinthetaA,1 		;generated sine wave value
		.bss sinthetaB,1 		;generated cosine wave value
		.bss vdcinvt,1 	;used in svpwm,vdcinvt=T/(2*vdc/87)
		.bss sector,1 	;svpwm sector
		.bss X,1 		;svpwm variable
		.bss Y,1 		;svpwm variable
		.bss Z,1 		;svpwm variable
		.bss t1,1 		;svpwm t1 (see sv pwm references for details)
		.bss t2,1 		;svpwm t2 (see sv pwm references for details)
		.bss taon,1 	;pwm commutation instant phase 1
		.bss tbon,1 	;pwm commutation instant phase 2
		.bss tcon,1 	;pwm commutation instant phase 3
        .bss Vref1,1  ;variable for sector calculation
        .bss Vref2,1  ;variable for sector calculation
        .bss Vref3,1  ;variable for sector calculation
        .bss taontemp,1		
        .bss count,1      
        .bss uaaddress,1
        .bss ubaddress,1  
        .bss t1tmp,1
        
*** end variables and constants initializations

		
		
		.text
START:
	    LDP	#T3PR>>7h	
        SPLK	#0004h,T3PR		;temporary init only
       	SPLK    #1001011001000000b,T3CON	;f=cpu/8
		LDP	#0h
		setc    INTM    
		LACC	IFR
		SACL	IFR		
		clrc    CNF 	
		setc    OVM 
		spm     0 	
		setc    SXM  
		SPLK	#0000h,IMR

		LDP	#WDKEY>>7h
		
		SPLK	#0208h,SCSR1 
		SPLK	#000eh,SCSR2
		
		SPLK	#006Fh,WDCR
		
		KICK_DOG
		 
		 
		MAR	*,AR0
		LDP	#0E1h     
		lar ar4,#79h
        lar ar5,#60h  
        lar ar0,#08000h
		lar ar1,#08800h
		lar ar6,#800h
		lar ar7,#0c00h
		
	 
****************************************************************
* I/O port initialization
****************************************************************
        LDP #DP_PF2
        LACL MCRA 
        OR #0000h 
        SACL MCRA 
        LACL MCRC
        OR #00ffh
        SACL MCRC
        LACL MCRB
        OR #0000h
        SACL MCRB  
        
        ldp #tmp
		zac
		sacl indexA
		sacl indextemp
		sacl tmp
		sacl tmptmp
		sacl Vref1
		sacl Vref2
		sacl Vref3 
		splk #1,count
		splk #0c00h,taontemp
		splk #748h,vdcinvt   ;4.12,if VDCpu=0.8046,vdcinvt=PWMPRD/VDC=1864=748h
		splk #1000h,um         ;peak43.5V
		splk #134,indexB 
		splk #8000h,uaaddress
		splk #9000h,ubaddress
		LDP	#GPTCONB>>7h
		splk    #0666h,ACTRB
		splk    #0ffebh,DBTCONB
		SPLK	#pwmprd,T3PR     
		splk    #300,CMPR4 	;no current sent to the motor
		splk    #300,CMPR5
		splk    #300,CMPR6
		splk    #0307h,COMCONB 
		splk    #8307h,COMCONB 
		SPLK	#0000000000000000b,GPTCONB
		SPLK	#0000000000000000b,T3CNT
		SPLK	#0000h,T3CMPR
		SPLK	#0000001000000001b,EVBIMRA
		SPLK	#0000001000000001b,EVBIFRA
		SPLK	#0000100001000000b,T3CON
		
		LDP	#0
		SPLK	#0000000000000011b,IMR
		CLRC	INTM
		
WAIT:
		NOP
		NOP
		B	WAIT
		
GISR2:
		NOP
		setc INTM
		mar *,ar4 		;ar4 active auxiliary reg (stack pointer)
					;ar4 initial value #79h
		mar *-
		sst #1,*- 		;save status register 1
		sst #0,*- 		;save status register 0
		sach *- 		;save ms word of accu
		sacl *- 		;save ls word of accu
*************************************
* end context saving                *
*************************************
            ldp #tmp
            lacc count
            sub #1
            sacl count
            bgz  uacal
            lacc #1
            sacl count  
               
	 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;    Following program is to test SVPWM agrithm.        ;
    ;;    The desired input three-phase sine-voltages        ;
    ;;    is get by lookup table.                            ;
    ;;      Ua=Umax*sin(teta)                                ;
    ;;      Ub=Umax*sin(teta-120)                            ;
    ;;      Uc=Umax*sin(teta+120)                            ;
    ;;      theta=omiga*t                                    ;
            ldp   #tmp
            mar   *,ar3        ;making ar3 as current AR
            lacl  indexA        ;; judging if indexA is in    
            and   #0ffh        ;; 0-200, if larger than 
            sub   #200         ;; 200,then index=index-201
            bcnd  sin_cirA,LT
            sacl  indexA
sin_cirA:    
          ; calculating ua
            lacl  indexA
            add   #sintab   ;look up sine table
            sacl  tmp
            lar   ar3,tmp
            lacl  *                                  
            sacl  sinthetaA  ;get value of sintetaA               
            lt    sinthetaA  ; Q15
            mpy   um     ;ua=um*sin(teta),um(Q12)=1000h
            pac          ; ua(Q12), for Q15*Q12=Q27, get off 
            sach  ua,1   ; low 16 bits,then Q11,so left-shift 
                         ; 1 bit, Q12
          ; calculating ub  
            lacl  indexB
            and   #0ffh
            sub   #200
            bcnd  sin_cirB,LT
            sacl  indexB
sin_cirB:
            lacl  indexB
            add   #sintab   ; in sine table lag 67 word
            sacl  tmp
            lar   ar3,tmp
            lacl  *         ;look up sine table                         
            sacl  sinthetaB  ;get value of sintetaA               
            lt    sinthetaB  ; Q15
            mpy   um     ;ub=Umax*sintetaB,Umax(Q12)=1000h
            pac          ; ub(Q12), for Q15*Q12=Q27, get off 
            sach  ub,1   ; low 16 bits,then Q11,so left-shift 
                         ; 1 bit, Q12
            
         
            
                                        
                                         
;            lacl indextemp
;            sub  #1
;            bcnd continue,LT
;            zac
;            sacl indextemp
            lacl  indexA
            and   #0ffh  
            add   #1        ;  inext=index+1,indicate next 
            sacl  indexA     ;  element of sine table                                           
            lacl  indexB
            and   #0ffh  
            add   #1         ;  inext=index+1,indicate next 
            sacl  indexB     ;  element of sine table                                           
;continue:
;            lacl indextemp
;            and #0ffh
;            add #1
;            sacl indextemp

        lacc sinthetaA 	;format 4.12,adjust ia to suit output
        sfr
		sfr
		sfr 		;12 bit dac, [0 1000h] = [0,5] volt
		sfr 
		sacl tmptmp
		add #800h 	;800h is 2.5 volt.
		sacl tmpA 	; data sent to dac0 buffer
		out tmpA,0   
	    out tmpA,4   

                                                ;
;;    End  ua, ub, uc calculation                            ;   
;;    We get the desired 3-phase voltages.                   ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;                                
           
                                 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;                                
;;           Clarke transformation                           ;
;;           (a,b)==>(alfa,beta)                             ;
;;           ualpfa=ua                                       ;
;;           ubeta=(2*ub+ua)/sqrt(3)                        ;            
                                
uacal:
        lacc  ua
        sacl  ualpfa    ;usalfa 4.12
        lacc  ub,1    ;ubeta=(2*ub+ua)/sqrt(3)               
        add   ua
        sacl  tmp
        lt    tmp
        mpy   #sqrt3inv ;093dh, 4.12, 1/sqrt(3)=0.57735                     
        pac                    
        sach  ubeta,4  ;usbeta(Q12), for Q12*Q12=Q24, 
                        ;get off low 16 bits,then Q8,                   
                        ;so left-shift 4 bit, Q12    
                        
        lacc ualpfa 	;format 4.12,adjust ia to suit output
        sfr
		sfr
		sfr 		;12 bit dac, [0 1000h] = [0,5] volt
		sfr 
		sacl tmptmp
		add #800h 	;800h is 2.5 volt.
		sacl tmpA 	; data sent to dac0 buffer
		out tmpA,1   
	    out tmpA,5
	        
	    lacc ubeta 	;format 4.12,adjust ia to suit output
	    sfr
		sfr
		sfr 		;12 bit dac, [0 1000h] = [0,5] volt
		sfr 
		sacl tmptmp
		add #800h 	;800h is 2.5 volt.
		sacl tmpA 	; data sent to dac0 buffer
		out tmpA,2   
	    out tmpA,6    
	     
	     
	     
	     
WP:		   
           clrc  c
		   lacc  uaaddress
		   sub #8fffh
		   bgez SVPWM 
		   lar ar1,t1tmp
	       lar ar2,uaaddress  
	       mar *,ar2
	       sar ar1,*+
	       sar ar2,uaaddress 
	       lar ar1,ubeta   
	       lar ar2,ubaddress  
	       mar *,ar2
	       sar ar1,*+
	       sar ar2,ubaddress 
	         
	                                                    
;      End  Clarke transformation                           ;                                
                                           
              
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;                                

⌨️ 快捷键说明

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