The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers.    


Datasheet Search Engine   
 
Part # or Description: • 5V RS232 Driver • 2SC5066* • "Real Time Clock" • "USB connector" • "blue led" 5mm • 10 watt zener diode • 2N3055* motorola
 
Search Tip: Try entering the part number only. Include a wildcard (eg. lm317* or 1n4148*)

 

 

Michel Platnic Digital Signal Processor Solutions Abstract T


Datasheet Thumbnail

  

Download PDF



Top Searches for this datasheet



Implementation Vector Control PMSM Using TMS320F240
Michel Platnic Digital Signal Processor Solutions
Abstract
This document presents solution controlling permanent magnet synchronous motor using Texas Instruments TMS320C24x digital signal processor (DSP). TMS320C24x family DSPs offers cost-effective design intelligent controllers brushless motors that fulfill enhanced operations consisting fewer system components, lower system cost, increased performances. control method presented relies field orientated control (FOC) together with field-weakening operation. This algorithm maintains efficiency wide range speeds, above nominal speed, takes into consideration torque changes with transient phases controlling flux directly from rotor coordinates. This report describes practical solution corresponding results.
Contents
Introduction Application Description.4 Convention.9 Software Organization Parameter Adaptation Field Weakening Results User Interface Conclusion References.37 Appendix TMS320F240 Software Appendix Linker File Appendix Sinewave Table Appendix Qbasic User Interface
Figures
Figure Figure Figure Figure Figure Three-Phase Synchronous Motor with Permanent Magnet Pair Pole Rotor Three BEMF Waveforms 1000rpm Inverter Topology.5 View TMS320F240 Board.6 ACPM750E with MCK240.7
Digital Signal Processing Solutions
December 1998
Stator Current Magnet Flux Space Vectors Rotating Reference Frame Relationship with Stationary Reference Frame Figure PMSM Control with Field Orientation.8 Figure Format Correspondence Diagram Figure Software Initialization Operating System.11 Figure General Software Flowchart Figure Control Algorithm Timing Figure Waiting Loop/User Interface Figure Control Routine Block Diagram Figure Block Diagram Including Closed Loop Field Weakening Control Figure Current Measurement Chain Figure Current Sensing Interface Block Diagram.17 Figure Sensed Current Values before Scaling.18 Figure SinG Calculation Using Sine Look-Up Table Figure SVPWM, Vectors Sectors Figure Assigning Right Duty Cycle Right Motor Phase Figure Field Weakening Real Operation.27 Figure Maximum Nominal Torque Speed.28 Figure Field Weakening Voltage Constraints.29 Figure Control Range PMSM Steady State.29 Figure Field Weakening Function Structure.30 Figure Speed Transient from 1000 Figure Speed Transient from 3000 Nominal Torque.33 Figure Speed Transient from -1000 1000 Nominal Torque Figure Speed Transient from 3000 Graph1 without Torque, Graph2 with 1.1Nm.34 Figure Steady-State Speed Nominal Speed Above Maximal Torque Figure Speed/Torque Plot.35 Figure User Screen.36
Figure
Introduction
Texas Instruments TMS320F240 Controller suitable wide range motor drives. TMS320F240 provides single chip solution integrating on-chip high computational power along with peripherals necessary electrical motor control. main effect this combination possible implementation advanced controls such vector control. High range controls increase system performance, reliability, efficiency, cost. This application report describes speed control implemented TMS320F240 three-phase Permanent Magnet drive with sinewave currents.
Permanent Magnet Motor
There mainly kinds three-phase synchronous motors (SM). uses rotor windings from stator. other uses permanent magnets. motor fitted with rotor windings requires brushes obtain current supply generate rotor flux. contacts are, this case, made rings have commutator segment. lifetime both brushes motor similar. drawbacks this structure maintenance needs lower reliability then limited. Replacing common rotor field windings pole structure with permanent magnets motor into category brushless motors. possible build brushless permanent magnet motors with even number magnet poles. magnets enables efficient radial space replaces rotor windings, therefore suppressing rotor copper losses. Advanced magnet materials permit considerable reduction motor dimensions while maintaining very high power density.
Figure Three-Phase Synchronous Motor with Permanent Magnet Pair Pole Rotor
application studied this report concerns permanent magnet motor.
Sinewave Currents
configurations permanent magnet brushless motor drives usually considered, depending back-electromagnetic force (BEMF) waveform:
Implementation Vector Control PMSM Using TMS320F240
Sinusoidal type Trapezoidal type
Different control strategies (and control hardware) implemented each. trapezoidal BEMF motor usually called brushless motor (BLDC). appropriate control turns stator phases using coarse rotor position. This control described application report, Implementation Speed Controlled Brushless Drive Using TMS320F240, literature number BPRA064. Sinewave stator currents drive sinusoidal BEMF drive called three-phase permanent magnet synchronous motor (PMSM). stator magnetic field accordance rotor field. This application report describes TMS320F240 Controller together with system considerations that allow high performance extracted from this category motor drives, also called BLDC phases-on.
Application Description
Motor Characteristics
synchronous machine with permanent magnets described this application report three-phase connected motor. motor includes following characteristics:
Stator phase line-to-line inductance: 4.8mH Line-to-line resistance: 2.1W Pole pairs: Nominal Torque 2.2Nm Nominal speed: 3000rpm Motor nominal power 690W Mechanical time constant: 1.5ms Electrical time constant: 2.3ms Thermal time constant: 30min Torque constant: 0.76Nm/A Voltage constant: 65Vpk/krpm Magnet material: NdFeB
above values given 20°C. back electromagnetic force sinusoidal shape stator phases supplied with sinusoidal currents.
Implementation Vector Control PMSM Using TMS320F240
Figure Three BEMF Waveforms 1000rpm
Power Electronics Hardware
ACPM750E used this application built around 750W IRTRAIN integrated power stage IRPT1056C from International Rectifier, which includes rectifier bridge three-phase ultra-fast IGBT inverter. converter topology supports either sinusoidal currents (three phases operation) direct currents (two phases operation). first control implemented this application report. Figure shows inverter topology used. power device securities wired (Shutdown, Fault, Clearfault, Itrip, reverse battery diode, varistor peak current protection). current sensing insured L.E.M. directly interfaced with TMS320F240. power board also supports voltage supply incremental encoder.
Figure Inverter Topology
Motor
Control Board
control hardware Texas Instruments TMS320F240 Evaluation Module (EVM). directly interfaced power electronics board. This evaluation board TMS320F240 Controller with oscillator, JTAG link, RS232 link, necessary output connectors. Figure depicting board.
Implementation Vector Control PMSM Using TMS320F240
Figure View TMS320F240 Board
Integrated Solution
This part describes features ACPM750E provides overview intelligent drive unit, which results when ACPM750E connected with Technosoft's Motion Control MCK240 board. ACPM750E power module three-phase motors, which directly controlled with MCK240 board. Both devices universal motion control (MC-BUS). They connected simply plugging MCK240 ACPM750E. ACPM750E offers galvanic isolated feedback signals motor currents voltage. Motor speed provided tachometer measured through adjustable-gain circuit. Motor position given incremental encoder three Hall sensor signals also read through MCK240. When ACPM750E combined with MCK240, results intelligent drive unit. This unit represents ideal development platform design implementation high performance control algorithms three-phase motors using Texas Instruments TMS320F240 (`F240) controller.
Implementation Vector Control PMSM Using TMS320F240
Figure ACPM750E with MCK240
Field Orientated Control Principle
vector control principle consists controlling angle amplitude components stator field. ease motor equation representation, components stator current represented rotating reference frame aligned with rotor axis, i.e., with magnet flux. motor torque permanent magnet machine depends only quadrature current component (torque component). this case, most convenient control strategy zero direct current component minimize torque current ratio then increase motor (and converter) efficiency. control current components requires knowledge instantaneous rotor position.
Implementation Vector Control PMSM Using TMS320F240
Figure Stator Current Magnet Flux Space Vectors Rotating Reference Frame Relationship with Stationary Reference Frame
ROTOR STATOR
control scheme proposed synchronous motor drive shown Figure based vector control principle arranged rotating frame introduced application report, Solution Permanent Magnet Asynchronous Motor, literature number BPRA044. three motor phase currents measured with current sensor, Clarke transform applied then modifies three-phase system into two-phase orthogonal system. output this transformation indicated i>S. These components stator current input Park transform that gives stator current rotating reference frame. Note that this second transformation needs rotor flux position. quadrature current component regulated reference value given speed controller, while direct current component zero minimize current torque ratio motor. outputs current controllers, representing voltage references, then impressed motor using Space Vector Modulation technique, once inverse transformation from rotating fixed stator reference performed. outer speed control loop completes scheme. controllers used standard regulators. Figure shows this basic scheme.
Figure PMSM Control with Field Orientation
idSr iqSr vdSr
vqSr
v=Sr v>Sr
PWM1
PWM2 PWM3
a,b,c
Implementation Vector Control PMSM Using TMS320F240
Convention
Software Variables
iS=, idr,
phase currents stator current (=,>) components flux component stator current torque component stator current flux torque command rotor flux position (d,q) components stator voltage (=,>) components stator voltage (input SVPWM) voltage constant using SVPWM voltage reference used sector determination SVPWM sector variable used SVPWM time vector application SVPWM commutation instant SVPWM variables speed speed reference voltage regulator output limitation phase current limitation speed regulator output limitation current regulator output limitation current regulator parameters speed regulator parameters field weakening regulator parameters speed loop period speed loop counter encoder pulses storing variable number pulses SPEEDSTEP
vS=ref, vS>ref vDCinvTc sector taon, tbon, tcon nref Iidrmin, Iidrmax Ismax iqrmin, iqrmax Vmin,Vmax Kpi, Kcor Kispeed, Kpispeed, Kcorspeed Kiweak, Kpiweak, Kcorweak SPEEDSTEP speedstep encincr, speedtmp
Base Values
Since TMS320F240 fixed-point DSP, unit (p.u.) model used motor variable representations. this model quantities referred base values. advantage this method that used motor (different parameters, power, user requirements, etc.) simply changing base values without changing part software. base values determined from nominal values with following equations:
Ibase base= BEMF wbase
Where BEMF values. BEMF measured nominal speed.
Implementation Vector Control PMSM Using TMS320F240
base values motor used this synchronous drive follows:
base 4.1A base= 195V base 314.15
quantities p.u. defined:
Ibase Vbase speed synchronous speed wbase
Numerical Consideration
p.u. model been developed that software representation speed, currents, voltages equal when drive reached nominal speed under nominal load. Knowing that during transients, current might reach higher values than nominal current (Ibase) achieve short response time. Assuming also that motor speed range might extended above nominal speed (wbase), every unit value greater than one. This fact forces implementation handle these situations thus determine best suited numerical format.
Numeric Format
numeric format used integer number fractional number. This numeric format noted: 4.12 format. resolution this format
0.00024414
correspondence from rated magnitude variable following: 7.99975586) (-32768 32767) This format been chosen because drive control quantities (most time) greater than four times their nominal values other words greater than four when unit model considered). Otherwise, different format will chosen. using representation range [-8;8] ensures that software values handle each drive control quantity only during steady state operation during transient operation well. this format p.u. variable correspondent word 01000h =4096). This representation allows both above mentioned variables eight times bigger than base quantities.
Implementation Vector Control PMSM Using TMS320F240
With sign extension mode set, link between real quantity 4.12 representation given Figure
Figure Format Correspondence Diagram
32767
24.4e-5 7.99975586
-32768
Software Organization
Software Synchronization
This software based modules: initialization control modules. first performed only once beginning. second module based waiting loop interrupted underflow event. When this interrupt flag corresponding Interrupt Service Routine (ISR) acknowledge serviced. Figure shows time diagram initialization operating system.
Figure Software Initialization Operating System
Underflow Interrupt T1CNT Sampling Period 60ms=2*PWMPRD
PWMPRD=600*50ns=30m Initialization Software Start
algorithm
Waiting Time
algorithm
complete algorithm computed within thus runs same frequency frequency. waiting loop could easily replaced human machine interface. interface software presentation beyond scope this report useful control code monitor control variables. overview software given flow chart below:
Implementation Vector Control PMSM Using TMS320F240
Figure General Software Flowchart
Start Hardware Initialization Variables Initialization
user interfac
Controller Full Compare Unit handled generate necessary pulsed signals power electronics board. generate symmetrical complementary signals frequency 16.6kHz with TIMER1 time base with DEADBAND unit disabled. sampling period 60ms achieved setting timer period T1PER (PWMPRD=258h).
Figure Control Algorithm Timing
PERIOD interrupt Tcmp Tcmp Tcmp Tcmp1' Tcmp3' Tcmp2'
Tpwm,k-1 Tpwm,k
Calculation cycle
Calculation cycle
Flow Chart
After F240 features variable initializations, software jumps waiting loop. Below presented user interface. interrupted every time interrupt occurs start control. This algorithm asynchronous from control uses MIPS used control code. behaves like waiting loop.
Implementation Vector Control PMSM Using TMS320F240
Figure Waiting Loop/User Interface
Main menu
User Interface
there data available
store into 'option'
option option option
there data available
store into 'variable'
there data available
store into 'variable'
option
next block diagram shows control interrupt service routine. executed same frequency PWM.
Implementation Vector Control PMSM Using TMS320F240
Figure Control Routine Block Diagram
Start Control utin
pling currents
teta reference Iqrinit initialize variables
Init phase?
Read encoder pulses lcula ositio
Calculate speed? (speedstep=SPEED
Calculate speed
speed regulator with itations integral correctio
Stator ltag (Vr) lcula tion
Volta lato lcula tion
lcula tion iqrm from
,b,c)->( Park nsfo lulate cos(T eta)
)->(d,q)
q-curren lato with itations integral correctio
d-curren lato with itations integral correctio
(d,q)->( Inve larke nsform
SVPW
trol utin
Implementation Vector Control PMSM Using TMS320F240
Block Diagram
Figure Block Diagram Including Closed Loop Field Weakening Control
interface
PMSM
Parameter Adaptation
This section deals with parameter adaptation depending motor specifications. Changes will done depending motor poles, rated speed, encoder resolution current sensor scaling. proportional integral regulators will explained user handle coefficient optimization. parameter adaptation described here needs done initialization part software.
Motor Poles
Depending motor poles, pulse increments have multiplied Kencoder that number counts equal 360° after electrical period (the angle 360° equivalent 1000h). general case Kencoder calculated follow:
Kencoder
1024 Encoder resolution
number pair poles. case three-pair pole motor having 1024 pulse encoder, variable Kencoder make filter follows:
Implementation Vector Control PMSM Using TMS320F240
Kencoder mpyu sach
.word encoder Kencoder
0c000h ;equivalent 4.12 format ;multiply encoder pulses Kencoder have therotor electrical position ;encoder pulses 1365 theta 0fffh degrees ;encoder pulses 2731 theta 1fffh 1*360 degrees ;encoder pulses 4096 theta 2fffh 2*360 degrees ;shift right 4.12 format then scaled ;between 2fffh
theta,2
lacl sacl
theta #0fffh theta
;filter angle between 0fffh
Initialization Vector
reference values permanent state, these values correspond current generating constant flux perpendicular magnet's flux produce constant torque. initialization phase, stator flux rotating, theta must place rotor aligned with phase rotor will aligned with being different from angle equals -90°.
INITANGLE
.set fc00h
;set -90°
this point motor should able rotate until reaches position aligned with phase then able generate some torque forced another position. amplitude starting current fixed amplitude, value capable driving maximum load torque open loop. respectively equal zero Iqrinit.
Iqrinit
.set
1000h ;set nominal current
Voltage
voltage constant usually found motor characteristic V/rpm maximum inverter voltage equal 310V rated voltage determined BEMF voltage measurement nominal speed. VDCpu variable that sets this magnitude. determined maximum inverter voltage (ex: 310V) divided normalizing factor Vbase, scaled format 4.12, e.g., (310/195)
196fh
VDCinvTc invert multiplied period PWMPRD, VDCinvTc (195/310)*PWMPRD
PWMPRD .set 258h ;equivalent 60us VDCinvTc .set 179h
Implementation Vector Control PMSM Using TMS320F240
Current Sensing Scaling
Hardware Interface
structure needs input two-phase currents. this application, currents sensed current-voltage transducers (LEM). current sensor output needs then rearranged scaled that they used control software 4.12 format values. complete structure current obtained depicted Figure
Figure Current Measurement Chain
Kcurrent
-512
range adjustement
1023
10-bit
interface
x=a,b
TMS320F240
this application output signal either positive negative. This signal thus needs translated range (0;5V) analog interface allow single voltage module read positive negative values.
(0;5V
resolution current measurements
resolution
integrated converters have resolution. corresponding voltage step
4.88 Figure shows different stages implemented
current sensing:
Figure Current Sensing Interface Block Diagram
2.5V analog Offset
Input Volts Imax Volts -2.5 -Imax Imax Output Voltage Output Voltage Volts
Implementation Vector Control PMSM Using TMS320F240
Note that Imax represents maximum measurable current, which necessarily equal maximum phase current. 2.5V analog offset digitally subtracted from conversion result, giving thus signed integer value sensed current. result this process represented below:
Figure Sensed Current Values before Scaling
Numerical Value before Scaling -Imax Imax -512
Sensed Current
Scaling Sensed Currents
Like every other quantity this application, sensed phase currents must expressed with p.u. model then converted into 4.12 format. Knowing that p.u. representation current defined ratio between measured current base current that maximum current handled hardware represented 512, p.u. current representation into 4.12 format performed multiplying sensed current following constant:
current
4096 base
This constant evaluated single calculation, only p.u. modeling also numerical conversion into 4.12 format. When nominal current flows motor running nominal speed current sensing scaling block output 1000h (equivalent 1pu). change numerical format simply changing numerator value. adapt this constant current sensing range simply recalculating Kcurrent with Imax value. Below given dedicated code scale current stored ADCFIFO1. each current measured, converter input used. this currents converted same time (the conversion time channel ms). application, channel channel were selected.
Implementation Vector Control PMSM Using TMS320F240
Calculate from measurement #0e0h NoConv ADCTRL1,1000b bcnd NoConv,TC ;wait laccADCFIFO1,10 sach ISR_Temp ;temporary variable lacl ISR_Temp #03ffh #512 ;the range [0fe00;01ffh] saclISR_Temp ;PM=10, ISR_Temp Kcurrent ;Kcurrent defined like .word sach 4.12 (1pu=1000h) ;PM=00
example, consider input representing current from -10A 10A. register range then:
Input Voltage
Related Current -10A +10A
ADC_FIFO hexa. Value 0000h FFC0h
ADC_FIFO Binary Value 0000 0000 0000 0000b 1111 1111 1100 0000b
variables software normalized. currents 1000h, which represents Ibase (4.1Amps). give better flexibility, constant Kcurrent defined with format 8.8. This does influence format currents which remain format 4.12. scaling factor required Kcurrent=(4096*10)/(512*4.1)*2 =1383h. format
Kcurrent .set 1383h
next step verify that currents sampled equal after scaling. this, emulate software until step into label `go'. breakpoint after sacl display memory where contained look F240 accumulator. memory exactly possible adjust directly software with addition offset (see comment offset software).
Current Regulation
currents controlled with regulator match their reference values iqr. output from regulator limited between Vmin Vmax. This anti-windup reset. Xiq, integral component, then adjusted from limitation. following figure illustrates block scheme algorithm:
Implementation Vector Control PMSM Using TMS320F240
output umax limitered umin
reference
error
output regulator
quantity controlled
INPUT
e=y-yr u=xi+K ul=u umax THEN ul=umax umin THEN ul=umin el=u-ul xi=xi+Ki e+Kcor
OUTPUT
proportional component named Kpi, Integral output limitation error elpi back integral component with coefficient Kcor relation Kcor=Ki/Kpi. Below regulator used control same scheme used
lacc sacl lacc apac sach bcnd lacc bcnd lacc neg_satq lacc #Vmin limiterq saturation Vmin epiq xiq,12 epiq #Kpi upi,4 upi,0 upimagzeroq,NTC #Vmin neg_satq,GT limiterq ;epiq
;upi Kpi*(iqr
;scale 4.12 ;test negative
upi<Vmin branch saturate ;value valid
upimagzeroq lacc #Vmax bcnd pos_satq,LT lacc limiterq pos_satq lacc #Vmax limiterq
;upi positive
upi>Vmax branch saturate ;value valid
;set saturation this point: Vmin Vmax
Implementation Vector Control PMSM Using TMS320F240
sacl sacl apac sach elpi elpi #Kcor epiq xiq,12 xiq,4 ;calculation integral coefficient ;xiq Kcor*(Vqr upi) Ki*(iqr ;Save reference value ;elpi
Kcor Kcor=Ki/Kpi replaced Kpi*(iqr iq), last equation
Kcor*(Vqr upi) Ki*(iqr
becomes
Kcor*(Vqr xiq)
Speed Regulation
speed given 1024 point incremental encoder. sensor output channels directly wired unit TMS320F240 Controller assigned timer counts number pulses, given timer counter register (T3CNT). each sampling period this value stored variable named encincr. mechanical time constant much lower than electrical one, speed regulation loop frequency might lower than current loop frequency. speed regulation loop frequency realized this application using software counter. This counter increments interrupts. period software variable called SPEEDSTEP. counter variable named speedstep. When speedstep equal SPEEDSTEP, number counted pulses stored another variable called speedtmp multiplied KSPEED motor speed. SPEEDSTEP multiplied current cycle time determines speed cycle time
Encoder Constant
TMS320F needs input signals count pulses generated encoder. They consist pulse sequences with variable frequency shifted quarter period degrees) apart. circuit counts both edges these quadrature-encoded input pulses. Therefore, frequency generated clock timer four times each input sequence. example, encoder 1024 pulses revolution, edges counted circuit 4096 revolution. This constant indicated with "Encpulses" number pulses normalized range Encpulses]. Encpulses .set 4096
case encoder with number steps being power process remains same.
Implementation Vector Control PMSM Using TMS320F240
*Read Encoder Pulses Normalize [0;EncoderPulses] #0e8h lacc T3CNT #ISR_Temp sacl ISR_Temp encoderold subtract previous sampling period value have ;the increment that we'll accumulate encoder sacl encincr encoder bcnd encmagzero,GT,EQ ;here start normalize encoder value ;range [0;Encpulses-1] #Encpulses ;the value encoder could negative, depends ;the rotating direction (depends motor windings ;PWM Channels connections) encmagzero sacl encoder ;now encoder value positive could ;greater than Encpulses-1 #Encpulses subtract Encpulses check whether ;difference negative. already have ;right value encoder bcnd encminmax,LT sacl encoder ;otherwise value encoder greater than ;Encpulses have store right value encminmax ;ok, encoder contains right value range lacc ;[0,Encpulses-1] ;the actual value will during next sacl encoderold ;sampling period
Speed Calculation
speedtmp variable holds number pulses SPEEDSTEP. following figure explains steps speed calculation.
speedtmp T3CNT
Kspeed
normalization
[0;Encoderpulses]
counter
(QEP circuit)
encoder
Kspeed constant that multiplies encoder increment calculate real speed named assembly software speed. case encoder detects only increment during speed control time, motor speed 4.12 format equal Kspeedpu
encoder constant format equal
Kspeed=Kspeedpu*256
determine speed with speedtmp number encoder steps during speed cycle time, code
sach speedtmp Kspeed ;multiply encoder pulses Kspeed (8.8 format constant) have value speed ;shift recover from Kspeed being format ;speed 4.12 format
speed,7
Implementation Vector Control PMSM Using TMS320F240
example, calculate Kspeed: Control cycle time SPEEDSTEP PWMPRD 28*60 Encpulses 4096 incr speedpu 3000
Kspeed (60/Encpulses) (1/SPEEDSTEP *PWMPRD) (4096/speedpu) Kspeed (60/4096) (1/(28*60*10 (4096/ 3000))*256 11.9*256 Kspeed 3048 0be7h Kspeed .set 0be7h ;14.28 format
Coordinate Transformation
Generation Sine Cosine Values
generate sine cosine values sine look-up table indirect addressing mode auxiliary register have been implemented. compromise between position accuracy used memory minimization, this table contains =256 words represent [0;2p] range. above computed position bits integer value) thus needs shifted positions right. This position bits integer value) used pointer (named Index) access this table. output table value represented 4.12 format. Figure shows theta, Index sine look-up table.
Figure SinG Calculation Using Sine Look-Up Table
Sine Table Address 4091 4095 4096 4095 4091 65435 65335 61445 61441 61440 61441 61445 65335 65435
Index
3p/2
Note that have cosine value, 256/4=40h must added sine Index. assembly code address sine look-up table given below:
Implementation Vector Control PMSM Using TMS320F240
sinTheta, cosTheta calculation *,ar5 theta mpyu SR8BIT sach Index lacl Index #0ffh #sintab sacl ar5,tmp lacl sacl sine ;sine Theta value, 4.12 format lacl Index ;The same #40h elements table #0ffh #sintab ar5,tmp
sacl lacc* saclcosine ;cosine Theta value, 4.12 format sinTheta, cosTheta calculation
(a,b,c)->(a,b) Transform (Clarke Transform)
more details, refer application report, Clarke Park Transforms TMS320C2xx, literature number BPRA048, where theory explained. format used also 4.12 format.
Clarke transform (a,b,c)->(alfa,beta) ialfaS=Ia ibetaS=(2*Ib+Ia)/sqrt(3) lacc sacl ialfaS lacc Ib,1 sacl ISR_Temp ISR_Temp #SQRT3inv sach ibetaS Clarke transform
;ialfaS=Ia
;shift places after multiplication
;ibetaS=(2*Ib+Ia)/sqrt(3) shift after multiplication
where SQRT3inv following constant (.set):
SQRT 3inv
0.577 093dh
Implementation Vector Control PMSM Using TMS320F240
(a,b)->(d,q) Transform (Park Transform)
more details refer application report, Clarke Park Transforms TMS320C2xx, literature number BPRA048, where theory explained. format used also 4.12 format. With quantity Theta consider rotor flux position.
Park transform (alfa, beta)->(d,q) ibetaS sinTheta ialfaS cosTheta mpya sinTheta sach shift places after multiplication lacc ibetaS mpys cosTheta apac sach Park transform
Inverse matrixes used perform back transformation from currents [id, [i1, i3].
Space Vector Modulation
Using three-leg inverter, eight transistor configurations possible. These configurations generate eight vectors which `zero' vectors. remaining vectors divide plane into sectors.
Figure SVPWM, Vectors Sectors
first step generating software determine sector where reference voltage Vref located. this, Vref transformed into stator coordinate system following criteria applied:
Implementation Vector Control PMSM Using TMS320F240
THEN A:=1, THEN B:=1, THEN C:=1, tor:= B+4C
ELSE A:=0 ELSE B:=0 ELSE C:=0
Depending sector, adjacent vectors chosen. binary representations adjacent basic vectors different only bit, that only upper transistor switches when switching pattern switches from vector adjacent one. vectors time weighted [t1, sample period produce desired output voltage pattern retained output signal symmetrical where centered. remaining time, shared equally each side within half period shown following graph.
Tcmp Tcmp Tcmp
following equations give method determinate right value compare register depending [t1,t2] sector. first step perform saturation control
PWMPRD THEN PWMPRD t1SAT PWMPRD
second step compute three necessary duty cycles. This shown below:
PWMPRD
More details about space vectors given application note BPRA073.
Implementation Vector Control PMSM Using TMS320F240
last step give right duty cycle (txon) right motor phase other words correct CMPRx) according sector. Figure depicts this determined.
Figure Assigning Right Duty Cycle Right Motor Phase
Sector Phase CMPR1 CMPR2 CMPR3 tbon taon tcon tbaon tcon tbon taon tbon tcon tcon tbon taon tcon taon tbon tbon tcon taon
Field Weakening
Field Weakening
Under certain assumptions possible extend control speed range beyond motor's nominal speed. This section explains possible process perform this speed range extension.
Field Weakening Principles
Under nominal load mechanical power increases linear function speed, nominal power (reached when speed equal nominal value). Knowing that mechanical power proportional torque times speed that nominal value been reached when speed equal 3000rpm (nominal value), torque production must reduced desired speed greater than 3000rpm. This shown Figure
Figure Field Weakening Real Operation
Constant Torque Region Pnominal Nominal Torque Mechanical Power Output Torque Constant Power Constant Power*Speed Region Region
Normal Nominal Speed Range Speed
Extended Speed Range
Speed
Note three different zones. constant power region nominal torque production behaves like inverse function speed, allowing thus constant power production (P=T constant Power*Speed region nominal torque production behaves inverse function squared speed.
Implementation Vector Control PMSM Using TMS320F240
maximum torque function equal constant first region (the phase voltage) increases linearly with speed. Above nominal speed phase voltage maintained constant equal nominal value, thus making maximum torque inverse function squared speed. This results curve shown Figure
Figure Maximum Nominal Torque Speed
Constant Torque Region Maximum Torque Constant Power Region Constant Power*Speed Region
Nominal Torque
Normal Nominal Speed Range Speed
Extended Speed Range
Speed
Note that nominal torque curve crosses maximum torque curve. This cross point brake point, delimiting constant power region constant power*speed region. Note also that nominal torque curve crosses depicted steady state torque curves stability zone (making nominal torque smaller than maximum torque) until brake point. Once this point been crossed nominal torque forced equal maximum torque, thus making power behave inverse function speed. These characteristics only related motor capabilities. Good control will enable full speed, torque efficiency drive exploited.
Field Weakening Constraints
drive constraints extended speed range first phase voltages second phase currents. Knowing that phase voltage references increase with speed their value exceed nominal value, flux component must then reduced down value that allows nominal phase voltage maintained desired speed reached. Knowing that phase currents increase with load, maximum resistive torque drive during extended speed range operation must value that keeps phase currents greater than their nominal value. maximum resistive torque decreases then function speed. Both maximum phase voltage flux references given normal extended speed range following scheme (see Figure 23).
Implementation Vector Control PMSM Using TMS320F240
Figure Field Weakening Voltage Constraints
Phase Voltage Flux
Nominal Flux Nominal voltage
Normal Speed Range
Nominal Speed
Extended Speed Range
Speed
Note that both voltage current constraints must respected steady state operation. fact, during transient operation phase current might reach several times nominal value without risk drive. This only assumes that resulting drive overheating dissipated before performing another transient operation.
Field Weakening Motor High Speeds with Closed Loop Scheme
stator current frequency increased achieve high speeds. stator voltage directly proportional motor flux angular speed. normal condition motor flux kept constant. then obvious that maximum stator speed reached with limit output voltage power converter. reach higher speed, flux reduced inverse angular speed keep stator voltage constant equal maximum.
Figure Control Range PMSM Steady State
Field control range
Voltage control range
Field control range
Implementation Vector Control PMSM Using TMS320F240
Practically, consider stator current rotating reference frame relationship with stationary reference frame, below speed where maximum output voltage reached, best choice d=±p/2 id=0. effect field weakening achieved advancing current vector beyond d=p/2, which means introducing current component negative d-axis. consequence, then torque reduced exceed maximum output current ismax:
schemes possible implement field weakening operation. simplest standard open loop control axis current reference. Despite relative simplicity this realization, following drawbacks:
reference current equation must worst-case condition operation because corresponds lower line voltage gives utilization inverter with higher voltages. High-speed reliability: guarantee correct operation control high speeds, necessary reduce further voltage capability inverter. reference current equation depends motor electrical characteristics, necessary consider these parameter variations determination.
closed loop control avoids these negative effects. consists feeding back proportional integral (PI) regulator with motor axis voltages applied motor calculating reference d-current component. This diagram allows exploit full voltage capability inverter independently line voltage motor characteristics. being determined, limitation range [iqrmin,iqrmax] then calculated exceed ismax, explained before.
TMS320F240 Field Weakening Implementation
This section describes detail field weakening closed-loop control system. calculations performed real time. look-up table approximation steady-state characteristics used this implementation.
Figure Field Weakening Function Structure
Vbase sqrt(x) Saturation Idrmin/Idrmax
Ismax^2
iqrmin iqrmax
Implementation Vector Control PMSM Using TMS320F240
used determine neutral-phase voltage.
square root calculated real time using Newton-Raphson method with recursive equation:
X(n) X(n-1) N/X(n-1)
Macro isqrt .macro lacc ;lacc X(0) ;Initial approximate root=N/2 sacl ;(AR5+1) X(0)/2 splk #10,* ;(AR5+2) (iterations square root) isqrt?: ;X(n) X(n-1) N/X(n-1) sbrk lacc subc #0FFFFh sacl lacc ;Repeat until iterations completed: sacl bcnd isqrt?,NEQ *lacc *.endm ;Restore result acclow:
reference value Vbase controlled with regulator generate output idr. field weakening region, |idr| increases. order over nominal stator current ismax, iqmax decreased with relation:
iqmax calculated serves limitation iqr, result speed controller. directly proportional motor torque, modifying iqmax also changes torque available motor.
Results
Software Implementation
proposed control scheme been implemented TMS320F240 EVM. control routines implemented using assembler language with fixed-precision numerical representation.
Implementation Vector Control PMSM Using TMS320F240
calculation time whole control algorithm described below: FOC+speed control FOC+field weakening FOC+speed control+ field weakening (us) Control (us) 32,6 35,6 MIPS 10,9 11,7 11,9 12,7
inverter switching frequency 16.6 kHz. timing control algorithm shown Figure control algorithm interrupt (PERIOD interrupt) generated event manager unit synchronize control generating ramp. speed reference main parameters control scheme changed real time means host linked evaluation board RS232 link.
Experimental Results
This section handles results different drive operations. motor been mounted test bench with adjustable resistive torque. power constant flux imposed drive that shaft aligns position that defined zero angle (index mark). This initialization phase performed that non-absolute encoder used position sensor. This phase does take into account direction shaft start current amplitude during initialization phase nominal current that shaft aligned even nominal torque.
Results until Nominal Speed
Figure Speed Transient from 1000
This speed transient picture given with torque. values observed oscilloscope directly derived from control variables through four digital-to-analog converters included F240 EVM.
Implementation Vector Control PMSM Using TMS320F240
plot1: n_ref reference speed plot2: sensed speed plot3: magnetizing current plot4: current proportional torque
scaling factor variables 1.25 volts (1000h). this case: 415mV equivalent 1000rpm. 1.56V equivalent 5.12Amps, maximum current.
first part plot illustrates behavior steady-state initialization phase. maintained Iqrinit 1.5Amps, starting phase current. After speed reference step, maximum value better dynamic response, then goes back steady-state value related torque implied.
Figure Speed Transient from 3000 Nominal Torque
This plot speed transient from zero speed nominal speed (3000rpm) nominal torque (2.2Nm). always kept zero, during transient reaches maximum current which higher (5.12Amps) than nominal current (4.1Amps). steady state equal nominal current conditions nominal power.
Implementation Vector Control PMSM Using TMS320F240
Figure Speed Transient from -1000 1000 Nominal Torque
speed transient from -1000rpm 1000rpm done phases. first step from -1000rpm zero speed helped resistive torque acceleration phase from 1000rpm. transient times increased increasing maximum value more than base value.
Field-Weakening Operation
Figure Speed Transient from 3000 Graph1 without Torque, Graph2 with 1.1Nm
Plot1 remains constant even during transients, voltage (plot3) does exceed maximum value equal Vbase, BEMF nominal speed. (plot2) increases maximum value iqrmax goes back value related torque imposed when speed reference reached. break observed comes from fact that this variable only calculated voltage above Vbase/2. last plot phase current. illustrates control performance never losing motor position.
Implementation Vector Control PMSM Using TMS320F240
Figure Steady-State Speed Nominal Speed Above Maximal Torque
first graph done nominal conditions 3000rpm 2.2Nm. equal zero maximum value iqrmax. equal Vbase. second graph done 4000rpm with 1.3Nm. controlled negative. 2.2Nm can't achieved, limited iqrmax, which updated that stator current
remains constant equal maximum ismax during field weakening
operation.
Figure Speed/Torque Plot
maximum speed reached above nominal speed. table below gives results term torque efficiency achieved depending speed.
Implementation Vector Control PMSM Using TMS320F240
Speed (rpm) Torque (Nm) Efficiency Power 1000 2,21 2000 2,21 3000 2,21 3500 1,91 3650 1,81 4000 1,31 4500 1,04 5000
User Interface
user interface implemented help programmer while optimizing some control parameters. allows changing speed, selection control variables visualized through four outputs, stop motor change real-time parameters. Many other options implemented. main program written Qbasic. Below appearance User screen:
Figure User Screen
Qbasic code given appendix. Another part needed perform data exchange from serial communication interface code found assembly code.
Conclusion
This document presented field orientated control scheme three-phase permanent magnet drive based Texas Instruments TMS320F240 Controller. been shown real-time processing capabilities this controller lead highly reliable effective drive. only drive reliability efficiency improved, motor drive cost effectiveness. This document also described speed variation capability, direct torque flux control, excellent dynamic behavior. This level performance been reached utilizing only 10.6 MIPS from MIPS available with code size exceeding 1.1Kword program memory with words data memory.
Implementation Vector Control PMSM Using TMS320F240
References
Texas Instruments, Field Orientated Control Three-Phase AC-Motors, Literature number: BPRA073, December 1997. Texas Instruments, Solution Permanent Magnet Asynchronous Motor, Literature number: BPRA044, Nov. 1996. Werner Leonard, Control Electrical Drives, Completely Revised Enlarged Edition, Springer, ISBN 3-540-59380-2. Texas Instruments, Current Measurement Using Single Shunt Resistor, Literature number: BPRA077, December 1997. T.J.E. Miller, Brushless Permanent-Magnet Reluctance Motor Drives, Oxford Science Publications, ISBN 0-19-859369-4. Texas Instruments, Implementation Speed Controlled Brushless Drive Using TMS320F240, Literature number BPRA064, July 1997, Texas Instruments, Clarke Park Transforms TMS320C2xx, literature number BPRA048, June 1998,
Appendix TMS320F240 Software
TEXAS INSTRUMENTS Field Orientated Control PMSM with field weakening File Name: focmck7.asm Originator: Michel Platnic Description:The software includes -PMSM field oriented control phase current measurement -PDPINT routine fault -Current closed-loop initialization phase BEMF real-time calculation -iqr real-time limit calculation -idr calculation -User Interface Function list: -c_int0 Target: TMS320F240, MCK240 Code Flashed ACPM750E Power board Digiplan Motor MD3450 status: Working History: Completed March .include ".\c240app.h" .mmregs Start .globl _c_int0 ;set _c_int0 global symbol .sect "vectors" _c_int0 ;reset interrupt handler _c_int1 ;RTI,SPI,SCI,Xint interrupt handler
_c_int1
Implementation Vector Control PMSM Using TMS320F240
_c_int2 _c_int3 _c_int4 _c_int5 _c_int6 .space 16*6 ;PWM interrupt handler ;capture/ encoder Interrupts ;reserve words interrupt table
_c_int3 _c_int4 _c_int5 _c_int6
Auxiliary Register used pointer context save stack used interruption c_int2 control calculation main program stack .usect "blockb2",15 ;space Status Register context save Page dac_val .usect "blockb2",5 ;space values Page Motor Digiplan Numeric formats: 4.12 fixed point format twos complement negative values integer sign fractional) except otherwise specified Nominal current Amps max= 2.2/0.76 *sqrt(2) (max value) Nominal Torque Rated Power 1150W Currents: 1000h (4.12)= Ibase (max value) Voltages: 1000h (4.12)= Vbase (max value) phase-neutral Angles [0;ffffh] [0;360] degrees Speed [0;1000h] (4.12) [0;3000] Numeric formats
Look-up tables .includes N.B. tables include elements sintab .usect "table",256 ;space copy sine table .sect "table_f" ;sine table sintab_flash .include sine.tab ;sine wave look-up table sine cosine waves generation ;generated BASIC program "SINTAB.BAS" ;4.12 format look-up tables .includes Variables constants initializations program flash array variable added front variable initialized later .data current sampling constants VKcurrent .set 00b38h constant
;8.8 format (*11.22) sampled currents normalization
;ADCIN6 current sampling) ;ADCIN14 current sampling) ;+/- 5.75 Amps Ibase Amps axis transformation constants VSQRT3inv .set 093dh ;1/SQRT(3) 4.12 format VSQRT32 .set 0ddbh ;SQRT(3)/2 4.12 format modulation constants PWMPRD .set 258h Tonmax MAXDUTY .set .set
;PWM Period=2*600 Tc=2*600*50ns=60us ;(50ns resolution) ;minimum duty cycle PWMPRD-2*Tonmax ;maximum utilization ;inverter
current regulators parameters .set 07Ah ;4.12 format 0.03
Implementation Vector Control PMSM Using TMS320F240
;4.12 ;4.12 ;Kcor speed regulators parameters VKispeed .set ;4.12 VKpispeed .set 06800h ;4.12 VKcorspeed .set ;4.12 VKpi VKcor .set .set 999h 0cch format 0.60 (include period) format 0.05 Ki/Kpi format 0.03 format format 0.0046
field-weakening regulators parameters VKiweak .set 07Ah ;4.12 format 0.03 VKpiweak .set 999h ;4.12 format 0.60 (include period) VKcorweak .set 0cch ;4.12 format 0.05 limitations Vbase .set 01000h Vmin .set 0ec00h Vmax .set 01400h limitations Vismax .set 0bb5h Idrmin Idrmax .set .set 0f44bh 00000h
;BEMF base speed ;4.12 format -1.25 ;4.12 format 1.25
;4.12 format 3Amps Limitation ;ACPM750E ;4.12 format -3Amps limit. ACPM750E ;4.12 format (1000h Ibase)
Initialization phase Iqrinit .set 009c1h
;4.12 format 2.5A (1000h Ibase)
Encoder variables constants VKencoder .set 0c000h ;this constant needed only with encoder used convert encoder pulses [0;4095] electric angle [0;360]=[0000h;1000h] ;2.14 format unsigned (see "Theta calculation" block details) Encpulses .set 4096 ;this constant needed only with encoder ;number encoder pulses round (mechanical) Speed estimated speed calculation constants Nbase .set 1000h ;Base speed Kspeed .set 0be7h ;this constant needed only with encoder used convert encoder pulses speed value. ;8.8 format 11.9 (see manual details about this constant calculation) ;base speed 3000rpm, PWMPR 258h SPEEDSTEP .set ;speed samplig period current sampling period Speed estimated speed calculation constants .bss tmp,1 ;temporary variable only !!!) .bss option,1 ;virtual menu option number .bss daout,1 ;address variable send DACs .bss daouttmp,1 ;value send DACs displaying table starts here .bss i1,1 ;phase current .bss i2,1 ;phase current .bss i3,1 ;phase current .bss Ua,1 ;Phase voltage .bss Ub,1 ;Phase voltage .bss Uc,1 ;Phase voltage .bss seno1,1 ;generated sine wave value .bss t1,1 ;SVPWM (see references details) .bss t2,1 ;SVPWM (see references details) .bss coseno,1 ;generated cosine wave value .bss Va,1 ;Phase voltage sector calculation .bss Vb,1 ;Phase voltage sector calculation .bss Vc,1 ;Phase voltage sector calculation .bss vDC,1 Voltage .bss taon,1 ;PWM commutation instant phase .bss tbon,1 ;PWM commutation instant phase
Implementation Vector Control PMSM Using TMS320F240
.bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss .bss tcon,1 theta,1 ;PWM commutation instant phase ;rotor electrical position range [0;1000h] ;4.12 format [0;360] degrees ;alfa-axis current ;beta-axis current ;alfa-axis reference voltage ;beta-axis reference voltage ;d-axis reference current ;q-axis reference current ;d-axis current ;q-axis current ;d-axis reference voltage ;q-axis reference voltage ;q-axis current regulator error ;d-axis current regulator error ;q-axis current regulator integral component ;d-axis current regulator integral component ;speed ;speed reference ;speed error (used speed regulator) ;speed regulator integral component ;SVPWM variable ;SVPWM variable ;SVPWM variable ;SVPWM sector display ;flag initialization phase
ialfa,1 ibeta,1 Valfar,1 Vbetar,1 idr,1 iqr,1 id,1 iq,1 Vdr,1 Vqr,1 epiq,1 epid,1 xiq,1 xid,1 n_ref,1 epispeed,1 xispeed,1 sectordisp,1 initphase,1 encoder,1 Vr,1 ;Phase voltage iqrmin,1 ;iqr limitation iqrmax,1 ;iqr limitation displaying table sector,1 serialtmp,1 da1,1 da2,1 da3,1 da4,1 vDCinvTc,1 epvr,1 xvr,1 indice1,1 upi,1 elpi,1 faultreset,1 tmp1,1 accb,2 acc_tmp,2 encoderold,1 encincr,1 speedtmp,1 speedstep,1 Kcurrent,1 SQRT3inv,1 SQRT32,1 Ki,1 Kpi,1 Kcor,1 Kispeed,1 Kpispeed,1 Kcorspeed,1 Kiweak,1 Kpiweak,1 Kcorweak,1
;SVPWM sector ;serial communication temporary variable ;DAC displaying table offset DAC1 ;DAC displaying table offset DAC2 ;DAC displaying table offset DAC3 ;DAC displaying table offset DAC4 ;VDCinv*(Tc/2) (used SVPWM) error field weakening integral term field weakening ;pointer used access sine look-up table regulators (current speed) output regulators (current speed) limitation error ;Used re-enable hardware protection ;tmp word words buffer words allow swapping ;encoder pulses value stored previous sampling ;period ;encoder pulses increment between consecutive ;sampling periods ;used accumulate encoder pulses increments ;calculate speed each speed sampling period) ;sampling periods down counter used define speed ;sampling period explanation given above explanation given above explanation given above explanation given above explanation given above explanation given above explanation given above explanation given above explanation given above explanation given above explanation given above explanation given above
Implementation Vector Control PMSM Using TMS320F240
.bss .bss ismax,1 Kencoder,1 explanation given above explanation given above
Variables constants initializations
.text
;link "text section
Macro Inputs: argument *AR5 !MUST POSITIVE! Outputs:result ACClow Notes: this function uses Newton-Raphson method: X(n) X(n-1) N/X(n-1) this function uses *(AR5+1) *(AR5+2) locations! isqrt .macro clrc lacc ;lacc X(0) ;Initial approximate root sacl ;(AR5+1) X(0)/2 splk #10,* ;(AR5+2) (iterations square root) isqrt?: ;X(n) X(n-1) N/X(n-1) sbrk lacc subc #0FFFFh sacl lacc sacl bcnd isqrt?,NEQ ;Repeat until iterations completed:
*lacc *setc .endm
;Restore result acclow:
_c_int2 Interrupt Service Routine synchronization control algorithm with underflow interrupt _c_int2: ************************ Context Saving ************************ larp ;context save *sst #1,*;status register #0,*;status register sach *;Accu. saved context save sacl *;Accu. high saved Context Saving lacc sacl bcnd *,ar5 #DP_EV IVRA #tmp #20H PDPRoutine,EQ ;used later DACs output
Implementation Vector Control PMSM Using TMS320F240
bcnd ControlRoutine,EQ ContextRestoreReturn Int2 Interrupt Service Routine ContextRestoreReturn Context restore Return larp lacl ;Accu. restored context restore *+,16 #0,*+ #1,*+ clrc INret Context Restore Return
PDPRoutine splk splk splk splk splk
#IFRA>>7 #001h,IFRA
;Clear flags, change ;with only underflow int.
#DP_EV #0fffh,ACTR #0207h,COMCON ;FIRST enable operation #8207h,COMCON ;THEN enable Compare operation #DP_PF2 #0FF00h,PBDATDIR;IOPB conf. output, logic re-enable protection circuitry ;after fault ACPM750E #200 ;wait minimum (needed circuitry) ;here 10us splk #0FF02h,PBDATDIR;IOPB conf. output, logic ContextRestoreReturn PDPRoutine ControlRoutine Current sampling conversions N.B. will have take only (LSB) #DP_PF2 splk #0FF08h,PCDATDIR;bit IOPC7 test purposes #DP_PF1 #186Dh,ADC_CNTL1;i2 conversion start ;ADCIN6 selected A/D1 ;ADCIN14 selected A/D2 ;01101101 current sampling conversion ADC_CNTL1,8 bcnd conversion,tc ;wait approximatly 6.6us lacc ADC_FIFO1,10 sach #DP_PF1 lacc ADC_FIFO2,10 sach fault enable test On/Off lacc faultreset bcnd initcontrol,EQ #DP_EV splk #0999h,ACTR #faultreset splk #0,faultreset splk
Implementation Vector Control PMSM Using TMS320F240
Initialization phase initcontrol lacl initphase bcnd noinit1,NEQ setc lacc #0fc00h sacl lacc sacl lacc sacl sacl sacl sacl sacl lacc sacl splk theta #Iqrinit encoder encoderold speedtmp #SPEEDSTEP speedstep #DP_EV #1,T3CNT #initphase
;are initialization phase
yes, theta 0fc00h 4.12 format degrees ;(align rotor with phase flux) ;q-axis reference current initialization q-axis ;reference current ;zero some variables flags ;restore speedstep value SPEEDSTEP next speed ;control loop ;zero Incremental Encoder value initialization step
;there need position speed calculation initialization phase (the rotor locked) Initialization phase noinit1 Encoder clrc lacc sacl sacl bcnd
pulses reading #DP_EV T3CNT encoderold
read encoder pulses ;encoder plug opposite direction ACPM
;subtract previous sampling period value have ;the increment that we'll accumulate encoder encincr encoder encmagzero,GT,EQ;here start normalize encoder value ;range [0;Encpulses-1] #Encpulses ;the value encoder could negative, depends ;the rotating direction (depends motor windings ;PWM Channels connections) encoder
encmagzero sacl
;now encoder value positive could ;greater than Encpulses-1 #Encpulses subtract Encpulses check whether ;difference negative. already have ;right value encoder bcnd encminmax,LT sacl encoder ;otherwise value encoder greater than ;Encpulses have store right value encminmax ;ok, encoder contains right value range lacc ;[0,Encpulses-1] ;the actual value will during next sacl encoderold ;sampling period Encoder pulses reading ******************* Theta calculation ******************* encoder mpyu sach Kencoder
;multiply encoder pulses Kencoder (4.12 format ;constant) have rotor electrical position ;encoder pulses theta 0fffh degrees ;encoder pulses 1600 theta 1fffh 1*360 degrees ;encoder pulses 3200 theta 2fffh 2*360 degrees
theta,2
Implementation Vector Control PMSM Using TMS320F240
lacl theta #0fffh sacl theta theta calculation Calculate speed update reference speed variables lacc speedstep ;are speed control loop (SPEEDSTEP times current ;control loop) sacl speedstep bcnd nocalc,GT aren't, skip speed calculation Speed calculation from encoder pulses speedtmp ;multiply encoder pulses Kspeed (8.8 format constant) have value speed #Kspeed sacl lacc ;zero speedtmp next calculation sacl speedtmp lacc #SPEEDSTEP ;restore speedstep value SPEEDSTEP sacl speedstep ;for next speed control loop Speed calculation from encoder pulses Speed regulator with integral component correction lacc n_ref sacl epispeed lacc xispeed,12 epispeed Kpispeed apac sach upi,4 ;here start saturate upi,0 bcnd upimagzeros,NTC value branch lacc iqrmin bcnd neg_sat,GT upi<iqrmin then branch saturate lacc ;value valid limiters neg_sat lacc iqrmin ;set saturated value limiters upimagzeros lacc bcnd lacc pos_sat lacc limiters sacl sacl ;Value positive iqrmax pos_sat,LT limiters iqrmax upi>iqrmax then branch saturate ;value valid
;set saturated value
elpi elpi Kcorspeed epispeed Kispeed
;Store reference value
Implementation Vector Control PMSM Using TMS320F240
apac xispeed,12 sach xispeed,4 Speed regulator with integral component correction Field-weakening algorithm with regulator Calculation sqrt(Vdr^2 Vqr^2) only n>Nbase/2 lacc #Nbase bcnd nocalc,GEQ ;calculate field-weakening n>Nbase/2 sqra sqra apac sach isqrt sacl ar5,#60h *,ar5 ;calculate square root Vr,6
;4.12 multiplication format
Voltage regulator with integral component correction (Vbase,Vr)->(idr) lacc #Vbase sacl epvr lacc xvr,12 epvr apac sach upi,4 bcnd lacc bcnd lacc neg_satv lacc upimagzerov lacc bcnd lacc pos_satv lacc limiterv sacl sacl upi,0 upimagzerov,NTC #Idrmin neg_satv,GT upi<Vmin branch saturate ;value valid limiterv #Idrmin limiterv ;set saturation
;Value positive #Idrmax pos_satv,LT limiterv #Idrmax upi>Vmax branch saturate ;value valid
;set saturation
elpi elpi Kcor
;Always negative
Implementation Vector Control PMSM Using TMS320F240
epvr apac xvr,12 sach xvr,4 voltage regulator with integral component correction Field-weakening algorithm limitation regulator Calculation sqrt(ismax^2 idr^2) Output iqrmax ar5,#60h *,ar5 ;4.12 multiplication format sqra sqrs ismax ;substract apac sach isqrt ;calculate square root sacl iqrmax,6 sacl iqrmin,6 field weakening routines Encoder update nocalc ;branch here don't have calculate speed lacc speedtmp ;use actual encoder increment update ;increments accumulator used calculate speed encincr sacl speedtmp Measured speed reference speed variables updating Sampled current scaling nominal current 1000h I_nominal lacc #045h ;then compensate offset (that should zero, isn't #3ffh #512 ;then have subtract offset (2.5V) have ;positive negative values sampled current sacl Kcurrent ;needed ACPM sacl ;sampled current 4.12 lacc sacl #03ch #3ffh #512 Kcurrent
;then compensate offset (that should zero, isn't)
Implementation Vector Control PMSM Using TMS320F240
sacl
;needed ACPM
sacl -(i3+i2) current sampling conversions Sampled current scaling (a,b,c) (alfa,beta) axis transformation ialfa ibeta sqrt(3) lacc sacl ialfa lacc sacl i2,1 SQRT3inv ;ibeta sqrt(3) ;SQRT3inv sqrt(3)) 093dh ;4.12 format 0.577350269
sach ibeta,4 Sampled current scaling (a,b,c) (alfa,beta) axis transformation Sine cosine wave calculation from theta values using sine look-up table lacc theta ;theta range [0;1000h] 4.12 format [0;360] degrees have pointer range [0;0ffh]) ;sine look-up table second third nibble #0ffh ;now contains pointer access table sacl indice1 #sintab sacl ar5,tmp *,ar5 lacl sacl seno1 ;now have sine value lacl indice1 ;the same thing cosine cos(theta) sin(theta+90°) #040h degrees elements table #0ffh sacl indice1 same pointer don't care) #sintab sacl ar5,tmp lacc sacl coseno ;now have cosine value Sine cosine wave calculation from theta values using sine look-up table d-axis q-axis current calculation (alfa,beta) (d,q) axis transformation ialfa cos(theta) ibeta sin(theta) =-ialfa sin(theta) ibeta cos(theta)
Implementation Vector Control PMSM Using TMS320F240
lacc ibeta ;TREG0=ibeta seno1 ;PREG=ibeta*sin(theta) ialfa ;ACC+=PREG TREG0=ialfa coseno ;PREG=ialfa*cos(theta) mpya seno1 ;ACC+=PREG PREG=ialfa*sin(theta) sach id,4 lacc ;ACC=0 ibeta ;TREG0=ibeta mpys coseno ;ACC-=(PREG=ialfa*sin(theta)) apac ;ACC+=PREG sach iq,4 d-axis q-axis current calculation q-axis current regulator with integral component correction (iq,iqr)->(Vqr) lacc sacl epiq lacc xiq,12 epiq apac sach upi,4 bcnd lacc bcnd lacc neg_satq lacc upi,0 upimagzeroq,NTC #Vmin neg_satq,GT upi<Vmin branch saturate ;value valid limiterq #Vmin limiterq ;set saturation
upimagzeroq lacc #Vmax bcnd pos_satq,LT lacc limiterq pos_satq lacc #Vmax
;Value positive upi>Vmax branch saturate ;value valid
;set saturation
limiterq sacl ;Save reference value sacl elpi elpi Kcor epiq apac xiq,12 sach xiq,4 q-axis current regulator with integral component correction d-axis current regulator with integral component correction (id,idr)->(Vdr) lacc sacl epid lacc xid,12
Implementation Vector Control PMSM Using TMS320F240
apac sach bcnd lacc bcnd lacc neg_satd lacc epid upi,4 upi,0 upimagzerod,NTC #Vmin neg_satd,GT upi<Vmin branch saturate ;value valid limiterd #Vmin limiterd ;set saturation
upimagzerod ;Value positive lacc #Vmax bcnd pos_satd,LT upi>Vmax branch saturate lacc ;value valid limiterd pos_satd lacc #Vmax ;set saturation limiterd sacl ;Save reference value sacl elpi elpi Kcor epid apac xid,12 sach xid,4 d-axis current regulator with integral component correction alfa-axis beta-axis voltages calculation (d,q) (alfa,beta) axis transformation Vbetar cos(theta) sin(theta) Valfar =-Vqr sin(theta) cos(theta) lacc ;TREG0=Vdr seno1 ;PREG=Vdr*sin(theta) ;ACC+=PREG TREG0=Vqr coseno ;PREG=Vqr*cos(theta) mpya seno1 ;ACC+=PREG PREG=Vqr*sin(theta) sach Vbetar,4 lacc ;ACC=0 ;TREG0=Vdr mpys coseno ;ACC-=(PREG=Vqr*sin(theta)) apac ;ACC+=PREG sach Valfar,4 alfa-axis beta-axis voltages calculation Phase 1(=a) 2(=b) 3(=c) Voltage calculation (alfa,beta) (a,b,c) axis transformation Valfar (-Valfar sqrt(3) Vbetar) (-Valfar sqrt(3) Vbetar) Vbetar ;TREG0=Vbetar SQRT32 ;PREG=Vbetar*(SQRT(3)/2) ;ACC=PREG Valfar,11 ;ACC-=Valfar*2^11
Implementation Vector Control PMSM Using TMS320F240
sach Ub,4 ;ACC=PREG ;ACC=-ACC Valfar,11 ;ACC-=Valfar*2^11 sach Uc,4 lacl Valfar ;ACC=Valfar sacl ;Ua=ACCL Phase 1(=a) 2(=b) 3(=c) Voltage calculation Phase 1(=a) 2(=b) 3(=c) Voltage calculation (alfa,beta) (a,b,c) axis transformation modified exchanging alfa axis with beta axis correct sector calculation SVPWM Vbetar (-Vbetar sqrt(3) Valfar) (-Vbetar sqrt(3) Valfar) Valfar ;TREG0=Valfar SQRT32 ;PREG=Valfar*(SQRT(3)/2) ;ACC=PREG Vbetar,11 ;ACC-=Vbetar*2^11 sach Vb,4 ;ACC=PREG ;ACC=-ACC Vbetar,11 ;ACC-=Vbetar*2^11 sach Vc,4 lacl Vbetar ;ACC=Vbetar sacl ;Va=ACCL Phase 1(=a) 2(=b) 3(=c) Voltage calculation SPACE VECTOR Pulse Width Modulation (see SVPWM references) vDCinvTc SQRT32 sach tmp,4 Vbetar sach lacc ;ACC Vbetar*K1 sach accb sacl accb+1 ;ACCB Vbetar*K1 sacl ;X=2*Vbetar*K1 vDCinvTc splk #1800h,tmp ;implement #01800h sach tmp,4 Valfar sach tmp,4 lacc ;reload with Valfar*K2 accb+1 accb,16 sacl Vbetar Valfar tmp,1 sacl Vbetar Valfar degrees sector determination lacl sacl sector lacc bcnd Va_neg,LEQ Va<0 sector lacc sector
Implementation Vector Control PMSM Using TMS320F240
sacl sector ;implement #1,sector Va_neg lacc bcnd Vb_neg,LEQ Vb<0 sector lacc sector sacl sector ;implement #2,sector Vb_neg lacc bcnd Vc_neg,LEQ Vc<0 sector lacc sector sacl sector ;implement #4,sector Vc_neg degrees sector determination calculation depending sector number lacl sector ;(see SPACE VECTOR Modulation references details) bcnd no1,NEQ lacc sacl lacc sacl t1t2out lacl sector bcnd no2,NEQ lacc sacl lacc sacl t1t2out lacl sector bcnd no3,NEQ lacc sacl lacc sacl t1t2out lacl sector bcnd no4,NEQ lacc sacl lacc sacl t1t2out lacl sector bcnd no5,NEQ lacc sacl lacc sacl t1t2out lacc sacl lacc
Implementation Vector Control PMSM Using TMS320F240
sacl t1t2out lacc minumum values must Tonmax #Tonmax bcnd t1_ok,GEQ t1>Tonmax then t1_ok lacl #Tonmax sacl t1_ok lacc #Tonmax bcnd t2_ok,GEQ t2>Tonmax then t2_ok lacl #Tonmax sacl t2_ok calculation lacc sacl bcnd t1+t2>2*Tonmax have saturate #MAXDUTY nosaturation,LT,EQ
saturation lacc #MAXDUTY,15 ;divide MAXDUTY (t1+t2) subc sacl ;calculate saturate values sach t1,1 sach t2,1 saturation nosaturation taon,tbon tcon calculation lacc #PWMPRD ;calculate commutation instants taon, tbon tcon channels ;taon=(PWMPRD-t1-t2)/2 sacl taon ;tbon=taon+t1 sacl tbon ;tcon=tbon+t2 sacl tcon taon,tbon tcon calculation sector switching lacl sector bcnd nosect1,NEQ bldd bldd bldd nosect1 lacl bcnd bldd bldd bldd nosect2 lacl tbon,#CMPR1 taon,#CMPR2 tcon,#CMPR3 dacout sector nosect2,NEQ taon,#CMPR1 tcon,#CMPR2 tbon,#CMPR3 dacout sector
;depending sector number have switch calculated taon, tbon tcon correct channel ;(see SPACE VECTOR Modulation references details) ;sector
;sector
Implementation Vector Control PMSM Using TMS320F240
bcnd nosect3,NEQ bldd taon,#CMPR1 ;sector bldd tbon,#CMPR2 bldd tcon,#CMPR3 dacout nosect3 lacl sector bcnd nosect4,NEQ bldd tcon,#CMPR1 ;sector bldd tbon,#CMPR2 bldd taon,#CMPR3 dacout nosect4 lacl sector bcnd nosect5,NEQ bldd tcon,#CMPR1 ;sector bldd taon,#CMPR2 bldd tbon,#CMPR3 dacout nosect5 bldd tbon,#CMPR1 ;sector bldd tcon,#CMPR2 bldd taon,#CMPR3 sector switching SPACE VECTOR Pulse Width Modulation
dacout output channels 'da1', 'da2', 'da3' 'da4' Output Digital analog Converter equivalent FFFh #sector lacc sector,7 ;scale sector have good displaying sacl sectordisp ;only display purposes lacc terminal sacl DAC1 lacc channel 'da1' daout ar5,daout
;get address first elements ;add selected output variable offset 'da1' sent ;now daout contains address variable send ;store
;indirect addressing, load value send ;the following instructions required adapt numeric format resolution DAC, 2000h [0,5] Volt ;-2000h Volt #800h Volt. sacl daouttmp prepare triggering DAC1 buffer daouttmp,DAC0_VAL channel 'da1' lacc terminal sacl DAC1 lacc channel 'da2' daout ar5,daout
;get address first elements ;add selected output variable offset 'da1' sent ;now daout contains address variable send ;store
;indirect addressing, load value send ;the following instructions required adapt numeric format resolution
Implementation Vector Control PMSM Using TMS320F240
Volt sacl lacc terminal sacl DAC1 lacc have DAC, want have number 2000h
#800h daouttmp prepare triggering DAC1 buffer daouttmp,DAC1_VAL channel 'da2' channel 'da3' daout ar5,daout
;get address first elements ;add selected output variable offset 'da1' sent ;now daout contains address variable send ;store
;indirect addressing, load value send ;the following instructions required adapt numeric format resolution have DAC, want have number 2000h Volt #800h sacl daouttmp prepare triggering DAC1 buffer daouttmp,DAC2_VAL channel 'da3' lacc terminal sacl DAC1 lacc channel 'da4' daout ar5,daout
;get address first elements ;add selected output variable offset 'da1' sent ;now daout contains address variable send ;store
;indirect addressing, load value send ;the following instructions required adapt numeric format resolution have DAC, want have number 2000h Volt #800h sacl daouttmp prepare triggering DAC1 buffer daouttmp,DAC3_VAL channel 'da4' splk splk tmp,DAC_VAL #IFRA>>7 #0200h,IFRA ;start conversion
;Clear flags, change with only underflow int.
#DP_PF2 #0FF88h,PCDATDIR;bit IOPC7
END: enable ContextRestoreReturn *END ControlRoutine
_c_int0: ************************* Board general settings ************************* clrc clrc Function disable watchdog timer
Implementation Vector Control PMSM Using TMS320F240
#DP_PF1 splk #006Fh, WD_CNTL splk #05555h, WD_KEY splk #0AAAAh, WD_KEY splk #006Fh, WD_CNTL Function initialise Event Manager GPTimer Full Enable Timer 1==0 interrupt INT2 CAP1 INT4 Capture reads tacho input other pins SYSCLK with 10MHz External #DP_PF1 splk #00000010b,CKCR0;PLL disabled ;LPM0 ;ACLK enabled ;SYSCLK 5MHz splk #10110001b,CKCR1;10MHz ACLK splk #01100000b,CKCR1;20MHz clk-in ACLK divide ;PLL ratio splk #10000011b,CKCR0;PLL enabled ;LPM0 ;ACLK enabled ;SYSCLK 10MHz CLKOUT SYSCLK splk #40C0h,SYSCR Clear lacc sacl reset variables SYSSR #69FFh SYSSR
zero wait states external memory lacc #0004h #tmp sacl tmp,WSGR Clear sacl sacl sacl sacl sacl sacl sacl sacl sacl sacl sacl sacl sacl sacl sacl sacl sacl sacl sacl sacl sacl sacl sacl Registers #DP_EV GPTCON T1CNT T1CMP T1PER T1CON T2CNT T2CMP T2PER T2CON T3CNT T3CMP T3PER T3CON COMCON ACTR SACTR DBTCON CMPR1 CMPR2 CMPR3 SCMPR1 SCMPR2 SCMPR3
Implementation Vector Control PMSM Using TMS320F240
sacl sacl sacl sacl sacl sacl CAPCON CAPFIFO FIFO1 FIFO2 FIFO3 FIFO4 ;1us software dead-band ;Nicol activation ;Bits 15-12 used, space ;PWM compare actions ;PWM5/PWM6 Active Low/Active ;PWM3/PWM4 Active Low/Active ;PWM1/PWM2 Active Low/Active
Initialise splk #0999h,ACTR
vector High High High
splk splk splk splk splk
#100,CMPR1 #200,CMPR2 #300,CMPR3 #0000h,DBTCON #0207h,COMCON
splk splk splk splk
#8207h,COMCON #PWMPRD,T1PER #0,T1CNT #0A800h,T1CON
dead band from Nicol ;FIRST enable operation ;Reload Full Compare when T1CNT=0 ;Disable Space Vector ;Reload Full Compare Action when T1CNT=0 ;Enable Full Compare Outputs ;Disable Simple Compare Outputs ;Full Compare Units Mode ;THEN enable Compare operation ;Set period ;Ignore Emulation suspend ;Cont Up/Down Mode ;x/1 prescalar ;Use TENABLE ;Disable Timer,enable later ;Internal Clock Source ;Reload Compare Register when T1CNT=0 ;Disable Timer Compare operation
Enable Timer lacc T1CON #40h sacl T1CON MICHEL 23/10/96 Nicol Board Channel enable 74HC541 chip enable connected IOPC3 Digital input/output Configure IO\function MUXing pins #DP_PF2 ;Enable Power Security Function splk #000Fh,OPCRA ;ADCIN 0-1-8-9 enabled ;IOPB enabled splk #0079h,OPCRB ;IOPC 0-3-7 enabled splk #0FF02h,PBDATDIR;IOPB conf. output, logic ;used re-enable protection circuitry ;after fault ACPM750E splk #0FF08h,PCDATDIR;IOPC 0-3-7 conf. output, ;IOPC logic END: enable Incremental encoder initialization Capture Incremental encoder correction with Xint2 #DP_EV splk #0000h,T3CNT ;configure counter register splk #00FFh,T3PER ;configure period register splk #9870h,T3CON ;configure enable Timer splk #0E2F0h,CAPCON selected Time base
Implementation Vector Control PMSM Using TMS320F240
encoder/capture initialization initialization #DP_PF1 splk #0003h,ADC_CNTL2;prescaler 10MHz SYSCLK lacc ADC_FIFO1 ;empty FIFO lacc ADC_FIFO1 lacc ADC_FIFO2 lacc ADC_FIFO2 initialization Variables initialization lacc ismax sacl iqrmax sacl iqrmin sacl sacl sacl n_ref sacl sacl indice1 sacl sacl sacl xispeed sacl sacl elpi sacl sacl sacl sacl faultreset splk #24,da1 splk #25,da2 splk #42,da3 splk #0,da4 splk #VKcurrent,Kcurrent splk #VSQRT3inv,SQRT3inv splk #VSQRT32, SQRT32 splk #VKi, splk #VKpi, splk #VKcor, Kcor splk #VKispeed, Kispeed splk #VKpispeed,Kpispeed splk #VKcorspeed,Kcorspeed splk #VKiweak, Kiweak splk #VKpiweak, Kpiweak splk #VKcorweak,Kcorweak splk #Vismax, ismax splk #VKencoder,Kencoder Table initialization *,AR5 AR5,#sintab #255 blpd #sintab_flash,*+ setc setc initializations
shift after multiplication sign extension
Implementation Vector Control PMSM Using TMS320F240
Code added make program without UART interface splk #122h,vDCinvTc ;Tc/vDC/2 PWMPRD/vDC ;The voltage 310V ;The BEMF 3000rpm Vbase ;vDC VDCpu ;vDC VDC/Vbase 2.07 with Vbase=150V splk #000h,initphase ;initialization phase startup
Initialize stack context save space reserved: DARAM 60h-80h (page ar4,#79h ar5,#60h Enable Interrupts Clear regs #DP_EV splk #07FFh,IFRA splk #00FFh,IFRB splk #000Fh,IFRC Enable Underflow splk #0201h,IMRA ;PDPINT enabled splk #0000h,IMRB splk #0000h,IMRC Enable XINT2 interruption encoder synchronization #DP_PF1 splk #0006 ,XINT2_CNTL ;set input splk #0007 ,XINT2_CNTL ;set input ;clear flag, detect rising edge ;low priority, enable interrupt (p6.41) ;Set INT2 INT4 clear Flags ;INT2 (PWM interrupt) used motor control synchronization ;INT4 used encoder synchronization lacc #0FFh sacl lacc #0000010b sacl clrc IN;set right control variable page ;enable interrupts, serve ;interrupts
Enable Interrupts Serial communication initialization #DP_PF1 splk #00010111b,SCICCR ;one stop bit, parity, 8bits splk #0013h,SCICTL1 ;enable splk #0000h,SCICTL2 ;disable interrupts splk #0000h,SCIHBAUD ;MSB splk #0082h,SCILBAUD ;LSB |9600 Baud sysclk 10MHz splk #0022h,SCIPC2 ;I/O setting splk #0033h,SCICTL1 ;end initialization
*************** Virtual Menu ***************
Implementation Vector Control PMSM Using TMS320F240
menu bcnd lacc sacl bcnd
#DP_PF1 SCIRXST,BIT6 menu,ntc SCIRXBUF #0ffh #option option #031h notone,neq
there character available repeat cycle (polling) ;only bits yes, store option ;now option have option number virtual menu option branch notone
***************************** Option Speed reference ***************************** navail11 #DP_PF1 SCIRXST,BIT6 there character available LSB)? bcnd navail11,ntc repeat cycle (polling) lacc SCIRXBUF #0FFh ;take #serialtmp sacl serialtmp yes, store serialtmp navail12 #DP_PF1 SCIRXST,BIT6 available bcnd navail12,ntc repeat cycle (polling) lacc SCIRXBUF,8 ;load upper byte #serialtmp serialtmp ;add with lower byte sacl n_ref ;store menu ;return main polling cycle Option speed reference notone lacc bcnd
option #032h nottwo,neq
option branch nottwo
***************************** Option update ***************************** navail21 #DP_PF1 SCIRXST,BIT6 bcnd navail21,ntc lacc SCIRXBUF #0FFh #da1 sacl navail22 #DP_PF1 SCIRXST,BIT6 bcnd navail22,ntc lacc SCIRXBUF #0FFh #da1 sacl navail23 #DP_PF1 SCIRXST,BIT6 bcnd navail23,ntc lacc SCIRXBUF #0FFh #da1 sacl navail24 #DP_PF1 SCIRXST,BIT6
there character available LSB)? repeat cycle (polling) ;take yes, store
there character available LSB)? repeat cycle (polling) ;take yes, store
there character available LSB)? repeat cycle (polling) ;take yes, store
there character available LSB)?
Implementation Vector Control PMSM Using TMS320F240
bcnd navail24,ntc lacc SCIRXBUF #0FFh #da1 sacl menu Option update nottwo lacc bcnd repeat cycle (polling) ;take yes, store ;return main polling cycle
option #033h notthree,neq
option branch notthree
***************************** Option initphase ***************************** navail31 #DP_PF1 SCIRXST,BIT6 bcnd navail31,ntc lacc SCIRXBUF #0FFh #serialtmp sacl serialtmp navail32 #DP_PF1 SCIRXST,BIT6 bcnd navail32,ntc lacc SCIRXBUF,8 #serialtmp serialtmp sacl initphase menu Option initphase notthree lacc bcnd
there character available LSB)? repeat cycle (polling) ;take yes, store serialtmp
available repeat cycle (polling) ;load upper byte ;add with lower byte ;store ;return main polling cycle
option #034h notfour,neq
option branch notfour
***************************** Option vDCinvTc ***************************** navail41 #DP_PF1 SCIRXST,BIT6 bcnd navail41,ntc lacc SCIRXBUF #0FFh #serialtmp sacl serialtmp navail42 #DP_PF1 SCIRXST,BIT6 bcnd navail42,ntc lacc SCIRXBUF,8 #serialtmp serialtmp sacl vDCinvTc menu Option vDCinvTc notfour lacc bcnd
there character available LSB)? repeat cycle (polling) ;take yes, store serialtmp
available repeat cycle (polling) ;load upper byte ;add with lower byte ;store ;return main polling cycle
option #035h notfive,neq
option branch notfive
***************************** Option Kpi, Kcor
Implementation Vector Control PMSM Using TMS320F240
***************************** navail51 #DP_PF1 SCIRXST,BIT6 bcnd navail51,ntc lacc SCIRXBUF #0FFh #serialtmp sacl serialtmp navail52 #DP_PF1 SCIRXST,BIT6 bcnd navail52,ntc lacc SCIRXBUF,8 #serialtmp serialtmp sacl navail53 #DP_PF1 SCIRXST,BIT6 bcnd navail53,ntc lacc SCIRXBUF #0FFh #serialtmp sacl serialtmp navail54 #DP_PF1 SCIRXST,BIT6 bcnd navail54,ntc lacc SCIRXBUF,8 #serialtmp serialtmp sacl navail55 #DP_PF1 SCIRXST,BIT6 bcnd navail55,ntc lacc SCIRXBUF #0FFh #serialtmp sacl serialtmp navail56 #DP_PF1 SCIRXST,BIT6 bcnd navail56,ntc lacc SCIRXBUF,8 #serialtmp serialtmp sacl Kcor menu Option notfive lacc bcnd
there character available LSB)? repeat cycle (polling) ;take yes, store serialtmp
available repeat cycle (polling) ;load upper byte ;add with lower byte ;store
there character available LSB)? repeat cycle (polling) ;take yes, store serialtmp
available repeat cycle (polling) ;load upper byte ;add with lower byte ;store
there character available LSB)? repeat cycle (polling) ;take yes, store serialtmp
available repeat cycle (polling) ;load upper byte ;add with lower byte ;store ;return main polling cycle
option #036h notsix,neq
option branch notsix
***************************** Option Kpispeed Kispeed Kcorspeed ***************************** navail61 #DP_PF1 SCIRXST,BIT6 there character available LSB)? bcnd navail61,ntc repeat cycle (polling) lacc SCIRXBUF #0FFh ;take #serialtmp sacl serialtmp yes, store serialtmp navail62
Implementation Vector Control PMSM Using TMS320F240
#DP_PF1 SCIRXST,BIT6 bcnd navail62,ntc lacc SCIRXBUF,8 #serialtmp serialtmp sacl Kpispeed navail63 #DP_PF1 SCIRXST,BIT6 bcnd navail63,ntc lacc SCIRXBUF #0FFh #serialtmp sacl serialtmp navail64 #DP_PF1 SCIRXST,BIT6 bcnd navail64,ntc lacc SCIRXBUF,8 #serialtmp serialtmp sacl Kispeed navail65 #DP_PF1 SCIRXST,BIT6 bcnd navail65,ntc lacc SCIRXBUF #0FFh #serialtmp sacl serialtmp navail66 #DP_PF1 SCIRXST,BIT6 bcnd navail66,ntc lacc SCIRXBUF,8 #serialtmp serialtmp sacl Kcorspeed menu Option notsix lacc bcnd
available repeat cycle (polling) ;load upper byte ;add with lower byte ;store
there character available LSB)? repeat cycle (polling) ;take yes, store serialtmp
available repeat cycle (polling) ;load upper byte ;add with lower byte ;store
there character available LSB)? repeat cycle (polling) ;take yes, store serialtmp
available repeat cycle (polling) ;load upper byte ;add with lower byte ;store ;return main polling cycle
option #037h notseven,neq
option branch notseven
***************************** Option Kpiweak Kiweak ***************************** navail71 #DP_PF1 SCIRXST,BIT6 bcnd navail71,ntc lacc SCIRXBUF #0FFh #serialtmp sacl serialtmp navail72 #DP_PF1 SCIRXST,BIT6 bcnd navail72,ntc lacc SCIRXBUF,8 #serialtmp serialtmp sacl Kpiweak navail73 #DP_PF1 SCIRXST,BIT6
Kcorweak
there character available LSB)? repeat cycle (polling) ;take yes, store serialtmp
available repeat cycle (polling) ;load upper byte ;add with lower byte ;store
there character available LSB)?
Implementation Vector Control PMSM Using TMS320F240
bcnd navail73,ntc lacc SCIRXBUF #0FFh #serialtmp sacl serialtmp navail74 #DP_PF1 SCIRXST,BIT6 bcnd navail74,ntc lacc SCIRXBUF,8 #serialtmp serialtmp sacl Kiweak navail75 #DP_PF1 SCIRXST,BIT6 bcnd navail75,ntc lacc SCIRXBUF #0FFh #serialtmp sacl serialtmp navail76 #DP_PF1 SCIRXST,BIT6 bcnd navail76,ntc lacc SCIRXBUF,8 #serialtmp serialtmp sacl Kcorweak menu Option notseven lacc bcnd repeat cycle (polling) ;take yes, store serialtmp
available repeat cycle (polling) ;load upper byte ;add with lower byte ;store
there character available LSB)? repeat cycle (polling) ;take yes, store serialtmp
available repeat cycle (polling) ;load upper byte ;add with lower byte ;store ;return main polling cycle
option #038h noteight,neq
option branch noteight
***************************** Option faultreset ***************************** navail81 #DP_PF1 SCIRXST,BIT6 bcnd navail81,ntc lacc SCIRXBUF #0FFh #serialtmp sacl serialtmp navail82 #DP_PF1 SCIRXST,BIT6 bcnd navail82,ntc lacc SCIRXBUF,8 #serialtmp serialtmp sacl faultreset menu Option faultreset noteight
there character available LSB)? repeat cycle (polling) ;take yes, store serialtmp
available repeat cycle (polling) ;load upper byte ;add with lower byte ;store ;return main polling cycle
menu
Implementation Vector Control PMSM Using TMS320F240
Appendix Linker File
TEXAS INSTRUMENTS File Name: link.cmd Originator: Michel Platnic Description:Link command file MEMORY SPECIFICATION MCK240 EVMF240 Target: TMS320F240, MCK240 EVMF240 status: Working History: Completed April MEMORY PAGE FLASH_VEC FLASH FLASH_TAB PAGE REGS BLK_B22 BLK_B0 BLK_B1 EXT_DATA /*-*/ SECTIONS ALLOCATION /*-*/ SECTIONS vectors FLASH_VEC PAGE INTERRUPT VECTOR TABLE .text FLASH PAGE CODE table_f FLASH_TAB PAGE Table flash program blockb2 BLK_B22 PAGE Data storage .data BLK_B0 PAGE .bss BLK_B0 PAGE GLOBAL VARS, STACK, HEAP table BLK_B1 PAGE
origin length origin 040h, length 0FC0h origin 1000h, length 0200h
origin origin origin origin origin
60h, 200h, 300h, 8000h,
length length length length length
100h 100h 1000h
Implementation Vector Control PMSM Using TMS320F240
Appendix Sinewave Table
.word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word 1092 1189 1285 1380 1474 1567 1660 1751 1842 1931 2019 2106 2191 2276 2359 2440 2520 2598 2675 2751 2824 2896 2967 3035 3102 3166 3229 3290 3349 3406 3461 3513 3564 3612 3659 3703 3745 3784 3822 3857 3889 3920 3948 3973 3996 4017 4036 4052 .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word 3166 3102 3035 2967 2896 2824 2751 2675 2598 2520 2440 2359 2276 2191 2106 2019 1931 1842 1751 1660 1567 1474 1380 1285 1189 1092 65435 65335 65235 65135 65035 64935 64836 64737 64639 64541 64444 64347 64251 64156 64062 63969 63876 63785 63694 63605 63517 63430 .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word 61833 61791 61752 61714 61679 61647 61616 61588 61563 61540 61519 61500 61484 61471 61460 61451 61445 61441 61440 61441 61445 61451 61460 61471 61484 61500 61519 61540 61563 61588 61616 61647 61679 61714 61752 61791 61833 61877 61924 61972 62023 62075 62130 62187 62246 62307 62370 62434 62501 62569 62640 62712 62785 62861 62938 63016 63096 63177 63260
Implementation Vector Control PMSM Using TMS320F240
.word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word 4065 4076 4085 4091 4095 4096 4095 4091 4085 4076 4065 4052 4036 4017 3996 3973 3948 3920 3889 3857 3822 3784 3745 3703 3659 3612 3564 3513 3461 3406 3349 3290 3229 .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word 63345 63260 63177 63096 63016 62938 62861 62785 62712 62640 62569 62501 62434 62370 62307 62246 62187 62130 62075 62023 61972 61924 61877 .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word .word 63345 63430 63517 63605 63694 63785 63876 63969 64062 64156 64251 64347 64444 64541 64639 64737 64836 64935 65035 65135 65235 65335 65435
Implementation Vector Control PMSM Using TMS320F240
Appendix Qbasic User Interface
OPEN "COM1: OUTPUT PRINT "1"; CHR$(0); CHR$(0); speed reference initialization PRINT "2"; CHR$(23); CHR$(25); CHR$(41); CHR$(3); initialization PRINT "3"; CHR$(0); CHR$(0); initialization phase speedref init Kcor Kispeed Kpispeed Kcorspeed .0046 Kiweak Kpiweak Kcorweak initphase$(0) "Init" initphase$(1) "Run" 600: period speedpu 3000: base speed ibase 4.1: base current Vbase 152: base voltage daout$(200) daout$(0) "ia" daout$(1) "ib" daout$(2) "ic" daout$(3) "Ua" daout$(4) "Ub" daout$(5) "Uc" daout$(6) "seno1" daout$(7) "t1" daout$(8) "t2" daout$(9) "coseno" daout$(10) "Va" daout$(11) "Vb" daout$(12) "Vc" daout$(13) "VDC" daout$(14) "taon" daout$(15) "tbon" daout$(16) "tcon" daout$(17) "theta" daout$(18) "ialfa" daout$(19) "ibeta" daout$(20) "Valfar" daout$(21) "Vbetar" daout$(22) "idr" daout$(23) "iqr" daout$(24) "idS" daout$(25) "iqS" daout$(26) "Vdr" daout$(27) "Vqr" daout$(28) "epiq" daout$(29) "epid" daout$(30) "xiq" daout$(31) "xid" daout$(32) daout$(33) "n_ref" daout$(34) "epispeed" daout$(35) "xispeed" daout$(36) daout$(37) daout$(38) daout$(39) "sector" daout$(40) "initphase"
Implementation Vector Control PMSM Using TMS320F240
daout$(41) daout$(42) daout$(43) daout$(44) COLOR LOCATE PRINT "("; PRINT USING "##"; PRINT daout$(i) LOCATE PRINT "("; PRINT USING "##"; PRINT daout$(i LOCATE PRINT "("; PRINT USING "##"; PRINT daout$(i LOCATE PRINT "("; PRINT USING "##"; PRINT daout$(i NEXT LOCATE COLOR PRINT Digital Control Permanent Magnet Motor" PRINT COLOR PRINT "<1>"; COLOR PRINT Speed_reference speedref; "rpm COLOR PRINT "<2>"; COLOR PRINT DAC_Outputs DAC1: daout$(da1); LOCATE PRINT "DAC2: daout$(da2); PRINT DAC3: daout$(da3); LOCATE PRINT "DAC4: daout$(da4); COLOR PRINT "<3>"; COLOR PRINT Init_phase (0=Init) initphase$(init); COLOR PRINT "<4>"; COLOR PRINT Vbase Vbase; "Volts COLOR PRINT "<8>"; COLOR PRINT Re-enable after fault" COLOR COLOR COLOR COLOR COLOR COLOR COLOR COLOR COLOR LOCATE LOCATE LOCATE LOCATE LOCATE LOCATE LOCATE LOCATE LOCATE PRINT PRINT PRINT PRINT PRINT PRINT PRINT PRINT PRINT <5>"; COLOR PRINT COLOR PRINT COLOR PRINT Kcor <6>"; COLOR PRINT Kpispeed COLOR PRINT Kispeed COLOR PRINT Kcorspeed <7>"; COLOR PRINT Kpiweak COLOR PRINT Kiweak COLOR PRINT Kcorweak Kpi; "pu)" "pu)" Kcor; "pu)" Kpispeed; "pu)" Kispeed; "pu)" Kcorspeed; "pu)" Kpiweak; "pu)" Kiweak; "pu)" Kcorweak; "pu)" "encoder" "Vr" "iqrmin" "iqrmax"
COLOR LOCATE PRINT "Choice init88 CLNG(init 256) VDCpu Vbase VDCinvTc VDCpu Kpipu 4096 Kipu 4096 Kcor Kpi) Kcorpu 4096 Kcor Kpispeedpu 4096 Kpispeed Kispeedpu 4096 Kispeed Kcorspeed (Kispeed Kpispeed) Kcorspeedpu 4096 Kcorspeed Kpiweakpu 4096 Kpiweak Kiweakpu 4096 Kiweak Kcorweak (Kiweak Kpiweak) Kcorweakpu 4096 Kcorweak INKEY$ LOOP UNTIL ((a$ "8") "1")) "r") "R") SELECT CASE CASE 4.12 format PRINT PRINT "Speed_Reference speedref; "rpm INPUT speedref$ speedref$ THEN speedrpu VAL(speedref$) speedpu (speedrpu 7.999755859#) THEN speedrpu 7.999755859# (speedrpu THEN speedrpu speedrefpu CLNG(speedrpu 4096)
Implementation Vector Control PMSM Using TMS320F240
(speedref THEN speedrefpu 65536 speedrefpu PRINT "1"; CHR$(speedrefpu 255); CHR$((speedrefpu 65280) 256) speedref speedrpu speedpu GOTO CASE standard decimal format PRINT PRINT "DAC1, DAC2, DAC3 DAC4 dach$ INKEY$ dach$ THEN dach$ CHR$(13) THEN dach$ THEN PRINT "DAC1 Output da1; INPUT THEN VAL(da$) dach$ THEN PRINT "DAC2 Output da2; INPUT THEN VAL(da$) dach$ THEN PRINT "DAC3 Output da3; INPUT THEN VAL(da$) dach$ THEN PRINT "DAC4 Output da4; INPUT THEN VAL(da$) PRINT "2"; CHR$(da1 255); CHR$(da2 255); CHR$(da3 255); CHR$(da4 255) GOTO CASE init THEN init ELSE init (init 255.9960938#) THEN init 255.9960938# (init THEN init init88 CLNG(init 256) PRINT "3"; CHR$(init88 255); CHR$((init88 65280) 256) GOTO CASE 4.12 format PRINT PRINT "Vbase Vbase; "Volts INPUT Vbase$ Vbase$ THEN (Vbase THEN VDCpu VAL(Vbase$) (VDCpu 7.999755859#) THEN VDCpu 7.999755859# (VDCpu THEN VDCpu VDCinvTc VDCpu PRINT "4"; CHR$(VDCinvTc 255); CHR$((VDCinvTc 65280) 256) Vbase VDCpu GOTO CASE 4.12 format PRINT PRINT "Kpi Kpi; INPUT Kpi$ Kpi$ THEN VAL(Kpi$) (Kpi 7.9) THEN (Kpi THEN PRINT INPUT THEN
Implementation Vector Control PMSM Using TMS320F240
VAL(Ki$) THEN THEN Kpipu 4096 Kipu 4096 Kcor Kpi) Kcorpu 4096 Kcor PRINT "5"; CHR$(Kpipu 255); CHR$((Kpipu 65280) 256); CHR$(Kipu 255); CHR$((Kipu 65280) 256); CHR$(Kcorpu 255); CHR$((Kcorpu 65280) 256) GOTO CASE 4.12 format PRINT PRINT "Kpispeed Kpispeed; INPUT Kpispeed$ Kpispeed$ THEN Kpispeed VAL(Kpispeed$) (Kpispeed 7.9) THEN Kpispeed (Kpispeed THEN Kpispeed PRINT Kispeed Kispeed; INPUT Kispeed$ Kispeed$ THEN Kispeed VAL(Kispeed$) (Kispeed THEN Kispeed (Kispeed THEN Kispeed Kpispeedpu 4096 Kpispeed Kispeedpu 4096 Kispeed Kcorspeed (Kispeed Kpispeed) Kcorspeedpu 4096 Kcorspeed Send "Option" "LSB" "MSB" PRINT "6"; CHR$(Kpispeedpu 255); CHR$((Kpispeedpu 65280) 256); CHR$(Kispeedpu 255); CHR$((Kispeedpu 65280) 256); CHR$(Kcorspeedpu 255); CHR$((Kcorspeedpu 65280) 256) GOTO CASE 4.12 format PRINT PRINT "Kpiweak Kpiweak; INPUT Kpiweak$ Kpiweak$ THEN Kpiweak VAL(Kpiweak$) (Kpiweak 7.9) THEN Kpiweak (Kpiweak THEN Kpiweak PRINT Kiweak Kiweak; INPUT Kiweak$ Kiweak$ THEN Kiweak VAL(Kiweak$) (Kiweak THEN Kiweak (Kiweak THEN Kiweak Kpiweakpu 4096 Kpiweak Kiweakpu 4096 Kiweak Kcorweak (Kiweak Kpiweak) Kcorweakpu 4096 Kcorweak Send "Option" "LSB" "MSB" PRINT "7"; CHR$(Kpiweakpu 255); CHR$((Kpiweakpu 65280) 256); CHR$(Kiweakpu 255); CHR$((Kiweakpu 65280) 256); CHR$(Kcorweakpu 255); CHR$((Kcorweakpu 65280) 256) GOTO CASE faultreset init88 CLNG(faultreset 256) PRINT "8"; CHR$(init88 255); CHR$((init88 65280) 256) GOTO CASE ELSE PRINT "1"; CHR$(speedrefpu 255); CHR$((speedrefpu 65280) 256)
Implementation Vector Control PMSM Using TMS320F240
PRINT "2"; CHR$(da1 255); CHR$(da2 255); CHR$(da3 255); CHR$(da4 255) PRINT "3"; CHR$(init88 255); CHR$((init88 65280) 256) PRINT "4"; CHR$(VDCinvTc 255); CHR$((VDCinvTc 65280) 256) PRINT "5"; CHR$(Kpipu 255); CHR$((Kpipu 65280) 256); CHR$(Kipu 255); CHR$((Kipu 65280) 256); CHR$(Kcorpu 255); CHR$((Kcorpu 65280) 256) PRINT "6"; CHR$(Kpispeedpu 255); CHR$((Kpispeedpu 65280) 256); CHR$(Kispeedpu 255); CHR$((Kispeedpu 65280) 256); CHR$(Kcorspeedpu 255); CHR$((Kcorspeedpu 65280) 256) PRINT "7"; CHR$(Kpiweakpu 255); CHR$((Kpiweakpu 65280) 256); CHR$(Kiweakpu 255); CHR$((Kiweakpu 65280) 256); CHR$(Kcorweakpu 255); CHR$((Kcorweakpu 65280) 256) GOTO SELECT CLOSE
INTERNET www.ti.com Register with TI&ME build custom information pages receive product updates automatically email.
Semiconductor Home Page http://www.ti.com/sc Distributors
PRODUCT INFORMATION CENTERS
Europe, Middle East, Africa Phone Deutsch +49-(0) 8161 3311 English +44-(0) 1604 3399 Francais +33-(0) 1-30 Italiano +33-(0) 1-30 +33-(0) 1-30-70 Email epic@ti.com Japan Phone International Domestic International Domestic Email Asia Phone International Domestic Australia
TMS320 Hotline email Americas Phone Email
+81-3-3457-0972 +0120-81-0026 +81-3-3457-1259 +0120-81-0036 pic-japan@ti.com
(281) 274-2320 (281) 274-2324 (281) 274-2323 dsph@ti.com +1(972) 644-5580 +1(972) 480-7800 sc-infomaster@ti.com
+886-2-3786800 1-800-881-011
Asia (continued) Number China Number Hong Kong Number India Number Indonesia Number Korea Malaysia Number Zealand Number Philippines Number Singapore Number Taiwan Thailand Number
-800-800-1450 10811 -800-800-1450 800-96-1111 -800-800-1450 000-117 -800-800-1450 001-801-10 -800-800-1450 080-551-2804 1-800-800-011 -800-800-1450 +000-911 -800-800-1450 105-11 -800-800-1450 800-0111-111 -800-800-1450 080-006800 0019-991-1111 -800-800-1450
Implementation Vector Control PMSM Using TMS320F240
IMPORTANT NOTICE Texas Instruments subsidiaries (TI) reserve right make changes their products discontinue product service without notice, advise customers obtain latest version relevant information verify, before placing orders, that information being relied current complete. products sold subject terms conditions sale supplied time order acknowledgement, including those pertaining warranty, patent infringement, limitation liability. warrants performance semiconductor products specifications applicable time sale accordance with TI's standard warranty. Testing other quality control techniques utilized extent deems necessary support this warranty. Specific testing parameters each device necessarily performed, except those mandated government requirements. CERTAIN APPLICATIONS USING SEMICONDUCTOR PRODUCTS INVOLVE POTENTIAL RISKS DEATH, PERSONAL INJURY, SEVERE PROPERTY ENVIRONMENTAL DAMAGE ("CRITICAL APPLICATIONS"). SEMICONDUCTOR PRODUCTS DESIGNED, AUTHORIZED, WARRANTED SUITABLE LIFE-SUPPORT DEVICES SYSTEMS OTHER CRITICAL APPLICATIONS. INCLUSION PRODUCTS SUCH APPLICATIONS UNDERSTOOD FULLY CUSTOMER'S RISK. order minimize risks associated with customer's applications, adequate design operating safeguards must provided customer minimize inherent procedural hazards. assumes liability applications assistance customer product design. does warrant represent that license, either express implied, granted under patent right, copyright, mask work right, other intellectual property right covering relating combination, machine, process which such semiconductor products services might used. TI's publication information regarding third party's products services does constitute TI's approval, warranty, endorsement thereof. Copyright 1998, Texas Instruments Incorporated trademark Texas Instruments Incorporated. Other brands names property their respective owners.
Implementation Vector Control PMSM Using TMS320F240

Other recent searches


TAP1000 - TAP1000   TAP1000 Datasheet
PCM80 - PCM80   PCM80 Datasheet
NT32525SG-WB - NT32525SG-WB   NT32525SG-WB Datasheet
MP4504 - MP4504   MP4504 Datasheet
KPK-3520MGCK - KPK-3520MGCK   KPK-3520MGCK Datasheet
JESD22-B111 - JESD22-B111   JESD22-B111 Datasheet
1SMA4741 - 1SMA4741   1SMA4741 Datasheet

 

Privacy Policy | Disclaimer
© 2012 Datasheet Archive