📄 aci_mras.asm
字号:
;=====================================================================================
; File name: ACI_MRAS.ASM
;
; Originator: Digital Control Systems Group
; Texas Instruments
;
; Description:
; Reactive power model reference adaptive system (MRAS) speed
; estimator of induction motor
;=====================================================================================
; History:
;-------------------------------------------------------------------------------------
; 9-15-2000 Release Rev 1.0
;================================================================================
; Applicability: F240,F241,C242,F243,F24xx. (Peripheral Independent).
;================================================================================
; Routine Name: aci_mras_calc Type: C Callable
;
; C prototype : void aci_mras_calc(struct ACIMRAS *p);
;
; The struct object is defined in the header file "aci_mras.h" as follows:
;
; typedef struct { int ualfa_mras; /* Input: alfa-axis phase voltage at k (Q15) */
; int ubeta_mras; /* Input: beta-axis phase voltage at k (Q15) */
; int ialfa_mras; /* Input: alfa-axis line current at k (Q15) */
; int ibeta_mras; /* Input: beta-axis line current at k (Q15) */
; int ialfa_old; /* History: alfa-axis line current at k-1 (Q15) */
; int ibeta_old; /* History: beta-axis line current at k-1 (Q15) */
; int imalfa_old_high; /* History: alfa-axis magnetizing current at k-1 (Q31) */
; int imalfa_old_low; /* History: alfa-axis magnetizing current at k-1 (Q31) */
; int imbeta_old_high; /* History: beta-axis magnetizing current at k-1 (Q31) */
; int imbeta_old_low; /* History: beta-axis magnetizing current at k-1 (Q31) */
; int imalfa_high; /* Variable: alfa-axis magnetizing current at k (Q31) */
; int imalfa_low; /* Variable: alfa-axis magnetizing current at k (Q31) */
; int imbeta_high; /* Variable: beta-axis magnetizing current at k (Q31) */
; int imbeta_low; /* Variable: beta-axis magnetizing current at k (Q31) */
; int ealfa; /* Variable: alfa-axis back emf at k (Q15) */
; int ebeta; /* Variable: beta-axis back emf at k (Q15) */
; int q; /* Variable: reactive power in reference model (Q15) */
; int q_hat; /* Variable: reactive power in adaptive model (Q15) */
; int error; /* Variable: reactive power error (Q15) */
; int K1; /* Parameter: constant using in reference model (Q10) */
; int K2; /* Parameter: constant using in adaptive model (Q15) */
; int K3; /* Parameter: constant using in adaptive model (Q8) */
; int K4; /* Parameter: constant using in adaptive model (Q15) */
; int K5; /* Parameter: constant using in adaptive model (Q15) */
; int K6; /* Parameter: constant using in adaptive model (Q15) */
; int K7; /* Parameter: constant using in adaptive model (Q15) */
; int Kp; /* Parameter: proportioanl gain (Q15) */
; int Ki_high; /* Parameter: integral gain (Q31) */
; int Ki_low; /* Parameter: integral gain (Q31) */
; int base_rpm; /* Parameter: base motor speed in rpm (Q3) */
; int wr_hat_mras; /* Output: estimated (per-unit) motor speed (Q15) */
; int wr_hat_rpm_mras; /* Output: estimated (rpm) motor speed (Q0) */
; int (*calc)(); /* Pointer to calculation function */
; } ACIMRAS;
;
; Frame Usage Details:
; step | a | b | c | d
;____________|_____________|______________|______________|_____________
; FR0 | tmp2_low | tmp1_high | tmp1_high |
; FR1 | tmp2_high | tmp1_low | tmp1_low |
; FR2 | sign1 | tmp4 | tmp2_high |
; FR3 | tmp1_low | sign1 | tmp2_low |
; FR4 | tmp1_high | sign2 | sign1 |
; FR5 | tmp5 | sign3 | |
; FR6 | tmp4 | tmp5 | |
; FR7 | | tmp2_low | |
; FR8 | | tmp2_high | |
; FR9 | | tmp3_low | |
; FR10 | | tmp3_high | |
;------------|-------------|--------------|--------------|
;sub section | REF_MODEL | ADT_MODEL | PI_MRAS |
;
;================================================================================
.def _aci_mras_calc
;================================================================================
__aci_mras_calc_framesize .set 000Bh
;----------------------------------------------------------------------------------
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
; Important!! Note that the default config is set all 1, if it is neccessary to be
; changed, the module library (e.g., clib_010.lib) must be rebuilt to take the effect.
;================================================================================
_aci_mras_calc:
; Assume now ARP=AR1
POPD *+ ; Keep return address
SAR AR0,*+ ; Keep old frame pointer (FP)
SAR AR1,* ; Keep old stack pointer (SP)
LARK AR0,__aci_mras_calc_framesize ; Load AR0 with frame size
LAR AR0,*0+,AR0 ; AR0->FP0 (new FP), ARP=AR0
;================================================================================
SBRK #3 ; ARP=AR0, AR0->FR0-3 (1st argument)
;----------------------------------------------------------------------------------
LAR AR2,* ; ARP=AR0, AR0->ualfa_mras, AR2->ualfa_mras
;----------------------------------------------------------------------------------
LAR AR3,* ; ARP=AR0, AR0->ualfa_mras, AR2->ualfa_mras, AR3->ualfa_mras
;----------------------------------------------------------------------------------
ADRK #3 ; ARP=AR0, AR0->FR0, AR2->ualfa_mras, AR3->ualfa_mras
;----------------------------------------------------------------------------------
MAR *,AR3 ; ARP=AR3, AR0->FR0, AR2->ualfa_mras, AR3->ualfa_mras
;----------------------------------------------------------------------------------
ADRK #19 ; ARP=AR3, AR0->FR0, AR2->ualfa_mras, AR3->K1
;----------------------------------------------------------------------------------
MAR *,AR2 ; ARP=AR2, AR0->FR0, AR2->ualfa_mras, AR3->K1
;----------------------------------------------------------------------------------
SETC SXM ; Turn sign extension mode on
; ARP=AR2, AR0->FR0, AR2->ualfa_mras, AR3->K1
;----------------------------------------------------------------------------------
SETC OVM ; Set overflow mode
; ARP=AR2, AR0->FR0, AR2->ualfa_mras, AR3->K1
;----------------------------------------------------------------------------------
SPM 0 ; Reset product mode
; ARP=AR2, AR0->FR0, AR2->ualfa_mras, AR3->K1
;----------------------------------------------------------------------------------
.if (ref_model_)
REF_MODEL:
;----------------------------------------------------------------------------------
LT * ; TREG = ualfa_mras (Q15)
; ARP=AR2, AR0->FR0, AR2->ualfa_mras, AR3->K1
;----------------------------------------------------------------------------------
ADRK #3 ; ARP=AR2, AR0->FR0, AR2->ibeta_mras, AR3->K1
;----------------------------------------------------------------------------------
MPY *- ; PREG = ualfa_mras*ibeta_mras (Q30)
; ARP=AR2, AR0->FR0, AR2->ialfa_mras, AR3->K1
;----------------------------------------------------------------------------------
PAC ; ACC = ualfa_mras*ibeta_mras (Q30)
; ARP=AR2, AR0->FR0, AR2->ialfa_mras, AR3->K1
;----------------------------------------------------------------------------------
NEG ; ACC = -ualfa_mras*ibeta_mras (Q30)
; ARP=AR2, AR0->FR0, AR2->ialfa_mras, AR3->K1
;----------------------------------------------------------------------------------
LT *- ; TREG = ialfa_mras (Q15)
; ARP=AR2, AR0->FR0, AR2->ubeta_mras, AR3->K1
;----------------------------------------------------------------------------------
MPY *+,AR0 ; PREG = ubeta_mras*ialfa_mras (Q30)
; ARP=AR2, AR0->FR0, AR2->ialfa_mras, AR3->K1, ARP=AR0
;----------------------------------------------------------------------------------
APAC ; ACC = ubeta_mras*ialfa_mrasualfa_mras*ibeta_mras (Q30)
; ARP=AR0, AR0->FR0, AR2->ialfa_mras, AR3->K1
;----------------------------------------------------------------------------------
SACL *+,1 ; FR0 = tmp2_low = ubeta_mras*ialfa_mrasualfa_mras*ibeta_mras (Q31)
; ARP=AR0, AR0->FR1, AR2->ialfa_mras, AR3->K1
;----------------------------------------------------------------------------------
SACH *+,1,AR2 ; FR1 = tmp2_high = ubeta_mras*ialfa_mrasualfa_mras*ibeta_mras (Q31)
; ARP=AR0, AR0->FR2, AR2->ialfa_mras, AR3->K1, ARP=AR2
;----------------------------------------------------------------------------------
LT * ; TREG = ialfa_mras (Q15)
; ARP=AR2, AR0->FR2, AR2->ialfa_mras, AR3->K1
;----------------------------------------------------------------------------------
ADRK #3 ; ARP=AR2, AR0->FR2, AR2->ibeta_old, AR3->K1
;----------------------------------------------------------------------------------
MPY *- ; PREG = ialfa_mras*ibeta_old (Q30)
; ARP=AR2, AR0->FR2, AR2->ialfa_old, AR3->K1
;----------------------------------------------------------------------------------
PAC ; ACC = ialfa_mras*ibeta_old (Q30)
; ARP=AR2, AR0->FR2, AR2->ialfa_old, AR3->K1
;----------------------------------------------------------------------------------
NEG ; ACC = -ialfa_mras*ibeta_old (Q30)
; ARP=AR2, AR0->FR2, AR2->ialfa_old, AR3->K1
;----------------------------------------------------------------------------------
LT *- ; TREG = ialfa_old (Q15)
; ARP=AR2, AR0->FR2, AR2->ibeta_mras, AR3->K1
;----------------------------------------------------------------------------------
MPY *,AR0 ; PREG = ibeta_mras*ialfa_old (Q30)
; ARP=AR2, AR0->FR2, AR2->ibeta_mras, AR3->K1, ARP=AR0
;----------------------------------------------------------------------------------
APAC ; ACC = ibeta_mras*ialfa_old-ialfa_mras*ibeta_old (Q30)
; ARP=AR0, AR0->FR2, AR2->ibeta_mras, AR3->K1
;----------------------------------------------------------------------------------
SACH *+ ; FR2 = sign1 Keeping sign
; ARP=AR0, AR0->FR3, AR2->ibeta_mras, AR3->K1
;----------------------------------------------------------------------------------
ABS ; ACC = |ibeta_mras*ialfa_old-ialfa_mras*ibeta_old| (Q30)
; ARP=AR0, AR0->FR3, AR2->ibeta_mras, AR3->K1
;----------------------------------------------------------------------------------
SACL *+,1 ; FR3 = tmp1_low = |ibeta_mras*ialfa_old-ialfa_mras*ibeta_old| (Q31)
; ARP=AR0, AR0->FR4, AR2->ibeta_mras, AR3->K1
;----------------------------------------------------------------------------------
SACH *-,1,AR3 ; FR4 = tmp1_high = |ibeta_mras*ialfa_old-ialfa_mras*ibeta_old| (Q31)
; ARP=AR0, AR0->FR3, AR2->ibeta_mras, AR3->K1, ARP=AR3
;----------------------------------------------------------------------------------
LT *,AR0 ; TREG = K1 (Q11)
; ARP=AR3, AR0->FR3, AR2->ibeta_mras, AR3->K1, ARP=AR0
;----------------------------------------------------------------------------------
MPYU * ; PREG = K1*tmp1_low
; ARP=AR0, AR0->FR3, AR2->ibeta_mras, AR3->K1
;----------------------------------------------------------------------------------
ADRK #3 ; ARP=AR0, AR0->FR6, AR2->ibeta_mras, AR3->K1
;----------------------------------------------------------------------------------
SPH *- ; FR6 = tmp4 = PREG high (save partial result)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -