📄 refframe.dsp
字号:
/***************************************************************************************
* *
* Library: Configuration of Reference Frame Functions for Park and *
* Clarke Transformations *
* *
* File: refframe.dsp *
* *
* Description: Referance Frame Control Code File *
* Purpose : Library Routines for Referance Frame Control *
* *
* Author : JC *
* Version : 1.0 *
* Date : January, 2002 *
* Modification History: None *
* *
* Embedded Control Systems *
* Analog Devices Inc. *
***************************************************************************************/
#include <main.h>;
/***************************************************************************************
* Calculate Configuration Register Contents from Parameters *
***************************************************************************************/
//None
/***************************************************************************************
* Constants Defined in the Module *
***************************************************************************************/
#define inverse_root3_ 0x49e6
#define root3_over_2_ 0x6ed9
#define minus_1_over_2_ 0xc000
/***************************************************************************************
* Routines Defined in this Module *
***************************************************************************************/
.global refframe_Forward_Clarke_;
.global refframe_Reverse_Clarke_;
.global refframe_Rotate_Vector_;
/***************************************************************************************
* Global Variables Defined in this Module *
***************************************************************************************/
/* None */
/***************************************************************************************
* Local Variables Defined in this Module *
***************************************************************************************/
/* None*/
/***************************************************************************************
* *
* Type: Routine *
* *
* Call: call refframe_Forward_Clark_; *
* *
* Performs Forward Clark Transformation *
* *
* Inputs and outputs are in 1.15 format *
* *
* Input: I1 = address of input vector (Va,Vb, Vc) *
* M1 = 1 *
* L1 = 0 *
* I0 = address of output vector (Vx,Vy) *
* M0 = 1 *
* L0 = 0 *
* input vector contains the *
* three-phase components *
* *
* Output: output vector contains components *
* in the stationary reference frame *
* *
* Modified: MX0, MY0, MR, AR, I0, I1 *
* *
***************************************************************************************/
.section/pm seg_pmcode;
refframe_Forward_Clarke_:
ar=dm(I1+=M1); // ar : Va
dm(I0+=M0) = ar; // Vx : ar
mx0 = inverse_root3_; // mx0 : 0.57735
my0 = dm(I1+=M1); // ax0 : Vb
mr = mx0*my0 (ss), my0 = dm(I1+=M1); // mr1 : 0.57735*Vb, my0 : Vc
mr = mr - mx0*my0 (ss); // mr : 0.57735*Vb - 0.57735*Vc
sat mr;
DM(I0+=M0)=mr1; // Vy : mr1
rts;
/***************************************************************************************
* *
* Type: Routine *
* *
* Call: call refframe_Reverse_Clark_; *
* *
* Performs Reverse Clark Transformation *
* *
* Inputs and outputs are in 1.15 format *
* *
* Input: I1 = address of input vector (Vx,Vy) *
* M1 = 1 *
* L1 = 0 *
* I2 = address of output vector (Va,Vb, Vc) *
* M2 = 1 *
* L2 = 0 *
* input vector contains components *
* in the stationary reference frame *
* *
* Output: output vector contains the *
* three-phase components *
* *
* *
* Modified: MX0, MY0, MX1, MY1, MR, I1, I2 *
* *
***************************************************************************************/
refframe_Reverse_Clarke_:
mx0=dm(I1+=M1); // mx0: Vx
mx1=dm(I1+=M1); // mx1: Vy
dm(I2+=M2)=mx0; // Va : mx0
my0=minus_1_over_2_; // my0: -0.5
my1=root3_over_2_; // my1: 0.866
mr=mx0*my0 (ss); // mr1: -0.5*Vx
mr=mr+mx1*my1 (ss); // mr1: -0.5*Vx + 0.866*Vy
SAT mr;
dm(I2+=M2)=mr1, mr=mx0*my0 (ss); // Vb: mr1 then mr1: -0.5*Vx
mr=mr-mx1*my1 (ss); // mr1: -0.5*Vx - 0.866*Vy
SAT mr;
dm(I2+=M2)=mr1; // Vc: mr1
rts;
/***************************************************************************************
* *
* Type: Routine *
* *
* Call: call refframe_Rotate_Vector_; *
* *
* Applies Rotation to vector pointed to by I0 *
* Inputs and outputs are in 1.15 format *
* *
* Input: MY0 = cosine of angle of rotation *
* MY1 = sine of angle of rotation (q) *
* I0 = address of input vector (Vi1,Vi2) *
* M0 = 1 *
* L0 = 0 *
* I1 = address of output vector (Vo1,Vo2) *
* M1 = 1 *
* L1 = 0 *
* input vector contains the components of the *
* vector to be transformed. *
* *
* Output: Output vector contains the components of the rotated vector. *
* *
* Modified: MX0, MX1, MR, I0, I1 *
* *
***************************************************************************************/
refframe_Rotate_Vector_:
mx0=DM(I0+=M0); // mx0: Vi1
mr=mx0*my0 (ss), mx1=DM(I0+=M0); // mr: Vi1*cos(q) then mx1: Vi2
mr=mr-mx1*my1(ss); // mr: Vi1*cos(q)-Vi2*sin(q)
SAT mr;
DM(I1+=M1)=mr1, mr=mx0*my1 (ss); // Vo1: mr then mr: Vi1*sin(q)
mr=mr+mx1*my0 (ss); // mr: Vi1*sin(q)+Vi2*cos(q)
SAT mr;
DM(I1+=M1)=mr1; // Vy: mr
rts;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -