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*)

 

 

Michael DiRenzo Digital Signal Processing Solutions ABSTRACT This


Datasheet Thumbnail

  

Download PDF



Top Searches for this datasheet



Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
Michael DiRenzo Digital Signal Processing Solutions
ABSTRACT This report describes basic operation switched reluctance motors (SRMs) demonstrates TMS320F240 DSP-based drive from Texas Instruments (TITM) used achieve wide variety control objectives. first part report offers detailed review operation characteristics SRMs. advantages disadvantages this type motor cited. second part report provides example application four-quadrant, variable speed drive system using shaft position sensor. example complete hardware software details developing drive system using TMS320F240. operation described, along with theoretical basis designing various control algorithms. example used baseline design which easily modified accommodate specific application. This report contains material previously released Texas Instruments application report Developing Drive System Using TMS320F240 (literature number SPRA420), been updated inclusion Application Design (ADK) switched reluctance motors.
Contents Introduction Motor Characteristics Torque-Speed Characteristics Electromagnetic Equations General Torque Equation Simplified Torque Equation Control Example Drive with Position Feedback Hardware Description 4.1.1 Characteristics 4.1.2 Control Hardware 4.1.3 Position Sensor 4.1.4 Power Electronics Hardware Software Description 4.2.1 Program Structure 4.2.2 Initialization Routines
trademark Texas Instruments Incorporated.
SPRA420A
4.2.3 Current Controller 4.2.4 Position Estimation 4.2.5 Velocity Estimation 4.2.6 Commutation 4.2.7 Velocity Controller References Appendix Software Listings TMS320F240-Based Drive With Position Sensor List Figures Figure Various Geometries Figure Torque-Speed Characteristics Figure Graphical Interpretation Magnetic Field Energy Figure Graphical Interpretation Magnetic Field Co-Energy Figure Basic Operation Current-Controlled Motoring Speed Figure Commutation 3-Phase Figure Single-Pulse Mode Motoring, High Speed Figure Shaft Position Sensor Figure Opto-Coupler Output Signals Rotor Angle Figure Opto-Coupler Connections TMS320F240 Figure Two-Switch Phase Inverter Figure Schematic Diagram Inverter Using IR2110 Connections Figure Block Diagram Controller Figure TMS320F240 Control Program Structure Figure Processor Timeline Showing Typical Loading Execution Control Algorithms Figure Initialization Flowchart Figure Approximate Current Loop Model Figure Frequency Response Plots Current Loop Unaligned Position (Squares) Aligned Position (Circles) Figure State Transition Diagram Position Pickoff Figure Simplified Block Diagram Velocity Loop Using Control Figure Open-Loop Frequency Response Velocity Loop Several Motor Speeds, 0.73 rad/s List Tables Table Parameters Table Benchmark Data Various Drive Software Modules
Introduction
Electric machines broadly classified into categories basis they produce torque electromagnetically variable reluctance. first category, motion produced interaction magnetic fields, generated stator other rotor. magnetic fields, mutually coupled, produce electromagnetic torque tending bring fields into alignment. same phenomenon causes opposite poles magnets attract like poles repel. vast majority motors commercial today operate this principle. These motors, which include induction motors, differentiated based their geometries magnetic fields generated. Some familiar ways generating these fields through energized windings, with permanent magnets, through induced electrical currents.
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
second category, motion produced result variable reluctance between rotor stator. When stator winding energized, producing single magnetic field, reluctance torque produced tendency rotor move minimum reluctance position. This phenomenon analogous force that attracts iron steel permanent magnets. those cases, reluctance minimized when magnet metal come into physical contact. motors that operate this principle, switched reluctance motor (SRM) falls into this class machines. construction, simplest electrical machines. Only stator windings. rotor contains conductors permanent magnets. consists simply steel laminations stacked onto shaft. because this simple mechanical construction that SRMs carry promise cost, which turn motivated large amount research SRMs last decade. mechanical simplicity device, however, comes with some limitations. Like brushless motor, SRMs directly from line, must always electronically commutated. Also, saliency stator rotor, necessary machine produce reluctance torque, causes strong non-linear magnetic characteristics, complicating analysis control SRM. surprisingly, industry acceptance SRMs been slow. This combination perceived difficulties with SRM, lack commercially available electronics with which operate them, entrenchment traditional machines marketplace. SRMs however, offer some advantages along with potential cost. example, they very reliable machines since each phase largely independent physically, magnetically, electrically from other motor phases. Also, because lack conductors magnets rotor, very high speeds achieved, relative comparable motors. Disadvantages often cited SRM; that they difficult control, that they require shaft position sensor operate, they tend noisy, they have more torque ripple than other types motors; have generally been overcome through better understanding mechanical design development algorithms that compensate these problems.
Motor Characteristics
basic operating principle quite simple; current passed through stator windings, torque generated tendency rotor align with excited stator pole. direction torque generated function rotor position with respect energized phase, independent direction current flow through phase winding. Continuous torque produced intelligently synchronizing each phase's excitation with rotor position. varying number phases, number stator poles, number rotor poles, many different geometries realized. examples shown Figure
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
2-phase, rotor poles/2 stator poles
4-phase, rotor poles/6 stator poles
3-phase, rotor poles/4 stator poles
5-phase, rotor poles/8 stator poles
Figure Various Geometries Note that although true these examples, number phases necessarily equal half number rotor poles. Generally, increasing number phases reduces torque ripple, expense requiring more electronics with which operate SRM. least phases required guarantee starting, least three phases required insure starting direction. number rotor poles stator poles must also differ insure starting.
Torque-Speed Characteristics
torque-speed operating point essentially programmable, determined almost entirely control. This features that makes attractive solution. envelope operating possibilities, course, limited physical constraints such supply voltage allowable temperature rise motor under increasing load. general, this envelope described Figure
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
Current Limit Constant Power, Torque
Base Speed
Speed
Figure Torque-Speed Characteristics Like other motors, torque limited maximum allowed current, speed available voltage. With increasing shaft speed, current limit region persists until rotor reaches speed where back-EMF motor such that, given voltage limitation more current winding-thus more torque from motor. this point, called base speed, beyond, shaft output power remains constant, it's maximum. still higher speeds, back-EMF increases shaft output power begins drop. This region characterized product torque square speed remaining constant.
Electromagnetic Equations
Although motor operation appears simple, accurate analysis motor's behavior requires formal, relatively complex, mathematical approach. instantaneous voltage across terminals single phase motor winding related flux linked winding Faraday's law,
where, terminal voltage, phase current, motor resistance, flux linked winding. Because double salient construction motor (both rotor stator have salient poles) because magnetic saturation effects, general, flux linked phase varies function rotor position, motor current. Thus, Equation expanded
where, defined instantaneous inductance, instantaneous back EMF.
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
General Torque Equation
Equation governs transfer electrical energy SRM's magnetic field. this section, equations which describe conversion field's energy into mechanical energy developed. Multiplying each side Equation electrical current, gives expression instantaneous power SRM,
left-hand side Equation represents instantaneous electrical power delivered SRM. first term right-hand side (RHS) Equation represents ohmic losses winding. power conserved, then second term Equation must represent mechanical power output power stored magnetic field. Thus,
where, instantaneous mechanical power, instantaneous power, which stored magnetic field. Because power, it's definition, time rate change energy, mechanical energy magnetic field energy. well known that mechanical power written product torque speed,
where, torque,
rotational velocity shaft.
Substitution Equation into Equation gives,
solving Equation torque yields equation,
constant flux, Equation simplifies
Since often desirable express torque terms current rather than flux, common express torque terms co-energy, instead energy. introduce concept co-energy, first consider graphical interpretation field energy. constant shaft angle,
integration Equation shows that magnetic field energy given
equation,
i(q,
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
graphically shaded area Figure
stored field energy
Flux Linkage angle, magnetization curve defines current function flux
Current
Figure Graphical Interpretation Magnetic Field Energy Now, consider Figure
stored field co-energy
Flux Linkage angle, magnetization curve defines flux function current
Current
Figure Graphical Interpretation Magnetic Field Co-Energy
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
fixed angle, magnetization curve define flux function current, instead current defined function flux. shaded area below curve,
f(q,
(10)
defined magnetic field co-energy. From Figure Figure that area defining field energy co-energy described relation,
Differentiating both sides Equation (11) yields
(11)
(12)
Solving differential field energy Equation (12) substituting back into Equation gives,
c(q,
(13)
simplification, general torque equation, Equation (13), usually simplified values constant current. differential co-energy written terms partial derivatives
c(q,
(14)
From Equation (13) Equation (14), fairly easy show that under constant current,
constant
(15)
Simplified Torque Equation
Often, analysis proceeds under assumption that, magnetically, motor remains unsaturated during operation. This assumption useful "first cut" control designs performance predictions. When magnetic saturation neglected, relationship from flux current given L(q) (16)
motor inductance varies only function rotor angle. Substituting Equation (16) into Equation (10) evaluating integral yields,
L(q)
(17)
then substituting Equation (17) into Equation (15) gives familiar simplified relationship torque,
(18)
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
Control
drives controlled synchronizing energization motor phases with rotor position. Figure illustrates basic strategy.
idealized inductance ideal current
current
voltage
Figure Basic Operation Current-Controlled Motoring Speed Equation (18) suggests, positive motoring) torque produced when motor inductance rising shaft angle increasing,
Thus, desired operation have current winding during this period time. Similarly, negative braking) torque produced supplying winding with current while
exact choice turn-on turn-off angles magnitude phase current, determine ultimate performance SRM. design commutation angles, sometimes called firing angles, usually involves resolution conflicting concerns maximizing torque output motor maximizing efficiency motor. general, efficiency optimized minimizing dwell angle (the dwell angle angle traversed while phase conducts), maximum torque achieved maximizing dwell angle take advantage potential torque output from given phase. simple effective commutation scheme depicted Figure
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
Torque
phase
Current
phase phase
Rotor Electrical Angle (deg)
Figure Commutation 3-Phase plot Figure dashed line shows torque that would generated phase should constant current flow through phase winding during entire electrical cycle SRM. With idealized current waveforms figure, resulting torque from motor shown solid line. turn-on turn-off angles coincide with region where maximum torque obtained given amount phase current. This commutation sequence tends optimize efficiency. Here, dwell angle electrical degrees used, which minimum dwell angle that used three-phase SRM, without regions zero torque. interest note from Figure that constant current results non-constant torque. might expected, schemes have been proposed Husain Ehsani1, Ilic-Spong, Kjaer, that attempt linearize output torque shaping controlling phase currents through some non-linear function that depends upon motor characteristics. This application, although covered this report, well suited implementation. Figure illustrates effect that choice commutation angles have upon performance. Equally important magnitude current that flows winding. Commonly, phase current sensed controlled closed-loop manner, seen voltage curve Figure control typically implemented using techniques.
Husain Ehsani, Torque Ripple Minimization Switched Reluctance Motor Drives
Current Control," Proc. APEC'94, 1994, 72-77.
Ilic-Spong, Miller, MacMinn, Thorp, "Instantaneous Torque Control
Electric Motor Drives," IEEE Trans. Power Electronics, Vol. 55-61, Jan. 1987.
Kjaer, Gribble, Miller, "High-grade Control Switched Reluctance Machines,"
IEEE Trans. Industry Electronics, Vol. 1585-1593, Nov. 1997.
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
control often described terms "low-speed" "high-speed" regimes. Low-speed operation typically characterized ability arbitrarily control current desired value. Figure illustrates waveforms typical low-speed operation. motor's speed increases, becomes increasingly difficult regulate current because combination back effects reduced amount time commutation interval. Eventually speed reached where phase conducts (remains during entire commutation interval. This mode operation, depicted Figure called single-pulse mode.
idealized inductance
current
voltage
Figure Single-Pulse Mode Motoring, High Speed When this occurs, motor speed increased increasing conduction period greater dwell angle) advancing firing angles, combination both. adjusting turn-on turn-off angles that phase commutation begins sooner, gain advantage producing current winding while inductance low, also having additional time reduce current winding before rotor reaches negative torque region. Control firing angles accomplished number ways, based type position feedback available optimization goal control, discussed publications Becerra, al,4 Miller.5 When position information more precisely known, more sophisticated approach used. approach continuously vary turn-on angle with fixed dwell. Near turn-on, Equation approximated
(19)
Becerra, Ehsani, Miller, "Commutation Motors," IEEE Trans. Power
Electronics, Vol. July 1993, 257-262.
Miller, "Switched Reluctance Motors Their Control," Magna Physics Publishing,
Hillsboro, Oxford, 1993.
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
Multiplying each side Equation (19) differential, solving gives,
(20)
using first order approximations yields equation calculating advance angle, (21)
where icmd desired phase current Vbus voltage.
Example Drive with Position Feedback
This section describes example application drive with position feedback. 3-phase 12/8 machine that speed current controlled.
Hardware Description
4.1.1
Characteristics
characteristics used this application report given Table Table Parameters
number phases, number stator poles, number rotor poles, nominal phase resistance, nominal aligned inductance, nominal unaligned inductance, phase current (max) voltage, Vbus
4.1.2
Control Hardware
control hardware used this application report TMS320F240 evaluation module (EVM).
4.1.3
Position Sensor
Shaft position information provided using 8-slot, slotted disk connected rotor shaft three opto-couplers mounted stator housing shown Figure
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
Housing
Opto-couplers
Rotor Shaft
Slotted Disk
Figure Shaft Position Sensor opto-couplers nominally located apart from each other along circumference disk. This configuration geometry produces output waveforms shown Figure
Opto
Opto
Opto
(mechanical angle) (electrical angle)
360/0
Figure Opto-Coupler Output Signals Rotor Angle This configuration generates opto-coupler edge every 7.5° mechanical rotation. every mechanical rotation signal pattern repeats, corresponding electrical cycle SRM, which there shaft revolution. this report both mechanical angle electrical angle referenced. Mechanical angle useful when considering velocity control SRM, electrical angle convenient when considering commutation. Electrical angle related mechanical angle number rotor poles, Figure angles arbitrarily defined with respect some convenient point. Here, 180° electrical defined aligned position phase motor. This easily verified energizing phase then monitoring opto-coupler output waveforms oscilloscope observe that rotor point where opto-coupler switches state, while opto-coupler opto-coupler high. 3-phase SRM, phases related position phase adding electrical degrees, respectively.
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
fundamentally identical position sensor implemented replacing opto-couplers with Hall-effect sensors embedding permanent magnets within teeth slotted disk. opto-couplers connected F240 shown Figure
Opto-coupler
CAPx
IOPx
1,2,3
Figure Opto-Coupler Connections TMS320F240 Here, each opto-coupler output connected both capture input digital input. will explained further detail below, capture inputs used once motor running, digital inputs used estimating initial rotor position starting SRM.
4.1.4
Power Electronics Hardware
amount current flowing through windings regulated switching power devices, such MOSFETs IGBTs, which connect each phase bus. power inverter topology important issue control because largely dictates motor controlled. There numerous options available, invariably decision will come down trading cost driver components against having enough control capability (independent control phases, current feedback, etc.) built into driver. popular configuration, used this application report, uses switches diodes phase. This topology depicted Figure
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
Phase Winding
Figure Two-Switch Phase Inverter Publications Vukosavic Stfanovic6 Miller7 offer several other configurations that require fewer switches phase, although with some penalty control flexibility maintaining phase independence. gate drive device, such IR2110, used turn semiconductor switches. topology Figure low-side switch usually held during commutation interval, while switch used implement control. independent current control each phase, low-ohm sense resistor placed between source low-side n-channel power MOSFET ground. schematic diagram inverter used this application report, including gate drive circuit connections EVM, given Figure
Vukosavic Stfanovic, "SRM Inverter Topologies: Comparative Evaluation," IEEE
Annual Meeting Conf. Record, 1990.
Miller (ed.), "Switched Reluctance Motor Drives," Intertec Communications Inc., Ventura
1988.
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
+VBUS IR2110 7403
MC14049
IRF740 0.01 MUR160 IRF710
HFA15TB60 HFA15TB60
+LOAD
2,4,6
IRFD123 -LOAD IRF740
1,3,5
SENSE RESISTOR LOGIC GROUND
POWER GROUND
ADCINx
1,2,3
Figure Schematic Diagram Inverter Using IR2110 Connections diagram shows components used single phase. Each phase uses IRF740 n-channel power MOSFETs switching elements output stage. IRF740 rated VDC, drain source resistance these devices 0.55 free-wheeling diodes used power stage HFA15TB60s, fast recovery diodes. HFA15TB60 reverse recovery time rated VDC, Logic implemented input gate drive such that power MOSFET turned only when bottom MOSFET also reasons this limitation, other circuit details, discussed more thoroughly publication Clemente Dubhashi.8
Software Description
software described this application report written designed operating 3-phase 12/8 closed loop current control closed loop speed control. block diagram algorithms implemented given Figure
Clemente Dubhashi, Floating MOS-Gate Driver IC," International Rectifier
Application Note AN-978A, International Rectifier, Segundo, 1990.
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
speed
torque
current controller icmd
Inverter
current
velocity controller
torque current advance angle calc
samp
position edges
commutation angles voltage
position estimator
optocouplers
position
velocity estimator
Figure Block Diagram Controller Velocity estimated monitoring elapsed time between opto-coupler edges, which known distance apart. velocity compensation algorithm determines torque required bring motor velocity commanded value. commutation algorithm converts torque command into phase current commands, current each phase individually regulated using fixed-frequency scheme. Further details each algorithms provided subsequent sections this report.
4.2.1
Program Structure
Figure shows structure control software TMS320F240 DSP.
Start
Routines: Background: Velocity Estimation Visual Feedback Timer ISR: Current Control Position Estimation Commutation Velocity Control Capture ISR: Store Capture Data Schedule Position msmt Update Schedule Velocity msmt Update
Initialization Routines: Setup Event Manager Initialization Algorithm Initialization Enable Interrupts Start Background
Figure TMS320F240 Control Program Structure
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
highest level, software consists initialization routines routines. Upon completion necessary initialization, background task started. background simply infinite loop, although when required, lower priority processing including velocity estimation visual feedback routine executed. velocity estimation involves double-precision division arithmetic, thus executed background mode that timeline violated. This algorithm initiated capture interrupt service routine. visual feedback function simply toggles board provide signal user that code running. time critical motor control processing done interrupt service routines. timer executed each occurrence maskable interrupt INT3. This interrupt corresponds event manager group interrupts, which enable only timer period interrupt, TPINT3. frequency, which this routine executed specified loading timer period register with desired value. control algorithms which implemented during timer current control, shaft position estimation, commutation, velocity control. illustrated Figure only current control shaft position estimation executed frequency,
timer period interrupts Timer Processing
Capture Processing
Background Processing
Figure Processor Timeline Showing Typical Loading Execution Control Algorithms Because their lower bandwidth requirements, velocity control commutation performed frequency F/5. Considering timer being sliced into fifths with pattern repeating every five slices, commutation only first slice velocity loop only second. Current control position estimation performed each slice.
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
Total Processing
capture interrupts current control position estimation commutation read store capture data velocity estimation velocity control
SPRA420A
capture interrupt service routine executed each occurrence maskable interrupt INT4. This interrupt corresponds event manager group interrupts, which enable three capture event interrupts, CAPINT1-3. This executes asynchronously timers board frequency execution dependent shaft speed according equation, capture frequency (Hz) shaft speed (rpm) (deg) (rev) (deg) (min) (sec) (22)
capture used determine which capture interrupt occurred, read appropriate capture FIFO register, then store data. Although algorithm explicitly executed this ISR, flags which initiate velocity position estimation actions. described above, velocity estimate update calculation performed background. position estimation algorithm, which executes during timer ISR, notified that position measurement been received. Table summarizes processing requirements each major software functions controller. Table Benchmark Data Various Drive Software Modules
Block Module Number Cycles 3620 1296 Execution Time 181.0 47.4 12.9 64.8 22.2 25.0 Execution Frequency 5000 5000 1000 1000 5000 5800 Relative Time 29.0 47.4 12.9 13.0 124.7
Velocity Estimation Visual Feedback Current Control Position Estimation Commutation Velocity Control Misc. Overhead Capture Context Switch Total
shaft speed 1000
Background Background Timer Timer Timer Timer Timer Capture RTS.LIB
data Table shows that when timer frequency, chosen kHz, that overall processor loading equal processor loading 124.7 62.4% 200.0 (23)
when running clock frequency. code size 2456 words words required variable/data storage. Thus, total memory requirement less than words. Complete code listings given Appendix should noted that this benchmark data taken with program data memory located chip, seen link.cmd file located appendix. improvement execution achieved moving .bss .stack sections firmware on-chip B0/B1 area moving .text section firmware flash memory.
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
4.2.2
Initialization Routines
flowchart describing initialization routines given Figure
reset
disable interrupts
setup
initialize event manager
initialize algroithm parameters
initialize program control counters flags
enable interrupts
start background
Figure Initialization Flowchart configured that watchdog timer disabled. TMS320F240 crystal, which used conjunction with module yield CPUCLK. event manager initialization configures timer units, capture units, compare units, converters. Also, CAP1-CAP4 IOPB0-IOPB3 pins, whose functions software programmable, configured operate capture pins digital output pins, respectively.
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
Each timers programmed operate continuous count mode. Timer provides timebase fixed-frequency control phase current. Timer provides timebase capture events, timer used provide interrupt fixed rate. compare units configured mode, where PWMs 1,3, (used switching high-side power MOSFET) configured active high. algorithm initialization defines parameters position estimation state machine sets initial conditions motor, example, setting shaft velocity estimate zero. Also, during this routine, logic states opto-couplers read from digital pins, this information used estimate rotor position. Upon initializing several flags counters which used program flow control, infinite loop background routine called, normal operation controlling drive begins. comments code listings found Appendix further information program initialization.
4.2.3
Current Controller
Current regulated fixed-frequency signals with varying duty cycles. TMS320F240 accomplishes this using compare units output logic circuits. compare units programmed mode, timer time base. desired output logic polarity controlled ACTR register. frequency specified loading period register timer T1PER, with value, defined
CPUCLK frequency frequency
(24)
F240, CPUCLK frequency MHz. percentage duty cycle phase controlled loading appropriate compare register, CMPRx, with appropriate value between 50%, 100%). frequency used. value significantly higher than bandwidth current loop also frequency which inaudible. percentage duty cycle command calculated current loop compensation algorithm, which designed using linear analysis. analysis begins with approximate model current loop, given Figure
Current Control Algorithm Loop Gain
Converter 1023
Feedback Gain
1023
Figure Approximate Current Loop Model
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
Using data Table with 999, 1.17 V/A, open-loop frequency response, G(), current loop, from icmd given Figure values phase inductance both aligned rotor position unaligned rotor position
gain 14.1 20log10(K) slope dB/decade desired
Magnitude (dB)
1.16 decade
Phase (deg)
-100 desired P.M. -200 -180
Frequency (Hz)
1000
Figure Frequency Response Plots Current Loop Unaligned Position (Squares) Aligned Position (Circles) Because digital implementation current loop, additional phase loss, beyond motor pole, contributed sample hold process processing delay inherent loop. These dynamics essentially limit current loop bandwidth open loop crossover frequency near time delay zero-order hold (ZOH) equal sampling period, this case µsec, µsec. Since phase loss frequency, pure time delay, given expression, loss using Equation (25), calculate that phase loss sampling equal loss 0.232 13.3 (26) (25)
Assuming that processing delay equal loop cycle, another µsec, then effect digital implementation yields about phase loss When combined with motor pole, phase loss through loop approximately 116°, loop gain, chosen such that point open-loop magnitude occurs then resulting phase margin loop will about 64°. This amount phase margin provides very stable loop design. gain loop given
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
1023 5.092 P@5@R
which, when written decibels, equal gain 14.1 10(K) frequencies where (R/L), magnitude loop response equal G(w) 14.1 10(K)
(27)
(28)
(29)
Equation (29), letting provides most conservative choice, resulting stable design rotor positions. Setting left-hand side Equation (29) while 2(370) rad/s, solving yields value which ensures desired open-loop crossover point current loop. this case 2.8. Often, controller used. this example adding integrator control will make much difference loop performance, except only very speeds, because integrator action must slower than motor pole stabilize loop. this example using 3-phase, 12/8 SRM, motor pole located near operating speed required produce equivalent commands current loops rpm. Thus, this case, only operating speeds lower than would integrator action helpful. current loop gain using ILOOP_GAIN constant file CONSTANT.H. this value, scaling used, thus setting ILOOP_GAIN results 2.75, which sufficiently close desired value 2.8, this application.
4.2.4
Position Estimation
Recall that Figure showed possible combinations opto-coupler output states electrical cycle SRM. transitions outputs define specific angles. This information readily described state machine, such Figure
Opto Opto
Opto
120°
300°
Opto
180° Opto 240°
Opto
Figure State Transition Diagram Position Pickoff
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
state, defined `zyx', where logic state opto-coupler opto-coupler state opto-coupler Position measurements made using this state machine identifying which opto-coupler transition occurs, using DSP's capture units. opto-couplers slotted disk provide position measurements discrete points electrical cycle SRM. Many commutation schemes, however, require continuous position information optimize performance. Thus, provide position estimate between measurements, equation,
q(k)
(30)
used, where estimation update rate represents time most recent capture edge. Equation (30) implemented, using double precision arithmetic, follows:
long delta-position mechanical angle speed; temp; (anSRM->wEst_10xrpm anSRM->wEst_10xrpm K_POSITION_EST anSRM->dp_remainder; anSRM->dp_remainder 0xffff; temp (int) 16); anSRM->position anSRM->position (temp NR); else speed -anSRM->wEst_10xrpm; speed K_POSITION_EST anSRM->dp_remainder; anSRM->dp_remainder 0xffff; temp (int) 16); anSRM->position anSRM->position (temp NR);
constant K_POSITION_EST (Q16), compensates units (shaft velocity available software SRM.wEst_10xrpm with units calculated according equation, K_POSITION_EST (rpm (sec) (min) (sec) (rev) 65535 (31)
for, kHz, K_POSITION_EST 1432. During startup, digital ports determine state rotor initial position estimated mid-range state. example, reading [100], (consistent with Figure yields initial position estimate electrical degrees. capture units provide subsequent measurements, recognizing edges, state transitions.
4.2.5
Velocity Estimation
three opto-coupler outputs produce edge every 7.5° mechanical rotation, each opto-coupler produces edge every 22.5° mechanical. each edge, velocity calculated according equation,
(32)
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
where, velocity estimate (rpm)
distance between opto-coupler edges (rev) time between edges (min)
number clock counts between edges fclk clock frequency (Hz)
time between edges determined from capture units. capture units programmed CAPCON register timer time base, trigger both rising falling edges. Timer programmed count 1.25 T2CON. Although trade-off resolution measuring clock frequency 1.25 chosen, versus maximum MHz, that 16-bit registers containing count overflow except very speeds. Using 1.25 clock, counter overflows only shaft speeds less than 71.5 rpm, considered very application. that operate (although degraded) speeds lower than about rpm, Equation (32) determined software counter number timer interrupts that occur between opto-coupler edges. shown that when instantaneous velocity estimated Equation (32) that quantization velocity estimate given
(33)
and, quantization velocity (rpm). design, 1/16 revolution (22.5° mechanical) fclk 1.25 MHz. Thus, 1200 rpm, quantization 0.31 rpm. Various filtering applied Equation (32) smoothing velocity estimate, depending upon application. What proven useful combination filtering form:
(34)
j+(k*5)
filter portion Equation (34) uses (from instantaneous velocity estimates. Because there opto-coupler edges electrical cycle, once cycle estimation errors removed.
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
filtering determination instantaneous velocity estimate calculated using double precision follows:
DWORD a1,a2,a3,a4,a5,a6; DWORD sum_cnt; inst_velocity; Obtain instantaneous velocity estimate (mode timer time base filter removing once electrical cycle effects (DWORD) anSRM->capture_delta[0][0]; (DWORD) anSRM->capture_delta[0][1]; (DWORD) anSRM->capture_delta[1][0]; (DWORD) anSRM->capture_delta[1][1]; (DWORD) anSRM->capture_delta[2][0]; (DWORD) anSRM->capture_delta[2][1]; sum_cnt a1+a2+a3+a4+a5+a6; apply "velocity delta_theta/delta_time" algorithm sum_cnt K1_VELOCITY_EST/sum_cnt; inst_velocity ((int) sum_cnt) anSRM->shaft_direction; else else, timer count time base
apply "velocity delta_theta/delta_time" algorithm sum_cnt inst_velocity ((int) sum_cnt) anSRM->shaft_direction;
Here, K1_VELOCITY_EST K2_VELOCITY_EST constants which incorporate units that instantaneous velocity estimate units (rpm 10). constants calculated using, K1_VELOCITY_EST K2_VELOCITY_EST 22.5 (deg) 1.25e6 (cnts) (sec) 5000 (cnts) (sec) (rev) (deg) (rev) (deg) (sec) (min) (sec) (min) (35)
(deg)
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
filtering implemented
long filt_velocity; filter smoothing velocity estimate filt_velocity (ALPHA anSRM->wEst_10xrpm) (ONE_MINUS_ALPHA inst_velocity); anSRM->wEst_10xrpm (int) (filt_velocity
filter coefficient, chosen equal 0.875, [ALPHA (Q3)]. approach zero higher bandwidth velocity estimate (less smoothing, more noise) approach more smoothing, less noise, lower bandwidth.
4.2.6
Commutation
commutation strategy ultimately determines performance SRM. Torque-speed range, machine efficiency, torque ripple, acoustic noise depend, some extent, commutation algorithm. Design commutation algorithm must consider requirements each these areas, while trading cost issues such algorithm complexity availability accuracy various sensors. current controlled SRM, commutation described transformation desired motor torque into desired phase currents. This described mathematically equation,
(36)
1,.,m total number motor phases. general, non-linear function shaft angle shaft speed desired torque command Tcmd voltage Vbus, motor instantaneous inductance, most simple choice given otherwise
g(q)
(37)
where dwell angle, must least equal 360°/m (electrical), avoid regions zero torque production. example commutation described Equation (37) illustrated Figure turn-on angle, typically degrees beyond unaligned position phase. Equation (37) useful only single-quadrant operation. four quadrant operation, Equation (37) must modified, example,
otherwise
(38)
g(q,
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
where conduction angles offset 180° electrical radians) when negative torque desired. This allows phase conduct during region where even more flexible approach, which results wider operating range SRM, allows turn-on dwell angles vary. example, Equation (38) extended allow functions velocity, desired torque, voltage. Often, minimizing torque ripple, commutation designed such that phases conduct simultaneously share producing desired torque. this case, Equation (38) further extended function form,
otherwise
(39)
g(q,
where sharing function. Sharing functions implemented this application report, however, further information choice sharing functions found publication Kjaer, Essentially commutation schemes form Equation (39) knowledge motor characteristics design non-linear function, that produces linear output torque. this example, commutation coefficients, were calculated using Equation (38), where (radians), (radians), advance angle, adv, given Equation (21). This yields single-quadrant, fixed-dwell, variable turn-on commutation algorithm. This algorithm implemented follows:
phase; WORD electricalAngle; WORD angle; channel; long advance; /*---------------------------*/ Advance angle calculation /*---------------------------*/ advance (anSRM->wEst_10xrpm anSRM->desiredTorque); advance advance Offset advance angle negative torque, required (anSRM->desiredTorque electricalAngle anSRM->position (int) advance; else electricalAngle anSRM->position PI_16 (int) advance; Kjaer, Gribble, Miller, 1585-1593.
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
(phase=0; phase< NUMBER_OF_PHASES; phase++) degree offsets phase angle electricalAngle phase TWOPIBYTHREE_16; turn phase between desired angles switch measure desired phase current (angle (PIBYSIX_16)) (angle (FIVEPIBYSIX_16)) anSRM->active[phase] channel anSRM->a2d_chan[phase]; switch_mux(channel,channel+8); else anSRM->active[phase]
seen code above, advance angle calculation (which yields advance angle units bits, 65535 bits electrical degrees) computed according equation, (bits)
(bits)
w(rpm
(40)
From Equation (21) Equation (40), show that calculation which includes Lmin accounts units given
(rpm
239.4 (bits) 65535 (bits)
(41)
(min) (sec)
(rev)
With Vbus given Table 776.25. However, value used because dividing multiples readily accomplished using simple shift instructions. application, this simplification provided satisfactory results.
4.2.7
Velocity Controller
Speed regulated closed-loop manner comparing desired shaft velocity estimated shaft velocity then compensating error. (proportional plus integral) control action velocity loop compensation, that steady-state velocity error zero. coefficients determined using linear analysis. Figure shows simplified model velocity loop, where coefficient, having units (rad/s)/A, non-linear quantity, including shaft/load inertia instantaneous torque constant SRM.
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
Velocity Loop Algorithm
Current Loop Gain
Gain
1023
Gain
Feedback Gain
Filter
Figure Simplified Block Diagram Velocity Loop Using Control figure, controls loop gain radian frequency zero. non-linearity non-linear torque/current relationship where non-saturating conditions given Equation (18) and, general, Equation (15). Thus, open-loop gain velocity loop will vary, approximately, current squared. This variation significant over operating range SRM. From example, gain variation Depending application, this gain variation need compensated, with square root law, example, stabilize loop. this example, loop compensation design with sufficient margin, expense dynamic response, that this variation ignored. filter used smoothing velocity estimate, z-transform given H(z) modeled Laplace domain shown Figure Another interesting feature this speed loop that although velocity loop update rate fixed-frequency kHz, feedback (provided opto-coupler edges) occurs variable rate which function rotor speed given (42)
samp (Hz)
(speed rpm)
(43)
This behavior generates variable time delay velocity loop, zero-order hold, also makes dynamics filter time-varying. Using information Table Figure possible obtain open-loop frequency response, (see Figure velocity loop, independent
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
-100 Phase (deg) 1200 -150 -200 -250 0.01
Magnitude
Frequency (Hz)
Figure Open-Loop Frequency Response Velocity Loop Several Motor Speeds, 0.73 rad/s phase loss variable time delay function rotor speed apparent. absolute magnitude function frequency unknown; however, shape magnitude phase correct. From Figure clearly desired open-loop crossover frequency range this particular loop. moving zero, beyond 0.73 rad/s, bandwidth extended, while trading stability margins. load inertia motor torque constant information known (i.e., known), then determined analytically; otherwise, velocity loop gain experimentally.
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
algorithm implemented
calculate error signal speed_error anSRM->wDes_10xrpm anSRM->wEst_10xrpm; integrate error*/ anSRM->integral_speed_error anSRM->integral_speed_error (long)speed_error; apply integrator limit (anSRM->integral_speed_error INTEGRAL_LIMIT) anSRM->integral_speed_error INTEGRAL_LIMIT; (anSRM->integral_speed_error -INTEGRAL_LIMIT) anSRM->integral_speed_error -INTEGRAL_LIMIT; filter*/ integral_error (int) 13); anSRM->desiredTorque ((KP*speed_error) integral_error;
This implements compensator, with integrator limits, form,
(44)
Through experimentation, determined that 0.5, provided satisfactory performance. software implementation integrator, multiplication performed. Thus, this factor carried implicitly 0.73 rad/s 1/1000 sec, 0.365. This approximately implemented setting (scaled 1000) file CONSTANT.H.
integrator limit value calculated such that condition
INTEGRAL_LIMIT 1000.
References
Anderson, Moore, Optimal Filtering, Prentice-Hall Publishing, Englewood Cliffs, 1979. Becerra, Ehsani, Miller, "Commutation Motors," IEEE Trans. Power Electronics, Vol. 257-262, July 1993. Clemente, Dubhashi, Floating MOS-Gate Driver IC," International Rectifier application note AN-978A, International Rectifier, Segundo, 1990. Husain, Ehsani, Torque Ripple Minimization Switched Reluctance Motor Drives Current Control," Proc. APEC'94, 1994. Ilic-Spong, Miller, MacMinn, Thorp, "Instantaneous Torque Control Electric Motor Drives," IEEE Trans. Power Electronics, Vol. Jan. 1987.
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
Kjaer, Gribble, Miller, "High-Grade Control Switched Reluctance Machines," IEEE Trans. Industry Electronics, vol. Nov. 1997. Lewis, Applied Optimal Control Estimation, Prentice Hall Publishing, Englewood Cliffs, 1992. Lyons, MacMinn, Preston, "Flux/Current Methods Rotor Position Estimation," IEEE Annual Meeting Conf. Record, 1991. Miller (ed.), "Switched Reluctance Motor Drives," Intertec Communications Inc., Ventura, 1988. Miller, "Switched Reluctance Motors Their Control," Magna Physics Publishing, Hillsboro, Oxford, 1993. Ray, Al-Bahadly, "Sensorless Methods Determining Rotor Position Switched Reluctance Motors," Proc. Conf., Vol. 1993. Vukosavic, Stfanovic, "SRM Inverter Topologies: Comparative Evaluation," IEEE Annual Meeting Conf. Record, 1990.
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
Appendix
Software Listings TMS320F240-Based Drive With Position Sensor
This appendix contains software implement drive using slotted disk type position sensor TMS320F240 DSP.
File TYPEDEFS.H C240.H CONSTANT.H SRM.H MAIN.C main( c_int3( c_int4( Time_Update_Position( Msmt_Update_Position( Msmt_Update_Velocity( Commutation_Algorithm( velocityController( currentController( EVMGR.C VECTORS.ASM LINK.CMD Major Modules Description header file data type definitions header file C240 register definitions header file constant defintions header file variable declarations supervisory program timer capture time update algorithm position estimation measurement update algorithm position estimation velocity estimation algorithm fixed-dwell, variable turn-on commutation algorithm shaft velocity loop compensation algorithm phase current loop compensation algorithm modules event manager initialization operating event manager peripherials interrupt vectors linker command file
SRM.C
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
File: TYPEDEFS.H TMS320x240 Test Code Texas Instruments, Inc. Copyright 1996 Texas Instruments Inc. 11/05/96 Version Jeff Crankshaw #ifndef TYPEDEFS_H #define TYPEDEFS_H #define FALSE #define TRUE typedef unsigned WORD; typedef unsigned long DWORD; typedef volatile WORD PORT; #define STR(x) #define OUTMAC(address,data) asm(" LDPK _"STR(data)); asm(" _"STR(data) STR(address)) #define INMAC(address,data) asm(" LDPK _"STR(data)); asm(" _"STR(data) STR(address)) #define Int_Read(addr) #define Int_Write(addr,data) #endif _TYPEDEFS (int (addr) (int (addr) (data) 16-bit data 32-bit data
File: C240.H TMS320x240 Test Code Texas Instruments, Inc. Copyright 1996 Texas Instruments Inc. 11/05/96 Version Jeff Crankshaw TMS320C240 Peripheral Register Addresses #ifndef c240_h #define c240_h #include "typedefs.h" definitions space macros #define STR(x) #define OUTMAC(address,data) asm(" LDPK _"STR(data)); asm(" _"STR(data) STR(address)) #define INMAC(address,data) asm(" LDPK _"STR(data)); asm(" _"STR(data) STR(address)) #define LED_LOC 000ch F240 space location LEDs
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
definitions core registers #define IMR_REG PORT )0x0004 #define IFR_REG PORT )0x0006 External Memory Interface Registers #define WSGR 0x0ffff Wait State Generator Register System Module Registers #define SYSCR PORT )0x07018) System Module Control Register #define SYSSR PORT )0x0701A) System Module Status Register #define SYSIVR PORT )0x0701E) System Interrupt Vector Register #define XINT1_CR PORT )0x07070) Int1 (type Control #define NMI_CR PORT )0x07072) maskable (type Control #define XINT2_CR PORT )0x07078) Int2 (type Control #define XINT3_CR PORT )0x0707A) Int3 (type Control #define PDPINT_CR PORT )0x0742C) Power Drive Protection cntl System Interrupt Vector Register Address offsets #define PHANTOM_INT_VECTOR 0x00 #define NMI_INT_VECTOR 0x02 #define XINT1_INT_VECTOR 0x01 #define XINT2_INT_VECTOR 0x11 #define XINT3_INT_VECTOR 0x1f #define SPI_INT_VECTOR 0x05 #define SCI_RX_INT_VECTOR 0x06 #define SCI_TX_INT_VECTOR 0x07 #define RTI_INT_VECTOR 0x10 #define PDP_INT_VECTOR 0x20 #define EV_CMP1_INT_VECTOR 0x21 #define EV_CMP2_INT_VECTOR 0x22 #define EV_CMP3_INT_VECTOR 0x23 #define EV_SCMP1_INT_VECTOR 0x24 #define EV_SCMP2_INT_VECTOR 0x25 #define EV_SCMP3_INT_VECTOR 0x26 #define EV_T1PER_INT_VECTOR 0x27 #define EV_T1CMP_INT_VECTOR 0x28 #define EV_T1UF_INT_VECTOR 0x29 #define EV_T1OF_INT_VECTOR 0x2a #define EV_T2PER_INT_VECTOR 0x2b #define EV_T2CMP_INT_VECTOR 0x2c #define EV_T2UF_INT_VECTOR 0x2d #define EV_T2OF_INT_VECTOR 0x2e #define EV_T3PER_INT_VECTOR 0x2f #define EV_T3CMP_INT_VECTOR 0x30 #define EV_T3UF_INT_VECTOR 0x31 #define EV_T3OF_INT_VECTOR 0x32 #define EV_CAP1_INT_VECTOR 0x33 #define EV_CAP2_INT_VECTOR 0x34 #define EV_CAP3_INT_VECTOR 0x35 #define EV_CAP4_INT_VECTOR 0x36 #define AC2_INT_VECTOR 0x04
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
Digital Registers #define OCRA PORT )0x07090) Output Control #define OCRB PORT )0x07092) Output Control #define PADATDIR PORT )0x07098) port Data Direction reg. #define PBDATDIR PORT )0x0709A) port Data Direction reg. #define PCDATDIR PORT )0x0709C) port Data Direction reg. Watch-Dog(WD) Real Time Int(RTI) Phase Lock Loop(PLL) Registers #define RTICNTR PORT )0x07021) Counter #define WDTCNTR PORT )0x07023) Counter #define WDTKEY PORT )0x07025) #define RTICR PORT )0x07027) Control #define WDCR PORT )0x07029) Control #define CKCR0 PORT )0x0702B) control #define CKCR1 PORT )0x0702D) control Analog-to-Digital Converter(ADC) registers #define ADCTRL1 PORT )0x07032) Control Status #define ADCTRL2 PORT )0x07034) Configuration #define ADCFIFO1 PORT )0x07036) Channel Result Data #define ADCFIFO2 PORT )0x07038) Channel Result Data Serial Peripheral Interface (SPI) Registers #define SPICCR PORT )0x07040) Config Control #define SPICTL PORT )0x07041) Operation Control #define SPISTS PORT )0x07042) Status #define SPIBRR PORT )0x07044) Baud rate control #define SPIEMU PORT )0x07046) Emulation buffer #define SPIBUF PORT )0x07047) Serial Input buffer #define SPIDAT PORT )0x07049) Serial Data #define SPIPC1 PORT )0x0704D) Port control reg1 #define SPIPC2 PORT )0x0704E) Port control reg2 #define SPIPRI PORT )0x0704F) Priority control Serial Communications Interface (SCI) Registers #define SCICCR PORT )0x07050) Comms Control #define SCICTL1 PORT )0x07051) Control #define SCIHBAUD PORT )0x07052) Baud rate control #define SCILBAUD PORT )0x07053) Baud rate control #define SCICTL2 PORT )0x07054) Control #define SCIRXST PORT )0x07055) Receive status #define SCIRXEMU PORT )0x07056) data buffer #define SCIRXBUF PORT )0x07057) Receive data buffer #define SCITXBUF PORT )0x07059) Transmit data buffer #define SCIPC1 PORT )0x0705D) Port control reg1 #define SCIPC2 PORT )0x0705E) Port control reg2 #define SCIPRI PORT )0x0705F) Priority control
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
Event Manager (EV) Registers #define GPTCON PORT )0x07400) General Timer Controls #define T1CNT PORT )0x07401) Counter Register #define T1CMP PORT )0x07402) Compare Register #define T1PER PORT )0x07403) Period Register #define T1CON PORT )0x07404) Control Register #define T2CNT PORT )0x07405) Counter Register #define T2CMP PORT )0x07406) Compare Register #define T2PER PORT )0x07407) Period Register #define T2CON PORT )0x07408) Control Register #define T3CNT PORT )0x07409) Counter Register #define T3CMP PORT )0x0740a) Compare Register #define T3PER PORT )0x0740b) Period Register #define T3CON PORT )0x0740c) Control Register #define COMCON PORT )0x07411) Compare Unit Control #define ACTR PORT )0x07413) Full Compare Unit Output Action Ctrl #define SACTR PORT )0x07414) Simple Comp Unit Output Action Ctrl #define DBTCON PORT )0x07415) Dead Band Timer Control #define CMPR1 PORT )0x07417) Full Compare Channel Threshold #define CMPR2 PORT )0x07418) Full Compare Channel Threshold #define CMPR3 PORT )0x07419) Full Compare Channel Threshold #define SCMPR1 PORT )0x0741a) Simple Comp Channel Threshold #define SCMPR2 PORT )0x0741b) Simple Comp Channel Threshold #define SCMPR3 PORT )0x0741c) Simple Comp Channel Threshold #define CAPCON PORT )0x07420) Capture Unit Control #define CAPFIFO PORT )0x07422) FIFO1-4 Status Register #define FIFO1 PORT )0x07423) Capture Channel FIFO #define FIFO2 PORT )0x07424) Capture Channel FIFO #define FIFO3 PORT )0x07425) Capture Channel FIFO #define FIFO4 PORT )0x07426) Capture Channel FIFO #define IMRA PORT )0x0742c) Group Interrupt Mask Register #define IMRB PORT )0x0742d) Group Interrupt Mask Register #define IMRC PORT )0x0742e) Group Interrupt Mask Register #define IFRA PORT )0x0742f) Group Interrupt Flag Register #define IFRB PORT )0x07430) Group Interrupt Flag Register #define IFRC PORT )0x07431) Group Interrupt Flag Register #define IVRA PORT )0x07432) Group Int. Vector Offset Register #define IVRB PORT )0x07433) Group Int. Vector Offset Register #define IVRC PORT )0x07434) Group Int. Vector Offset Register #endif /*File: CONSTANT.H /*Target Processor: TMS320F240 /*Compiler Version: /*Assembler Version: /*Created: 10/1/97 Constants control algorithms
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
clock frequencies time related constants #define PWM_FREQ 20000 frequency (Hz) #define SYSCLK_FREQ 20000000 clock frequency (Hz) #define CPU_INT_FREQ 5000 timer frequency (Hz) #define ONE_HALF_SECOND (CPU_INT_FREQ/2) current loop algorithm constants #define ILOOP_GAIN #define ILIMIT #define MAXIMUM_DUTYRATIO 1023
current loop gain: (Q3: gain 2.75) current limit: (1023 bits 0.855 4.273 limit duty cycle: (SYSCLK_FREQ/PWM_FREQ
velocity loop algorithm constants #define INTEGRAL_LIMIT 2793472 integrator limit #define (Q13*1000): 0.366 #define position velocity estimation algorithm constants #define K_POSITION_EST 1432 #define K1_VELOCITY_EST 281250000 #define K2_VELOCITY_EST 62500 #define ALPHA alpha 0.875 #define ONE_MINUS_ALPHA 1-alpha 0.125 motor geometry related #define number rotor poles #define NUMBER_OF_PHASES Electrical Angles: 2*pi (rad) 65535 #define PIBYSIX_16 5461 #define PIBYFOUR_16 8192 #define PIBYTHREE_16 10923 #define TWOPIBYTHREE_16 21845 #define THREEPIBYFOUR_16 24576 #define FIVEPIBYSIX_16 27307 #define PI_16 32768 #define FOURPIBYTHREE_16 43690 #define FIVEPIBYTHREE_16 54613 #define TWOPI_16 65535 /*File: SRM.H /*Target Processor: TMS320F240 /*Compiler Version: /*Assembler Version: /*Created: 10/1/97 Variable declarations control algorithm #include "constant.h"
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
#include "typedefs.h" position estimation state machine data structure typedef struct state; WORD position; direction; state_machine; variables data structure: /*a2d_chan[i] sets which used phase current /*desiredTorque torque command (output velocity loop) /*integral_speed_error velocity loop integrator compensator /*iDes[i] current command phase /*capture_edge[i] timer count value occurence most recent capture /*capture_delta[i][2] change timer count value between occurences capture events. most recent events stored. /*delta_count change software counter timer between occurences capture event. /*wEst_10xrpm shaft velocity estimate (units rpm*10) wDes_10xrpm desired shaft velocity (units rpm*10) active[i] flag indicating whether phase iFB[i] current feedback measurement phase dutyRatio[i] commanded duty ratio high-side phase /*position shaft position estimate (electrical degrees) scaled: 2*pi (rad) 65535 bits /*position_state position state (defined opto-couplers) /*shaft_direction direction which shaft rotating. /*trans_lut[7][4] position state machine /*position_initial_guess[7] initial position guess, based state /*dp_remainder 16-bit remainder used position estimation /*last_capture most recent capture occur typedef struct a2d_chan[NUMBER_OF_PHASES]; desiredTorque; long integral_speed_error; WORD iDes[NUMBER_OF_PHASES]; WORD capture_edge[NUMBER_OF_PHASES]; WORD WORD delta_count; wEst_10xrpm; wDes_10xrpm; active[NUMBER_OF_PHASES]; WORD iFB[NUMBER_OF_PHASES]; dutyRatio[NUMBER_OF_PHASES]; WORD position; position_state; shaft_direction; state_machine trans_lut[7][4]; WORD position_initial_guess[7]; long dp_remainder; last_capture; anSRM_struct;
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
/*PROTOTYPE DEFINITIONS void eventmgr_init(); void initializeSRM(anSRM_struct *anSRM); void Commutation_Algorithm( anSRM_struct *anSRM); void *anSRM); void velocityController( anSRM_struct *anSRM); void currentController( anSRM_struct *anSRM); void *anSRM); void *anSRM, mode); void *anSRM); void switch_lowside(int phaseactive); void switch_mux(int adc1, adc2); void disable_interrupts(); void dsp_setup(); void void enable_interrupts(); void start_background(); void check_for_stall(); /*File: MAIN.C /*Target Processor: TMS320F240 /*Compiler Version: /*Assembler Version: /*Created: 10/31/97 This file main program control drive with /*position sensor /*INCLUDE FILES #include "c240.h" #include "srm.h" /*GLOBAL VARIABLE DECLARATIONS count; slice; old_count; Update_Velocity; Toggle_LED; Msmt_Update; anSRM_struct SRM; LEDvalue; /*MAIN PROGRAM void main() disable_interrupts(); dsp_setup(); initializeSRM(&SRM); eventmgr_init(); enable_interrupts(); start_background();
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
/*BACKGROUND TASKS /*Upon completion required initialization, main /*program starts background task. background /*simply infinite loop. Time critical motor control /*processing done interrupt service routines lower /*priority processing done background, when they /*are needed. background operations defined: /*1) Update_Velocity when capture interrupt occurs, stores capture data then intiates this task. velocity update done background, because doing floating point division. /*2) Toggle_LED this task toggles provide visual feedback user that code running. This task initiated fixed rate ONE_HALF_SECOND value. void start_background() while /*----------------------*/ Velocity update task /*----------------------*/ (Update_Velocity) (Update_Velocity
capture data time base Msmt_Update_Velocity(&SRM,1);
else
else shaft rotating slowly, capture data error overflow. count timer ISR's between captures time base. Msmt_Update_Velocity(&SRM,2);
Update_Velocity /*-----------------------*/ Visual feedback task /*-----------------------*/ (Toggle_LED) LEDvalue -LEDvalue; (LEDvalue asm(" 000ch"); else asm(" 000ch"); Toggle_LED SRM.wDes_10xrpm 6000; motor speed command units (rpm just hard-coded here, setup another background task allow command from external input infinite loop
/*TIMER
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
/*This interrupt service routine executed each /*occurence maskable interrupt INT3. This /*interrupt corresponds event manager group interrupts, /*of which enable only timer period interrupt, TPINT3. /*The frequency, which this routine executed specified /*using CPU_INT_FREQ parameter. /*The control algorithms which implemented during /*timer are: Current control (frequency Rotor position estimation (frequency Commutation (frequency F/5) Velocity control (frequency F/5) /*Additionally, time measured (coarsely) counting /*the number executions this ISR, which runs /*known fixed rate. This measure time used several /*reasons, including: precaution against over-current, simple /*test made determine rotor stalled. Also, visual feedback task initiated correct /*amount time elapsed. void c_int3() *IFR_REG 0x0004; *IFRB 0xff; currentController(&SRM); (Msmt_Update) Msmt_Update_Position(&SRM); Msmt_Update else Time_Update_Position(&SRM); check_for_stall(); count count slice slice (slice Commutation_Algorithm(&SRM); else (slice velocityController(&SRM); else (slice slice (count ONE_HALF_SECOND) Toggle_LED count /*CAPTURE increment count increment slicer clear interrupt flags
current loop algorithm position estimation recent capture edge this information else, propagate using algorithm
commutation slice. velocity loop algorithm
reset slicer
flag toggling LED, time
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
/*This interrupt service routine executed each /*occurence maskable interrupt INT4. This /*interrupt corresponds event manager group interrupts, /*of which enable three capture event interrupts, /*CAPINT1-3. This executes asynchronously /*frequency execution dependent shaft speed /*of SRM. /*The performs following processing: clear interrupt flags; determine which capture occured; read appropriate capture FIFO register; store capture data; flag position update using measurement; flag initiating velocity estimate update background; return; void c_int4() groupc_flags; capture; delta_count; WORD edge_time; *IFR_REG 0x0008; clear interrupt flag
determine which capture interrupt occured read appropriate FIFO groupc_flags *IFRC; read event manger interrupt flag register (groupc_flags 0x1){ *IFRC 0xf9; capture edge_time read_fifo(capture); else (groupc_flags 0x2) *IFRC 0xfa; capture edge_time read_fifo(capture); else (groupc_flags 0x4) *IFRC 0xfc; capture edge_time read_fifo(capture); else *IFRC 0xff; capture capture clear flag register read FIFO capture
capture
valid capture
valid capture occured, store capture data flags foor position velocity estimate updates. most recent time intervals between edges saved allow some filtering velocity estimate. number timer ISR's which occur between capture interrupts also checked. When this time exceeds certain value, then capture data could error overflow, lower resolution delta-time associated with count used velocity estimate calculation.
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
(capture SRM.last_capture capture; save capture data capture-1; SRM.capture_delta[n][1] SRM.capture_delta[n][0]; SRM.capture_delta[n][0] edge_time SRM.capture_edge[n]; SRM.capture_edge[n] edge_time; Msmt_Update position update flag
flags select time base with velocity update delta_count count old_count; old_count count; (delta_count delta_count delta_count ONE_HALF_SECOND; (delta_count 100) shaft speed counter SRM.delta_count delta_count; Update_Velocity
else else, shaft speed 1.25MHz SRM.delta_count delta_count; Update_Velocity
/*UTILITY SUBROUTINES void disable_interrupts() asm(" SETC INTM"); void dsp_setup() temp; /*------------------------*/ Disable watchdog timer /*------------------------*/ temp *WDCR; temp temp 0x68; *WDCR temp;
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
initialize module XTAL1) *CKCR1 0xb1; 20MHz CPUCLK 10MHz crystal mult ratio *CKCR0 0xc3; low-power mode ACLK enabled, enabled, SYSCLK=CPUCLK/2 *SYSCR 0x40c0; void initialize_counters_and_flags() count slice old_count Toggle_LED LEDvalue Update_Velocity Msmt_Update current timer count slice count timer count last capture edge flag visual feedback background task current value flag velocity update background task flag mode position estimate update
void enable_interrupts() *IFR_REG 0xffff; *IFRA 0xffff; *IFRB 0xffff; *IFRC 0xffff; *IMR_REG 0x000c; *IMRA 0x0000; *IMRB 0x0010; *IMRC 0x0007; asm(" CLRC INTM"); void check_for_stall() delta_count; assumed have stalled number timer ISR's which executed exceeds 1000. this corresponds roughly rpm. this condition detected, opto-coupler levels read rotor position re-initialized delta_count count old_count; (delta_count delta_count delta_count ONE_HALF_SECOND; (delta_count 1000) SRM.wEst_10xrpm SRM.position_state *PBDATDIR 0x7; SRM.position Clear pending interrupts
Enable Interrupts: INT4 INT3 Disable event manager Group interrupts Enable timer period interrupt Enable CAP1-CAP3 interrupts*/ Global interrupt enable
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
File: SRM.C /*Target Processor: TMS320F240 /*Compiler Version: /*Assembler Version: /*Created: 10/31/97 This file contains algorithms control anSRM using position sensor. position sensor consists slotted /*disk opto-couplers.
/*INCLUDE FILES #include "srm.h" #include "c240.h" /*TIME UPDATE ROTOR POSITION ESTIMATE Between capture events, which provide shaft position /*measurement, position estimated according equation theta(k) theta(k-1) delta_t; /*where theta position measurement (electrical angle) current shaft velocity estimate delta_t execution frequency algorithm /*The arithmetic performed using double precision. /*input: position (where 2^16 2*pi radians) (units (constant incorporate delta_t units) /*output: position (where 2^16 2*pi radians) /*pseudo-code: position position void *anSRM)
long speed; temp;
delta-position mechanical angle
(anSRM->wEst_10xrpm anSRM->wEst_10xrpm K_POSITION_EST anSRM->dp_remainder; anSRM->dp_remainder 0xffff; temp (int) 16); anSRM->position anSRM->position (temp NR); else speed -anSRM->wEst_10xrpm; speed K_POSITION_EST anSRM->dp_remainder; anSRM->dp_remainder 0xffff; temp (int) 16); anSRM->position anSRM->position (temp NR); Time_Update_Position
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
/*MEASUREMENT UPDATE ROTOR POSITION ESTIMATE capture interrupt, rotor positions. between interrupts, pickoff will states, defined opto-couplers. states defined [zyx] where: output opto-coupler output opto-coupler output opto-coupler /*State /*State /*State /*State /*State /*State void *anSRM) old_state, new_state; cap; Based capture current state, state from state-machine look-up table anSRM->last_capture; old_state anSRM->position_state; new_state transition valid, update position state (new_state valid transition, update data anSRM->position anSRM->shaft_direction anSRM->position_state new_state; else else, valid transition, opto-coupler level re-initialize position estimate anSRM->position_state *PBDATDIR 0x7;
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
/*VELOCITY ESTIMATION ALGORITHM This algorithm estimates shaft velocity. executed /*after each capture interrupt received. shaft /*moving fast enough, this routine called with mode /*the capture data used. Otherwise, timer ISRs /*which executed between capture events used /*velocity calculation. /*Velocity calculated according equation: delta_theta delta_t /*where delta_theta known: (7.5 mech between each capture) (22.5 mech between same capture) /*and delta_t measured number clock cycles. /*The algorithm implemented double precision /*the form: Kx_VELOCITY_EST/count /*where constant Kx_VELOCITY_ESTIMATE (x=1,2) incorporates /*delta_theta other units that units (rpm 10). void *anSRM, mode) DWORD a1,a2,a3,a4,a5,a6; DWORD sum_cnt; inst_velocity; long filt_velocity; Obtain instantaneous velocity estimate (mode timer time base filter removing once electrical cycle effects (DWORD) anSRM->capture_delta[0][0]; (DWORD) anSRM->capture_delta[0][1]; (DWORD) anSRM->capture_delta[1][0]; (DWORD) anSRM->capture_delta[1][1]; (DWORD) anSRM->capture_delta[2][0]; (DWORD) anSRM->capture_delta[2][1]; sum_cnt a1+a2+a3+a4+a5+a6; apply velocity delta_theta/delta_time algorithm sum_cnt K1_VELOCITY_EST/sum_cnt; inst_velocity ((int) sum_cnt) anSRM->shaft_direction; else else, timer count time base
apply velocity delta_theta/delta_time algorithm sum_cnt inst_velocity ((int) sum_cnt) anSRM->shaft_direction; filter smoothing velocity estimate
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
filt_velocity (ALPHA anSRM->wEst_10xrpm) (ONE_MINUS_ALPHA inst_velocity); anSRM->wEst_10xrpm (int) (filt_velocity end, velocity estimation /*COMMUTATION ALGORITHM four quadrant commutation algorithm, using fixed-dwell angle electrical degrees variable turn angle. With fixed dwell electrical degrees, only single phase /*is active time. advance angle calculated function speed desired current. void *anSRM) phase; WORD electricalAngle; WORD angle; channel; long advance; whats_active; desiredCurrent; temp; /*---------------------------*/ Advance angle calculation /*---------------------------*/ advance (anSRM->wEst_10xrpm anSRM->desiredTorque); advance advance Offset advance angle negative torque, required (anSRM->desiredTorque electricalAngle anSRM->position (int) advance; desiredCurrent anSRM->desiredTorque; else electricalAngle anSRM->position PI_16 (int) advance; desiredCurrent -anSRM->desiredTorque; each phase whats_active 0x0; (phase=0; phase< NUMBER_OF_PHASES; phase++) degree offsets phase angle electricalAngle phase TWOPIBYTHREE_16; turn phase between desired angles switch measure desired phase current (angle (PIBYSIX_16)) (angle (FIVEPIBYSIX_16)) anSRM->active[phase] temp phase; channel anSRM->a2d_chan[phase]; switch_mux(channel,channel+8); anSRM->iDes[phase] desiredCurrent; (anSRM->iDes[phase] ILIMIT) anSRM->iDes[phase] ILIMIT; else
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
anSRM->active[phase] temp anSRM->iDes[phase] whats_active whats_active temp; switch low-side FETs, required switch_lowside(whats_active); /*VELOCITY CONTROL LOOP ALGORITHM algorithm implements compensator velocity /*control SRM. filter limits integrator /*to prevent windup void velocityController(anSRM_struct *anSRM) speed_error; integral_error; calculate error signal speed_error anSRM->wDes_10xrpm anSRM->wEst_10xrpm; integrate error anSRM->integral_speed_error anSRM->integral_speed_error (long)speed_error; apply integrator limit (anSRM->integral_speed_error INTEGRAL_LIMIT) anSRM->integral_speed_error INTEGRAL_LIMIT; (anSRM->integral_speed_error -INTEGRAL_LIMIT) anSRM->integral_speed_error -INTEGRAL_LIMIT; filter integral_error (int) 13); anSRM->desiredTorque ((KP*speed_error) integral_error; velocityController
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
/*CURRENT CONTROL LOOP ALGORITHM void currentController(anSRM_struct *anSRM) phase; ierr; (phase=0; phase NUMBER_OF_PHASES; phase++) each active phase (anSRM->active[phase] /*--------------------*/ read converter /*--------------------*/ anSRM->iFB[phase] read_a2d(1); /*---------------------------*/ calculate error signal /*---------------------------*/ ierr anSRM->iDes[phase] anSRM->iFB[phase]; /*---------------------------*/ current loop compensation /*---------------------------*/ anSRM->dutyRatio[phase] ILOOP_GAIN ierr; anSRM->dutyRatio[phase] (anSRM->dutyRatio[phase] /*------------------*/ limit duty ratio /*------------------*/ (anSRM->dutyRatio[phase] anSRM->dutyRatio[phase] (anSRM->dutyRatio[phase] MAXIMUM_DUTYRATIO) anSRM->dutyRatio[phase] MAXIMUM_DUTYRATIO; else, phase active else anSRM->iFB[phase] anSRM->dutyRatio[phase] loop output signals high-side FET's *CMPR1 anSRM->dutyRatio[0]; *CMPR2 anSRM->dutyRatio[1]; *CMPR3 anSRM->dutyRatio[2]; currentController /*SRM ALGORITHM INITIALIZATION void initializeSRM(anSRM_struct *anSRM) i,j;
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
define positions current feedback each phase anSRM->a2d_chan[0] phase current ADCIN1 anSRM->a2d_chan[1] phase current ADCIN2 anSRM->a2d_chan[2] phase current ADCIN3 Define position estimation state machine. Given current state, capture event, with every transition (capture event), parameters defined: trans_lut[i][j].state state trans_lut[i][j].position shaft position trans_lut[i][j].direction shaft direction fill table with zeros. zeros will define illegal transitions (i=0; i<7; i++) (j=0; j<4; j++) anSRM->trans_lut[i][j].state anSRM->trans_lut[i][j].position 'new-state' definitions anSRM->trans_lut[1][2].state anSRM->trans_lut[1][3].state anSRM->trans_lut[2][1].state anSRM->trans_lut[2][3].state anSRM->trans_lut[3][1].state anSRM->trans_lut[3][2].state anSRM->trans_lut[4][1].state anSRM->trans_lut[4][2].state anSRM->trans_lut[5][1].state anSRM->trans_lut[5][3].state anSRM->trans_lut[6][2].state anSRM->trans_lut[6][3].state
'shaft direction' definitions
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
'shaft position' definitions anSRM->trans_lut[1][2].position TWOPIBYTHREE_16; anSRM->trans_lut[1][3].position PI_16; anSRM->trans_lut[2][1].position PIBYTHREE_16; anSRM->trans_lut[2][3].position anSRM->trans_lut[3][1].position PIBYTHREE_16; anSRM->trans_lut[3][2].position TWOPIBYTHREE_16; anSRM->trans_lut[4][1].position FOURPIBYTHREE_16; anSRM->trans_lut[4][2].position FIVEPIBYTHREE_16; anSRM->trans_lut[5][1].position FOURPIBYTHREE_16; anSRM->trans_lut[5][3].position PI_16; anSRM->trans_lut[6][2].position FIVEPIBYTHREE_16; anSRM->trans_lut[6][3].position define initial guesses each state. initial position assumed midpoint each state TWOPIBYTHREE_16 PIBYSIX_16; PIBYSIX_16; PIBYTHREE_16 PIBYSIX_16; FOURPIBYTHREE_16 PIBYSIX_16; PI_16 PIBYSIX_16; FIVEPIBYTHREE_16 PIBYSIX_16; read opto-couplers initial position estimate anSRM->position_state *PBDATDIR 0x7; anSRM->position /*-------------------------*/ initial conditions /*-------------------------*/ for(i NUMBER_OF_PHASES; i++) anSRM->iDes[i] anSRM->active[i] anSRM->iFB[i] anSRM->capture_delta[i][0] 65535; anSRM->capture_delta[i][1] 65535; anSRM->wEst_10xrpm anSRM->shaft_direction anSRM->dp_remainder anSRM->integral_speed_error anSRM->wDes_10xrpm /*File: EVMGR.C /*Target Processor: TMS320F240 /*Compiler Version: /*Assembler Version: /*Created: 10/31/97 This file contains routines initializing using event manager peripherials.
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
/*INCLUDE FILES #include "c240.h" #include "constant.h"
/*EVENT MANAGER INITIALIZATION Through appropriate programming event manager control /*registers, this routine sets event manager that: /*all timers continuous count mode /*timer provides desired frequency timebase /*timer counts 1/16 CPUCLK used time base capture events. Prescaling prevents overflow except only shaft speeds. /*timer provides interrupt /*A/D conversions synchronized with timer period occurences /*compare units configured mode /*PWMs 1,3, (used high-side switching) active /*PWMs 2,4, (used low-side switching) forced hi/low /*sets shared pins capture inputs digital inputs interface with opto-couplers /*initiates continuous conversions. GPTCON Initialization parameters GPTCON 0x1055 xxx1 0000 0101 0101 _---_---_-- (15-13) Read-only status bits ---------| (12-11) Start timer period ------| (10-9) timer event starts --------| (8-7) timer event starts -----------| Enable timer compares -------------------| (5-4) Timer active ------------------------| (3-2) Timer active ---------------------------| (1-0) Timer active -----------------------------| T3CON Initialization parameters T3CON 0x9040 1001 0000 0100 0000 _----_ -_-- (15-14) Stop suspend --------------| (13-11) Continuous up-count mode --------| (10-8) Clock prescaler -----------------| TENABLE --------------------|| Enable timer ---------------------------| (5-4) internal clock source -----------------| (3-2) Reload zero ------------------------------| disable timer compare -------------------------|| period register ------------------------| T2CON Initialization parameters T2CON 0x9440 1001 0100 0100 0000 _----_ -_--
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
(15-14) Stop suspend --------------| (13-11) Continuous up-count mode --------| (10-8) Clock prescaler 1/16 --------------| TENABLE --------------------|| Enable timer ---------------------------| (5-4) internal clock source -----------------| (3-2) Reload zero ------------------------------| disable timer compare -------------------------|| period register ------------------------| T1CON Initialization parameters T1CON 0x9040 1001 0000 x100 0000 _----_ -_-- (15-14) Stop suspend --------------| (13-11) Continuous up-count mode --------| (10-8) Clock prescaler -----------------| Reserved timer --------------------|| Enable timer ---------------------------| (5-4) internal clock source -----------------| (3-2) Reload zero ------------------------------| Disable timer compare -------------------------|| period register ------------------------| COMCON Initialization parameters COMCON 0x8207 1000 0010 xxxx x111 _--_ --_- -_---_-_ (15) Enable compares --------------| (14-13) Reload compare ------------|| (12) Disable Space Vector --------| (11-10) Reload ACTR ------------------| Enable full compare output pins -----|| Hi-Z simple compare output pins ------| Simple compare time base ---------------| (6-5) Simple compare reload --------------------| (4-3) Simple compare SACTR reload ----------------| Compare mode -----------------------||| Compare mode ------------------------|| Compare mode -------------------------| ACTR Initialization parameters ACTR 0x0111 xxxx 0001 0001 0001 (15-12) Space vector related ------| (11-10) PWM6 Force ------------------| (9-8) PWM5 Active --------------------| (7-6) PWM4 Force -----------------------| (5-4) PWM3 Active ------------------------| (3-2) PWM2 Force ----------------------------| (1-0) PWM1 Active ------------------------------| ADCTRL1 Initialization parameters ADCTRL1 0x2c00 0010 110x 0000 0000
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
_-_- _-_- _--- |||| |||| (15) Suspend Soft ---------------|||| |||| (14) Suspend Free ----------------||| |||| (13) Start Conversions ----------|| |||| (12) Disable Channel ---------------| |||| (11) Enable Channel ------------------|||| (10) Continuous conversion -------------||| Disable interrupt ------------------|| Interrupt flag -------------------| Conversion status ----------------------| (6-4) ADC1 select --------------------------| (3-1) ADC2 select ------------------------------| Start conversion ---------------------------| void eventmgr_init() WORD iperiod; Initialize timer provide desired interrupt iperiod (SYSCLK_FREQ/CPU_INT_FREQ) *GPTCON 0x1055; *T3PER iperiod; *T3CON 0x9040; Setup general-purpose control Load timer period register Initialize timer control register
Initialize timer provide time base fixed frequency generation iperiod (SYSCLK_FREQ/PWM_FREQ) *T1PER iperiod; *T1CON 0x9040; Load timer period Initialize timer control register
Initialize timer provide time base clocking capture events *T2PER 0xffff; Load timer period *T2CON 0x9440; Initialize timer control register Setup Compare units outputs *ACTR 0x0111; Initialize action output pins *DBTCON 0x0; Disable deadband *CMPR1 0x0; Clear period registers *CMPR2 0x0; *CMPR3 0x0; *COMCON 0x0207; Setup COMCON enable *COMCON 0x8207; Setup COMCON enable
/*-------------------*/ Setup shared pins ------------------*/ *OCRA 0x0; pins IOPB0-IOPB7 IOPA0-IOPA3 pins *OCRB 0xf1; pins are: ADSOC, /BIO, CAP1-CAP4 *PBDATDIR 0xf0f0; inputs IOPB0-IOPB3 outputs IOPB4-IOPB7, high /*---------------------*/ Setup capture units /*---------------------*/ *CAPCON 0x0; reset capture control register *CAPFIFO 0xff; Clear FIFO's *CAPCON 0xb0fc; enable #1-3, Timer2, both edges
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
/*---------------------*/ Setup converter /*---------------------*/ *ADCTRL1 0x2c00; Initialize control register *ADCTRL2 0x0403; Clear FIFO's, Pre-scaler /*SWITCH INPUT CHANNEL Each converter unit input multiplexer which must selected desired channel, prior sampling. channel selected manipulating bits ADCTRL1 control register inputs: adc1 desired input channel range: adc2 desired input channel range: 8-15 /*outputs: none void switch_mux(int adc1, adc2) WORD ctrl_word; ctrl_word 0x2c00; ctrl_word ctrl_word (adc1 ctrl_word ctrl_word ((adc2-8) *ADCTRL1 ctrl_word; *ADCTRL2 0x0403; /*READ FIFO REGISTER This routine used read sampled data from /*appropriate FIFO. 10-bit data stored /*FIFO bits 15-6. right shift limits data /*to range 0-1023. /*inputs: a2d_chan which FIFO read range: /*outputs: inval data range: 0-1023 bits 1023 bits WORD read_a2d(int a2d_chan) WORD inval; (a2d_chan inval (*ADCFIFO1 0x03ff; else (a2d_chan inval (*ADCFIFO2 0x03ff; return inval; /*SWITCH LOW-SIDE MOSFETS mask channel select bits ADC1 channel bits ADC2 channel bits
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
state low-side power MOSFETS controlled /*level PWM2, PWM4, PWM6 output pins, phases /*A, respectively. Active high logic used, /*but since low-side switches used commutation /*instead control, just force-low /*force-high action options. /*inputs: phaseactive bits 0,1, control state PWM2, PWM4, PWM6 output pins, respectively. (ex. phaseactive will force PWM2 PWM6 high, PWM4 /*outputs: none void switch_lowside(int phaseactive) WORD action; load action register mask PWM2, PWM4, PWM6 force action *ACTR; action action 0xf333; Force PWM2 phase0 active (phaseactive 0x1) action action 0x000c; Force PWM4 phase1 active (phaseactive 0x2) action action 0x00c0; Force PWM6 phase2 active (phaseactive 0x4) action action 0x0c00; Write word action register *ACTR action;
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
/*READ CAPTURE FIFO REGISTERS This routine used read data from capture FIFO /*registers. /*inputs: capture which FIFO read? range /*outputs fifo_data range 0-65535 WORD read_fifo(int capture) WORD fifo_data; fifo_status; (capture fifo_data *FIFO1; read value fifo_status *CAPFIFO 0x0300; read status register, mask while (fifo_status else (capture fifo_data *FIFO2; read value fifo_status *CAPFIFO 0x0c00; read status register, mask while (fifo_status else (capture fifo_data *FIFO3; read value fifo_status *CAPFIFO 0x3000; read status register, mask while (fifo_status !=0); else fifo_data 0xffff; error, valid capture return fifo_data;
bits
bits
bits
File: VECTORS.ASM Target Processor: TMS320F240 Assembler Version: Created: 10/31/97 This file contains interrupt vectors .length .option .option ILLEGAL INTERRUPT ROUTINE .text .def _int_0 _int_0: _int_0 ILLEGAL INTERRUPT SPIN
Switched Reluctance Motor Control Basic Operation Example Using TMS320F240
SPRA420A
INTERRUPT VECTORS .sect "VECTOR" .ref _c_int0 .ref _c_int3 .ref _c_int4 _c_int0 RESET _int_0 INT1 _int_0 INT2 _c_int3 INT3 _c_int4 INT4 _int_0 INT5 _int_0 INT6 _int_0 Reserved _int_0 _int_0 _int_0 _int_0 _int_0 _int_0 _int_0 _int_0 _int_0 _int_0 TRAP _int_0 _int_0 _int_0 _int_0
.end
Linker command file TMS320F240 vectors.obj evmgr.obj srm.obj autoinitialization model main.map main.out c:\2xxtools\rts2xx.lib
MEMORY PAGE PAGE PAGE DATA: SECTIONS .VECTOR .text .cinit .switch .mmrs .data .bss .const .stack .sysmem
VECTORS: CODE: MMRS: origin origin origin
origin 0x0000 length origin 0x0040 length origin 0x0000 length origin 0x0060 length 0x0100 length 0x0100 0x0300 length 0x0100 0xa000 length 0x2000
0x0040 0x1FC0 0x0060 0x0020 DARAM DARAM EMIF
EMIF EMIF MMRS DARAM
VECTORS CODE CODE CODE MMRS DATA DATA DATA DATA DATA
PAGE PAGE PAGE PAGE PAGE PAGE PAGE PAGE PAGE PAGE
Memory Mapped Registers
Switched Reluctance Motor Control Basic Operation Example 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 2000, Texas Instruments Incorporated

Other recent searches


UG1260 - UG1260   UG1260 Datasheet
SUV85N10-10 - SUV85N10-10   SUV85N10-10 Datasheet
SMD5032 - SMD5032   SMD5032 Datasheet
MU9C1965A - MU9C1965A   MU9C1965A Datasheet
MCF5307 - MCF5307   MCF5307 Datasheet
CY7C1516JV18 - CY7C1516JV18   CY7C1516JV18 Datasheet
CY7C1527JV18 - CY7C1527JV18   CY7C1527JV18 Datasheet
CY7C1518JV18 - CY7C1518JV18   CY7C1518JV18 Datasheet
CY7C1520JV18 - CY7C1520JV18   CY7C1520JV18 Datasheet
BVU-5K5QT4 - BVU-5K5QT4   BVU-5K5QT4 Datasheet
BVT-5K5QT4 - BVT-5K5QT4   BVT-5K5QT4 Datasheet

 

Privacy Policy | Disclaimer
© 2012 Datasheet Archive