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

📄 asy_motor_control.asm

📁 异步电机驱动程序
💻 ASM
📖 第 1 页 / 共 3 页
字号:
          pac
          and    #07ffh
          add    _current_pi_error2
          sacl   _current_pi_error2     
          sub    #2048
          blz    Buck_cc
          sacl   _current_pi_error2
          spm    3
          pac  
          sfr
          sfr   
          sfr
          sfr  
          sfr
          add   #1
          add   _current_id_sum
          sacl  _current_id_sum
          b     pi_onit2 

Buck_cc:

          spm   3
          pac
          sfr
          sfr   
          sfr
          sfr     
          sfr
          add   _current_id_sum
          sacl  _current_id_sum
                    
pi_onit2:

          lacc  _current_id_sum
          abs
          sub   #3200
          blz   yg2
          lacc  _current_id_sum
                     
          blz   no_neg_id                
          splk  #3200,_current_id_sum                    
          b     yg2
          
no_neg_id:  

          splk  #-3200,_current_id_sum
          
yg2:       

          lacc  _current_id_sum   
          ;b    Buck_dd
          and   #07h  
          add   _current_pi_error3
          sacl  _current_pi_error3
          sub   #8
          blz   Buck_dd  
          sacl  _current_pi_error3
          lacc  _current_id_sum 
          rpt   #2
          sfr
          add   #1
          add   _current_udref 
          sacl  _current_udref 
          b     current_pi_id_d

Buck_dd:   
       
          lacc  _current_id_sum 
          rpt   #2
          sfr      
          add   _current_udref 
          sacl  _current_udref 
          
current_pi_id_d:

          lacc  _current_id_err
          sub   _current_id_err_old
          sacl  _pi_temp
          lt    _pi_temp
          mpy   _current_kd
          spm   3
          pac             
          sfr
          sfr 
          add   _current_udref
          sacl  _current_udref 

Buck_pi_limit_id:

          lacc  _current_udref 
          abs
          sub  #400
          BLZ   Buck_pwm_over_id        ;限幅值
          lacc  _current_udref
         
          blz  Buck_u_limit_id
          SPLK  #400,_current_udref 
          B     Buck_pwm_over_id
          
Buck_u_limit_id:

          SPLK  #-400,_current_udref 
          
Buck_pwm_over_id:

          lacc  _current_id_err
          sacl  _current_id_err_old
         
;         .endif                      ;d轴电流调节结束
         
;================================================
;        .if inv_park                 ;PARK反变换
;===========================================================================
;  vsbeta_ref=vsq_ref*cosTeta_cm+vsd_ref*sinTeta_cm
;  vsalfa_ref=-vsq_ref*sinTeta_cm+vsd_ref*cosTeta_cm
;===========================================================================
u_park:
       ; lacc    _current_given
       ; sacl    _current_uqref
        
        ;splk #0, _current_udref
        
        ;splk #0, _current_uqref
        
        ;setc SXM        
        spm    	0
        lacc   	#0
		;ldpk    _current_udref
		lt    	_current_udref                	
		mpy   	_sin_value
		lta   	_current_uqref           		
		mpy   	_cos_value
		mpya  	_sin_value
		sach  	_vsbeta_ref,1
		 
		lacc   	#0
		lt    	_current_udref       			
		mpys   	_cos_value
		apac
		sach   	_vsalfa_ref,1
        
;        .endif                 ;PARK反变换结束
        
;==========================================================================

;       .if svpwm_modulation           ;svpwm modulation
;===========================================================================

        ;setc    SXM
        ;ldpk    _vsbeta_ref
        lacc  	_vsbeta_ref   
        sacl  	_vref1
        lt    	_vsalfa_ref
        mpy   	#sqrt32
        spm   	0
        pac 
        sach  	_vref4,4
        lacc  	_vsbeta_ref 
        sfr
        neg
        sacl  	_vref5
        add   	_vref4
        sacl  	_vref2
        lacc  	_vref5
        sub   	_vref4
        sacl  	_vref3
         
        lacc  	_vref1
        sacl  	_x
        lacc  	_vref4
        sub   	_vref5
        sacl  	_y
        lacc  	_vref4
        add   	_vref5
        neg
        sacl  	_z
    
        lacc  	_vref1
        bgz   	ua
        splk  	#0,_a
        b     	uaon
ua:
        splk  	#1,_a
              
uaon:
        lacc  	_vref2
        bgz   	ub
        splk   	#0,_b
        b     	ubon
ub:
        splk  	#1,_b
ubon:
        lacc 	_vref3
        bgz   	uc
        splk  	#0,_c
        b  		ucon
uc:
        splk  	#1,_c
ucon:   
        lacc  	_c,2
        add  	_b,1
        add  	_a 
        sacl  	_sector
        sub  	#1
        bz   	f_sector1
        sub  	#1
        bz   	f_sector2
        sub   	#1
        bz   	f_sector3
        sub   	#1
        bz   	f_sector4
        sub   	#1
        bz   	f_sector5
        sub   	#1   
        bz   	f_sector6
        b    	cmp_ok
f_sector1:
        lacc  	_z
        sacl  	_t1
        lacc  	_y
        sacl  	_t2
        
        b    	t1t2out 
           
f_sector2:
        lacc 	_y
        sacl 	_t1
        lacc  	_x
        neg
        sacl  	_t2
    
        b    	t1t2out   
            
f_sector3:
        lacc  	_z
        neg
        sacl 	_t1
        lacc  	_x
              
        sacl 	_t2
   
        b    	t1t2out  
          

                            
f_sector4:
        lacc  	_x
        neg
        sacl  	_t1
        lacc  	_z
        sacl  	_t2 
   
        b    	t1t2out 
f_sector5:
        lacc   	_x
             
        sacl  	_t1
        lacc  	_y
        neg
        sacl  	_t2
 
        b    	t1t2out 
          
f_sector6:
        lacc 	_y
        neg
        sacl  	_t1
        lacc  	_z
        neg
        sacl  	_t2
        
t1t2out:     
        b   	t1t2_ok

        lt   	_t1
        mpy  	#pwmprd
        spm  	1
        pac
              
        sach  	_t1,3
 
        lt  	_t2
        mpy   	#pwmprd
        spm  	1
        pac 
              
        sach  	_t2 ,3
t1t2_ok:              
        lacc   	_t1
        bgz   	t1_ok
        splk   	#0,_t1
t1_ok:
        lacc  	_t2
        bgz   	t2_ok
        splk   	#0,_t2
t2_ok:
        lacc   	_t1
        add    	_t2
        sacl   	_tmp
        sub    	#pwmprd
        blez   	nosaturation
             
              
        lacc  	#pwmprd,15
        rpt   	#15
        subc  	_tmp
        sacl  	_tmp
        lt    	_tmp
        mpy   	_t1
        spm    	0
        pac 
        sach  	_t1,1
        mpy   	_t2
        pac
        sach  	_t2,1
nosaturation:
        lacc  	#pwmprd
        sub   	_t1
        sub   	_t2
        sfr
        sacl  	_taon
        add  	_t1
        sacl  	_tbon
        add  	_t2
        sacl  	_tcon
              
        lacc  	_sector
        sub   	#1
        bnz   	nosect1
        lacc   	_tbon
        sacl   	_cmp1
        lacc   	_taon
        sacl   	_cmp2
        lacc   	_tcon
        sacl   	_cmp3
        b      	cmp_ok
              
nosect1:
        sub  	#1
        bnz   	nosect2
        lacc  	_taon
        sacl  	_cmp1
        lacc  	_tcon
        sacl  	_cmp2
        lacc   	_tbon
        sacl   	_cmp3
        b   	cmp_ok
                                                                    
nosect2:
        sub   	#1
        bnz   	nosect3
        lacc  	_taon
        sacl  	_cmp1
        lacc  	_tbon
        sacl  	_cmp2
        lacc   	_tcon
        sacl  	_cmp3
        b   	cmp_ok

nosect3:
        sub   	#1
        bnz   	nosect4
        lacc  	_tcon
        sacl   	_cmp1
        lacc   	_tbon
        sacl   	_cmp2
        lacc   	_taon
        sacl   	_cmp3
        b   	cmp_ok
        
nosect4:
        sub   	#1
        bnz   	nosect5
        lacc  	_tcon
        sacl  	_cmp1
        lacc   	_taon
        sacl   	_cmp2
        lacc   	_tbon
        sacl   	_cmp3
        b    	cmp_ok
            

nosect5:
        lacc   	_tbon
        sacl  	_cmp1
        lacc   	_tcon
        sacl   	_cmp2
        lacc  	_taon
        sacl 	_cmp3  
        
cmp_ok:
        
        ;lacc  	    #pwmprd          ;反向逻辑需要进行以下修正
        ;sub    	_cmp1
        ;sacl   	_cmp1  
        ;lacc   	#pwmprd
        ;sub    	_cmp2
        ;sacl   	_cmp2
        ;lacc   	#pwmprd
        ;sub    	_cmp3
        ;sacl   	_cmp3  
;================================
;这里要考虑实际输出的矢量与电机正
;方向的关系,来决定上述是否要减
;================================        
        lacc  _n_ref
        bnz    back
        ;b      save
            
            splk #0,_speed_err
            splk #0,_speed_err_old
            splk #0,_current_given
            splk #0,_speed_pi_error
            splk #0,_speed_pi_error1
            splk #0,_speed_sum
            splk #0,_t2_sum

            splk #0,_current_iq_err
            splk #0,_current_iq_err_old
            splk #0,_current_uqref
            splk #0,_current_pi_error
            splk #0,_current_pi_error1
            splk #0,_current_iq_sum
           
            splk #0,_current_id_err
            splk #0,_current_id_err_old
            splk #0,_current_udref
            splk #0,_current_pi_error2
            splk #0,_current_pi_error3
            splk #0,_current_id_sum
            
            splk #0,_fs
            splk  #0,_thet
            splk  #0,_imr
            splk  #0,_cur_error
            splk  #0,_cur_error1
            splk  #0,_cur_error2
            splk  #0,_foc_temp      
            
            
            splk #0,_cmp1
            splk #0,_cmp2
            splk #0,_cmp3
            
;            .endif

            
save:            
       ;splk  #400,_cmp1
       ;splk  #500,_cmp2
       ;splk  #500,_cmp3
        
        b     back
        
        lacc   	cmpr_value
		sub    	#1  
		sacl   	cmpr_value
		bgz   	back
		splk   	#100,cmpr_value 
		;b     back
		
		
		clrc   	sxm
		mar    	*,ar4
		ldp     #6h
		lar     ar4,51h
		ldpk   	_thet
		lacc   	_thet
		sacl   	*
		lacc    ar4_temp
		add     #1
		sacl    ar4_temp
		sub   	#0a800h
		blz   	next_sample
		splk    #0a000h,ar4_temp
		
next_sample:
  		ldp     #6h
		mar    	*,ar6
		lar     ar6,52h
		ldpk   	_sin_value
		lacc   	_sin_value
		sacl   	*
		lacc    ar6_temp
		add     #1
		sacl    ar6_temp
		sub    	#0b000h
		blz    	back
		splk    #0a800h,ar6_temp
		
back:		
            ret  
           

⌨️ 快捷键说明

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