⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mc1.c

📁 基于56F8346的异步电机VVVF控制程序。
💻 C
📖 第 1 页 / 共 5 页
字号:

LABEL_3:
    /* Find sector -----------------------------------------------------*/
    /*                                                                  */
    /* if (B > 0 && A <= 0 && MR0 <= 0) then sector 4                   */
    /*                                                                  */
    /* Sector 4 calculation(s) -----------------------------------------*/
    /* PhaseA = 0                                                       */
    /* PhaseB = PhaseA-alpha*sqrt(3)/2+beta/2                           */
    /* PhaseC = PhaseB-beta                                             */
    /* Y0     = 4                                                       */
    /*------------------------------------------------------------------*/
    move.w  #0x0000,A               /* A   = 0                          */
    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   */
    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 = 0                                                       */
    /* PhaseC = PhaseB-beta                                             */
    /* PhaseA = PhaseC+alpha*sqrt(3)/2+beta/2                           */
    /* Y0     = 6                                                       */
    /*------------------------------------------------------------------*/
    move.w  #0x0000,B               /* B   = 0                          */
    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 = 0                                                       */
    /* PhaseA = PhaseC+alpha*sqrt(3)/2+beta/2                           */
    /* PhaseB = PhaseA-alpha*sqrt(3)/2+beta/2                           */
    /* Y0 = 2                                                           */
    /*------------------------------------------------------------------*/
    move.w  #0x0000,A               /* A   = 0                          */
    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_svmPwmIct (bean MC_SpaceVectorMod)
**
**     Description :
**         This function calculates the appropriate duty-cycle
**         ratios needed to generate a given stator reference
**         voltage, using a conventional Inverse Clark
**         Transformation.
**     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_svmPwmIct(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                                           */
    /* B    = alpha*sqrt(3)/2-beta/2                                    */
    /* A    =-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                 /* A   = alpha*sqrt(3)/2            */
    move.w  X:(R2+1),B
    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,A                     /* A   = -beta/2                    */
    sub     C,A                     /* A   = -alpha*sqrt(3)/2-beta/2    */

    /*------------------------------------------------------------------*/
    /* Find sector in the hexagon                                       */
    /*------------------------------------------------------------------*/
    clr.w   Y0                      /* Y0 = 0                           */
    tst     D                       /* test: beta                       */
    ble     LABEL_1                 /* if (MR0 <= 0) then goto LABEL_1  */
    inc.w   Y0                      /* else          then Y0+=1;        */

LABEL_1:
    tst     B                       /* test: B                          */
    ble     LABEL_2                 /* if (B <= 0)  then goto LABEL_2   */
    add.w   #0x2,Y0                 /* else         then Y0+=2;         */

LABEL_2:
    tst     A                       /* test: A                          */
    ble     LABEL_3                 /* if (A <= 0)  then goto LABEL_3   */
    add.w   #0x4,Y0                 /* else         then Y0+=4;         */

LABEL_3:
    /* Calculation(s) --------------------------------------------------*/
    /* MR0  = alpha/2                                                   */
    /* A    = beta*sqrt(3)/2-alpha/2                                    */
    /*------------------------------------------------------------------*/
    move.w  D,Y1                    /* Y1  = beta                       */
    mpyr    Y1,X0,A     X:(R2)+,B   /* A   = beta*sqrt(3)/2             */
                                    /* B   = alpha                      */
    asr     B                       /* B   = alpha/2                    */
    move.w  B,D                     /* MR0 = alpha/2                    */
    sub     B,A                     /* A   = beta*sqrt(3)/2-alpha/2     */
    clr.w   X0                      /* X0  = 0                          */
    move.w  #0x4000,B               /* B   = 0.5                        */
    add     D,B                     /* B   = 0.5+alpha/2                */
    move.w  B,X:(R3)                /* phaseA = B                       */
    tst     B                       /* test: B                          */
    bge     LABEL_4                 /* 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -