An 1937

Embed Size (px)

Citation preview

Freescale Semiconductor, Inc.Order by AN1937/D (Motorola Order Number) Rev. 0, 9/02

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

3-Phase Switched Reluctance Motor Control with Encoder Using DSP56F80xFreescale Semiconductor, Inc...ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Contents1. Introduction ....................................1 2. Motorola DSP, Advantages and Features .....................................2 3. Target Motor Theory...................... 43.1 Switched Reluctance Motor ............4 3.2 Mathematical Description of an SR Motor ...............................................6 3.3 Digital Control of an SR Motor ......8 3.4 Voltage and Current Control for SR Motors............................................10

Design of a Motor Control Application Based on the Motorola Software Development KitPeter Balazovic, Radim Visinka

1.

4. Switched Reluctance Motor Control Techniques with Encoder Position Sensor .......................124.1 4.2 4.3 4.4 Encoder Sensor .............................13 Commutation Angle Calculation ..13 Commutation Strategy ..................15 The Current Controller..................16

Introduction

This Application Note describes the design of an advanced 3-Phase Switched Reluctance (SR) motor drive. It is based on Motorolas DSP56F80x family for dedicated motor control devices. The software design takes advantage of the SDK (Software Development Kit) developed by Motorola. SR motors are gaining wider popularity among variable speed drives. This is due to their simple low-cost construction characterized by an absence of magnets and rotor winding, high level of performance over a wide range of speeds, and fault-tolerant power stage design. for numerous applications, availability and the moderate cost of the necessary electronic components make SR drives a viable alternative to other commonly used motors like AC, BLDC, PM Synchronous or universal motors. The concept of this application is an advance speed closed loop SR drive with encoder position sensor. An inner current loop with PI controller is included. The encoder position sensor provides an accurate measurement of the actual rotor position necessary for proper commutation. This application serves as an example of an advanced SR motor control. The entire system is designed using a Motorola DSP with SDK support. It also illustrates the usage of dedicated motor control libraries that are included in the SDK. The application helps start the development of the advanced SR drive dedicated to the targeted application.

5. System Design ..............................175.1 System Outline ..............................17 5.2 Application Description ................17

6. Hardware Implementation ............306.1 Hardware Setup.............................30 6.2 Motor-Brake Specifications ..........33

7. Software Design ...........................347.1 Data Flow ......................................34 7.2 State Diagram................................38 7.3 Software Design ............................40

8. Implementation Notes .................. 458.1 Scaling of Quantities .....................45 8.2 Velocity Calculation .....................48

9. SDK Implementation ...................499.1 9.2 9.3 9.4 9.5 Drivers and Library Function........49 Appconfig.h File ...........................50 Initialization of Drivers .................50 Interrupts .......................................50 PC Master Software ......................50

10. DSP Usage .................................52 11. References ..................................53

Motorola, Inc., 2002. All rights reserved.

For More Information On This Product, Go to: www.freescale.com

3-Phase SR Motor Control with Encoder

Motorola DSP, Advantages and Features

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

This Application Note includes a description of Motorola DSP features, basic SR motor theory, system design concept, hardware implementation, and software design including the use of the software visualization tool.

2.

Motorola DSP, Advantages and Features

The Motorola DSP56F80x family is well suited for digital motor control, combining a DSPs computational ability with an MCUs controller features on a single chip. These DSPs offer many dedicated peripherals like a Pulse Width Modulation (PWM) unit, Analog-to-Digital Converter (ADC), timers, communications peripherals (SCI, SPI, CAN), on-board Flash and RAM. Generally, all family members are well-suited for Switched Reluctance motor control. One typical member of the family, the DSP56F805, provides the following peripheral blocks: Two Pulse Width Modulator modules (PWMA & PWMB), each with six PWM outputs, three Current Sense inputs, and four Fault inputs; fault tolerant design with deadtime insertion; supports both Center- and Edge- aligned modes Twelve bit, Analog to Digital Converters (ADCs), supporting two simultaneous conversions with dual 4-pin multiplexed inputs; the ADC can be synchronized by PWM Two Quadrature Decoders (Quad Dec0 & Quad Dec1), each with four inputs, or two additional Quad Timers A & B Two dedicated General Purpose Quad Timers totaling 6 pins: Timer C with 2 pins and Timer D with 4 pins CAN 2.0 A/B Module with 2-pin ports used to transmit and receive Two Serial Communication Interfaces (SCI0 & SCI1), each with two pins, or four additional GPIO lines Serial Peripheral Interface (SPI), with configurable 4-pin port, or four additional GPIO lines Computer Operating Properly (COP) Watchdog Timer Two dedicated external interrupt pins Fourteen dedicated General Purpose I/O (GPIO) pins, 18 multiplexed GPIO pins External reset pin for hardware reset JTAG/On-Chip Emulation (OnCE) Software-programmable, Phase Lock Loop-based frequency synthesizer for the DSP core clock Table 2-1. Memory ConfigurationDSP56F801 Program Flash Data Flash Program RAM Data RAM Boot Flash 8188 x 16-bit 2K x 16-bit 1K x 16-bit 1K x 16-bit 2K x 16-bit DSP56F803 32252 x 16-bit 4K x 16-bit 512 x 16-bit 2K x 16-bit 2K x 16-bit DSP56F805 32252 x 16-bit 4K x 16-bit 512 x 16-bit 2K x 16-bit 2K x 16-bit DSP56F807 61436 x 16-bit 8K x 16-bit 2K x 16-bit 4K x 16-bit 2K x 16-bit

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

2

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Motorola DSP, Advantages and Features

The most interesting peripherals, from the switched reluctance motor control point of view, are the fast Analog-to-Digital Converter (ADC) and the Pulse-Width-Modulation (PWM) on-chip modules. They offer extensive freedom of configuration, enabling efficient control of SR motors. The PWM module incorporates a PWM generator, enabling the generation of control signals for the motor power stage. The module has the following features: Three complementary PWM signal pairs, or six independent PWM signals Complementary channel operation Deadtime insertion Separate top and bottom pulse width correction via current status inputs or software Separate top and bottom polarity control Edge-aligned or center-aligned PWM signals 15 bits of resolution Half-cycle reload capability Integral reload rates from one to 16 Individual software-controlled PWM output Programmable fault protection Polarity control 20mA current sink capability on PWM pins Write-protectable registers

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

The SR motor control application utilizes the PWM module set in independent PWM mode, permitting fully independent generation of control signals for all switches of the power stage. In addition to the PWM generators, the PWM outputs can be controlled separately by software, allowing the setting of the control signal to logical 0 or 1. Thus, the state of the control signals can be changed instantly at a given rotor position (phase commutation) without changing the contents of the PWM value registers. This change can be made asynchronously with the PWM duty cycle update. The Analog-to-Digital Converter (ADC) consists of a digital control module and two analog sample and hold (S/H) circuits. It has the following features: 12-bit resolution Maximum ADC clock frequency is 5MHz with 200ns period Single conversion time of 8.5 ADC clock cycles (8.5 x 200 ns = 1.7s) Additional conversion time of 6 ADC clock cycles (6 x 200 ns = 1.2s) Eight conversions in 26.5 ADC clock cycles (26.5 x 200 ns = 5.3s) using simultaneous mode ADC can be synchronized to the PWM via the sync signal Simultaneous or sequential sampling Internal multiplexer to select two of eight inputs Ability to sequentially scan and store up to eight measurements Ability to simultaneously sample and hold two inputs Optional interrupts at end of scan at zero crossing or if an out-of-range limit is exceeded Optional sample correction by subtracting a pre-programmed offset value Signed or unsigned result Single ended or differential inputs

MOTOROLA

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

3

Target Motor Theory

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

The application utilizes the ADC on-chip module in simultaneous mode and sequential scan. The sampling is synchronized with the PWM pulses for precise sampling and reconstruction of phase currents. Such a configuration allows instant conversion of the desired analog values of all phase currents, voltages and temperatures.

3.

Target Motor Theory

3.1 Switched Reluctance MotorA Switched Reluctance (SR) motor is a rotating electric machine where both stator and rotor have salient poles. The stator winding is comprised of a set of coils, each of which is wound on one pole. The rotor is created from lamination in order to minimize the eddy-current losses.

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

SR motors differ in the number of phases wound on the stator. Each of them has a certain number of suitable combinations of stator and rotor poles. Figure 3-1 illustrates a typical 3-Phase SR motor with a 6/4 (stator/rotor) pole configuration.Phase C Phase A Phase B Stator (6 poles)

Stator Winding

Rotor (4 poles)

Aligned position on Phase A

Figure 3-1. 3-Phase 6/4 SR Motor The motor is excited by a sequence of current pulses applied at each phase. The individual phases are consequently excited, forcing the motor to rotate. The current pulses need to be applied to the respective phase at the exact rotor position relative to the excited phase. When any pair of rotor poles is exactly in line with the stator poles of the selected phase, the phase is said to be in an aligned position, i.e., the rotor is in the position of maximal stator inductance (see Figure 3-1). If the interpolar axis of the rotor is in-line with the stator poles of the selected phase, the phase is said to be in an unaligned position - the rotor is in a position of minimal stator inductance. The inductance profile of SR motors is triangular shaped, with maximum inductance when it is in an aligned position and minimum inductance when unaligned. Figure 3-2 illustrates the idealized triangular-like inductance profile of all three phases of an SR motor with phase A highlighted. The individual Phases A, B, and C are shifted electrically by 120o relative to each other. The interval, when the respective phase is powered, is called the dwell angle - dwell. It is defined by the turn-on on and the turn-off off angle.

4

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Target Motor Theory

When the voltage is applied to the stator phase, the motor creates torque in the direction of increasing inductance. When the phase is energized in its minimum inductance position, the rotor moves to the forthcoming position of maximal inductance. The movement is defined by the magnetization characteristics of the motor. A typical current profile for a constant phase voltage is shown in Figure 3-2. For a constant phase voltage the phase current has its maximum in the position when the inductance starts to increase. This corresponds to the position when the rotor and the stator poles start to overlap. When the phase is turned off, the phase current falls to zero. The phase current present in the region of decreasing inductance generates negative torque. The torque generated by the motor is controlled by the applied phase voltage and by the appropriate definition of switching turn-on and turn-off angles. For more details, see [3]. As is apparent from the description, the SR motor requires position feedback for motor phase commutation. In many cases, this requirement is addressed by using position sensors, like encoders, Hall sensors, etc. The result is that the implementation of mechanical sensors increases costs and decreases system reliability. Traditionally, developers of motion control products have attempted to lower system costs by reducing the number of sensors. A variety of algorithms for sensorless control have been developed, most of which involve evaluation of the variation of magnetic circuit parameters that are dependent on the rotor position [2], [5].

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

6WDWRU 3KDVH $ 5RWRU

$OLJQHG

8QDOLJQHG

$OLJQHG

/&

LSK$

/%

/$

SRVLWLRQ WLPH

SKDVH $ HQHUJL]LQJ

GZHOO RQBSK$ RIIBSK$SRVLWLRQ WLPH

Figure 3-2. Phase Energizing The motor itself is a low cost machine of simple construction. High-speed operation is possible, thus the motor is suitable for high speed applications, like vacuum cleaners, fans, white goods, etc. As discussed above, the disadvantage of the SR motor is the need for shaft-position information for the proper switching of individual phases. Also, the motor structure causes noise and torque ripple. The greater the number of poles, the smoother the torque ripple, but motor construction and control electronics become more expensive. Torque ripple can also be reduced by advanced control techniques, such as phase current profiling.

MOTOROLA

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

5

Target Motor Theory

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

3.2 Mathematical Description of an SR MotorAn SR motor is a highly non-linear system, so a non-linear theory describing the behavior of the motor was developed. Based on this theory, a mathematical model can be created. On one hand it enables the simulation of SR motor systems and on the other hand, it makes the development and implementation of sophisticated algorithms for controlling the SR motor easier. The electromagnetic circuit of the SR motor is characterized by non-linear magnetization. Figure 3-3 illustrates a magnetization characteristic for a specific SR motor [1]. It is a function between the magnetic flux , the phase current i and the motor position . The influence of the phase current is mostly apparent in the aligned position, where saturation effects can be observed. The magnetization characteristic curve defines the non-linearity of the motor. The torque generated by the motor phase is a function of the magnetic flux, therefore the phase torque is not constant for a constant phase current for different motor positions. This creates torque ripple and noise in the SR motor.

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Figure 3-3. Magnetization Characteristics of the SR Motor A mathematical model of an SR motor can be developed. The model is based on the electrical diagram of the motor, incorporating the phase resistance and phase inductance [1]. The diagram for one phase is illustrated in Figure 3-4.

6

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Target Motor Theory

LSK

USK

/SK I

XSK

Figure 3-4. Electrical Diagram of One SR Motor Phase According to Figure 3-4, any voltage applied to a phase of the SR motor can be described as a sum of voltage drops in the phase resistance and induced voltages on the phase inductance:

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

u ph ( t ) = r ph i ph ( t ) + u Lph ( t )where: uph rph iph uLph is the voltage applied to a phase is the phase resistance is the phase current is the induced voltages over the phase inductance.

(EQ 3-1.)

The equation (EQ 3-1.) supposes that all phases are independent and have no mutual influence. The induced voltage uLph is defined by the magnetic flux linkage ph , that is a function of the phase current iph and the rotor position ph. So the induced voltage can be expressed as:

ph ( i ph, ph ) di ph ph ( i ph, ph ) d ph d ph ( i ph, ph ) u Lph ( t ) = ----------------------------------- = ---------------------------------- -------- + ---------------------------------- ---------i ph ph dt dt dtThen the phase voltage can be expressed as:

(EQ 3-2.)

d ph ( i ph, ph ) u ph ( t ) = r ph i ph ( t ) + ----------------------------------dtor:

(EQ 3-3.)

ph ( i ph, ph ) di ph ph ( i ph, ph ) uph ( t ) = r ph i ph ( t ) + ---------------------------------- -------- + ---------------------------------- i ph ph dtwhere:

(EQ 3-4.)

is the angular speed of the motor.

MOTOROLA

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

7

Target Motor Theory

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

The torque Mph generated by one phase can be expressed as:I ph

M ph =

0

ph ( i ph, ph ) ---------------------------------- di ph ph

(EQ 3-5.)

The mathematical model of an SR motor is then represented by a system of equations, describing the conversion of electromechanical energy. For 3-Phase SR motors the equation (EQ 3-4.) can be expanded as follows:

a ( i a, a ) di a a ( i a, a ) ua ( t ) = r a i a ( t ) + --------------------------- ------ + --------------------------- i a a dt

(EQ 3-6.)

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

b ( i b, b ) di b b ( i b, b ) u b ( t ) = r b i b ( t ) + --------------------------- ------ + --------------------------- i b b dt c ( i c, c ) di c c ( i c, c ) u c ( t ) = r c i c ( t ) + -------------------------- ------ + -------------------------- i c c dtwhere a, b, c index the individual phases.

(EQ 3-7.)

(EQ 3-8.)

As stated in the above equations, the mutual effect between individual phases is not considered.

3.3 Digital Control of an SR MotorThe SR motor is driven by voltage strokes coupled with the given rotor position. The profile of the phase current together with the magnetization characteristics define the generated torque and thus the speed of the motor. Due to this fact, the motor requires electronic control for operation. Several power stage topologies are being implemented, according to the number of motor phases and the desired control algorithm. The particular structure of the SR power stage structure defines the freedom of control for an individual phase. A power stage with two independent power switches per motor phase is the most used topology. Such a power stage for 3-Phase SR motors is illustrated in Figure 3-5. It permits control of the individual phases fully independent of each other and thus permits the widest freedom of control. Other power stage topologies share some of the power devices for several phases, thus saving on power stage cost, but with these the phases cannot be controlled fully independently. Note that this particular topology of SR power stage is fault tolerant, in contrast to power stages of AC induction motors, because it eliminates the possibility of a rail-to-rail short circuit. During normal operation, the electromagnetic flux in an SR motor is not constant and must be built for every stroke. In the motoring period, these strokes correspond to the rotor position when the rotor poles are approaching the corresponding stator pole of the excited phase. In the case of Phase A, shown in Figure 3-1, the stroke can be established by activating the switches Q1 and Q2. At low-speed operation the Pulse Width Modulation (PWM), applied to the corresponding switches, modulates the voltage level. Two basic switching techniques can be applied: Soft switching - where one transistor is left turned on during the whole commutation period and PWM is applied to the other one Hard switching - where PWM is applied to both transistors simultaneously

8

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Target Motor Theory

DC Voltage

Q1 PWM_Q1+

D1 PWM_Q3

Q3

D1 PWM_Q5

Q5

D1

Phase A D2 Q2

Phase B D2 Q4

Phase C D2 Q6

Cap

PWM_Q2

PWM_Q4

PWM_Q6

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

GND

Figure 3-5. 3-Phase SR Power Stage Figure 3-6 illustrates both soft and hard switching PWM techniques. The control signals for the upper and the lower switches of the above-described power stage define the phase voltage and thus the phase current. The soft switching technique generates lower current ripple compared to the hard switching technique. Also, it produces lower acoustic noise and less EMI. Therefore, soft switching techniques are often preferred for motoring operation. For more details, see [3].Vhyvtrq ThQyr 6yvtrq Vhyvtrq 6yvtrq

SQyr

Dqphpr

QXH VrTvpu

QXH

QXH GrTvpu

W

'&

W

'&

QuhrWyhtr

W

'&

W

'&

Quhr8r

UP

UPss

Qvv

UP

UPss

Qvv

TsTvpuvt

ChqTvpuvt

Figure 3-6. Soft Switching and Hard SwitchingMOTOROLA 3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com 9

Target Motor Theory

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

3.4 Voltage and Current Control for SR MotorsA number of control techniques for SR motors exist. They differ in the structure of the control algorithm and in position evaluation. Two basic techniques for controlling SR motors can be distinguished, according to the motor variables that are being controlled: Voltage control - where phase voltage is a controlled variable Current control - where phase current is a controlled variable

3.4.1 Voltage Control of an SR MotorIn voltage control techniques, the voltage applied to the motor phases is constant during the complete sampling period of the speed control loop. The commutation of the phases is linked to the position of the rotor.

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

The voltage applied to the phase is directly controlled by a speed controller. The speed controller processes the speed error, the difference between the desired speed and the actual speed, and generates the desired phase voltage. The phase voltage is defined by a PWM duty cycle implemented at the DC-Bus voltage of the SR inverter. The phase voltage is constant during a complete dwell angle. The technique is illustrated in Figure 3-7. The current and the voltage profiles can be seen in Figure 3-8. The phase current is at its peak at the position when the inductance starts to increase (stator and rotor poles start to overlap) due to the change in the inductance profile. .3RZHU 6WDJH

&RQWUROOHU GHVLUHG HUURU6SHHG &RQWUROOHU 3:0 2XWSXW 'XW\ &\FOH 3:0 *HQHUDWRU

DFWXDO

RQ

RII

Figure 3-7. Voltage Control Technique

10

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Target Motor Theory

LSK

/

SKDVH FXUUHQW GHFD\V WKURXJK WKH IO\ EDFN GLRGHV

RQ

X

RII

SRVLWLRQ WLPH

8'&%XV3:0

SK

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

SRVLWLRQ WLPH 3:0 6SHHG &RQWUROOHU 2XWSXW

8

'&%XV

Figure 3-8. Voltage Control Technique - Voltage and Current Profiles

3.4.2 Current Control of an SR MotorIn current control techniques the voltage applied to the motor phases is modulated to reach the desired current at the powered phase. For most applications, the desired current is constant during the complete sampling period of the speed control loop. The commutation of the phases is linked to the position of the rotor. The voltage applied to the phase is controlled by a current controller with an external speed control loop. The speed controller processes the speed error, the difference between the desired speed and the actual speed, and generates the desired phase current. The current controller evaluates the difference between actual and desired phase current and calculates the appropriate PWM duty cycle. The phase voltage is defined by a PWM duty cycle implemented at the DC-Bus voltage of the SR inverter. Thus, the phase voltage is modulated at the rate of the current control loop. This technique is illustrated in Figure 3-9. The processing of the current controller needs to be linked to the commutation of the phases. When the phase is turned on (commutated), a duty cycle of 100% is applied to the phase. The increasing actual phase current is regularly compared to the desired current. As soon as the actual current slightly exceeds the desired current, the current controller is turned on. Current controller controls the output of the duty cycle until the phase is turned off (following commutation). The procedure is repeated for each commutation cycle of the motor. The current and the voltage profiles can be seen in Figure 3-10. In ideal cases the phase current is controlled to follow the desired current.

MOTOROLA

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

11

Switched Reluctance Motor Control Techniques with Encoder Position Sensor

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

3RZHU 6WDJH

&RQWUROOHU GHVLUHG HUURU 6SHHG &RQWUROOHU

LGHVLUHG

LHUURU

3:0 2XWSXW 'XW\ &\FOH &XUUHQW &RQWUROOHU 3:0 *HQHUDWRU

DFWXDO

LDFWXDO

RQ

RII

Freescale Semiconductor, Inc...

Figure 3-9. Current Control Technique

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

/ LGHVLUHG LSK

SKDVH FXUUHQW GHFD\V WKURXJK WKH IO\ EDFN GLRGHV

8'&%XV

RQ

XSK

RII

SRVLWLRQ WLPH

SRVLWLRQ WLPH 3:0 &XUUHQW &RQWUROOHU 2XWSXW

8

'&%XV

Figure 3-10. Current Control Technique - Voltage and Current Profiles

4.

Switched Reluctance Motor Control Techniques with Encoder Position Sensor

A single-chip control system provides sufficient computational power for advanced algorithms permitting efficient motor control over wide speed ranges. There are several ways to control an SR motor. This control technique presents the current control method with shaft position information.

12

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

3:0

MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 20054.1 Encoder Sensor

Switched Reluctance Motor Control Techniques with Encoder Position Sensor

Whenever mechanical rotary motions have to be monitored, the encoder is the most important interface between the mechanics and the control unit. Encoders transform rotary or linear movement into a sequence of electrical pulses. A rotary encoder can differentiate a number of discrete positions per revolution. The number of segments determines the resolution of the movement and hence the accuracy of the position and this number is called its points per revolution. The speed of an encoder is in counts-per-second. Although there are various kinds of digital encoders, the most common one is the optical encoder. Rotary and linear optical encoders are used frequently for motion and position sensing. A disc or a plate containing opaque and transparent segments passes between a light source (such an LED) and detector to interrupt a light beam. The electronic signals that are generated are then fed into the DSP controller where position and velocity information is calculated based upon the signals received. Many incremental encoders also have a feature called the index pulse. In rotary encoders an index pulse occurs once per encoder revolution. It is used to establish an absolute mechanical reference position within one encoder count of the 360 encoder rotation. The index signal can be used to do several tasks in the system. It can be used to reset or preset the position counter and/or generate an interrupt signal to the system controller.90 el

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Phase A

Phase B time

Figure 4-1. Quadrature Encoder Signals Quadrature encoders are a particular kind of incremental encoder with at least two output signals, generally called Phase A and Phase B. As seen in Figure 4-1, channel B is offset 90 degrees from channel A. The addition of a second channel provides direction information in the feedback signal. This signal, leading or lagging by 90 electrical degrees, guarantees the exact determination of the direction of rotation at all times. The ability to detect direction is critical if encoder rotation stops on a pulse edge. Without the ability to decode direction, the counter may count each transition through the rising edge of the signal and lose position. Another benefit of the quadrature signal scheme is the ability to electronically multiply the counts during one encoder cycle. In the times-1 mode, all counts are generated on the rising edges of channel A. In the times-2 mode, both the rising and falling edges of channel A are used to generate counts. In the times-4 mode, the rising and falling edges of channel A and channel B are used to generate counts. This increases the resolution by a factor of four. For encoders with sine wave output, the channels may be interpolated for very high resolution.

4.2 Commutation Angle CalculationIn an SR motor the switched-on and switched-off angles are complex functions of many parameters and are variable for optimum operation. Their fine tuning is necessary to maintain optimum performance at different motor speed and load conditions. The control of firing angle can be accomplished a number of ways and strongly depends on position sensor. If the position information is precisely acquired, it is possible to suitably utilize a sophisticated algorithm.

MOTOROLA

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

13

Switched Reluctance Motor Control Techniques with Encoder Position Sensor

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

This control technique varies the firing angle continuously with the fixed dwell angle. The switched-on angle is calculated in such a way that the excitation current should reach the maximum defined value at the beginning of the stator and rotor tooth overlap. The phase current is built up in corresponding windings of the stator since the inductance is at a minimum level in an unaligned position and there is adequate time to increase it to the desired value before the motoring torque is being produced. The conduction angle remains fixed through the entire run of the application to ensure the phase current is decreased before reaching the braking region (following the aligned position). The calculation neglects the stator winding resistance, which simplifies the equation. The resistance neglect can be recognized only at large values of resistance R, which is the case of very small switched reluctance machines. Figure 4-2 explains the proposed algorithm for advance angle calculation. The computation method is derived from (EQ 3-6.) - (EQ 3-8.) and is rearranged into the following expression as:

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

di ph dL ph u ph = r ph i ph + L ph --------- + i ph ---------- dt dwhere: uph rph iph Lph

(EQ 4-1.)

is the voltage applied to a phase is the phase resistance is the phase current is the phase inductance is the rotor position

idesired iphase Lunaligned

0

on

uapplied

position / time

100% PWM

Figure 4-2. Commutation Angle Calculation The unaligned phase inductance is considered as constant near the turn-on instant. If voltage drop across phase resistance is neglected, then the following expression is given as (EQ 4-2.) using a first order approximation:

i desired on = L unaligned --------------- actual u ph14 3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

(EQ 4-2.)

MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005where:on

Switched Reluctance Motor Control Techniques with Encoder Position Sensor

is the advanced angle

idesired is the desired current to be achieved Lunaligned is the unaligned inductance uphase is the applied phase voltageactual is the actual rotor speed

4.3 Commutation StrategyIn general, the commutation strategy determines the performance of the SR motor. The commutation method uses rotor position feedback to derive the commutating signals for the inverter switches. The controlled parameters are the applied phase voltage and the turn-on angle on. The dwell angle is fixed prior to motor starts. The number of commutations per mechanical revolution is proportional to the number of rotor poles and number of stator phases (EQ 4-3.). It arises from the mechanical construction of the SR motor. The number of motor commutations is calculated as follows:NumOfCommut = N r m

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

(EQ 4-3.)

where:umOfCommut is the number of commutations per one mechanical revolution

Nr m

is the number of rotor poles is the number of stator phases

An SR motor is usually described in terms of low-speed and high-speed regions. The low-speed operating region is graphically depicted in Figure 4-3. In this low-speed operating area, the phase current can be arbitrarily controlled to any desired value. Increasing the rotor speed makes it difficult to control the phase current. There is an influence of back-EMF effect combined with a diminishing amount of time to perform the commutation.Current Actual Inductance Estimated Inductance

idesired

iph

0

advanceUDC-Bus

on

edge

off

360

uapplied

Position / Time

idesired reached

PWM = 100%

PWM = Current Controller Output

-UDC-Bus

Figure 4-3. Commutation StrategyMOTOROLA 3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com 15

Switched Reluctance Motor Control Techniques with Encoder Position Sensor

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

The commutation itself can be performed in a number of ways. The presented control technique utilizes the encoder sensor information to initiate the commutation routine, which ensures turn-off of the previous stator phase, and consecutively the next stator phase is turned on depending on the direction of the rotor rotation. The appropriate firing angle, on, is calculated through advance angle calculation (see Section 4.2). The commutation software algorithm determines the necessary advance angle, advance, for turning on the correct stator phase. The full DC-Bus voltage is applied after switching on the correct phase in the advance instant. If the actual value of phase current exceeds the desired current value then the current controller with sufficient controller initialization is started to maintain the actual value of the phase current within the requested magnitude. This is achieved by chopping the DC-Bus voltage. The simplest scheme is to leave the lower transistor on during current regulation and to switch the upper one on and off at a high fixed PWM frequency with a varying duty cycle. This strategy is often called soft switching (see Figure 3-6). The current waveform during soft switching is similar to that shown in Figure 4-3.

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

4.4 The Current ControllerBasically, there are three different modes of operation, namely, voltage control, current control, and single-pulse control. The current control method is normally used to control the torque efficiently, while single-pulse mode is entered for high-speed operation. The main difficulty when designing switched reluctance motor current controllers is that the winding back electromotive force (back-EMF) and electrical time constant vary significantly within one electrical cycle and with the motor speed and phase current level. The voltage equation of the SRM is given by (EQ 3-4.). This equation indicates a nonlinear model which is dependent on position, current and speed. The electrical time constant of a phase winding and the back-EMF vary greatly with current and rotor position. As Figure 4-3 implies, the current controller is switched on when the desired stator phase current is reached. At this point, the slope of increasing inductance (inductance derivation over position) is considered as a constant value, and the phase current is preserved at a defined target value; then (EQ 3-4.) can be rearranged as follows:

dL ph ( ph ) u phase_applied ( t ) = r ph i ph ( t ) + i ph ( t ) ------------------------ d ph

(EQ 4-4.)

The applied phase voltage is roughly maintained near the value of (EQ 4-4.), where iph is the desired phase current, is the actual angular speed of the rotor. Derivation over the position of the corresponding phase inductance is determined from motor parameter measurement. Knowing these parameters, the initial current controller is set up using (EQ 4-4.) in the time instance (red point - see Figure 4-4) when the controller is switched on.

idesired reachedUDC-Bus

uapplied

uapplied

Position / Time PWM = 100% PWM = Current Controller Output -UDC-Bus

Figure 4-4. Phase Voltage Generation16 3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

System Design

5.

System Design

5.1 System OutlineThis system is designed to drive a 3-Phase SR motor. The application meets the following performance specifications: Speed control of an SR motor with Encoder position sensor with an inner current closed loop Targeted for DSP56F803EVM, DSP56F805EVM, DSP56F807EVM Running on a 3-Phase SR HV Motor Control Development Platform at a variable line voltage of between 115V AC and 230V AC (voltage range -15% ... +10%) The control technique incorporates current SRM control with speed closed loop motor starts from any motor position with rotor alignment one direction of rotation motoring mode minimal speed 600 rpm maximal speed 2600 rpm at input power line 230V AC maximal speed 1600 rpm at input power line 115V AC Encoder position reference for commutation Manual Interface (Start/Stop switch, Up/Down push button control, LED indicator) PC master software control interface (motor Start/Stop, speed set-up) Power stage identification DC-Bus over-voltage, DC-Bus under-voltage, DC-Bus over-current and over-heating fault protection PC master software Monitor graphical control page (required speed, actual motor speed, operational mode PC/manual, start/stop status, drive fault status, DC-Bus voltage level, identified power stage boards, system status) speed scope (observes actual and desired speeds) current controller (observes actual and desired phase current, applied phase voltage)

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

5.2 Application DescriptionFor the drive, a standard system concept was chosen (see Figure 5-1). The system incorporates the following hardware parts: A 3-Phase SR high-voltage development platform (power stage with optoisolation board, motor brake) Feedback sensors: DC-Bus voltage, current Phase A, current Phase B, current Phase C, temperature A DSP56F80x controller

MOTOROLA

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

17

System Design

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

3-Phase SR Power Stage

Line AC

AC 6 DC Voltage Current Temperature PWM

SRM

LOAD

DSP56F80x Fault Protection

EADC

Freescale Semiconductor, Inc...

START STOP

Speed Cmd.

Speed Error

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

DOWN

Speed Controller

Current Cmd.

Current Error

Current Controller

Desired Volatge

Duty DC-Bus Cycle Ripple Elimination PWM Generation

UP

MUX DC Bus Voltage Commutation

PC Remote Control SCI Phase Current Speed Feedback

Commutation Angle Calculation

Speed Feedback

Speed Calculation

Quad Dec Position Feedback

Figure 5-1. System Concept The DSP runs the main control algorithm. It generates 3-Phase PWM output signals for the SR motor power stage according to the user interface input and feedback signals. The drive can be controlled in two different ways (or operational modes): In Manual operational mode, the required speed is set by a Start/Stop switch and Up and Down push buttons. In PC master software operational mode, the required speed is set by the PC master software

After RESET, the drive is initialized and it automatically enters MANUAL operational mode. Note, PC master software can only take over control when the motor is stopped. When the Start command is detected (using the Start/Stop switch or the PC master software button Start) and while no fault is pending, the start-up sequence with the rotor alignment is performed and the motor is started. Rotor position is evaluated using an encoder position sensor. The commutation angle is calculated according to the desired speed, the desired current and the actual DC-Bus voltage. When the actual position of the rotor is equal to the reference position, the commutation of the phases in the desired direction of rotation is done; the actual phase is turned off and the following phase is turned on.

18

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

System Design

The actual motor speed is derived from the position information, so an additional velocity sensor is unneeded. The reference speed is calculated according to the control signals (start/stop switch, up/down push buttons) and PC master software commands (when controlled by the PC master software). The acceleration/deceleration ramp is implemented. The comparison between the reference speed and the measured speed gives a speed error. Based on the speed error, the speed controller generates the desired phase current. When the phase is commutated, it is turned on with a duty cycle of 100%. Then, during each PWM cycle, the actual phase current is compared with the desired current. As soon as the actual current exceeds the desired current, the current controller is turned on. The current controller controls the output duty cycle until the phase is turned off (following commutation). Finally, the 3-Phase PWM control signals are generated. The procedure is repeated for each commutation cycle of the motor. DC-Bus voltage, DC-Bus current, and power stage temperature are measured during the control process. The measurements are used for DC-Bus over-voltage, DC-Bus under-voltage, DC-Bus over-current and over-temperature protection of the drive. DC-Bus under-voltage and over-temperature protection are performed by software, while DC-Bus over-current and the DC-Bus over-voltage fault signals utilize the Fault inputs of the DSP on-chip PWM module. The line voltage is measured during initialization of the application. According to the detected level, the 115VAC or 230VAC mains are recognized. If the line voltage is detected outside -15% ... +10% of the nominal voltage, the fault "Out of the Mains Limit" disables drive operation. If any of the above mentioned faults occur, the motor control PWM outputs are disabled in order to protect the drive. The fault status can only be exited when the fault conditions have disappeared and the Start/Stop switch is moved to the STOP position. The fault state is indicated by the on-board LED. The SR power stage uses a unique configuration of power devices, different than AC or BLDC configuration. SR software would cause the destruction of AC or BLDC power stages due to the simultaneous switching of the power devices. Since the application software could be accidentally loaded into an AC or BLDC drive, the software incorporates a protection feature to prevent this. Each power stage contains a simple module which generates a logic signal sequence that is unique for that type of power stage. During the initialization of the chip, this sequence is read and evaluated according to the decoding table. If the correct SR power stage is not identified, the fault, "Wrong Power Stage", disables drive operation.

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

5.2.1 Initialization and Start-UpBefore the motor can be started, rotor alignment and initialization of the control algorithms must be performed (see Figure 5-2) since the absolute position is not known.

MOTOROLA

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

19

System Design

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

B

Start Command Accepted

^ ^

C

A

Turn on Phases B & C

Any Rotor Position

Wait to Ensure the Initial Pulse

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Turn Off Phase C

Wait 550msec B C A

Rotor Stabilized

Measure Phase Resistance as an Average of 32 Measurements

Phase B Aligned

Commutate Phases (Turn off Phase B, Turn on Phase A)

Motor Starts

Figure 5-2. Start-Up Sequence First, the rotor needs to be aligned to a known position to be able to start the motor in the desired direction of rotation. This is done in the following steps: 1. Two phases are turned on simultaneously (Phases B & C) 2. After 50msec one phase is turned off (Phase C), the other phase stays powered (Phase B) 3. After an additional 550 msec, the rotor is stabilized enough in the aligned position with respect to the powered phase (Phase B). Step 1 provides the initial impulse to the rotor. If Phase B is exactly in an unaligned position and thus does not generate any torque, Phase C provides the initial movement. Then, Phase C is disconnected and Phase B stays powered (Step 2). The stabilization pulse to Phase B must be long enough to stabilize the rotor in the aligned position with respect to that phase. In total the stabilization takes 1 sec. After this time, the rotor is stable enough to reliably start the motor in the desired direction of rotation.20 3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 20055.2.2 Position and Speed Sensing

System Design

The position information is used to generate accurate switching instants of the power converter, ensuring drive stability and fast dynamic response. Velocity feedback is derived from the position information, so that an additional velocity sensor is unneeded. All members of the Motorola DSP 56F80x family, except 56F801 have an on-chip quadrature decoder module connected to a quadrature timer. This peripheral is commonly used for position and speed sensing. The quadrature decoder position counter counts up/down each edge of Phase A and Phase B signals according to their order (see Figure 5-3). The Phase A and Phase B inputs of the DSP controller are routed through a switch matrix to a general purpose timer module and quadrature decoder module as well (see Figure 5-4). The timer module can use all four available inputs as normal timer input capture channels. This does not preclude the use of the quadrature decoder module. Both timer and decoder take advantage of the digital filter incorporated in the quadrature decoder module.

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Figure 5-3. Quadrature Encoded Signals The presented application uses the quad decoder module approach for speed measurement using a 16-bit position difference counter. The counter acts as a differentiator whose count value is proportional to the change in position since the last time the position counter was read. The speed can be computed by calculating the change in the position counter per unit time, or by reading the position difference counter register (POSD) and calculating speed. The second method is employed in this application for rotor speed measurement and also as a feedback signal to the speed controller. The position difference register (POSD) is regularly scanned at the pre-defined time period and consecutively this value is used to compute the actual rotor speed. In addition, quadrature decoder module 0 shares pins with quadrature timer module A. If the shared pins are not configured as timer outputs, then the pins are available for use as inputs to the quad decoder modules. The quad timer module contains four identical counter/timer groups. Due to the wide variability of quad timer modules, it is possible to use this module to decode quadrature encoder signals and to sense position and speed as well. The presented application uses the configuration arranged for position sensing and commutation instance determination. The quad timer A0 and the quad timer A1 decode the primary and secondary external inputs as quad-encoded signals generated by the rotary sensor to monitor movement of the motor shaft. Quad signal decoding provides both count and direction information. The timer A0 is programmed to count up to a programmed value that corresponds to one electric revolution and then immediately to re-initialize after the terminal count value is reached. This timer A0 is assigned as a master and broadcast compares signals to quad timer A1. The timer A1 is configured to be re-initialized to a predetermined value when a master timers compare event occurs. This counter continues repeatedly counting past the compare value. When the count matches the compare value, an interrupt is enabled and the compare register 2 value is used for commutation instances generation.

MOTOROLA

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

21

System Design

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Not used Decoder 0 moduleEDGE DETECT STATE MACHINE GLITCH FILTER DELAY WATCHDOG TIMER

Phase A Phase B Index Home

POSITION DIFFERENCE COUNTER

POSITION COUNTER

REV COUNTER

Freescale Semiconductor, Inc...

Timer Input Capture ChannelsSWITCH MATRIX

Timer A0

Timer A2

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Timer A1

Timer A3 Timer A module

Figure 5-4. Decoder and Timer Arrangement

5.2.3 Commutation AlgorithmThe SR motor commutation strategy uses rotor position feedback to drive the commutating signals for the inverter switches. The core of the control algorithm includes the calculation of the commutation angle, and phases commutation. The calculation of the commutation angle is performed according to (EQ 4-2.). It is calculated regularly during motor operation. The commutation algorithm is described in Figure 5-5. After the finish of the start-up routine, which includes the alignment procedure and initialization of the necessary commutation variables, the rotor is sufficiently stabilized and is ready for run mode. This is the point from which the commutation routine has to start. The first procedure of the commutation routine is to turn on the corresponding phase. Choosing the correct phase to switch on depends on the defined rotation of the rotor. The turn on angle is at the unaligned position, and the current rises linearly until the poles begin to overlap. In a regular switched reluctance motor, the angle of rising inductance is half of the pole-pitch. The pole pitch is the angle of rotation between two successive aligned positions. Ideally, the flux should be zero throughout the period of falling inductance, because current flowing in that period produces a negative (or braking) torque. To avoid this, the dwell angle dwell can be restricted. In practice, a dwell angle of 120 electrical degrees is usually used, because the gain in torque-impulse during the increasing inductance exceeds the small braking torque impulse. This condition occurs when the current has a tail extending beyond the aligned position. The torque is negative during this tail period, but it is small. The turn-off angle off instant is determined.

22

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

System Design

START

Turn ON PHASE

off = dwell + on

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

on=f(, i, u, L)

on > off

NO

YES

off = on

actual > offNO YES Turn OFF PHASE

actual > onNO YES

