📄 mc1.c
字号:
move.w A,X:(R3+1) /* PhaseB = A */
sub D,A /* A = A-beta */
move.w A,X:(R3+2) /* PhaseC = A */
move.w #4,Y0 /* Y0 = 4 */
bra LABEL_END /* goto end of module */
LABEL_1:
/* Find sector -----------------------------------------------------*/
/* */
/* if (B <= 0 && A > 0 && MR0 > 0)then sector 1 */
/* */
/* Sector 1 calculation(s) -----------------------------------------*/
/* PhaseC = 1-alpha*sqrt(3)/2-beta/2 */
/* PhaseB = PhaseC+beta */
/* PhaseA = PhaseB+alpha*sqrt(3)/2-beta/2 */
/* Y0 = 1 */
/*------------------------------------------------------------------*/
tst A /* test: alpha*sqrt(3)/2-beta/2 */
ble LABEL_4 /* if (A <= 0) then goto LABEL_4 */
tst D /* test: beta */
ble LABEL_5 /* if (MR0 <= 0) then goto LABEL_5 */
move.w #0x7FFF,A /* A = 1 */
add B,A /* A = 1-alpha*sqrt(3)/2-beta/2 */
move.w A,X:(R3+2) /* PhaseC = A */
add D,A /* A = A+beta */
move.w A,X:(R3+1) /* PhaseB = A */
add C,B /* B = -beta/2 */
add C,B /* B = alpha*sqrt(3)/2-beta/2 */
add B,A /* A = A+alpha*sqrt(3)/2-beta/2 */
move.w A,X:(R3) /* PhaseA = A */
move.w #1,Y0 /* Y0 = 1 */
bra LABEL_END /* goto end of module */
LABEL_5:
/* Find sector -----------------------------------------------------*/
/* */
/* if (B <= 0 && A > 0 && MR0 <= 0) then sector 6 */
/* */
/* Sector 6 calculation(s) -----------------------------------------*/
/* PhaseB = 1-alpha*sqrt(3)/2+beta/2 */
/* PhaseC = PhaseB-beta */
/* PhaseA = PhaseC+alpha*sqrt(3)/2+beta/2 */
/* Y0 = 6 */
/*------------------------------------------------------------------*/
move.w #0x7FFF,B /* B = 1 */
sub A,B /* B = 1-alpha*sqrt(3)/2+beta/2 */
move.w B,X:(R3+1) /* PhaseB = B */
sub D,B /* B = B-beta */
move.w B,X:(R3+2) /* PhaseC = B */
sub C,A /* A = -beta/2 */
sub C,A /* A = -alpha*sqrt(3)/2-beta/2 */
sub A,B /* B = B+alpha*sqrt(3)/2+beta/2 */
move.w B,X:(R3) /* PhaseA = B */
move.w #6,Y0 /* Y0 = 6 */
bra LABEL_END /* goto end of module */
LABEL_4:
/* Find sector -----------------------------------------------------*/
/* */
/* if (B <= 0 && A <= 0) then sector 2 */
/* */
/* Sector 2 calculation(s) -----------------------------------------*/
/* PhaseC = 1-beta/2 */
/* PhaseA = PhaseC+alpha*sqrt(3)/2+beta/2 */
/* PhaseB = PhaseA-alpha*sqrt(3)/2+beta/2 */
/* Y0 = 2 */
/*------------------------------------------------------------------*/
move.w #0x7FFF,A /* A = 1 */
sub D,A /* A = 1-beta */
move.w A,X:(R3+2) /* PhaseC = A */
sub B,A /* A = A+alpha*sqrt(3)/2+beta/2 */
move.w A,X:(R3) /* PhaseA = A */
add C,B /* B = -beta/2 */
add C,B /* B = alpha*sqrt(3)/2-beta/2 */
sub B,A /* A = A-alpha*sqrt(3)/2-beta/2 */
move.w A,X:(R3+1) /* PhaseB = A */
move.w #2,Y0 /* Y0 = 2 */
LABEL_END:
/* Limit outputs ---------------------------------------------------*/
/* */
/* if (phaseA < 0 ) phaseA = 0; */
/* if (phaseB < 0 ) phaseB = 0; */
/* if (phaseC < 0 ) phaseC = 0; */
/*------------------------------------------------------------------*/
clr.w X0 /* X0 = 0 */
move.w X:(R3),B /* B = phaseA */
tst B /* test: B */
bge LABEL_6 /* if (B >= 0) then goto LABEL_6 */
move.w X0,X:(R3) /* else then phaseA = 0 */
LABEL_6:
move.w X:(R3+1),B /* B = phaseB */
tst B /* test: B */
bge LABEL_7 /* if (B >= 0) then goto LABEL_7 */
move.w X0,X:(R3+1) /* else then phaseB = 0 */
LABEL_7:
move.w X:(R3+2),B /* B = phaseC */
tst B /* test: B */
bge LABEL_8 /* if (B >= 0) then goto LABEL_8 */
move.w X0,X:(R3+2) /* else then phaseC = 0 */
LABEL_8:
moveu.w X:(SP),OMR
nop
suba #2,SP
rts
}
/*
** ===================================================================
** Method : MC1_svmAlt (bean MC_SpaceVectorMod)
**
** Description :
** This function calculates the appropriate duty-cycle
** ratios to generate a given stator reference voltage using
** a special Space Vector Modulation technique, termed Space
** Vector Modulation with Alternate Nulls. In this technique,
** null switching states are combined from state O000 in
** even sectors and state O111 in odd sectors.
** Parameters :
** NAME - DESCRIPTION
** * p_AlphaBeta - Pointer to structure
** with direct (alpha/a) and quadrature
** (beta/b) components of the stator
** voltage vector.
** * p_abc - Pointer to structure where the
** calculated duty-cycles will be stored.
** Returns :
** --- - The function returns an integer value
** representing the Sector number in which
** the instantaneous stator reference
** voltage vector is located.
** ===================================================================
*/
int asm MC1_svmAlt(mc_sPhase *p_AlphaBeta,mc_s3PhaseSystem *p_abc)
{
adda #0x2,SP
move.w OMR,X:(SP)
bfclr #0x10,OMR /* set saturation OFF (SA = 0) */
/* Calculation(s) --------------------------------------------------*/
/* MR0 = beta */
/* MR1 = alpha*sqrt(3)/2 */
/* A = alpha*sqrt(3)/2-beta/2 */
/* B = -alpha*sqrt(3)/2-beta/2 */
/*------------------------------------------------------------------*/
move.w x:(R2+1),D /* beta */
move.w X:(R2)+,Y0 /* Y0 = alpha */
move.w #0x6EDA,X0 /* X0 = sqrt(3)/2 */
mpyr Y0,X0,A X:(R2)+,B /* A = alpha*sqrt(3)/2 */
asr B /* B = beta/2 */
move.w A,C /* MR1 = alpha*sqrt(3)/2 */
sub B,A /* A = alpha*sqrt(3)/2-beta/2 */
move.w A,B /* B = alpha*sqrt(3)/2-beta/2 */
sub C,B /* B = -beta/2 */
sub C,B /* B = -alpha*sqrt(3)/2-beta/2 */
/* Find sector -----------------------------------------------------*/
/* */
/* if (B > 0 && A > 0) then sector 5 */
/* */
/* Sector 5 calculation(s) -----------------------------------------*/
/* PhaseB = 1+beta */
/* PhaseA = PhaseB+alpha*sqrt(3)/2-beta/2 */
/* PhaseC = PhaseA-alpha*sqrt(3)/2-beta/2 */
/* Y0 = 5 */
/*------------------------------------------------------------------*/
tst B /* test: -alpha*sqrt(3)/2-beta/2 */
ble LABEL_1 /* if (B <= 0) then goto LABEL_1 */
tst A /* test: alpha*sqrt(3)/2-beta/2 */
ble LABEL_2 /* if (A <= 0) then goto LABEL_2 */
move.w #0x7FFF,B /* B = 1 */
add D,B /* B = 1+beta */
move.w B,X:(R3+1) /* PhaseB = B */
add A,B /* B = B+alpha*sqrt(3)/2-beta/2 */
move.w B,X:(R3) /* PhaseA = B */
sub C,A /* A = -beta/2 */
sub C,A /* A = -alpha*sqrt(3)/2-beta/2 */
add A,B /* B = B-alpha*sqrt(3)/2-beta/2 */
move.w B,X:(R3+2) /* PhaseC = B */
move.w #5,Y0 /* Y0 = 5; */
jmp LABEL_END /* goto end of module */
LABEL_2:
/* Find sector -----------------------------------------------------*/
/* */
/* if (B > 0 && A <= 0 && MR0 > 0) then sector 3 */
/* */
/* Sector 3 calculation(s) -----------------------------------------*/
/* PhaseA = 1+alpha*sqrt(3)/2-beta/2 */
/* PhaseC = PhaseA-alpha*sqrt(3)/2-beta/2 */
/* PhaseB = PhaseC+beta */
/* Y0 = 3 */
/*------------------------------------------------------------------*/
tst D /* test: beta */
ble LABEL_3 /* if (MR0 <= 0) then goto LABEL_3 */
move.w #0x7FFF,B /* B = 1 */
add A,B /* B = 1+alpha*sqrt(3)/2-beta/2 */
move.w B,X:(R3) /* PhaseA = B */
sub C,A /* A = -beta/2 */
sub C,A /* A = -alpha*sqrt(3)/2-beta/2 */
add A,B /* B = B-alpha*sqrt(3)/2-beta/2 */
move.w B,X:(R3+2) /* PhaseC = B */
add D,B /* B = B+beta */
move.w B,X:(R3+1) /* PhaseB = B */
move.w #3,Y0 /* Y0 = 3 */
bra LABEL_END /* goto end of module */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -