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

📄 foc.asm

📁 该软件是关于交流异步电动机磁场定向调速控制的汇编程序
💻 ASM
📖 第 1 页 / 共 4 页
字号:

*************************************************************
* TEXAS INSTRUMENTS *
* Sensored Speed Field Orientated Control of an AC *
* induction motor *
*************************************************************
* ASYNCHRONOUS Motor (LAFERT) *
* File Name : foc.ASM *
* USER INTERFACE program : foc.BAS *
* ia, ib sampled currents, on line current model, FOC *
* Author : Riccardo Di Gabriele *
*************************************************************
.include  "c240app.h"
.mmregs
***********************************************************
* Start
***********************************************************
.globl _c_int0 ;set _c_int0 as global symbol
.sect "vectors"
b _c_int0 ;reset interrupt handler
_c_int1 b _c_int1 ;
b _c_int2 ;PWM interrupt handler
_c_int3 b _c_int3 ;
_c_int4 b _c_int4 ;
_c_int5 b _c_int5 ;
_c_int6 b _c_int6 ;
.space 16*6 ;reserve 6 words in interrupt table
***********************************************************
* Auxiliary Register used
* ar7 pointer for context save stack
* ar5 used in the interruption c_int2
***********************************************************
stack .usect "blockb2",15 ;space for Status Register
;context save in Page 0
dac_val .usect "blockb2",5 ;space for dac values in
;Page 0
*** Motor LAFERT, ST 61 L4 ***
*** Numeric formats: all 4.12 fixed point format twos
*** complement for negative values (4 integer & sign + 12
*** fractional) except otherwise specified
* Currents: 1000h (4.12)= 4.1 A = Ibase=1.41*In0=1.41*2.9
* Voltages: 1000h (4.12)= 179.6 V = Vbase=1.41*Vn0=1.41*127
* Angles : [0;ffffh] = [0;360] degrees
* Speed : [0;1000h] (4.12) = [0;1500] rpm
*** END Numeric formats
***********************************************************
* Look-up table .includes
* N.B. it includes 256 elements
***********************************************************
.sect "table"
sintab                ;sine wave look-up
.word 0
.word 101
.word 201
.word 301
.word 401
.word 501
.word 601
.word 700
.word 799
.word 897
.word 995
.word 1092
.word 1189
.word 1285
.word 1380
.word 1474
.word 1567
.word 1660
.word 1751
.word 1842
.word 1931
.word 2019
.word 2106
.word 2191
.word 2276
.word 2359
.word 2440
.word 2520
.word 2598
.word 2675
.word 2751
.word 2824
.word 2896
.word 2967
.word 3035
.word 3102
.word 3166
.word 3229
.word 3290
.word 3349
.word 3406
.word 3461
.word 3513
.word 3564
.word 3612
.word 3659
.word 3703
.word 3745
.word 3784
.word 3822
.word 3857
.word 3889
.word 3920
.word 3948
.word 3973
.word 3996
.word 4017
.word 4036
.word 4052
.word 4065
.word 4076
.word 4085
.word 4091
.word 4095
.word 4096
.word 4095
.word 4091
.word 4085
.word 4076
.word 4065
.word 4052
.word 4036
.word 4017
.word 3996
.word 3973
.word 3948
.word 3920
.word 3889
.word 3857
.word 3822
.word 3784
.word 3745
.word 3703
.word 3659
.word 3612
.word 3564
.word 3513
.word 3461
.word 3406
.word 3349
.word 3290
.word 3229
.word 3166
.word 3102
.word 3035
.word 2967
.word 2896
.word 2824
.word 2751
.word 2675
.word 2598
.word 2520
.word 2440
.word 2359
.word 2276
.word 2191
.word 2106
.word 2019
.word 1931
.word 1842
.word 1751
.word 1660
.word 1567
.word 1474
.word 1380
.word 1285
.word 1189
.word 1092
.word 995
.word 897
.word 799
.word 700
.word 601
.word 501
.word 401
.word 301
.word 201
.word 101
.word 0
.word 65435
.word 65335
.word 65235
.word 65135
.word 65035
.word 64935
.word 64836
.word 64737
.word 64639
.word 64541
.word 64444
.word 64347
.word 64251
.word 64156
.word 64062
.word 63969
.word 63876
.word 63785
.word 63694
.word 63605
.word 63517
.word 63430
.word 63345
.word 63260
.word 63177
.word 63096
.word 63016
.word 62938
.word 62861
.word 62785
.word 62712
.word 62640
.word 62569
.word 62501
.word 62434
.word 62370
.word 62307
.word 62246
.word 62187
.word 62130
.word 62075
.word 62023
.word 61972
.word 61924
.word 61877
.word 61833
.word 61791
.word 61752
.word 61714
.word 61679
.word 61647
.word 61616
.word 61588
.word 61563
.word 61540
.word 61519
.word 61500
.word 61484
.word 61471
.word 61460
.word 61451
.word 61445
.word 61441
.word 61440
.word 61441
.word 61445
.word 61451
.word 61460
.word 61471
.word 61484
.word 61500
.word 61519
.word 61540
.word 61563
.word 61588
.word 61616
.word 61647
.word 61679
.word 61714
.word 61752
.word 61791
.word 61833
.word 61877
.word 61924
.word 61972
.word 62023
.word 62075
.word 62130
.word 62187
.word 62246
.word 62307
.word 62370
.word 62434
.word 62501
.word 62569
.word 62640
.word 62712
.word 62785
.word 62861
.word 62938
.word 63016
.word 63096
.word 63177
.word 63260
.word 63345
.word 63430
.word 63517
.word 63605
.word 63694
.word 63785
.word 63876
.word 63969
.word 64062
.word 64156
.word 64251
.word 64347
.word 64444
.word 64541
.word 64639
.word 64737
.word 64836
.word 64935
.word 65035
.word 65135
.word 65235
.word 65335
.word 65435
;table for sine and
;cosinewaves generation
;generated by the BASIC
;program "SINTAB.BAS"
;4.12 format
*** END look-up table .includes
***********************************************************
* Variables and constants initializations
***********************************************************
.data
*** current sampling constants
;ADCIN0 (ia current sampling)
;ADCIN8 (ib current sampling)
Kcurrent .word 1383h ;8.8 format (19.51) sampled,这与2407A的例程是一个数值
;currents normalization constant
Kr .set 0eh ;Kr=T/Tr=3.3117*10-3 (4.12 f),Tr为转子时间常数,Tr=Lr/Rr(详见手册)
Kt .set 1b0h ;Kt=1/(Tr*wBase)=105.42*10-3 (f 4.12)
K .set 148h ;K=65536/200, the K constant
;must take the rotor flux
;position from 0 to 65535 in
;200 sample times
*** axis transformation constants
SQRT3inv .set 093dh ;1/SQRT(3) 4.12 format
SQRT32 .set 0ddbh ;SQRT(3)/2 4.12 format
SR8BIT .word 100h ;used to shift bits 8 right
*** PWM modulation constant
PWMPRD .set 1000 ;PWM Period=2*1000 ->
;Tc=2*1000*50ns=100us (50ns resolution)
*** PI current regulators parameters
Ki .word 0100h ;4.12 format=0.0625
Kpi .word 01000h ;4.12 format=1
Kcor .word 0100h ;4.12 format=0.0625
*** PI speed regulators parameters
Kin .word 35h ;4.12 format=0.012939453
Kpin .word 482bh ;4.12 format=4.510498047
Kcorn .word 0bh ;4.12 format=0.002685546
*** Field Weakening polynomial coefficients
p3 .word -5 ;8.8 format
p2 .word 56
p1 .word -209
p0 .word 300
*** vSqref and VdSr limitations
Vmin .set 0ec00h ;4.12 format=-1.25 pu
Vmax .set 1400h ;4.12 format=1.25 pu
*** iSqref limitations
Isqrefmin .set -3277 ;4.12 format=-0.8 pu
Isqrefmax .set 3277 ;4.12 format=0.8 pu
*** Speed calculation constants
Kspeed .set 0da7h ;this constant is needed only
;with encoder it is used to
;convert encoder pulses to a speed value.
;8.8 format = 13.65
SPEEDSTEP .set 30 ;speed samplig period =
;current sampling period *
;SPEEDSTEP
ctrl_n ;label control variable page
.bss tmp,1 ;temporary variable (to use in ISR only !!!)
.bss tmp1,1 ;temporary variable
.bss n_ref8_8,1 ;8.8 format reference speed
;for Field Weakening behavior
.bss option,1 ;virtual menu option number
.bss daout,1 ;address of the variable to
;send to the DACs
.bss daouttmp,1 ;value to send to the DACs
*** DAC displaying table starts here
.bss ia,1 ;phase current ia
.bss ib,1 ;phase current ib
.bss ic,1 ;phase current ic
.bss t1,1 ;SVPWM T1 (see SV PWM references for details)
.bss t2,1 ;SVPWM T2 (see SV PWM references for details)
.bss Vref1,1 ;variable for sector calculation
.bss Vref2,1 ;variable for sector calculation
.bss Vref3,1 ;variable for sector calculation
.bss VDC,1 ;DC Bus Voltage
.bss taon,1 ;PWM commutation instant phase 1
.bss tbon,1 ;PWM commutation instant phase 2
.bss tcon,1 ;PWM commutation instant phase 3
.bss iSalfa,1 ;alfa-axis current即啊拉法轴电流分量
.bss iSbeta,1 ;beta-axis current即倍他轴电流
.bss vSal_ref,1 ;alfa-axis reference voltage
.bss vSbe_ref,1 ;beta-axis reference voltage
.bss iSdref,1 ;d-axis reference current
.bss iSqref,1 ;q-axis reference current
.bss iSd,1 ;d-axis current
.bss iSq,1 ;q-axis current
.bss vSdref,1 ;d-axis reference voltage
.bss vSqref,1 ;q-axis reference voltage
.bss epiq,1 ;q-axis current regulator error
.bss epid,1 ;d-axis current regulator error
.bss xiq,1 ;q-axis current regulator integral component
.bss xid,1 ;d-axis current regulator integral component
.bss n,1 ;speed
.bss n_ref,1 ;speed reference
.bss epin,1 ;speed error (used in speed regulator)
.bss xin,1 ;speed regulator integral component
.bss X,1 ;SVPWM variable
.bss Y,1 ;SVPWM variable
.bss Z,1 ;SVPWM variable
.bss sector,1 ;SVPWM sector
.bss Teta_cm1,1 ;rotor flux position with current
;model used only in the
;communication program
.bss sinTeta_cm,1 ;sine rotor flux position with
;current model, 4.12 f
.bss cosTeta_cm,1 ;cosine rotor flux position with
;current model, 4.12 f
.bss i_mr,1 ;magnetizing current (used only in
;the current model), 4.12 f
.bss fs,1 ;rotor flux speed 4.12 f
*** END DAC displaying table
.bss run,1 ;initialization flag

⌨️ 快捷键说明

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