Figure 5-5. Commutation Algorithm Flowchart The next step of the proposed commutation algorithm is to calculate the advance turn-on angle. The entire calculation explanation is presented in Section 4.2. The firing angle on is set up for the next commutation instant. The presented commutation algorithm does not allow parallel current conduction of two phases at the same time. The angle comparison of turn-on on and turn-off off assures that the current phase is turned off before the following phase is turned on. In the case of a 120 electrical degree dwell angle, the switching on and switching off are performed simultaneously. If the conduction (dwell) angle is restricted, the turning off overtakes turning on, as is clear in Figure 5-5. The comparison actual > off block waits for an appropriate position to commutate off the corresponding stator phase, and in the next comparison actual > on block the algorithm remains the same until the proper position occurs to switch on the following stator phase. The algorithm loop is closed and ready for other commutation occurrences.MOTOROLA 3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com 23

System Design

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

5.2.4 Current Controller ImplementationThe current controller utilization flowchart reveals the algorithm process of the controller switching. If the appropriate stator phase is turned on, the DC-Bus voltage is applied to the corresponding rotor phase. The phase current rises almost linearly until a predefined target value is attained. At this point, by the processing of the proposed algorithm the current controller is switched on and maintains the actual current flowing within the desired value. Before the current controller is switched on, the necessary initialization is required. It is mainly concerned with the integral portion in the k-1 step of the current PI controller. This part of the controller structure is preset according to equation (EQ 4-4.). The following commutation instance turns the controller flag off so the corresponding rotor phase is fully voltage loaded until reaching the desired value of phase current. Figure 5-6 clarifies the entire controller usage algorithm.

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

START

Commutate ?

NO

YES

Controller OFF

NO

Controller OFF ?

YESiphase>idesired

NO

YESController ON Controller INITuapplied =U_dc_bus

uapplied = controller

Figure 5-6. Controller Utilization

24

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 20055.2.5 Current and Voltage Measurement

System Design

Precise measurement of phase current and DC-Bus voltage is a key factor for current control implementation.

5.2.5.1 Current SensingCurrent measurement needs to be investigated according to the current sensors used and the influence of the noise on the measurement. The quality of current measurement depends heavily on the type of current sensors used. The most useful are Hall effect sensors. Unfortunately, these sensors are expensive and thus not suitable for most cost-sensitive applications. Therefore, current shunt resistors inserted into the current path of the phase are often implemented (see Figure 5-7). The phase current is sensed as a voltage drop across the sense resistor.

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

+ DC Bus Voltage T1 PWM_T1 Phase A D1

D2 PWM_T2

T2

R3

sense

GND V_ref 1.65V ref

R4

Figure 5-7. Shunt Resistors Current Sensors When the power switches soft switching is used (the lower switch is left ON during a complete commutation period, while the upper switch is modulated by the PWM), the current is not visible on the shunt resistor all the time. The soft switching phase current, measured at the shunt resistor, is shown in Figure 5-8. The phase current is visible only when both switches are turned on (the phase current flows through switches and the sensing resistor) or when both switches are turned off (phase current flows through the freewheeling diodes and the sensing resistor). When both switches of the phase are turned on, the measured current is negative, so it needs to be inverted. The diagram shows that for a reliable current shape reconstruction, the sensing needs to be synchronized with the PWM frequency at the center of the PWM pulse and both positive and the negative voltage drop polarities should be measured. The zero current may be set to half of the ADC range, so both the positive and the negative voltage drops on the phase current shunt resistors can be measured. The voltage drop is then amplified according to the ADC range. Proceeding like this, the current can be read with accuracy and credibility.

MOTOROLA

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

+

R_sense

R2

-

sense

R1 ADC OP

25

System Design

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Figure 5-9 illustrates the actual phase currents of a 3-Phase motor, measured on the shunt resistors as described above. The previously specified current sensing method is described from the DSP processor point of view. It seems the measured phase current is negative, which is caused by inverting differential amplifier. Actually, the measured phase current flowing through shunt resistor is sensed and consecutively inverted by a differential amplifier.

Top Switch (T1) Time

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Bottom Switch (T2) Time T 1 T 2 D1 T 2 Actual Phase Current T 1 T2 D1 D2

0 Time

Sensed Voltage Drop

0 Time

ADC Synchronization

Figure 5-8. Soft Switching Current Sensed on ADC

26

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

System Design

Current Sensing 0.4 0.2Phase Current [A]

Phase A Phase B Phase C

00 0.01 0.02 0.03 0.04 0.05

-0.2 -0.4 -0.6 -0.8Time [sec]

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Figure 5-9. Phase Current Measured at Current Shunt Resistors The low cost shunt resistor sensors create one serious issue. Due to the low-voltage drop sensed across the shunt current resistors, the measured signals are susceptible to noise. A technique for noise elimination has been developed and successfully implemented. The technique is based on the assumption that the same noise is induced simultaneously on all measured signals. The method supposes the measurement of two signals simultaneously, one known signal (a reference) and one signal to be measured. Then the reference signal consists of a known signal and noise, while the measured signal consists of an actual signal and the same noise. MeasuredSignal = ActualSignal + Noise ReferenceSignal = KnownSignal + Noise (EQ 5-1.) (EQ 5-2.)

If the noise is the same, it can be eliminated by subtraction of the reference signal from the measured signal. As described above, the necessary condition is the simultaneous sampling of both signals, ensuring that the noise on both signals is identical. ActualSignal = MeasuredSignal - ReferenceSignal + KnownSignal (EQ 5-3.)

This technique has been implemented for phase current sensing. The SR motor is controlled in a way in which the phases are commutated sequentially, which means that when the working phase is turned off, the following phase, in the direction of rotation, is turned on. Thus one phase of the motor is never powered during a complete commutation interval. This phase is considered as a reference. Because the reference phase is not powered, the reference phase current should be equal to zero. The measured value of the reference current can be then considered as noise for a given commutation interval. The actual phase current is equal to the difference between the measured current and the reference current: Iph = Isensed - Ireference (EQ 5-4.)

The reference signal needs to be commutated together with the commutation of the phases. Table 5-1. defines the active, discharge and reference phases for the commutation sequence C - B - A - C. It is derived from Figure 5-9.

MOTOROLA

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

27

System Design

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Table 5-1. Commutation Sequence of the Reference PhaseStep1 2 3 1

Active Phase C B A C

Discharge Phase A C B A

Reference Phase B A C B

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

The efficiency of the current sensing noise reduction technique is illustrated in Figure 5-10. The figures illustrate the phase current as it is measured (the active phase current is inverted compared to Figure 5-9), and the same current with the implemented noise reduction technique. As can be seen, the implemented technique improves current sensing significantly. It eliminates not only the noise on the current sensors, but also the noise induced on the sensing cables and the noise of the ADC reference power supply.

5.2.5.2 Voltage SensingThe DC-Bus voltage sensor is represented by a simple voltage divider. DC-Bus voltage does not change rapidly. It is nearly constant with the ripple given by the power supply structure. If a bridge rectifier for rectification of AC line voltage is used, the ripple frequency is two times the AC line frequency. The ripple amplitude should not exceed 10% of the nominal DC-Bus value, if the power stage is designed correctly. The measured DC-Bus voltage needs to be filtered in order to eliminate noise. One of the most useful techniques is at moving average filter, that calculates an average value from the last N samples:Nu DCBus =

n=1

u DCBus ( n )

(EQ 5-1.)

In order to increase the precision of the voltage sensing, the voltage drop on the power switches and on the diodes of the power stage can be incorporated into the determination of the actual voltage present in the motor phase.

28

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

System Design

0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 0 -0.1

I active not corrected I discharge not corrected

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

current [A]

0.01

0.02 time [sec]

0.03

0.04

0.05

0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 0 -0.1

I active I discharge

current [A]

0.01

0.02 time [sec]

0.03

0.04

0.05

Figure 5-10. Measured 3-Phase Currents without Noise Correction and with Noise Correction Implemented

MOTOROLA

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

29

Hardware Implementation

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

5.2.6 Power Module Temperature SensingThe measured power module temperature is used for thermal protection The hardware realization is shown in Figure 5-11. The circuit consists of four diodes connected in series, a bias resistor, and a noise suppression capacitor. The four diodes have a combined temperature coefficient of 8.8 mV/C. The resulting signal, Temp_sense, is fed back to an A/D input where software can be used to set safe operating limits. In the presented application, the temperature in degrees Celsius is calculated according to the conversion equation:Temp_sense - b temp = ------------------------------------a

(EQ 5-2.)

where: temp is the power module temperature in degrees Celsius is the voltage drop on the diodes which is measured by ADC is the diode-dependent conversion constant (a = -0.0073738) is the diode-dependent conversion constant (b = 2.4596)

