📄 mc1.c
字号:
/** ###################################################################
** THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
** Filename : MC1.C
** Project : vvvf_56F8346
** Processor : 56F8346
** Beantype : MC_SpaceVectorMod
** Version : Bean 01.006, Driver 01.09, CPU db: 2.87.097
** Compiler : Metrowerks DSP C Compiler
** Date/Time : 2008-3-7, 9:38
** Abstract :
** This bean encapsulates modulation techniques. The Modulation techniques
** are used in various motor control applications. They are considered
** a direct bridge between a function eliminating voltage ripple on the
** DCBus and real hardware of the Pulse Width Modulation (PWM) block in the Digital
** Signal Processor (DSP).
** Settings :
** This bean has no settings.
** Contents :
** svmStd - int MC1_svmStd(mc_sPhase *p_AlphaBeta,mc_s3PhaseSystem *p_abc);
** svmU0n - int MC1_svmU0n(mc_sPhase *p_AlphaBeta,mc_s3PhaseSystem *p_abc);
** svmU7n - int MC1_svmU7n(mc_sPhase *p_AlphaBeta,mc_s3PhaseSystem *p_abc);
** svmAlt - int MC1_svmAlt(mc_sPhase *p_AlphaBeta,mc_s3PhaseSystem *p_abc);
** svmPwmIct - int MC1_svmPwmIct(mc_sPhase *p_AlphaBeta,mc_s3PhaseSystem *p_abc);
** svmSci - int MC1_svmSci(mc_sPhase *p_AlphaBeta,mc_s3PhaseSystem *p_abc);
** svmElimDcBusRip - void MC1_svmElimDcBusRip(Frac16 invModIndex,Frac16 u_DcBusMsr,mc_sPhase...
**
** (c) Freescale Semiconductor
** 2004 All Rights Reserved
**
** (c) Copyright UNIS, spol. s r.o. 1997-2005
** UNIS, spol. s r.o.
** Jundrovska 33
** 624 00 Brno
** Czech Republic
** http : www.processorexpert.com
** mail : info@processorexpert.com
** ###################################################################*/
/* MODULE MC1. */
#include "MC1.h"
#include "prototype.h"
/* Undefine CodeWarrior intrinsic functions */
#undef sub
#undef add
/* Define names for the volatile registers */
#define MR0 X:<0x0030
#define MR1 X:<0x0031
#define MR2 X:<0x0032
#define MR3 X:<0x0033
#define MR4 X:<0x0034
/* Static function prototype(s) */
static asm Frac16 get_sign (Frac16 val);
/* The sector assignment table - used by modules svmSci and svmPwmIct */
static const int sectors[] = {2,2,6,1,4,3,5};
/*
** ===================================================================
** Method : MC1_svmStd (bean MC_SpaceVectorMod)
**
** Description :
** This function calculates appropriate duty-cycle ratios,
** which are needed for generating the given stator
** reference voltage vector using a special Space Vector
** Modulation technique, termed Standard Space Vector
** Modulation.
** Parameters :
** NAME - DESCRIPTION
** * p_AlphaBeta - Pointer to the
** structure containing direct (alpha/a)
** and quadrature (beta/b) components of
** the stator voltage vector.
** * p_abc - Pointer to the structure containing
** calculated duty-cycle ratios of the
** 3-Phase system.
** Returns :
** --- - The function returns an integer value
** representing the Sector number in which
** the instantaneous stator reference
** voltage vector is located.
** ===================================================================
*/
int asm MC1_svmStd(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)/2 */
/* 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 */
asr B /* B = (1+beta)/2 */
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)/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 */
asr B /* B =(1+alpha*sqrt(3)/2-beta/2)/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 */
jmp >LABEL_END /* goto end of module */
LABEL_3:
/* Find sector -----------------------------------------------------*/
/* */
/* if (B > 0 && A <= 0 && MR0 <= 0) then sector 4 */
/* */
/* Sector 4 calculation(s) -----------------------------------------*/
/* PhaseA = (1+alpha*sqrt(3)/2+beta/2)/2 */
/* PhaseB = PhaseA-alpha*sqrt(3)/2+beta/2 */
/* PhaseC = PhaseB-beta */
/* Y0 = 4 */
/*------------------------------------------------------------------*/
move.w #0x7FFF,A /* A = 1 */
sub B,A /* A = 1+alpha*sqrt(3)/2+beta/2 */
asr A /* A =(1+alpha*sqrt(3)/2+beta/2)/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 */
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)/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 */
asr A /* A =(1-alpha*sqrt(3)/2-beta/2)/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 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -