📄 aci_mras.asm
字号:
;=======================================================================
; File Name: aci_mras.asm
;
; Module Name: ACI_MRAS
;
; Initialization Routine: ACI_MRAS_INIT
;
; Originator: Digital Control Systems Group
; Texas Instruments
;
; Description: Reactive Power Model Reference Adaptive System (MRAS)
; Speed Estimator of Induction Motor
;
;
; |~~~~~~~~~~~~~~~~~~~~|
; ualfa_mras o----->|Q15 |
; ubeta_mras o----->|Q15 ACI_MRAS Q15|----->o wr_hat_mras
; ialfa_mras o----->|Q15 Q0|----->o wr_hat_rpm_mras
; ibeta_mras o----->|Q15 |
; |____________________|
;
; Target dependency: C2xx core only
;
;=====================================================================================
; History:
;-------------------------------------------------------------------------------------
; 9-15-2000 Release Rev 1.0
;===========================================================================
;(To use this Module, copy this section to main system file)
; .ref ACI_MRAS, ACI_MRAS_INIT ;function call
; .ref ualfa_mras, ubeta_mras ;Inputs
; .ref ialfa_mras, ibeta_mras ;Inputs
; .ref wr_hat_mras,wr_hat_rpm_mras ;Outputs
;===========================================================================
;Module definitions for external reference.
.def ACI_MRAS, ACI_MRAS_INIT ;function call
.def ualfa_mras, ubeta_mras ;Inputs
.def ialfa_mras, ibeta_mras ;Inputs
.def wr_hat_mras, wr_hat_rpm_mras ;Outputs
;===========================================================================
ref_model_ .set 1 ; set 1 to activate reference model, otherwise set 0
adt_model_ .set 1 ; set 1 to activate adaptive model, otherwise set 0
pi_mras_ .set 1 ; set 1 to activate PI controller, otherwise set 0
motor1 .set 0 ; 1-Hp motor (WEG)
motor2 .set 0 ; 1-Hp motor (Dayton)
motor3 .set 1 ; 1/4-Hp motor (Dayton)
.if (motor1)
K1_ .set 10958 ; for K1 (Q10)
K2_ .set 1891 ; for K2 (Q15)
K3_ .set 16217 ; for K3 (Q8)
K4_ .set 23 ; for K4 (Q15)
K5_ .set 32749 ; for K5 (Q15)
K6_ .set 1235 ; for K6 (Q15)
K7_ .set 19 ; for K7 (Q15)
.endif
.if (motor2)
K1_ .set 17484 ; for K1 (Q10)
K2_ .set 1672 ; for K2 (Q15)
K3_ .set 22811 ; for K3 (Q8)
K4_ .set 23 ; for K4 (Q15)
K5_ .set 32754 ; for K5 (Q15)
K6_ .set 1235 ; for K6 (Q15)
K7_ .set 14 ; for K7 (Q15)
.endif
.if (motor3)
K1_ .set 19251 ; for K1 (Q10)
K2_ .set 5350 ; for K2 (Q15)
K3_ .set 10805 ; for K3 (Q8)
K4_ .set 23 ; for K4 (Q15)
K5_ .set 32739 ; for K5 (Q15)
K6_ .set 1234 ; for K6 (Q15)
K7_ .set 29 ; for K7 (Q15)
.endif
BASE_RPM_ .set 28800 ; for base_rpm (Q3)
.include x24x_app.h
ualfa_mras .usect "mras_aci",1 ; Measured alfa-axis voltage at k (pu)
ubeta_mras .usect "mras_aci",1 ; Measured beta-axis voltage at k (pu)
ialfa_mras .usect "mras_aci",1 ; Measured alfa-axis current at k (pu)
ibeta_mras .usect "mras_aci",1 ; Measured beta-axis current at k (pu)
wr_hat_mras .usect "mras_aci",1 ; Estimated rotor speed at k (pu)
wr_hat_rpm_mras .usect "mras_aci",1 ; Estimated rotor speed at k (rpm)
ialfa_old .usect "mras_aci",1 ; Measured alfa-axis current at k-1 (pu)
ibeta_old .usect "mras_aci",1 ; Measured beta-axis current at k-1 (pu)
ealfa .usect "mras_aci",1 ; Alfa-axis back emf (pu)
ebeta .usect "mras_aci",1 ; Beta-axis back emf (pu)
imalfa_high .usect "mras_aci",1 ; Alfa-axis magnetizing current at k (pu)
imalfa_low .usect "mras_aci",1 ; Alfa-axis magnetizing current at k (pu)
imbeta_high .usect "mras_aci",1 ; Beta-axis magnetizing current at k (pu)
imbeta_low .usect "mras_aci",1 ; Beta-axis magnetizing current at k (pu)
imalfa_old_high .usect "mras_aci",1 ; Alfa-axis magnetizing current at k-1 (pu)
imalfa_old_low .usect "mras_aci",1 ; Alfa-axis magnetizing current at k-1 (pu)
imbeta_old_high .usect "mras_aci",1 ; Beta-axis magnetizing current at k-1 (pu)
imbeta_old_low .usect "mras_aci",1 ; Beta-axis magnetizing current at k-1 (pu)
q .usect "mras_aci",1 ; Reactive power in reference model (pu)
q_hat .usect "mras_aci",1 ; Reactive power in adaptive model (pu)
error .usect "mras_aci",1 ; Reactive error (pu)
K1 .usect "mras_aci",1 ; Constant using in reference model
K2 .usect "mras_aci",1 ; Constant using in adaptive model
K3 .usect "mras_aci",1 ; Constant using in adaptive model
K4 .usect "mras_aci",1 ; Constant using in adaptive model
K5 .usect "mras_aci",1 ; Constant using in adaptive model
K6 .usect "mras_aci",1 ; Constant using in adaptive model
K7 .usect "mras_aci",1 ; Constant using in adaptive model
Kp .usect "mras_aci",1 ; PI proportionnal constant
Ki_high .usect "mras_aci",1 ; PI integral constant (high 16 bit)
Ki_low .usect "mras_aci",1 ; PI integral constant (low 16 bit)
tmp1_high .usect "mras_aci",1 ; 32-bit temporary variable (high 16 bit)
tmp1_low .usect "mras_aci",1 ; 32-bit temporary variable (low 16 bit)
tmp2_high .usect "mras_aci",1 ; 32-bit temporary variable (high 16 bit)
tmp2_low .usect "mras_aci",1 ; 32-bit temporary variable (low 16 bit)
tmp3_high .usect "mras_aci",1 ; 32-bit temporary variable (high 16 bit)
tmp3_low .usect "mras_aci",1 ; 32-bit temporary variable (low 16 bit)
tmp4 .usect "mras_aci",1 ; 16-bit temporary variable
tmp5 .usect "mras_aci",1 ; 16-bit temporary variable
sign1 .usect "mras_aci",1 ; Checking sign variable for Q31 multiplication
sign2 .usect "mras_aci",1 ; Checking sign variable for Q31 multiplication
sign3 .usect "mras_aci",1 ; Checking sign variable for Q31 multiplication
base_rpm .usect "mras_aci",1 ; Base motor speed in rpm (Q3 signed)
;=========================
ACI_MRAS_INIT:
;=========================
LDP #K1
SPLK #K1_,K1 ; K1 = (Ls-Lm^2/Lr)*Ib/(T*Vb) (Q11)
SPLK #K2_,K2 ; K2 = Lm^2*Ib/(Lr*Tr*Vb) (Q15)
SPLK #K3_,K3 ; K3 = Tr*Wb (Q8)
SPLK #K4_,K4 ; K4 = (Wb*T)^2/2 (Q15)
SPLK #K5_,K5 ; K5 = 1-T/Tr+T^2/(2*Tr^2) (Q15)
SPLK #K6_,K6 ; K6 = Wb*(T-T^2/Tr) (Q15)
SPLK #K7_,K7 ; K7 = T/Tr-T^2/(2*Tr^2) (Q15)
SPLK #BASE_RPM_,base_rpm ; Base motor speed in rpm (Q3)
SPLK #0000h,q ; Initial value of q in reference model
SPLK #0000h,q_hat ; Initial value of q_hat in adaptive model
SPLK #0000h,ialfa_old ; Initial value of ialfa
SPLK #0000h,ibeta_old ; Initial value of ibeta
SPLK #0000h,imalfa_old_low ; Initial value of imalfa (low 16 bit)
SPLK #0000h,imalfa_old_high ; Initial value of imalfa (high 16 bit)
SPLK #0000h,imbeta_old_low ; Initial value of imbeta (low 16 bit)
SPLK #0000h,imbeta_old_high ; Initial value of imbeta (high 16 bit)
SPLK #0000h,wr_hat_mras ; Initial value of angular speed
SPLK #0000h,error ; Initial value of error of reactive power
SPLK #0050h,Kp ; PI proportionnal constant (Q15)
SPLK #001Dh,Ki_high ; PI integral constant (high 16 bit) (Q31)
SPLK #0DEADh,Ki_low ; PI integral constant (low 16 bit) (Q31)
RET
;=========================
ACI_MRAS:
;=========================
SPM 0 ; Reset product mode
SETC SXM ; Set sign extension mode
SETC OVM ; Set overflow mode
LDP #ibeta_old
.if (ref_model_)
;=========================
;REF_MODEL:
;=========================
; ------------------------ Start reference model section ----------------------------
; K1*(ibeta(k)*ialfa(k-1)-ialfa(k)*ibeta(k-1)) = tmp1 => Q10*(Q15*Q15-Q15*Q15) = Q31
LT ibeta_old ; TREG = ibeta(k-1) (Q15)
MPY ialfa_mras ; PREG = ialfa(k)*ibeta(k-1) (Q30)
PAC ; ACC = ialfa(k)*ibeta(k-1) (Q30)
NEG ; Make result negative
LT ialfa_old ; TREG = ialfa(k-1) (Q15)
MPY ibeta_mras ; PREG = ibeta(k)*ialfa(k-1) (Q30)
APAC ; ACC = ibeta(k)*ialfa(k-1)-ialfa(k)*ibeta(k-1) (Q30)
SACH sign1 ; Keep sign for ibeta(k)*ialfa(k-1)-ialfa(k)*ibeta(k-1)
ABS ; ACC = |ibeta(k)*ialfa(k-1)-ialfa(k)*ibeta(k-1)| (Q30)
SACH tmp1_high,1 ; tmp1_high = |ibeta(k)*ialfa(k-1)-ialfa(k)*ibeta(k-1)| (Q31)
SACL tmp1_low,1 ; tmp1_low = |ibeta(k)*ialfa(k-1)-ialfa(k)*ibeta(k-1)| (Q31)
; now they're positive.
LT K1 ; TREG = K1 (Q10)
MPYU tmp1_low ; PREG = K1*tmp1_low
SPH tmp4 ; tmp4 = PREG high (save partial result)
SPL tmp5 ; tmp5 = PREG low
MPYU tmp1_high ; PREG = K1*tmp1_high
PAC ; ACC = K1*tmp1_high
ADDS tmp4 ; ACC = K1*tmp1_high + tmp4
SACH tmp1_high,6 ; tmp1_high = ACC high (Q31)
SACL tmp1_low,6 ; tmp1_low = ACC low (Q31)
LACC tmp5 ; ACC = tmp5
AND #0FC00h ; Pick MSB 6 bits in low 16 bits of K1*tmp1_low
SACH tmp5,6 ; tmp5 = MSB 6 bits in low 16 bits of K1*tmp1_low
LACL tmp5 ; ACC = tmp5
ADDS tmp1_low ; tmp1_low = MSB 6 bits in low 16 bits of K1*tmp1_low + tmp1_low
SACL tmp1_low ; tmp1_high = ACC low
; check the sign condition
LACC sign1 ; ACC = sign1
BCND DONE0, GT ; Check sign1 = positive ?
LACC tmp1_high,16 ; ACC high = tmp1_high
ADDS tmp1_low ; ACC = tmp1_high tmp3_low
NEG ; Make the result negative
SACH tmp1_high ; tmp1_high = ACC high
SACL tmp1_low ; tmp1_low = ACC low
DONE0
; ialfa(k)*ubeta(k)-ibeta(k)*ualfa(k) = tmp2 => Q15*Q15-Q15*Q15 = Q31
LT ibeta_mras ; TREG = ibeta(k) (Q15)
MPY ualfa_mras ; PREG = ibeta(k)*ualfa(k) (Q30)
PAC ; ACC = ibeta(k)*ualfa(k) (Q30)
NEG ; Make result negative
LT ialfa_mras ; TREG = ialfa(k) (Q15)
MPY ubeta_mras ; PREG = ialfa(k)*ubeta(k) (Q30)
APAC ; ACC = ialfa(k)*ubeta(k)-ibeta(k)*ualfa(k) (Q30)
SACL tmp2_low,1 ; tmp2 = ialfa(k)*ubeta(k)-ibeta(k)*ualfa(k) (L 16 bit) (Q31)
SACH tmp2_high,1 ; tmp2 = ialfa(k)*ubeta(k)-ibeta(k)*ualfa(k) (H 16 bit) (Q31)
; tmp4 = q(k) = tmp2 - tmp1 => Q15 = Q31 - Q31
Q
LACC tmp2_high,16 ; ACC high = tmp2_high (Q31)
ADDS tmp2_low ; ACC low = tmp2_low (Q31)
SUBS tmp1_low ; ACC = tmp2_low-tmp1_low (Q31)
SUBH tmp1_high ; ACC = tmp2_high-tmp1_high (Q31)
SACH tmp4 ; tmp4 or q(k) = tmp2_high-tmp1_high (Q15)
; Averaging the reactive power => (q(k)+q(k-1))/2
LACC tmp4 ; ACC = q(k) (Q15)
ADD q ; ACC = q(k)+q(k-1) (Q15)
SFR ; ACC = (q(k)+q(k-1))/2 (Q15)
SACL q ; q(k) = (q(k)+q(k-1))/2 (Q15)
; Update ialfa(k-1) = ialfa(k) and ibeta(k-1) = ibeta(k)
LACC ialfa_mras ; ACC low = ialfa(k) (Q15)
SACL ialfa_old ; ialfa(k-1) = ialfa(k) (Q15)
LACC ibeta_mras ; ACC low = ibeta(k) (Q15)
SACL ibeta_old ; ibeta(k-1) = ibeta(k) (Q15)
; ------------------------- End reference model section ----------------------------
.endif
.if (adt_model_)
;=========================
;ADT_MODEL:
;=========================
; ------------------------ Start adaptive model section ----------------------------
IM_ALFA
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -