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

📄 imvc07_a.h

📁 2407的交流电机控制程序
💻 H
字号:
;******************************************************************************************
;	File Name	: IMVC07_a.h                   
;	Project	: IMVC position control on ACPM750 AC Power Module Kit with
;					  TMS320LF2407 DSP controller
;==========================================================================================
;	Target Sys  : MSK2407 DSP board + ACPM750 v3.2 power module
;	Description : Definition and space allocation for program variables. Macros definitions. 
;  Originator/s: Technosoft Ltd.
;	Status      : OK
;==========================================================================================
;	Copyright ?2000 Technosoft
;==========================================================================================
	.text
;------------------------------------------------------------------------------------------
; Constant defines for motion control modules
;------------------------------------------------------------------------------------------
C_PI_2		       .set	04000h	; constant PI/2
C_2_PI_3		.set	05555h	; constant 2*PI/3
C_4_PI_3		.set	0AAAAh	; constant 4*PI/3
;------------------------------------------------------------------------------------------
C_SAT_I_Q_REF		.set	3334h	; constant to saturate i_q_ref at 0x6666h
C_SAT_U_D_REF		.set	3334h	; constant to saturate u_d_ref at 0x6666h
C_SAT_U_Q_REF		.set	3334h	; constant to saturate u_q_ref at 0x6666h
C_SAT_OMG_REF		.set	3334h	; constant to saturate omg_ref at 0x6666h


;------------------------------------------------------------------------------------------
satval1    .set    4000h
satval2    .set    6000h
satval3    .set    7000h
satval4    .set    7800h
satval5    .set    7C00h
satval6    .set    7E00h
satval7    .set    7F00h
satval8    .set    7F80h
satval9    .set    7FC0h
satval10   .set    7FE0h
satval11   .set    7FF0h
satval12   .set    7FF8h
;******************************************************************************************
	.data
;------------------------------------------------------------------------------------------
sintab: .include   sine.tab
tabend:
tabsize: .set    tabend - sintab -1
;------------------------------------------------------------------------------------------

;	Global functions
;	================
	.global	_loadsatvals
;--------------------------------------
	.global	_pi_reg_pos
	.global	_init_pi_reg_pos
;--------------------------------------
	.global	_pi_reg_omg
	.global	_init_pi_reg_omg
;--------------------------------------
	.global	_pi_reg_id
	.global	_init_pi_reg_id
;--------------------------------------
	.global	_pi_reg_iq
	.global	_init_pi_reg_iq
;--------------------------------------
	.global       _start_encoder
	.global       _read_encoder
;--------------------------------------
	.global	_start_pwm
	.global	_update_pwm
;--------------------------------------
	.global       _tabcdq
	.global       _tdqabc
	.global       _sine
;--------------------------------------  
	.global _InitializeKernel
;--------------------------------------
	.global	_cfgiopb1 
	.global	_setiopb1 
	.global	_resetiopb1 
;--------------------------------------
; Local variables
;----------------
dif_pos_ref	       .usect "MCK_1", 1
dif_pos		.usect "MCK_1", 1
e_pos			.usect "MCK_1", 1
;--------------------------------------
dif_omg_ref	       .usect "MCK_1", 1
dif_omg		.usect "MCK_1", 1
e_omg			.usect "MCK_1", 1
;--------------------------------------
dif_id_ref	       .usect "MCK_1", 1
dif_id		       .usect "MCK_1", 1
e_id			.usect "MCK_1", 1
;--------------------------------------
dif_iq_ref	       .usect "MCK_1", 1
dif_iq		       .usect "MCK_1", 1
e_iq			.usect "MCK_1", 1
;--------------------------------------
temp1			.usect "MCK_1", 1
temp_lo		.usect "MCK_1", 1
temp_hi		.usect "MCK_1", 1
;--------------------------------------
; Global variables
;-----------------
_pdpint_events	.usect "MCK_1", 1
		       .global _pdpint_events
_ad_res_0	       .usect "MCK_1", 1
		       .global _ad_res_0
_ad_res_1	       .usect "MCK_1", 1		
		       .global _ad_res_1
_offset_ia	       .usect "MCK_1", 1
		       .global _offset_ia
_offset_ib	       .usect "MCK_1", 1
		       .global _offset_ib
;--------------------------------------
_fast_max_count	.usect "MCK_1", 1
	             .global _fast_max_count
_middle_max_count	.usect "MCK_1", 1
		       .global _middle_max_count
_slow_max_count	.usect "MCK_1", 1
		       .global _slow_max_count

;--------------------------------------
_i_a		.usect "MCK_1", 1
		.global	_i_a			; reference phase currents, abc frame
_i_b		.usect "MCK_1", 1 		
		.global	_i_b
;--------------------------------------
_i_alpha	.usect "MCK_1", 1
		.global	_i_alpha		; alphabeta frame currents
_i_beta		.usect "MCK_1", 1	
	       .global	_i_beta
;--------------------------------------	
_i_d		.usect "MCK_1", 1
		.global	_i_d			; rotor currents, dq frames
_i_q		.usect "MCK_1", 1	
	      .global	_i_q
;--------------------------------------	
_u_d_ref	.usect "MCK_1", 1
		.global	_u_d_ref		  ; stator voltages, dq frames
_u_q_ref	.usect "MCK_1", 1		
		.global	_u_q_ref
;--------------------------------------
_u_alpha_ref	.usect "MCK_1", 1
		.global	_u_alpha_ref          ; alphabeta frame voltages
_u_beta_ref	.usect "MCK_1", 1	
		.global	_u_beta_ref
;--------------------------------------
_u_dc_ref	.usect "MCK_1", 1
		.global	_u_dc_ref	        ; reference dc voltage, dc frame
_i_d_ref	.usect "MCK_1", 1
		.global _i_d_ref
;--------------------------------------	
_sin_theta	.usect "MCK_1", 1 
		.global	_sin_theta
_cos_theta	.usect "MCK_1", 1		
		.global	_cos_theta
;--------------------------------------
_position	.usect "MCK_1", 1									
		.global _position
_theta	       .usect "MCK_1", 1 
		.global _theta
;--------------------------------------
satvals12	.usect "MCK_1", 12
		.global satvals12
;--------------------------------------
temp	       .usect "MCK_1", 1
		.global temp
;--------------------------------------
_u_a_ref	.usect "MCK_1", 1		
		.global _u_a_ref
_u_b_ref	.usect "MCK_1", 1
		.global _u_b_ref
_u_c_ref	.usect "MCK_1", 1		
		.global _u_c_ref
;--------------------------------------
_pwm_period	.usect "MCK_1", 1		
		.global _pwm_period
_adr_cmp_plus	.usect "MCK_1", 1
		.global _adr_cmp_plus
_adr_cmp_minus	.usect "MCK_1", 1		
		.global _adr_cmp_minus
_new_actr_value	.usect "MCK_1", 1
		.global _new_actr_value
;--------------------------------------
_crt_comp	.usect "MCK_1", 1
		.global      _crt_comp
_ctrl_ps_per	.usect "MCK_1", 1
		.global	_ctrl_ps_per
_ctrl_crt_per	.usect "MCK_1", 1
		.global	_ctrl_crt_per
_ctrl_pos_per	.usect "MCK_1", 1
		.global	_ctrl_pos_per


;--------------------------------------
_Kps_id	.usect "MCK_1", 1
		.global _Kps_id	
_sf_P_id	.usect "MCK_1", 1
		.global _sf_P_id
_Kis_id	.usect "MCK_1", 1
		.global _Kis_id				
_sf_I_id	.usect "MCK_1", 1
		.global _sf_I_id
_id_ref_1	.usect "MCK_1", 1
	      .global _id_ref_1
_id_1		.usect "MCK_1", 1
	      .global _id_1
_e_id_1	.usect "MCK_1", 1
	      .global _e_id_1
_I_id_1_high	.usect "MCK_1", 1
	       .global _I_id_1_high
_I_id_1_low	.usect "MCK_1", 1
	       .global _I_id_1_low
_ud_ref_low	.usect "MCK_1", 1
	       .global _ud_ref_low
;--------------------------------------
_i_q_ref	.usect "MCK_1", 1
		.global _i_q_ref
_Kps_iq	.usect "MCK_1", 1
		.global _Kps_iq
_sf_P_iq	.usect "MCK_1", 1
		.global _sf_P_iq
_Kis_iq	.usect "MCK_1", 1
		.global _Kis_iq
_sf_I_iq	.usect "MCK_1", 1
		.global _sf_I_iq
_iq_ref_1	.usect "MCK_1", 1
		.global _iq_ref_1
_iq_1		.usect "MCK_1", 1
		.global _iq_1
_e_iq_1	.usect "MCK_1", 1
		.global _e_iq_1
_I_iq_1_high	.usect "MCK_1", 1
		.global _I_iq_1_high
_I_iq_1_low	.usect "MCK_1", 1
		.global _I_iq_1_low
_uq_ref_low	.usect "MCK_1", 1
		.global _uq_ref_low
;--------------------------------------
_omg		.usect "MCK_1", 1
		.global _omg
_omg_ref	.usect "MCK_1", 1
		.global _omg_ref
_Kps_omg	.usect "MCK_1", 1
		.global _Kps_omg
_sf_P_omg	.usect "MCK_1", 1
		.global _sf_P_omg
_Kis_omg	.usect "MCK_1", 1
		.global _Kis_omg
_sf_I_omg	.usect "MCK_1", 1
		.global _sf_I_omg
_omg_ref_1	.usect "MCK_1", 1
		.global _omg_ref_1
_omg_1		.usect "MCK_1", 1
		.global _omg_1
_e_omg_1	.usect "MCK_1", 1
		.global _e_omg_1
_I_omg_1_high	.usect "MCK_1", 1
		.global _I_omg_1_high
_I_omg_1_low	.usect "MCK_1", 1
		.global _I_omg_1_low
_iq_ref_low	.usect "MCK_1", 1
		.global _iq_ref_low
;--------------------------------------
_pos		.usect "MCK_1", 1
		.global _pos
_pos_ref	.usect "MCK_1", 1
		.global _pos_ref
_Kps_pos	.usect "MCK_1", 1
		.global _Kps_pos
_Kis_pos	.usect "MCK_1", 1
		.global _Kis_pos
_pos_ref_1	.usect "MCK_1", 1
		.global _pos_ref_1
_pos_1		.usect "MCK_1", 1
		.global _pos_1
_e_pos_1	.usect "MCK_1", 1
		.global _e_pos_1
_I_pos_1_high	   .usect "MCK_1", 1
		.global _I_pos_1_high
_I_pos_1_low	.usect "MCK_1", 1
		.global _I_pos_1_low
_omg_ref_low	.usect "MCK_1", 1
		.global _omg_ref_low


;----------- logger --------------
_log_indx	.usect "LOGGER", 1
		.global _log_indx
_log_count	.usect "LOGGER", 1
		.global _log_count
_log_size	.usect "LOGGER", 1
		.global _log_size
_log_time	.usect "LOGGER", 1
		.global _log_time
_log_p		.usect "LOGGER", 9
		.global _log_p
_log_table	.usect "LOGGER", 1ff0h
		.global _log_table
;----------- reference -----------
_ref_long	.usect "REFER", 2
		.global _ref_long
_ctrl_time	.usect "REFER", 2
		.global _ctrl_time
_ref_indx	.usect "REFER", 2
		.global _ref_indx
_ref_time_val	  .usect "REFER", 100
		.global _ref_time_val
_ref_HL	.usect "REFER", 200
		.global _ref_HL
;---------------------------------
_C_slip 	.usect "MCK_1", 1
		.global _C_slip
_C_omg 	.usect "MCK_1", 1
		.global _C_omg
_Sh_omg	 .usect "MCK_1", 1
		.global _Sh_omg
_Sh_slip 	.usect "MCK_1", 1
		.global _Sh_slip
_theta_low	 .usect "MCK_1", 1
		.global _theta_low
_theta_inc 	.usect "MCK_1", 1
		.global _theta_inc
;--------------------------------------
_flag_active_fast .usect "MCK_1", 1
		.global _flag_active_fast
_flag_active_middle .usect "MCK_1", 1
		.global _flag_active_middle
_flag_active_slow	.usect "MCK_1", 1
		.global _flag_active_slow
;------------------------------------------------------------------------------------------
_counter_fast	.usect "MCK_1", 1
		.global _counter_fast
_counter_middle	.usect "MCK_1", 1
		.global _counter_middle
_counter_slow	 .usect "MCK_1", 1
		.global _counter_slow
set_WS		.usect "MCK_1", 1
		.global set_WS
;------------------------------------------------------------------------------------------
; M A C R O - Definitions
;------------------------------------------------------------------------------------------
RESBIT		.macro	DMA, MASK	;Clear bit Macro
	LACL	DMA
	AND	#MASK
	SACL	DMA
	.endm

SETBIT		.macro	DMA, MASK	;Set bit Macro
	LACL	DMA
	OR	#MASK
	SACL	DMA
	.endm
;------------------------------------------------------------------------------------------
; Saturation Macros
;
;	+---------------------------------------+
;	|	MUST BE USED UNDER OVM = 1	|
;	+---------------------------------------+
;
; After "satx", the next instruction is "SACH mem,x"
;------------------------------------------------------------------------------------------
sat1	.macro
	LDP	#satvals12
	ADD	satvals12,16
	SUB	satvals12,16
	SUB	satvals12,16
	ADD	satvals12,16
	.endm
;
sat2	.macro
	LDP	#satvals12
	ADD	satvals12+1,16
	SUB	satvals12+1,16
	SUB	satvals12+1,16
	ADD	satvals12+1,16
	.endm
;
sat3	.macro
	LDP	#satvals12
	ADD	satvals12+2,16
	SUB	satvals12+2,16
	SUB	satvals12+2,16
	ADD	satvals12+2,16
	.endm
;
sat4	.macro
	LDP	#satvals12
	ADD	satvals12+3,16
	SUB	satvals12+3,16
	SUB	satvals12+3,16
	ADD	satvals12+3,16
	.endm
;
sat5	.macro
	LDP	#satvals12
	ADD	satvals12+4,16
	SUB	satvals12+4,16
	SUB	satvals12+4,16
	ADD	satvals12+4,16
	.endm
;
sat6	.macro
	LDP	#satvals12
	ADD	satvals12+5,16
	SUB	satvals12+5,16
	SUB	satvals12+5,16
	ADD	satvals12+5,16
	.endm
;
sat7	.macro
	LDP	#satvals12
	ADD	satvals12+6,16
	SUB	satvals12+6,16
	SUB	satvals12+6,16
	ADD	satvals12+6,16
	.endm
;------------------------------------------------------------------------------------------
; Saturation Macro for Regulator output
;	+---------------------------------------+
;	|	MUST BE USED UNDER OVM = 1	|
;	+---------------------------------------+
sat_reg_out .macro C_SAT
	ADD	#C_SAT,15
	SUB	#C_SAT,15
	SUB	#C_SAT,15
	ADD	#C_SAT,15
	.endm
;------------------------------------------------------------------------------------------
; Saturation Macro depending on ind
;------------------------------------------------------------------------------------------
;SATurates and ShiFts Left accumulator
;Should be used after [scaling and] [A]PAC, before using a 32 bit result
;After "satsfl ind", the next instruction is "SACH mem"
;	+---------------------------------------+
;	|	1. MUST BE USED UNDER OVM = 1	|
;	|	2. MUST BE USED UNDER DP = #ind	|
;	+---------------------------------------+
;Action: Rawaccumulator is saturated to +-(2^(31-(ind+1))) and then left
;	 shifted by (1<= ind <=12) and thus brought in Q31 format
;Effect: Avoids overflow
;------------------------------------------------------------------------------------------
SATSFL	.macro  ind
	sar	AR3, *+
	sar	AR0, *+,AR3
	LAR	AR3, ind
	LAR	AR0, #satvals12
	MAR	*0+
	ADD	*,16
	SUB	*,16
	SUB	*,16
	ADD	*,16,AR1
	RPT	ind
	SFL
	mar	*-
	lar	AR0, *-	
	lar	AR3, *
	.endm
;------------------------------------------------------------------------------------------
END_ISR		.macro
	larp    AR1             				; ARP=1, AR1=TOS+5
	mar     *-              				; AR1--, AR1=TOS+4
	zals    *-              				; restore ACCL, AR1=TOS+3
	addh    *-	        				; restore ACCH, AR1=TOS+2
	lst     #0, *-          				; restore ST0, AR1=TOS+1
	lst     #1, *-          				; restore ST1, AR1=TOS    
;
	clrc    INTM
	ret
	.endm
;------------------------------------------------------------------------------------------
	

⌨️ 快捷键说明

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