Freescale Semiconductor, Inc...

Temp_sense

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

a b

+3.3V_A

R1 2.2k - 1% D1 D2 ADC BAV99LT1 BAV99LT1 C1 100nF

Figure 5-11. Temperature Sensing Topology

6.

Hardware Implementation

6.1 Hardware SetupAs already stated, the application runs on Motorola motor control DSPs using the DSP EVM boards and a dedicated 3-Phase SR high-voltage platform. The application can be controlled by the following Motorola motor control DSPs: DSP56F803 DSP56F805 DSP56F807

30

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Hardware Implementation

Application hardware setup is shown in Figure 6-1. The system hardware setup for a particular DSP varies only by EVM Board used. The application software is identical for all DSPs. The EVM and chip differences are handled by the SDK off-chip drivers for the particular DSP EVM board. Detailed application HW setup can be found in the document Targeting_DSP5680x_Platform that is part of the SDK documentation [12]. Dedicated users manuals describe the individual boards in detail. The Users Manuals incorporate a schematic of the board, description of individual function blocks and a bill of materials for the board. The individual boards can be ordered from Motorola as standard products. Descriptions of all the mentioned boards and documents can be found at: http://www.motorola.com/ All system parts are supplied and documented according to the following references: U1 - Controller Board for DSP56F803: supplied as: DSP56803EVM described in: DSP56F803EVMUM/D DSP Evaluation Module Hardware Users Manual - see [9] or U1 - Controller Board for DSP56F805: supplied as: DSP56805EVM described in: DSP56F805EVMUM/D DSP Evaluation Module Hardware Users Manual - see [10] or U1 - Controller Board for DSP56F807: supplied as: DSP56807EVM described in: DSP56F807EVMUM/D DSP Evaluation Module Hardware Users Manual - see [11] U2 - 3-Phase SR High-Voltage Power Stage supplied as a kit with an Optoisolation Board as: ECOPTHIVSR described in: MEMC3PSRHVPSUM/D Motorola Embedded Motion Control 3-Phase SR High-Voltage Power Stage Users Manual - see [14] U3 - Optoisolation Board (not supposed to be in the final application) supplied in 3-ph. SR High Voltage Power Stage as: ECOPTHIVSR or supplied separately as: ECOPT - optoisolation board described in: MEMCOBUM/D Optoisolation Board Users Manual - see [13] MB1 Motor-Brake SR40V + SG40N supplied as: ECMTRHIVSR Warning: The use of optoisolation (optocouplers and optoisolation amplifiers) is strongly recommended during development to avoid electric shock or any damage to the development equipment.

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

MOTOROLA

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

31

Freescale Semiconductor, Inc...32 Hardware Implementation

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Figure 6-1. 3-Phase SR High Voltage Platform Configuration

!W98

BI9

8E E !

#syhvii phiyr

#syhvii

Freescale Semiconductor, Inc.

8EQ EQ !

phiyr

8 &RQWUROOHU %RDUG

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com MOTOROLA

G

I

Q@

SK 65 +LJK 9ROWDJH 3RZHU 6WDJH (&+,965

E #

E

2SWRLVRODWLRQ %RDUG (&237

E!

'63[(90

!#W68 #(% C

E " E ""E "$ E "!E "#E "%

H8Uhiyr Quhr Quhr6 Quhr7 Quhr8 8y Xuvr Srq 7yhpx

White1 White2 Red1 Red2 Black1 Black2

0%

0RWRU%UDNHVID"8rpUhiyr

659E$

6*1

(&237+,965

8yyr 9TQ$%A'" 9TQ$%A'$ 9TQ$%A'&

8 Q E" E

%vp 6HQ 6!$

@pqr8Uhiyr

White

Red

@pqr

Black

(&075+,965

8yr 9TQ$%A'" 9TQ$%A'$ 9TQ$%A'&

8 E! E!" E#

ChyyTrI8rprq

8rp@pqrArrqihpx

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 20056.2 Motor-Brake Specifications

Hardware Implementation

The SR Motor Brake set incorporates a 3-Phase SR Motor and attached BLDC motor brake. The detailed specifications are listed in Table 6-1. The SR motor has six stator poles and four rotor poles. This combination yields 12 strokes (or pulses) per single mechanical revolution. The SR motor is characterized by a dedicated inductance profile. The motor inductance profile as a function of mechanical position is shown in Figure 6-2. The mechanical angle 90omech corresponds to one electrical period of the stroke. The presented profile was used for the determination of the advanced commutation angle. On the motor brake shaft, a position encoder and position Hall sensor are attached. They allow position sensing if it is required by the control algorithm. The introduced drive uses the Encoder for the position determination Table 6-1. Motor - Brake Specifications

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Set Manufacturer eMotor Type: Stator / Rotor Poles: Motor Specification: Speed Range: Nominal Voltage: Nominal Current: Brake Type Brake Specification: Nominal Voltage: Nominal Current: Type Position Encoder

EM Brno, Czech Republic SR40V (3-Phase SR Motor) 6/4 < 5000 rpm 3 x 300V 1.2A SG40N 3-Phase BLDC Motor 3 x 27V 2.6 A Baumer Electric BHK 16.05A 1024-12-5 1024

Pulses per Revolution

MOTOROLA

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

33

Software Design

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

0.8 0.7 0.6 Inductance [H] 0.5 0.4 0.3 0.2 Phase A Phase B Phase C

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

0.1 0 -40 -30 -20 -10 10 20 30 40 50 mechanical angle [deg] 60 0

Figure 6-2. Inductance Characteristic

7.

Software Design Control algorithm data flow State diagram Software implementation

This section describes the design of the software blocks of the drive. The software will be described in terms of:

7.1 Data FlowThe control algorithm of a closed loop SR drive is described in Figure 7-1 and Figure 7-2. It is based on the system description. The individual processes are described in detail in the following sections.

34

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Software Design

Speed Settting SPEED SETTING

PC PC Master Software MASTER

Position Sensor POSITION SENSOR

omega_required_mech

omega_reqPCM_mech

position_difference

position_actual

Acceleration Ramp

Speed Calculation

see 2nd page

Freescale Semiconductor, Inc...

see 2nd page

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

omega_desired

omega_actual

u_dc_bus I_active

Speed ControllerI_active I_desired

Commutation Angle Calculation

Current Controllertheta On u_desired theta Off

DC-Bus Ripple Elimination

Commutation

outputDutyCycle

&srmCmtData

PWM GenerationPWM Outputs Pwm_AT Pwm_AB Pwm_BT Pwm_BB Pwm_CT Pwm_CB

Figure 7-1. System Data Flow I - SR Motor Control

MOTOROLA

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

35

Software Design

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

DC-Bus Volatge A-D Converter

3-Phase CURRENTS A-D Converter

ADC Correction Current MUX

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

u_dc_bus

i_active

see 1st page

Figure 7-2. System Data Flow II - AD Converter

7.1.1 Acceleration RampThis process calculates the desired speed based on the required speed according to the acceleration / deceleration ramp. The required speed is set either manually, using the push buttons (when in manual operational mode), or by PC master software (when in PC master software operational mode).

7.1.2 Speed CalculationThe process calculates the actual speed of the motor. The calculation is based on the evaluation of the position information. The on-chip Quadrature Decoder provides information on position difference through a 16-bit counter. When the position register is read, the position difference of the counters contents are copied into the position difference hold register (POSDH) and position difference counter is cleared. The register is regularly read and the captured value is used for speed calculation. The speed is computed by reading the position difference counter register per pre-defined time sample. A software moving average filter applied to the speed measurement is incorporated into the process for greater noise immunity. The actual motor speed is calculated as the average value of the last four measurements.

7.1.3 Speed ControllerThis process calculates the desired phase current according to the speed error. Speed error is the difference between the actual speed and desired speed. A Proportional-Integrational (PI) type of controller is implemented. The constants of the speed controller are tuned experimentally according to the load profile and the speed limits.

36

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 20057.1.4 Current Controller

Software Design

This process calculates the duty cycle of the PWM based on phase current error. Phase current error is the difference between the actual phase current and desired phase current. A PI type of controller is implemented. The current controller constants are tuned experimentally according to the type of used motor used.

7.1.5 DC-Bus Ripple EliminationThis process provides the elimination of the voltage ripple on the DC-Bus. It compensates an amplitude of the desired phase voltage generated by the PI current controller. The output of the calculation is the duty cycle of the PWM that is applied to corresponding stator phase.

7.1.6 PWM Generation

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

This process sets the on-chip PWM module for generation of the control pulses for the 3-Phase SR motor power stage. Generation of these pulses is based on the software control register that is formulated by the process of the Commutation Calculation and is based on the required duty cycle generated by the Speed Controller process. The calculated software control word is loaded into the proper PWM register and the PWM duty cycle is updated according to the required duty cycle. The PWM Generation process is accessed regularly at a rate given by the PWM frequency. It is frequent enough to ensure the precise generation of commutation pulses.

7.1.7 ADC Correction and Current MUXThis process takes care of the Analog-to-Digital Converter. The sampling of the ADC is synchronized to the PWM pulses. The process selects the proper ADC channels to be converted and reads and processes the results of the ADC conversion. The active and discharge phase currents are selected and corrected using the measured reference noise signal. The DC-Bus voltage and temperature are filtered using a moving average filter. See Section 5.2.5 Current and Voltage Measurement for a detailed description.

7.1.8 Commutation Angle CalculationThis process calls the commutation angle calculation routine which calculates the advanced angle according to the actual speed, the DC-Bus voltage and the desired current (see Section 4.2). The algorithm 3-Phase SR Motor Commutation Angle Calculation srmcac generates the required advance angle of commutation according to the principle described in Section 4.2. Before the calculation routine call, the scaling constant must be properly determined./* scaling constant */ scale_const = FRAC16((L_UN*I_MAX*OMEGA_MAX*4)/(U_MAX*60));

The following functions of the algorithm need to be called in order to calculate the commutation angle:/* routine call */ adv_angle = srmcacAngleCalc(i_ph,u_ph,w_actual,scale_const); /* u_ph => voltage across phase winding */ /* i_ph => phase current */ /* w_actual => actual speed */

These functions are called in the Process Commutation. A detailed description of the algorithm can be found in the SDK algorithm documentation.

MOTOROLA

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

37

Software Design

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

7.1.9 CommutationThis process provides the comutation of the motor phases. The DSP on-chip PWM module is used in a mode for generation of independent output signals that can be controlled either by software or by the PWM module. The commutation technique distinguishes the three following cases: When the PWM output needs to be modulated, the PWM generator controls the channel directly When the PWM output needs to be switched to an inactive state (0), the software output control of the corresponding PWM channel is handed over and the channel is turned off manually When the PWM output needs to be switched to the active state (1), the software output control of the corresponding PWM channel is handed over and the channel is turned on manually

Freescale Semiconductor, Inc...

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

The on-chip PWM module enables control of the outputs from the PWM module either by the PWM generator, or by using the software. Setting the output control enable bit, OUTCTLx, enables software to drive the PWM outputs instead of the PWM generator. In independent mode, with OUTCTLx = 1, the output bit OUTx controls the PWMx channel. Setting or clearing the OUTx bit activates or deactivates the PWMx output. The OUTCTLx and OUTx bits are in the PWM output control register. This control technique requires the preparation of the output control register. For the calculation of the OUTCTLx and OUTx bits in the PWM output control register, a dedicated commutation algorithm, 3-Phase SR Motor Commutation Handler for H/W Configuration 2-Switches-per-Phase, srmcmt3ph2spp, was developed. The algorithm generates an output control word according to the desired action and the desired direction of rotation. For example, when Phase A needs to be turned off, the algorithm sets the corresponding OUTCTLx bits to enable the output control of the required PWMs and clears the OUTx bits to turn off the PWMs. The other output control register bits are not affected. A detailed description of the algorithm can be found in the SDK motor control library.

7.2 State DiagramThe processes described above are implemented in a single state machine, as illustrated in Figure 7-3. The state machine provides a transition amongst the application states INIT, STOP, RUN, FAULT. The following variables are used to invoke the transition between the individual states: switchState (Stop, Run): state of the Start/Stop switch appFault (NO_FAULT, any fault): fault occurrence appOpMode (change from Manual to PC and vice versa): change operational mode

38

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Software Design

S@T@U

,1,7 6WDWHhAhy 2IPfA6VGU vpuThr 2T hAhy 13IPfA6VGU vpuThr 2T

hPHqr puhtr

)$8/7 6WDWH

6723 6WDWH

Freescale Semiconductor, Inc...

hAhy 13IPfA6VGU

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

vpuThr 2T vpuThr 2S hAhy 2IPfA6VGU hAhy 2IPfA6VGU hAhy 13IPfA6VGU

581 6WDWH

Figure 7-3. Application State Diagram

7.2.1 Application State - INITAfter RESET the application enters the INIT state. In this state, the drive is disabled and the motor cannot be started. If any fault is detected, the application transits to the FAULT state (protection against faults). If no fault is present, and the Start/Stop switch is detected in the STOP position, the application transits to the STOP state (protection against start after reset if the Start/Stop switch is accidentally in START position).

7.2.2 Application State - STOPThe STOP state can be entered either from the INIT state or from the RUN state. In the STOP state, the drive is enabled and the application waits for the START command. When the application is in the STOP state, the operational mode can be changed, either from MANUAL mode to PC master software mode or vice versa. When the operational mode is changed, the application always transits to the INIT state. If any fault in the STOP state is detected, the application enters the FAULT state (fault protection). If no fault is present and the start command is accepted, the application transits to the RUN state and the motor is started.

7.2.3 Application State - RUNThe RUN state can be entered from the STOP state. In the RUN state the drive is enabled and the motor is running.

MOTOROLA

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

39

Software Design

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

If any fault in the RUN state is detected, the application enters the FAULT state (fault protection). If no fault is present and the STOP command is accepted the application transits to the STOP state and the motor is stopped.

7.2.4 Application State - FAULTThe STOP state can be entered from any state. In the FAULT state, the drive is disabled and the application waits for the faults to be cleared. When it is detected that the fault has been eliminated, and the fault clear command is accepted (the Start/Stop switch is moved to the STOP position), then the application transits to the INIT state.

7.3 Software Design

Freescale Semiconductor, Inc...

The general software diagram incorporates: (1) the Main routine entered from Reset, and (2) the Interrupt Service Routines (ISR). The diagram is illustrated in Figure 7-4.

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

After Reset, the Main routine provides board identification, initialization of the DSP, initialization of the application, and then it enters an infinite background loop. The background loop contains Fault Detection, Application State Machine, and a scheduler routine. The scheduler routine provides the timing sequence for two tasks called Timeout 1 and Timeout 2. The Timeout 1 and Timeout 2 flags are periodically set to predetermined intervals by the ADC Conversion Completed ISR. The scheduler utilizes these flags and calls the required routines: The routine in Timeout 1 provides a user interface, calculates the required speed, the start-up routines and the speed ramp (acceleration/deceleration). The routine in Timeout 2 calculates the Speed Controller.

The Timeout 1 and Timeout 2 tasks are performed in the run state, instead of interrupt routines, in order to reduce time and avoid software bottlenecks. The following interrupt service routines are utilized: ADC Conversion Completed ISR - services ADC and provides all the control tasks linked to the event; the ADC is synchronized with the PWM pulses. Fault ISR - services faults invoked by external hardware faults. SCI ISR - services PC master software communication. Push Button Up ISR - services the Up Push Button. Push Button Down ISR - services the Down Push Button. Timer A1 Compare ISR - services Commutation Callback.

40

3-Phase SR Motor Control with Encoder For More Information On This Product, Go to: www.freescale.com

MOTOROLA

Freescale Semiconductor, Inc. ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Software Design

Interrupt Service Routines

ADC Conversion Completed Interrupt

RESET

ADC Interrupt Handlers done

Initialize DSP & Application doneBackground Tasks

Freescale Semiconductor, Inc...

PWM Fault Interrupt

ARCHIVED BY FREESCALE SEMICONDUCTOR, INC. 2005

Fault Detection Fault Interrupt Handler done SCI Interrupt Application State Machine done SCI & PC master software Interrupt Handler done IRQ0, IRQ1 Interrupt done Push Buttons Interrupt Handlers Timeout 2 NO timeout Timeout 1Timeout 1

done

S/W Timeout ? done

Timeout 2

TMRA1 Compare Interrupt

Commutation Interrupt Handler done

Figure 7-4. Software Design - General