User Tools

Site Tools

blog:2024-09-30_003



2024-09-30 Share: TI SVPWM

Note

  • Code Example for Calculation of T1 and T2 Using Equation 7
    • .data
      ********************************************************************
      ** Decomposition matrices indexed by the sector, s, Uout is in **
      ********************************************************************
      decomp_ .WORD 20066 ; D1–scaled by 2 to the 14th power
      .WORD -11585
      .WORD 0
      .WORD 23170
      .WORD -20066
      .WORD 11585
      .WORD 20066
      .WORD 11585
      .WORD 0
      .WORD 23170
      .WORD -20066
      .WORD -11585
      .WORD 0
      .WORD -23170
      .WORD -20066
      .WORD 11585
      .WORD -20066
      .WORD -11585
      .WORD 20066
      .WORD -11585
      .WORD 20066
      .WORD 11585
      .WORD 0
      .WORD -23170
      ; .
      ; .
      .bss decomp,24 ; decomposition matrices
      .bss temp,1 ; temporary storage
      .txt
      ********************************************************************
      ** Initialize the decomposition matrices **
      ********************************************************************
      LAR AR0,#decomp ; Point to 1st destination
      LAR AR1,#(24-1) ; 24 entries
      LACC #decomp_ ; Point to 1st data item
      MAR *,AR0 ; Point to AR0
      init_table
      TBLR *+,1 ; Move data&pnt to nextdesti.
      ADD #1 ; Point to next data item
         BANZ init_table,0        ; Continue if there is more
      ; .
      ; .
      ;-------------------------------------------------------------------
      ; Calculate T1&T2 as compare values based on: Tpwn Uout=V1*T1+V2*T2
      ;
      ; i.e. [T1 T2]=Tpwn*inverse[V1 V2]*Uout
      ; i.e. [0.5*T1 0.5*T2]=Tp*inverse[V1 V2]*Uout
      ; i.e. [0.5*C1 0.5*C2]=inverse[V1 V2]*Uout=M(sector)*Uout
      ; where C1=T1/Tp, C2=T2/Tp, are normalized T1&T2 wrt Tp
      ; M(sector)=inverse of [V1 V2] = decomposition matrix
      ; obtained through table lookup
      ; Uout=Transpose of [Ud Uq]
      ; Tp=Timer 1 period = 0.5*Tpwm
      ; Tpwm=PWM period Tpwm
      ; Input S: sector of Uout (0-5)
      ; Ud: d compo. of Uout(0-1/sqrt(2)), D2(Scaled by 2**13)
      ; Uq: q compo. of Uout(0-1/sqrt(2)), D2(Scaled by 2**13)
      ; t1_period_: Timer period (for PWM freq)
      ; t1_periods: Timer period in D10 (Scaled by 2**5)
      ; Output cmp_0: 0.5(1-0.5C1-0.5C2)Tp cmp value for 1st-to-tog ch
      ; cmp_1: cmp_0+0.5C1Tp cmp value for 2nd-to-tog ch
      ; cmp_2: cmp_1+0.5C2Tp cmp value for 3rd-to-tog ch
      ;--------------------------------------------------------------------
         LACC #decomp            ;
         ADD S,2                 ;
         SACL temp               ; get the pointer
         LAR AR0,temp            ; point to parameter table
      ; Calculate 0.5C1 based on 0.5C1=Ud*M(1,1)+Uq*M(1,2)
         LT Ud                   ; D2
         MPY *+                  ; M(1,1) Ud: D2*D1=D(3+1)
         PAC                     ; D4
         LT Uq                   ; D4
         MPY *+                  ; M(1,2) Uq: D2*D1=D(3+1)
         APAC                    ; 0.5*C1: D4+D4=D4
         BGEZ cmp1_big0          ; continue if bigger than zero
         ZAC                     ; set to 0 if less than zero
         cmp1_big0 SACH temp     ; D4
         LT temp                 ; D4
         MPY t1_periods          ; *Tp: D4*D10 = D(14+1)
         PAC                     ;
         Sach cmp_1              ; 0.5C1Tp: D15 (integer)
      ; Calculate 0.5C2 based on 0.5C2=Ud*M(2,1)+Uq*M(2,2)
      LT Ud ; D2
      MPY *+ ; M(2,1) Ud: D2*D1=D(3+1)
      PAC ; D4
      LT Uq ; D4
      MPY *+ ; M(2,2) Uq: D2*D1=D(3+1)
      APAC ; 0.5*C2: D4+D4=D4
      BGEZ cmp2_big0 ; continue if bigger than zero
      ZAC ; zero it if less than zero
      cmp2_big0 SACH temp ; D4
      LT temp ; D4
      MPY t1_periods ; *Tp: D4*D10 = D(14+1)
      PAC ;
      Sach cmp_2 ; 0.5C2Tp: D15 (integer)
      ; Calculate compare value 3 based on 0.5C0Tp=(1-0.5C1-0.5C2)Tp
      LACC #t1_period_ ; Calculate 0.5*C0
      SUB cmp_1 ;
      SUB cmp_2 ; 0.5*C0Tp = (1-0.5*C1 -0.5*C2)Tp: D15
      BGEZ cmp0_big0 ; continue if bigger than zero
      ZAC ; zero it if less than zero
      cmp0_big0 sfr ; divide by 2
      SACH cmp_0 ; 0.25*C0Tp: D15 (integer)

TAGS

  • 16 person(s) visited this page until now.

Permalink blog/2024-09-30_003.txt · Last modified: 2024/10/01 17:10 by jethro

oeffentlich