Freescale Semiconductor, Inc... Freescale Semiconductor, Inc. 3-Phase Switched Reluctance Motor Drive Control with Encoder Using 56F805 Designer Reference Manual 56800 Hybrid Controller DRM031/D Rev. 0, 03/2003 MOTOROLA.COM/SEMICONDUCTORS For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc... Freescale Semiconductor, Inc. For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... 3-Phase Switched Reluctance motor Control with Encoder Using 56F805 Designer Reference Manual — Rev. 0 by: Peter Balazovic Motorola Czech System Laboratories Roznov pod Radhostem, Czech Republic DRM031 — Rev. 0 Designer Reference Manual MOTOROLA 3 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Revision history To provide the most up-to-date information, the revision of our documents on the World Wide Web will be the most current. Your printed copy may be an earlier revision. To verify you have the latest information available, refer to: http://www.motorola.com/semiconductors Freescale Semiconductor, Inc... The following revision history table summarizes changes contained in this document. For your convenience, the page number designators have been linked to the appropriate location. Revision history Date Revision Level January 2003 1 Description Initial revision Designer Reference Manual Page Number(s) N/A DRM031 — Rev. 0 4 MOTOROLA For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Designer Reference Manual — 3-Ph. SR Motor Control with Encoder List of Sections Section 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Freescale Semiconductor, Inc... Section 2. Target Motor Theory . . . . . . . . . . . . . . . . . . . . 21 Section 3. Switched Reluctance Motor Control Techniques with Encoder Position Sensor. . . . . . . . . . . . . . . 35 Section 4. System Description. . . . . . . . . . . . . . . . . . . . . 43 Section 5. Hardware Design. . . . . . . . . . . . . . . . . . . . . . . 65 Section 6. Software Design . . . . . . . . . . . . . . . . . . . . . . . 77 Section 7. System Setup . . . . . . . . . . . . . . . . . . . . . . . . . 99 Appendix A. References. . . . . . . . . . . . . . . . . . . . . . . . . 115 Appendix B. Glossary. . . . . . . . . . . . . . . . . . . . . . . . . . . 117 DRM031 — Rev. 0 Designer Reference Manual MOTOROLA 5 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... List of Sections Designer Reference Manual DRM031 — Rev. 0 6 MOTOROLA For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Designer Reference Manual — 3-Ph. SR Motor Control with Encoder Table of Contents Freescale Semiconductor, Inc... Section 1. Introduction 1.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15 1.2 Application Benefit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 1.3 Motorola DSP Advantages and Features . . . . . . . . . . . . . . . . . 16 Section 2. Target Motor Theory 2.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21 2.2 Switched Reluctance Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 2.3 Mathematical Description of SR Motor . . . . . . . . . . . . . . . . . . . 24 2.4 Digital Control of SR Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . .28 2.5 Voltage and Current Control of SR Motors . . . . . . . . . . . . . . . . 30 Section 3. Switched Reluctance Motor Control Techniques with Encoder Position Sensor 3.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35 3.2 Encoder Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 3.3 Commutation Angle Calculation . . . . . . . . . . . . . . . . . . . . . . . . 37 3.4 Commutation Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39 3.5 Current Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41 Section 4. System Description 4.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43 4.2 System Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 DRM031 — Rev. 0 Designer Reference Manual MOTOROLA 7 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Table of Contents 4.3 Application Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Freescale Semiconductor, Inc... Section 5. Hardware Design 5.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65 5.2 System Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 5.3 DSP56F805EVM Controller Board . . . . . . . . . . . . . . . . . . . . . . 67 5.4 3-Phase SR High-Voltage Power Stage . . . . . . . . . . . . . . . . . . 68 5.5 Optoisolation Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 5.6 Motor-Brake Specifications. . . . . . . . . . . . . . . . . . . . . . . . . . . .72 5.7 Hardware Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Section 6. Software Design 6.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77 6.2 Data Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 6.3 State Diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 6.4 Software Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 6.5 Scaling of Quantities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 6.6 Velocity Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Section 7. System Setup 7.1 Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99 7.2 Application Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 7.3 Application Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 7.4 Application Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 7.5 Project Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 7.6 Application Build and Execute . . . . . . . . . . . . . . . . . . . . . . . . 111 7.7 Warning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 Designer Reference Manual DRM031 — Rev. 0 8 MOTOROLA For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Appendix A. References Freescale Semiconductor, Inc... Appendix B. Glossary DRM031 — Rev. 0 Designer Reference Manual MOTOROLA 9 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... Table of Contents Designer Reference Manual DRM031 — Rev. 0 10 MOTOROLA For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Designer Reference Manual — 3-Ph. SR Motor Control with Encoder List of Figures Figure Title Page 3-Phase 6/4 SR Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22 Phase Energizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Magnetization Characteristics of SR Motor . . . . . . . . . . . . . . . 25 Electrical Diagram of One SR Motor Phase . . . . . . . . . . . . . . . 26 3-Phase SR Power Stage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Soft Switching and Hard Switching. . . . . . . . . . . . . . . . . . . . . . 30 Voltage Control Technique . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 Voltage Control Technique - Voltage and Current Profiles. . . . 32 Current Control Technique . . . . . . . . . . . . . . . . . . . . . . . . . . . .33 Current Control Technique - Voltage and Current Profiles . . . . 34 Quadrature Encoder Signals . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Commutation Angle Calculation . . . . . . . . . . . . . . . . . . . . . . . . 38 Commutation Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40 Phase Voltage Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 System Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Start-Up Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Quadrature Encoded Signals . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Decoder and Timer Arrangement . . . . . . . . . . . . . . . . . . . . . . . 51 Commutation Algorithm Flowchart . . . . . . . . . . . . . . . . . . . . . . 53 Current Controller Utilization. . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Shunt Resistors Current Sensors . . . . . . . . . . . . . . . . . . . . . . . 56 Soft Switching Current Sensed on ADC . . . . . . . . . . . . . . . . . . 58 Phase Current Measured at Current Shunt Resistors . . . . . . . 59 Measured 3-Phase Currents without and with Implemented Noise Correction . . . . . . . . . . . . . . . . . . . . . . . . . 62 4-11 Temperature Sensing Topology . . . . . . . . . . . . . . . . . . . . . . . . 63 5-1 3-Phase SR High Voltage Platform Configuration . . . . . . . . . . 66 5-2 Block Diagram of the DSP56F805EVM . . . . . . . . . . . . . . . . . . 68 5-3 3-ph. SR HV Power Stage . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 Freescale Semiconductor, Inc... 2-1 2-2 2-3 2-4 2-5 2-6 2-7 2-8 2-9 2-10 3-1 3-2 3-3 3-4 4-1 4-2 4-3 4-4 4-5 4-6 4-7 4-8 4-9 4-10 DRM031 — Rev. 0 Designer Reference Manual MOTOROLA 11 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. List of Figures 5-4 6-1 6-2 6-3 6-4 6-5 7-1 Freescale Semiconductor, Inc... 7-2 7-3 7-4 7-5 7-6 7-7 Inductance Characteristic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 System Data Flow I - SR Motor Control . . . . . . . . . . . . . . . . . . 78 System Data Flow II - AD Converter. . . . . . . . . . . . . . . . . . . . .79 Application State Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Software Design - General Overview . . . . . . . . . . . . . . . . . . . . 87 Electrical Angle Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 RUN/STOP Switch and UP/DOWN Buttons on DSP56F805EVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 USER and PWM LEDs on DSP56F805EVM . . . . . . . . . . . . . 103 PC Master Software Control Window . . . . . . . . . . . . . . . . . . . 105 Setup of 3-Phase SR Motor Control Application Using DSP56F805EVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 DSP56F805EVM Jumper Reference . . . . . . . . . . . . . . . . . . . 108 Target Build Selection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 Execute Make Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 Designer Reference Manual DRM031 — Rev. 0 12 MOTOROLA For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Designer Reference Manual — 3-Ph. SR Motor Control with Encoder List of Tables Table Freescale Semiconductor, Inc... 1-1 4-1 5-1 5-2 5-3 7-1 7-2 Title Page Memory Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Commutation Sequence of the Reference Phase . . . . . . . . . . 60 Electrical Characteristics of Power Stage. . . . . . . . . . . . . . . . . 71 Electrical Characteristics of Optoisolation Board . . . . . . . . . . . 72 Motor - Brake Specifications. . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Motor Application States. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 DSP56F805EVM Jumper Settings . . . . . . . . . . . . . . . . . . . . . 108 DRM031 — Rev. 0 Designer Reference Manual MOTOROLA 13 For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... List of Tables Designer Reference Manual DRM031 — Rev. 0 14 MOTOROLA For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. Designer Reference Manual — 3-Ph. SR Motor Control with Encoder Section 1. Introduction Freescale Semiconductor, Inc... 1.1 Contents 1.2 Application Benefit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 1.3 Motorola DSP Advantages and Features . . . . . . . . . . . . . . . . . 16 1.2 Application Benefit This Designer Reference Manual describes the design of an advanced 3-phase Switched Reluctance (SR) motor drive. It is based on Motorola’s DSP56F80x family dedicated for motor control devices. 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 a moderate cost of the necessary electronic components, the SR drives make a viable alternative to other commonly used motors like AC, BLDC, PM synchronous or universal motors. The concept of this application is an advanced 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 application helps to start the development of the advanced SR drive dedicated to the targeted application. This Designer Reference Manual includes a description of Motorola DSP features, basic SR motor theory, system design concept, hardware DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Introduction For More Information On This Product, Go to: www.freescale.com 15 Freescale Semiconductor, Inc. Introduction implementation, and software design including a use of the software visualization tool. 1.3 Motorola DSP Advantages and Features Freescale Semiconductor, Inc... The Motorola DSP56F80x family is well suited for digital motor control, combining a DSP’s computational ability with an MCU’s 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 and 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 and Quad Dec1), each with four inputs, or two additional Quad Timers A and B • Two dedicated General Purpose Quad Timers totalling 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 Communications Interfaces (SCI0 and 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 Designer Reference Manual 16 DRM031 — Rev. 0 Introduction For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Introduction Motorola DSP Advantages and Features • 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-Locked-Loop-based frequency synthesizer for the DSP core clock Freescale Semiconductor, Inc... Table 1-1. Memory Configuration DSP56F801 DSP56F803 DSP56F805 DSP56F807 Program Flash 8188 x 16-bit 32252 x 16-bit 32252 x 16-bit 61436 x 16-bit Data Flash 2K x 16-bit 4K x 16-bit 4K x 16-bit 8K x 16-bit Program RAM 1K x 16-bit 512 x 16-bit 512 x 16-bit 2K x 16-bit Data RAM 1K x 16-bit 2K x 16-bit 2K x 16-bit 4K x 16-bit Boot Flash 2K x 16-bit 2K x 16-bit 2K x 16-bit 2K x 16-bit 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 DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Introduction For More Information On This Product, Go to: www.freescale.com 17 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... Introduction • 15 bits of resolution • Half-cycle reload capability • Integral reload rates from 1 to 16 • Individual software-controlled PWM output • Programmable fault protection • Polarity control • 20mA current sink capability on PWM pins • Write-protectable registers 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.7µs) • Additional conversion time of 6 ADC clock cycles (6 x 200 ns = 1.2µs) • Eight conversions in 26.5 ADC clock cycles (26.5 x 200 ns = 5.3µs) 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 Designer Reference Manual 18 DRM031 — Rev. 0 Introduction For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... Introduction Motorola DSP Advantages and Features • 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 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. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Introduction For More Information On This Product, Go to: www.freescale.com 19 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... Introduction Designer Reference Manual 20 DRM031 — Rev. 0 Introduction For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Designer Reference Manual — 3-Ph. SR Motor Control with Encoder Section 2. Target Motor Theory Freescale Semiconductor, Inc... 2.1 Contents 2.2 Switched Reluctance Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 2.3 Mathematical Description of SR Motor . . . . . . . . . . . . . . . . . . . 24 2.4 Digital Control of SR Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . .28 2.5 Voltage and Current Control of SR Motors . . . . . . . . . . . . . . . . 30 2.2 Switched Reluctance Motor A 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. 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 2-1 illustrates a typical 3-phase SR motor with a 6/4 (stator/rotor) pole configuration. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Target Motor Theory For More Information On This Product, Go to: www.freescale.com 21 Freescale Semiconductor, Inc. Target Motor Theory Phase C Phase A Phase B Stator (6 poles) Freescale Semiconductor, Inc... Stator Winding Rotor (4 poles) Aligned position on Phase A Figure 2-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 2-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 2-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. Designer Reference Manual 22 DRM031 — Rev. 0 Target Motor Theory For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Target Motor Theory Switched Reluctance Motor Freescale Semiconductor, Inc... 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 2-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 Miller, T.J.E., Switched Reluctance Motors and Their Control. As is apparent from the description, the SR motor requires the 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, see AN1912/D of Motorola Inc. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Target Motor Theory For More Information On This Product, Go to: www.freescale.com 23 Freescale Semiconductor, Inc. Target Motor Theory Aligned Unaligned Aligned Stator Phase A Rotor Freescale Semiconductor, Inc... LC iphA LB LA position / time θdwell phase A energizing θon_phA θoff_phA position / time Figure 2-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. 2.3 Mathematical Description of SR Motor An 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 Designer Reference Manual 24 DRM031 — Rev. 0 Target Motor Theory For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Target Motor Theory Mathematical Description of SR Motor development and implementation of sophisticated algorithms for controlling the SR motors easier. The electromagnetic circuit of the SR motor is characterized by non-linear magnetization. Figure 2-3 illustrates a magnetization characteristic for a specific SR motor. 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. Freescale Semiconductor, Inc... The magnetization characteristics 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. Figure 2-3. Magnetization Characteristics of 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. The diagram for one phase is illustrated in Figure 2-4. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Target Motor Theory For More Information On This Product, Go to: www.freescale.com 25 Freescale Semiconductor, Inc. Target Motor Theory iph rph Lph=f(θ) Freescale Semiconductor, Inc... uph Figure 2-4. Electrical Diagram of One SR Motor Phase According to Figure 2-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: u ph ( t ) = r ph ⋅ i ph ( t ) + u Lph ( t ) (EQ 2-1.) where: uph is the voltage applied to a phase rph is the phase resistance iph is the phase current uLph is the induced voltage over the phase inductance. The equation (EQ 2-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 dt (EQ 2-2.) Designer Reference Manual 26 DRM031 — Rev. 0 Target Motor Theory For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Target Motor Theory Mathematical Description of SR Motor Then the phase voltage can be expressed as: dΨ ph ( i ph, θ ph ) u ph ( t ) = r ph ⋅ i ph ( t ) + ---------------------------------dt (EQ 2-3.) or: ∂Ψ ph ( i ph, θ ph ) di ph ∂Ψ ph ( i ph, θ ph ) - ⋅ --------- + ----------------------------------- ⋅ ω u ph ( t ) = r ph ⋅ i ph ( t ) + ---------------------------------∂i ph ∂θ ph dt Freescale Semiconductor, Inc... (EQ 2-4.) where: ω is the angular speed of the motor. The torque Mph generated by one phase can be expressed as: I ph M ph = ∫ ∂Ψ ph ( i ph, θ ph ) ----------------------------------- di ph ∂θ ph (EQ 2-5.) 0 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 2-4.) can be expanded as follows: ∂Ψ a ( i a, θ a ) di a ∂Ψ a ( i a, θ a ) u a ( t ) = r a ⋅ i a ( t ) + --------------------------- ⋅ ------ + --------------------------- ⋅ ω ∂i a ∂θ a dt (EQ 2-6.) ∂Ψ b ( i b, θ b ) di b ∂Ψ b ( i b, θ b ) - ⋅ ------- + --------------------------- ⋅ ω u b ( t ) = r b ⋅ i b ( t ) + -------------------------∂i b ∂θ b dt (EQ 2-7.) ∂Ψ c ( i c, θ c ) di c ∂Ψ c ( i c, θ c ) u c ( t ) = r c ⋅ i c ( t ) + -------------------------- ⋅ ------ + --------------------------- ⋅ ω ∂i c ∂θ c dt (EQ 2-8.) where a, b, c index the individual phases. As stated in the above equations, the mutual effect between individual phases is not considered. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Target Motor Theory For More Information On This Product, Go to: www.freescale.com 27 Freescale Semiconductor, Inc. Target Motor Theory 2.4 Digital Control of SR Motor Freescale Semiconductor, Inc... The 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 2-5. It permits control of the individual phases fully independent of each other and thus allows 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 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 case of Phase A, shown in Figure 2-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 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 Designer Reference Manual 28 DRM031 — Rev. 0 Target Motor Theory For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Target Motor Theory Digital Control of SR Motor DC Voltage Q1 PWM_Q1 + D1 Phase A Q3 PWM_Q3 Phase B Q5 PWM_Q5 D1 Phase C Cap D2 D2 Q2 Freescale Semiconductor, Inc... D1 PWM_Q2 D2 Q4 PWM_Q4 Q6 PWM_Q6 GND Figure 2-5. 3-Phase SR Power Stage Figure 2-6 illustrates both soft and hard switching PWM techniques. The control signals for upper and 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. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Target Motor Theory For More Information On This Product, Go to: www.freescale.com 29 Freescale Semiconductor, Inc. Target Motor Theory Unaligned Aligned Unaligned Aligned Stator Poles Rotor Poles Inductance PWM Upper Switch PWM Freescale Semiconductor, Inc... PWM Lower Switch +VDC +VDC Phase Voltage -VDC -VDC Phase Current Turn On Turn Off Position Turn On Soft Switching Turn Off Position Hard Switching Figure 2-6. Soft Switching and Hard Switching 2.5 Voltage and Current Control of SR Motors A 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 Designer Reference Manual 30 DRM031 — Rev. 0 Target Motor Theory For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Target Motor Theory Voltage and Current Control of SR Motors 2.5.1 Voltage Control of an SR Motor In 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... 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 2-7. The current and the voltage profiles can be seen in Figure 2-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 change in the inductance profile. . Power Stage Controller ωdesired Σ - ωerror ωactual Speed Controller PWM Output Duty Cycle PWM Generator θon θoff Figure 2-7. Voltage Control Technique DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Target Motor Theory For More Information On This Product, Go to: www.freescale.com 31 Freescale Semiconductor, Inc. Target Motor Theory L iph UDC-Bus*PWM θoff position / time uph position / time PWM = Speed Controller Output Freescale Semiconductor, Inc... θon phase current decays through the fly back diodes -UDC-Bus Figure 2-8. Voltage Control Technique - Voltage and Current Profiles 2.5.2 Current Control of an SR Motor In 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 Designer Reference Manual 32 DRM031 — Rev. 0 Target Motor Theory For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Target Motor Theory Voltage and Current Control of SR Motors Freescale Semiconductor, Inc... SR inverter. Thus, the phase voltage is modulated at the rate of the current control loop. This technique is illustrated in Figure 2-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 2-10. In ideal cases, the phase current is controlled to follow the desired current. Power Stage Controller ωerror ωdesired Σ - idesired Speed Controller ωactual Current Controller Σ - PWM Output Duty Cycle ierror iactual θon PWM Generator θoff Figure 2-9. Current Control Technique DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Target Motor Theory For More Information On This Product, Go to: www.freescale.com 33 Freescale Semiconductor, Inc. Target Motor Theory L idesired iph θon θoff Freescale Semiconductor, Inc... UDC-Bus phase current decays through the fly back diodes position / time uph PWM = Current Controller Output PWM = 100% position / time -UDC-Bus Figure 2-10. Current Control Technique - Voltage and Current Profiles Designer Reference Manual 34 DRM031 — Rev. 0 Target Motor Theory For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Designer Reference Manual — 3-Ph. SR Motor Control with Encoder Section 3. Switched Reluctance Motor Control Techniques with Encoder Position Sensor Freescale Semiconductor, Inc... 3.1 Contents 3.2 Encoder Sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 3.3 Commutation Angle Calculation . . . . . . . . . . . . . . . . . . . . . . . . 37 3.4 Commutation Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39 3.5 Current Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41 3.2 Encoder 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 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 as 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 DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Switched Reluctance Motor Control Techniques with Encoder Position Sensor For More Information On This Product, Go to: www.freescale.com 35 Freescale Semiconductor, Inc. Switched Reluctance Motor Control Techniques the position counter and/or generate an interrupt signal to the system controller. 90° el Freescale Semiconductor, Inc... Phase A Phase B time Figure 3-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 3-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. Designer Reference Manual 36 DRM031 — Rev. 0 Switched Reluctance Motor Control Techniques with Encoder Position Sensor For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Switched Reluctance Motor Control Techniques with Encoder Position Sensor Commutation Angle Calculation 3.3 Commutation Angle Calculation In 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 in 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. Freescale Semiconductor, Inc... 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 3-2 explains the proposed algorithm for advance angle calculation. The computation method is derived from (EQ 2-6.) (EQ 2-8.) and is rearranged into the following expression as: di ph dL ph u ph = r ph i ph + L ph ⋅ -------- + i ph ⋅ ----------- ⋅ ω dt dθ (EQ 3-1.) where: DRM031 — Rev. 0 MOTOROLA uph is the voltage applied to a phase rph is the phase resistance iph is the phase current Lph is the phase inductance θ is the rotor position Designer Reference Manual Switched Reluctance Motor Control Techniques with Encoder Position Sensor For More Information On This Product, Go to: www.freescale.com 37 Freescale Semiconductor, Inc. Switched Reluctance Motor Control Techniques idesired iphase Lunaligned Freescale Semiconductor, Inc... 0° uapplied θon position / time 100% PWM Figure 3-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 3-2.) using a first order approximation: i desired θ on = L unaligned ⋅ --------------⋅ ω actual u ph (EQ 3-2.) where: θon is the advance angle idesired is the desired current to be achieved Lunaligned is the unaligned inductance uphase is the applied phase voltage ωactual is the actual rotor speed Designer Reference Manual 38 DRM031 — Rev. 0 Switched Reluctance Motor Control Techniques with Encoder Position Sensor For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Switched Reluctance Motor Control Techniques with Encoder Position Sensor Commutation Strategy 3.4 Commutation Strategy Freescale Semiconductor, Inc... In 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 the motor starts. The number of commutations per mechanical revolution is proportional to the number of rotor poles and number of stator phases (EQ 3-3.). It arises from the mechanical construction of the SR motor. The number of motor commutations is calculated as follows: NumOfCommut = N r ⋅ m (EQ 3-3.) where: NumOfCommut is the number of commutations per one mechanical revolution Nr is the number of rotor poles m 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 3-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. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Switched Reluctance Motor Control Techniques with Encoder Position Sensor For More Information On This Product, Go to: www.freescale.com 39 Freescale Semiconductor, Inc. Switched Reluctance Motor Control Techniques Current Actual Inductance Estimated Inductance iph Freescale Semiconductor, Inc... idesired 0° θadvance θon UDC-Bus θedge uapplied θoff 360° Position / Time idesired reached PWM = 100% PWM = Current Controller Output -UDC-Bus Figure 3-3. Commutation Strategy 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 3.3). The commutation software algorithm determines the necessary advance angle, θadvance, for turning on the correct stator phase. In the θadvance instant, full DC-Bus voltage is applied after switching on the correct phase. If actual value of the phase current exceeds desired current value then the current controller with sufficient controller initialization is started to maintain actual value of the phase current within the requested magnitude. This is achieved by chopping the DC-Bus voltage. Designer Reference Manual 40 DRM031 — Rev. 0 Switched Reluctance Motor Control Techniques with Encoder Position Sensor For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Switched Reluctance Motor Control Techniques with Encoder Position Sensor Current Controller 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 2-6). The current waveform during soft switching is similar to that shown in Figure 3-3. 3.5 Current Controller Freescale Semiconductor, Inc... Basically, 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. Major difficulty, when designing switched reluctance motor current controllers, is that the winding back electromotive force (back-EMF) and the electrical time constant vary significantly within one electrical cycle and with the motor speed and the phase current level. The voltage equation of the SRM is given by (EQ 2-4.). This equation indicates a non-linear 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 3-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 2-4.) can be rearranged as follows: dL ph ( θ ph ) u phase_applied ( t ) = r ph ⋅ i ph ( t ) + i ph ( t ) ⋅ -----------------------⋅ω dθ ph (EQ 3-4.) The applied phase voltage is roughly maintained near the value of (EQ 3-4.), where iph is the desired phase current, and ω is the actual angular speed of the rotor. Derivation over the position of the corresponding phase inductance is determined from motor parameter measurements. Knowing these parameters, the initial current controller is set up using (EQ 3-4.) in the time instance (see the red point in Figure 3-4) when the controller is switched on. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Switched Reluctance Motor Control Techniques with Encoder Position Sensor For More Information On This Product, Go to: www.freescale.com 41 Freescale Semiconductor, Inc. Switched Reluctance Motor Control Techniques idesired reached uapplied UDC-Bus uapplied Position / Time Freescale Semiconductor, Inc... PWM = 100% PWM = Current Controller Output -UDC-Bus Figure 3-4. Phase Voltage Generation Designer Reference Manual 42 DRM031 — Rev. 0 Switched Reluctance Motor Control Techniques with Encoder Position Sensor For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Designer Reference Manual — 3-Ph. SR Motor Control with Encoder Section 4. System Description Freescale Semiconductor, Inc... 4.1 Contents 4.2 System Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 4.3 Application Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 4.2 System Outline This 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 DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Description For More Information On This Product, Go to: www.freescale.com 43 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... System Description • Manual interface (Start/Stop switch, Up/Down push button control, LED indicator) • PC master software control interface (motor Start/Stop, speed setup) • 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) 4.3 Application Description For the drive, a standard system concept was chosen (see Figure 4-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, phase A current, phase B current, phase C current, temperature • A DSP56F80x controller board Designer Reference Manual 44 DRM031 — Rev. 0 System Description For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. System Description Application Description 3-Phase SR Power Stage Line AC AC 6 SRM DC Voltage Current Temperature DSP56F80x Freescale Semiconductor, Inc... Speed Cmd. Speed Error DOWN Speed Controller - LOAD E ADC Fault Protection START STOP PWM Current Cmd. Current Error Current Controller Desired Duty Volatge DC-Bus Cycle Ripple Elimination PWM Generation - UP MUX DC Bus Voltage PC Remote Control Commutation Phase Current SCI Commutation Angle Calculation Speed Feedback Speed Feedback Speed Calculation Position Feedback Quad Dec Figure 4-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, that PC master software can only take over the DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Description For More Information On This Product, Go to: www.freescale.com 45 Freescale Semiconductor, Inc. System Description control when the motor is stopped. When the Start command is detected (using the Start/Stop switch or the PC master software “Start” button) and while no fault is pending, the start-up sequence with the rotor alignment is performed and the motor is started. Freescale Semiconductor, Inc... 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. 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. The DC-Bus under-voltage and the over-temperature protection are performed by software, while the DC-Bus over-current and the DC-Bus over-voltage fault signals utilize 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 the -15% ... +10% range of the nominal voltage, the fault "Out of the Mains Limit" disables the drive operation. If Designer Reference Manual 46 DRM031 — Rev. 0 System Description For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. System Description Application Description Freescale Semiconductor, Inc... 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 toggld through 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. The SR software would cause the destruction of AC or BLDC power stages due to 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 could happen. 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 the drive operation. 4.3.1 Initialization and Start-Up Before the motor can be started, the rotor alignment and initialization of the control algorithms must be performed (see Figure 4-2) since the absolute position is not known. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Description For More Information On This Product, Go to: www.freescale.com 47 Freescale Semiconductor, Inc. System Description B Start Command Accepted { C A Any Rotor Position Turn on Phases B & C Freescale Semiconductor, Inc... Wait to Ensure the Initial Pulse Turn Off Phase C Wait 550msec Rotor Stabilized { Measure Phase Resistance as an Average of 32 Measurements B C A Phase B Aligned Commutate Phases (Turn off Phase B, Turn on Phase A) Motor Starts Figure 4-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 Designer Reference Manual 48 DRM031 — Rev. 0 System Description For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. System Description Application Description aligned position with respect to the powered phase (phase B). Freescale Semiconductor, Inc... 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. 4.3.2 Position and Speed Sensing 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 DSP56F80x family, except for the 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 4-3). The phase A and the 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 4-4). The timer module can use all four available inputs as normal timer input capture channels. This does not preclude a use of the quadrature decoder module. Both timer and decoder take an advantage of the digital filter incorporated in the quadrature decoder module. Figure 4-3. Quadrature Encoded Signals DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Description For More Information On This Product, Go to: www.freescale.com 49 Freescale Semiconductor, Inc. System Description Freescale Semiconductor, Inc... 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 the speed. The second method is employed in this application for the 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 wide variability of quad timer modules, it is possible to use this module to decode quadrature encoder signals and to sense the position and the 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 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 A0 timer 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 A0 timer is assigned as a master and broadcast compares signals to quad timer, A1. The A1 timer is configured to be re-initialized to a predetermined value when a master timer’s 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. Designer Reference Manual 50 DRM031 — Rev. 0 System Description For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. System Description Application Description Not used WATCHDOG TIMER Decoder 0 module Freescale Semiconductor, Inc... Phase A Phase B Index Home EDGE DETECT STATE MACHINE POSITION DIFFERENCE COUNTER POSITION COUNTER REV COUNTER GLITCH FILTER Timer Input Capture Channels DELAY SWITCH MATRIX Timer A0 Timer A2 Timer A1 Timer A3 Timer A module Figure 4-4. Decoder and Timer Arrangement 4.3.3 Commutation Algorithm The 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 3-2.). It is calculated regularly during motor operation. The commutation algorithm is described in Figure 4-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 it 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 DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Description For More Information On This Product, Go to: www.freescale.com 51 Freescale Semiconductor, Inc. System Description Freescale Semiconductor, Inc... successive aligned positions. Ideally, the flux should be zero throughout the period of falling inductance, because a 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. Designer Reference Manual 52 DRM031 — Rev. 0 System Description For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. System Description Application Description START Turn ON PHASE Freescale Semiconductor, Inc... θoff = θdwell + θon θon=f(ω, i, u, L) θon > θoff NO YES NO θoff = θon θactual > θoff YES Turn OFF PHASE NO θactual > θon YES Figure 4-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 3.3 Commutation Angle Calculation. 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 DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Description For More Information On This Product, Go to: www.freescale.com 53 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... System Description 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 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 4-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. 4.3.4 Current Controller Implementation The 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 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 3-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 4-6 clarifies the entire controller usage algorithm. Designer Reference Manual 54 DRM031 — Rev. 0 System Description For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. System Description Application Description START Commutate ? NO YES Freescale Semiconductor, Inc... Controller OFF NO Controller OFF ? YES iphase>idesired NO YES Controller ON Controller INIT uapplied =U_dc_bus uapplied = controller Figure 4-6. Current Controller Utilization 4.3.5 Current and Voltage Measurement Precise measurement of phase current and DC-Bus voltage is a key factor for current control implementation. 4.3.5.1 Current Sensing Current measurement needs to be investigated according to the used current sensors and the influence of the noise on the measurement. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Description For More Information On This Product, Go to: www.freescale.com 55 Freescale Semiconductor, Inc. System Description 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 4-7). The phase current is sensed as a voltage drop across the sense resistor. Freescale Semiconductor, Inc... + DC Bus Voltage T1 D1 PWM_T1 Phase A D2 T2 PWM_T2 R3 sense R2 R4 GND V_ref ADC + R_sense R1 - sense OP 1.65V ref Figure 4-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 4-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 (the 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 Designer Reference Manual 56 DRM031 — Rev. 0 System Description For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. System Description Application Description 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. Freescale Semiconductor, Inc... Figure 4-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. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Description For More Information On This Product, Go to: www.freescale.com 57 Freescale Semiconductor, Inc. System Description Top Switch (T1) Time Bottom Switch (T2) Time Sensed Voltage Drop Actual Phase Current Freescale Semiconductor, Inc... T 1 T 2 D1 T 2 T1 T 2 D1 D2 0 Time 0 Time ADC Synchronization Figure 4-8. Soft Switching Current Sensed on ADC Designer Reference Manual 58 DRM031 — Rev. 0 System Description For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. System Description Application Description Phase A Current Sensing Phase B Phase C 0.4 Freescale Semiconductor, Inc... Phase Current [A] 0.2 0 0 0.01 0.02 0.03 0.04 0.05 -0.2 -0.4 -0.6 -0.8 Time [sec] Figure 4-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 (EQ 4-1.) ReferenceSignal = KnownSignal + Noise (EQ 4-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=MeasuredSignalReferenceSignal +KnownSignal(EQ 4-3.) DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Description For More Information On This Product, Go to: www.freescale.com 59 Freescale Semiconductor, Inc. System Description Freescale Semiconductor, Inc... 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 4-4.) The reference signal needs to be commutated together with the commutation of the phases. Table 4-1 defines the active, discharge and reference phases for the commutation sequence C - B - A - C. It is derived from Figure 4-9. Table 4-1. Commutation Sequence of the Reference Phase Step Active Phase Discharge Phase Reference Phase 1 C A B 2 B C A 3 A B C 1 C A B The efficiency of the current sensing noise reduction technique is illustrated in Figure 4-10. The figures illustrate the phase current as it is measured (active phase current is inverted - compared to Figure 4-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. Designer Reference Manual 60 DRM031 — Rev. 0 System Description For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. System Description Application Description 4.3.5.2 Voltage Sensing The 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. Freescale Semiconductor, Inc... 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: –N u DCBus = ∑ u DCBus ( n ) (EQ 4-5.) n=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. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Description For More Information On This Product, Go to: www.freescale.com 61 Freescale Semiconductor, Inc. System Description I active not corrected 0.7 I discharge not corrected 0.6 Freescale Semiconductor, Inc... current [A] 0.5 0.4 0.3 0.2 0.1 0 0 0.01 0.02 0.03 0.04 0.05 0.03 0.04 0.05 -0.1 time [sec] I active 0.7 I discharge 0.6 current [A] 0.5 0.4 0.3 0.2 0.1 0 0 0.01 0.02 -0.1 time [sec] Figure 4-10. Measured 3-Phase Currents without and with Implemented Noise Correction Designer Reference Manual 62 DRM031 — Rev. 0 System Description For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. System Description Application Description 4.3.6 Power Module Temperature Sensing Freescale Semiconductor, Inc... The measured power module temperature is used for thermal protection. The hardware realization is shown in Figure 4-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 a 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 4-6.) where: temp is the power module temperature in degrees Celsius Temp_sense is voltage drop on diodes which is measured by ADC a is diode-dependent conversion constant (a = -0.0073738) b is diode-dependent conversion constant (b = 2.4596) +3.3V_A R1 2.2k - 1% D1 D2 ADC BAV99LT1 BAV99LT1 C1 100nF Figure 4-11. Temperature Sensing Topology DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Description For More Information On This Product, Go to: www.freescale.com 63 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... System Description Designer Reference Manual 64 DRM031 — Rev. 0 System Description For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Designer Reference Manual — 3-Ph. SR Motor Control with Encoder Section 5. Hardware Design Freescale Semiconductor, Inc... 5.1 Contents 5.2 System Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 5.3 DSP56F805EVM Controller Board . . . . . . . . . . . . . . . . . . . . . . 67 5.4 3-Phase SR High-Voltage Power Stage . . . . . . . . . . . . . . . . . . 68 5.5 Optoisolation Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 5.6 Motor-Brake Specifications. . . . . . . . . . . . . . . . . . . . . . . . . . . .72 5.7 Hardware Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 5.2 System Configuration The application is designed to drive the 3-phase SR motor. The application is controlled by the Motorola DSP56F805 motor control DSP. It consists of the following modules (see Figure 5-1): • DSP56F805EVM Control Board • 3-Ph. SR High Voltage Power Stage • Optoisolation Board • 3-phase Switched Reluctance Motor DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Hardware Design For More Information On This Product, Go to: www.freescale.com 65 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... Hardware Design Figure 5-1. 3-Phase SR High Voltage Platform Configuration Designer Reference Manual 66 DRM031 — Rev. 0 Hardware Design For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Hardware Design DSP56F805EVM Controller Board 5.3 DSP56F805EVM Controller Board The DSP56F805EVM is used to demonstrate the abilities of the DSP56F805 and to provide a hardware tool allowing the development of applications that use the DSP56F805. Freescale Semiconductor, Inc... The DSP56F805EVM is an evaluation module board that includes a DSP56F805 part, peripheral expansion connectors, external memory and a CAN interface. The expansion connectors are for signal monitoring and user feature expandability. The DSP56F805EVM is designed for the following purposes: • Allowing new users to become familiar with the features of the 56800 architecture. The tools and examples provided with the DSP56F805EVM facilitate evaluation of the feature set and the benefits of the family. • Serving as a platform for real-time software development. The tool suite enables the user to develop and simulate routines, download the software to on-chip or on-board RAM, run it, and debug it using a debugger via the JTAG/OnCETM port. The breakpoint features of the OnCE port enable the user to easily specify complex break conditions and to execute user-developed software at full-speed, until the break conditions are satisfied. The ability to examine and modify all user accessible registers, memory and peripherals through the OnCE port greatly facilitates the task of the developer. • Serving as a platform for hardware development. The hardware platform enables the user to connect external hardware peripherals. The on-board peripherals can be disabled, providing the user with the ability to reassign any and all of the DSP's peripherals. The OnCE port's unobtrusive design means that all of the memory on the board and on the DSP chip are available to the user. The DSP56F805EVM provides the features necessary for a user to write and debug software, demonstrate the functionality of that software and interface with the customer's application-specific device(s). The DSP56F805EVM is flexible enough to allow a user to fully exploit the DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Hardware Design For More Information On This Product, Go to: www.freescale.com 67 Freescale Semiconductor, Inc. Hardware Design DSP56F805's features to optimize the performance of their product, as shown in Figure 5-2. DSP56F805 Freescale Semiconductor, Inc... RESET LOGIC RESET MODE/IRQ LOGIC MODE/IRQ Program Memory 64Kx16-bit Address, Data & Control SPI SCI #0 RS-232 Interface SCI #1 Peripheral Expansion Connector(s) TIMER Debug LEDs PWM LEDs Over V Sense GPIO Over I Sense Memory Expansion Connector(s) Zero Crossing Detect JTAG Connector DSub 25-Pin DSub 9-Pin CAN Interface CAN Data Memory 64Kx16-bit 4-Channel 10-bit D/A JTAG/OnCE PWM #1 A/D Parallel JTAG Interface PWM #2 Low Freq Crystal XTAL/EXTAL 3.3 V & GND Primary UNI-3 Secondary UNI-3 Power Supply 3.3V, 5.0V & 3.3VA Figure 5-2. Block Diagram of the DSP56F805EVM 5.4 3-Phase SR High-Voltage Power Stage Motorola’s embedded motion control series high-voltage (HV) switched reluctance (SR) power stage is a 180 watt (1/4 horsepower), 3-phase power stage that will operate off of DC input voltages from 140 volts to 230 volts and AC line voltages from 100 volts to 240 volts. In combination with one of Motorola’s Embedded Motion Control Series control boards and an optoisolation board, it provides a software development platform that allows algorithms to be written and tested, Designer Reference Manual 68 DRM031 — Rev. 0 Hardware Design For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Hardware Design 3-Phase SR High-Voltage Power Stage without the need to design and build a power stage. It supports a wide variety of algorithms for controlling switched reluctance motors. Freescale Semiconductor, Inc... Input connections are made via 40-pin ribbon cable connector J14. Power connections to the motor are made on output connector J13. Phase A, phase B, and phase C are labeled Ph. A, Ph. B, Ph. C on the board. Power requirements are met with a single external 140-volt to 230-vo lt DC power supply or an AC line voltage. Either input is supplied through connector J11. Current measuring circuitry is set up for 2.93 amps full scale. Both bus and phase leg currents are measured. A cycle-by-cycle overcurrent trip point is set at 2.69 amps. The HV SR power stage has both a printed circuit board and a power substrate. The printed circuit board contains IGBT gate drive circuits, analog signal conditioning, low-voltage power supplies, power factor control circuitry, and some of large passive power components. This board also has a MC68HC705JJ7 microcontroller used for board configuration and identification. All of the power electronics that need to dissipate heat are mounted on the power substrate. This substrate includes the power IGBTs, brake resistors, current-sensing resistors, a power factor correction MOSFET, and temperature sensing diodes. Table 5-3 shows a block diagram. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Hardware Design For More Information On This Product, Go to: www.freescale.com 69 Freescale Semiconductor, Inc. Hardware Design HV POWER INPUT SWITCH MODE POWER SUPPLY SIGNALS TO/FROM CONTROL BOARD PFC CONTROL dc BUS BRAKE 3-PHASE IGBT POWER MODULE 3-PHASE SR TO MOTOR GATE DRIVERS Freescale Semiconductor, Inc... PHASE CURRENT PHASE VOLTAGE BUS CURRENT BUS VOLTAGE MONITOR BOARD ID BLOCK Figure 5-3. 3-ph. SR HV Power Stage The electrical characteristics in Table 5-1 apply to operation at 25°C with a 160-Vdc supply voltage. Designer Reference Manual 70 DRM031 — Rev. 0 Hardware Design For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Hardware Design Optoisolation Board Table 5-1. Electrical Characteristics of Power Stage Freescale Semiconductor, Inc... Characteristic Symbol Min Typ Max Units DC input voltage Vdc 140 160 230 V AC input voltage Vac 100 208 240 V Quiescent current ICC — 70 — mA Min logic 1 input voltage VIH 2.0 — — V Max logic 0 input voltage VIL — — 0.8 V Input resistance RIn — 10 kΩ — Analog output range VOut 0 — 3.3 V Bus current sense voltage ISense — 563 — mV/A Bus voltage sense voltage VBus — 8.09 — mV/V Peak output current IPK — — 2.8 A Brake resistor dissipation (continuous) PBK — — 50 W Brake resistor dissipation (15 sec pk) PBK(Pk) — — 100 W Pdiss — — 85 W Total power dissipation 5.5 Optoisolation Board Motorola’s embedded motion control series optoisolation board links signals from a controller to a high-voltage power stage. The board isolates the controller, and peripherals that may be attached to the controller, from dangerous voltages that are present on the power stage. The optoisolation board’s galvanic isolation barrier also isolates control signals from high noise in the power stage and provides a noise-robust systems architecture. Signal translation is virtually one-for-one. Gate drive signals are passed from controller to power stage via high-speed, high dv/dt, digital optocouplers. Analog feedback signals are passed back through HCNR201 high-linearity analog optocouplers. Delay times are typically DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Hardware Design For More Information On This Product, Go to: www.freescale.com 71 Freescale Semiconductor, Inc. Hardware Design 250 ns for digital signals, and 2 µs for analog signals. Grounds are separated by the optocouplers’ galvanic isolation barrier. Freescale Semiconductor, Inc... Both input and output connections are made via 40-pin ribbon cable connectors. The pin assignments for both connectors are the same. For example, signal PWM_AT appears on pin 1 of the input connector and also on pin 1 of the output connector. In addition to the usual motor control signals, an MC68HC705JJ7CDW serves as a serial link, which allows controller software to identify the power board. Power requirements for controller side circuitry are met with a single external 12-Vdc power supply. Power for power stage side circuitry is supplied from the power stage through the 40-pin output connector. The electrical characteristics in Table 5-2 apply to operation at 25°C, and a 12-Vdc power supply voltage. Table 5-2. Electrical Characteristics of Optoisolation Board Characteristic Symbol Min Typ Max Units Notes Power Supply Voltage Vdc 10 12 30 V Quiescent Current ICC 70(1) 200(2) 500(3) mA DC/DC converter Min Logic 1 Input Voltage VIH 2.0 — — V HCT logic Max Logic 0 Input Voltage VIL — — 0.8 V HCT logic Analog Input Range VIn 0 — 3.3 V Input Resistance RIn — 10 — kΩ Analog Output Range VOut 0 — 3.3 V Digital Delay Time tDDLY — 0.25 — µs Analog Delay Time tADLY — 2 — µs 1. Power supply powers optoisolation board only. 2. Current consumption of optoisolation board plus DSP EVM board (powered from this power supply) 3. Maximum current handled by DC/DC converters 5.6 Motor-Brake Specifications The SR motor-brake set incorporates a 3-Ph. SRM and attached BLDC motor brake. The detailed specifications are listed in Table Designer Reference Manual 72 DRM031 — Rev. 0 Hardware Design For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Hardware Design Motor-Brake Specifications Freescale Semiconductor, Inc... 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 5-4. 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 5-3. Motor - Brake Specifications Set Manufacturer Motor Specification: Brake Specification: EM Brno, Czech Republic eMotor Type: SR40V (3-phase SR Motor) Stator / Rotor Poles: 6/4 Speed Range: < 5000 rpm Nominal Voltage: 3 x 300V Nominal Current: 1.2A Brake Type SG40N 3-phase BLDC Motor Nominal Voltage: 3 x 27V Nominal Current: 2.6 A Type Baumer Electric BHK 16.05A 1024-12-5 Pulses per Revolution 1024 Position Encoder DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Hardware Design For More Information On This Product, Go to: www.freescale.com 73 Freescale Semiconductor, Inc. Hardware Design 0.8 0.7 Inductance [H] 0.5 Phase A Phase B 0.4 Phase C 0.3 0.2 0.1 60 50 40 30 20 10 0 -10 -20 -30 0 -40 Freescale Semiconductor, Inc... 0.6 mechanical angle [deg] Figure 5-4. Inductance Characteristic 5.7 Hardware Documentation All the system parts are supplied and documented according to the following references: • U1 - Controller Board for DSP56F805: – supplied as: DSP56805EVM – described in: DSP56F805EVMUM/D DSP Evaluation Module Hardware User’s Manual • 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 User’s Manual • U3 - Optoisolation Board Designer Reference Manual 74 DRM031 — Rev. 0 Hardware Design For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Hardware Design Hardware Documentation – supplied with 3-ph. SR High Voltage Power Stage as: ECOPTHIVSR – or supplied alone as: ECOPT - optoisolation board – described in: Motorola Embedded Motion Optoisolation Board User’s Manual MEMCOBUM/D • MB1 Motor-Brake AM40V + SG40N – supplied as: ECMTRHIVAC Freescale Semiconductor, Inc... Detailed descriptions of individual boards can be found in comprehensive User’s Manuals belonging to each board. The manuals are available on the Motorola Web. The User’s Manual incorporates the schematic of the board, description of individual function blocks and a bill of materials. An individual board can be ordered from Motorola as a standard product. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Hardware Design For More Information On This Product, Go to: www.freescale.com 75 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... Hardware Design Designer Reference Manual 76 DRM031 — Rev. 0 Hardware Design For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Designer Reference Manual — 3-Ph. SR Motor Control with Encoder Section 6. Software Design Freescale Semiconductor, Inc... 6.1 Contents 6.2 Data Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 6.3 State Diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 6.4 Software Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 6.5 Scaling of Quantities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 6.6 Velocity Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 6.2 Data Flow The control algorithm of a closed loop SR drive is described in Figure 6-1 and Figure 6-2. It is based on the system description. The individual processes are described in detail in the following sections. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Software Design For More Information On This Product, Go to: www.freescale.com 77 Freescale Semiconductor, Inc. Software Design PC MASTER SPEED SETTING omega_required_mech POSITION SENSOR omega_reqPCM_mech Acceleration position_difference position_actual Speed Calculation see next page Freescale Semiconductor, Inc... Ramp see next page omega_actual omega_desired u_dc_bus I_active Speed Controller I_active Commutation Angle Calculation I_desired Current Controller theta Off theta On u_desired DC-Bus Ripple Elimination Commutation outputDutyCycle &srmCmtData PWM Generation PWM Outputs Pwm_AT Pwm_AB Pwm_BT Pwm_BB Pwm_CT Pwm_CB Figure 6-1. System Data Flow I - SR Motor Control Designer Reference Manual 78 DRM031 — Rev. 0 Software Design For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Software Design Data Flow DC-Bus Volatge A-D Converter 3-Phase CURRENTS A-D Converter Freescale Semiconductor, Inc... ADC Correction Current MUX u_dc_bus i_active see next page Figure 6-2. System Data Flow II - AD Converter 6.2.1 Acceleration Ramp This 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 operating mode), or by PC master software (when in PC master software operating mode). 6.2.2 Speed Calculation The 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 counter’s contents are copied into the position DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Software Design For More Information On This Product, Go to: www.freescale.com 79 Freescale Semiconductor, Inc. Software Design difference hold register (POSDH) and position difference counter is cleared. Freescale Semiconductor, Inc... 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 for moving average filter is 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. 6.2.3 Speed Controller This 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. 6.2.4 Current Controller 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. 6.2.5 DC-Bus Ripple Elimination This 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. Designer Reference Manual 80 DRM031 — Rev. 0 Software Design For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Software Design Data Flow Freescale Semiconductor, Inc... 6.2.6 PWM Generation This process sets the on-chip PWM module for generation of the control pulses for the 3-Ph. SRM 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. 6.2.7 ADC Correction and Current MUX This 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 4.3.5 Current and Voltage Measurement for a detailed description. 6.2.8 Commutation Angle Calculation This 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 3.3 Commutation Angle Calculation). The algorithm 3-Phase SR Motor Commutation Angle Calculation srmcacAngleCalc generates the required advance angle of commutation according to the principle described in 3.3 Commutation Angle Calculation. Before the calculation routine call, the scaling constant must be properly determined (see 6.5 Scaling of Quantities). /* scaling constant */ DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Software Design For More Information On This Product, Go to: www.freescale.com 81 Freescale Semiconductor, Inc. Software Design 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: Freescale Semiconductor, Inc... adv_angle /* /* /* /* routine call */ = 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. 6.2.9 Commutation This 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 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. Designer Reference Manual 82 DRM031 — Rev. 0 Software Design For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... Software Design State Diagram 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. 6.3 State Diagram The processes described above are implemented in a single state machine, as illustrated in Figure 6-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 DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Software Design For More Information On This Product, Go to: www.freescale.com 83 Freescale Semiconductor, Inc. Software Design RESET INIT State appFault = NO_FAULT & switchState = Stop switchState = Stop appFault <> NO_FAULT Freescale Semiconductor, Inc... appOpMode change STOP State switchState = Run & appFault = NO_FAULT FAULT State appFault <> NO_FAULT switchState = Stop & appFault = NO_FAULT appFault <> NO_FAULT RUN State Figure 6-3. Application State Diagram 6.3.1 Application State - INIT After 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 starting after reset if the Start/Stop switch is accidentally in the START position). 6.3.2 Application State - STOP The 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. Designer Reference Manual 84 DRM031 — Rev. 0 Software Design For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Software Design Software Design When the application is in the STOP state, the operating mode can be changed, either from MANUAL mode to PC master software mode or vice versa. When the operating mode is changed, the application always transits to the INIT state. Freescale Semiconductor, Inc... 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. 6.3.3 Application State - RUN The RUN state can be entered from the STOP state. In the RUN state the drive is enabled and the motor is running. 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. 6.3.4 Application State - FAULT The 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. 6.4 Software Design 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 6-4. After Reset, the Main routine provides board identification, initialization of the DSP, initialization of the application, and then it enters an infinite DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Software Design For More Information On This Product, Go to: www.freescale.com 85 Freescale Semiconductor, Inc. Software Design background loop. The background loop contains Fault Detection, Application State Machine, and a scheduler routine. Freescale Semiconductor, Inc... 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 Designer Reference Manual 86 DRM031 — Rev. 0 Software Design For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Software Design Software Design Interrupt Service Routines ADC Conversion Completed Interrupt RESET ADC Interrupt Handlers Initialize DSP & Application Freescale Semiconductor, Inc... done done Background Tasks PWM Fault Interrupt Fault Detection Fault Interrupt Handler done done Application State Machine SCI Interrupt done SCI & PC master software Interrupt Handler Timeout 1 done NO timeout IRQ0, IRQ1 Interrupt Timeout 1 S/W Timeout ? done Timeout 2 done Push Buttons Interrupt Handlers done Timeout 2 TMRA1 Compare Interrupt Commutation Interrupt Handler done Figure 6-4. Software Design - General Overview DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Software Design For More Information On This Product, Go to: www.freescale.com 87 Freescale Semiconductor, Inc. Software Design 6.4.1 Initialization After Reset, the initialization of the DSP is performed. At the beginning of the initialization, interrupts are disabled; at the end of initialization they are enabled. Freescale Semiconductor, Inc... DSP Initialization: • Disable Interrupts • Identify power stage board – identify SR High-Voltage H/W set • Initialize ADC on-chip module – ADC triggered simultaneously – associate interrupt with ADC conversion completed event – 1st sample of ADC_A: Current Phase A – 2nd sample of ADC_A: DC-Bus Voltage – 3rd sample of ADC_A: Temperature – 1st sample of ADC_B: Current Phase B – 2nd sample of ADC_B: Current Phase C – 3rd sample of ADC_B: void • Initialize Quadrature Timer A0 on-chip module (position measurement) – set Quad count mode – count repeatedly up to 1024 • Initialize Quadrature Timer A1 on-chip module (commutation callback) – set Quad count mode – count repeatedly, the binary roll over • Initialize Quadrature Decoder on-chip module – sets digital filter for input signals – connects Quadrature Decoder signals to the Quadrature Timer A1 Designer Reference Manual 88 DRM031 — Rev. 0 Software Design For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Software Design Software Design • Initialize PWM on-chip module: – center aligned independent PWM mode, positive polarity – set PWM modulus for PWM frequency at 16kHz – set PWM interrupt reload of each PWM pulse – set FAULT2 (DC-Bus over-current fault) in manual mode, interrupt enabled Freescale Semiconductor, Inc... – set FAULT1 (DC-Bus over-voltage fault) in manual mode, interrupt enabled – associate interrupt with PWM Fault events • Initialize brake driver • Initialize LED driver • Initialize push buttons – push buttons on interrupts IRQ0, IRQ1 • Initialize switch driver – switch driver used for DSP56F805EVM and DSP56F807EVM Application initialization: • Set individual parameters of the application to their initial values • Start ADC conversion • Measure offset of individual current sensors • Measure DC-Bus voltage and temperature • Calculate application parameters according to DC-Bus voltage • Initialize Quadrature Timer C2 Driver (ADC-PWM Synchronization) – set ADC synchronization delay to 0 – enable Quadrature Timer C2 to be started on first SYNC • Initialize ADC Driver – set ADC synchronization ON – enable 8-sample conversion DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Software Design For More Information On This Product, Go to: www.freescale.com 89 Freescale Semiconductor, Inc. Software Design • Initialize all variables for motor start-up • Set ADC according to start-up phase • Enable interrupts Freescale Semiconductor, Inc... 6.4.2 Fault Detection The Fault Detection routine checks application faults. If a fault occurs, it disables the PWM outputs and sets the application FAULT status. Note that in the case of DC-Bus over-current and DC-Bus over-voltage faults, PWM outputs are disabled directly via internal PWM module fault protection see 6.4.7 Fault ISR. 6.4.3 Application State Machine The Application State Machine provides transition between the individual states of the application: INIT, STOP, RUN, and FAULT. For reference, see 6.3 State Diagram. 6.4.4 Scheduler Timeout 1 This routine is accessed from the main scheduler in a period of Timeout 1 (10 msec). The following tasks are then performed: • Push button filter - debounces push button switching noise • Start/Stop switch filter - debounces Start/Stop switch noise • According to the operating mode, desired speed is calculated – in manual mode according to the push buttons – in PC master software control mode, according to the PC master software command • Start-up routine is performed if required and start-up switching pattern is generated. For a detailed description refer to 4.3.1 Initialization and Start-Up. • Speed command is calculated using the acceleration / deceleration ramp using the desired speed setup Designer Reference Manual 90 DRM031 — Rev. 0 Software Design For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Software Design Software Design • LED is controlled according to the state of the drive. It can indicate a STOP state, RUN state or FAULT state. 6.4.5 Scheduler Timeout 2 This state is accessible from the main scheduler in a period of Timeout 2 (2.5 msec). The following tasks are then performed: Freescale Semiconductor, Inc... • Speed controller calculates the desired phase current according to the actual and the desired speed. The speed controller constants are determined experimentally and set during the initialization of the chip. 6.4.6 ADC Conversion Completed ISR The ADC Conversion Completed ISR is the most critical routine and the most demanding the processor time. Most of the application control processes need to be linked with this ISR. The Analog-to-Digital converter is initiated synchronously with a PWM reload pulse (center of the PWM pulse). It scans all three phase currents, the DC-Bus voltage and the temperature at once. When the conversion is finalized, the ADC Completed ISR is called. The routine provides the following services and calculations: • Reads the ADC conversion results (phase currents, noise, DC-Bus voltage, temperature) • Calculates the ADC offsets for phase currents • Current controller calculates the desired phase voltage according to the desired and the actual phase current • Provides commutation if required • Records selected recorder variables (PC master software) • Loads PWM registers • Calculates the references for software timers Timer1 and Timer2 • Enables the next ADC synchronization trigger DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Software Design For More Information On This Product, Go to: www.freescale.com 91 Freescale Semiconductor, Inc. Software Design 6.4.7 Fault ISR Freescale Semiconductor, Inc... The PWM Fault ISR is the highest priority interrupt implemented in the software. In the case of a DC-Bus over-current or a DC-Bus over-voltage fault detection, the external hardware circuit generates a fault signal, that is detected on the Fault input pin of the DSP. The signal disables the motor control PWM outputs in order to protect the power stage and generates a Fault interrupt, where the fault condition is handled. The routine records the corresponding fault source to the fault status register. 6.4.8 SCI ISR This interrupt handler provides SCI communication and PC master software service routines. These routines are fully independent of the motor control tasks. 6.4.9 Push Button Up/Down ISR The Push Button Interrupt Handlers take care of the push buttons service. The Up Button Interrupt Handler sets the Up Button flag, the Down Button Interrupt Handler sets the Down Button flag. The desired speed is incremented/decremented according to the debounced Up/Down Button flag. 6.4.10 TMRA1 Compare ISR The compare interrupt handler takes care of commutation call. This callback routine sets-on the commutate flag to indicate that the commutation is required. The commutation flag is regularly checked in the ADC conversion-completed routine and upon a successful compare, the commutation routine is called to perform commutation itself. 6.5 Scaling of Quantities The SR motor control application uses a fractional representation for all real quantities except time. The N-bit signed fractional format is Designer Reference Manual 92 DRM031 — Rev. 0 Software Design For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Software Design Scaling of Quantities represented using 1.[N-1] format (1 sign bit, N-1 fractional bits). Signed fractional numbers (SF) lie in the following range: – 1.0 ≤ SF ≤ +1.0 -2 –[ N – 1 ] (EQ 6-1.) Freescale Semiconductor, Inc... For words and long-word signed fractions, the most negative number that can be represented is -1.0, whose internal representation is $8000 and $80000000, respectively. The most positive word is $7FFF or 1.0 2-15, and the most positive long-word is $7FFFFFFF or 1.0 - 2-31. The following equation shows the relationship between the real and the fractional representations: Real Value Fractional Value = ----------------------------------------------Real quantity range (EQ 6-2.) where: Fractional Value is the fractional number of the real value [Frac16] Real Value is the real value of the quantity [V, A, rpm, etc.] Real quantity range is the maximal range of the quantity, defined in the application [V, A, rpm, etc.] 6.5.1 Voltage Scaling The application voltages are scaled to the maximal measured voltage. For DC-Bus voltage the scaling equation is the following: V DC_BUS u_dc_bus = ----------------------------V MAX (EQ 6-3.) Where: u_dc_bus is the scaled variable of the DC-Bus voltage [Frac16] VDC_BUS is the measured DC-Bus voltage [V] VMAX is the maximal measurable DC-Bus voltage [V] In the application, VMAX = 407V for the high voltage platform. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Software Design For More Information On This Product, Go to: www.freescale.com 93 Freescale Semiconductor, Inc. Software Design The other application voltage variables are scaled in the same way (active phase voltage u_active, discharge phase voltage u_discharge, DC-Bus under-voltage limit, start-up voltage). 6.5.2 Phase Current Scaling Freescale Semiconductor, Inc... The application phase currents are scaled to the maximal measured phase current. For the active phase current the scaling equation is the following: i active i_active = ------------------------------i phase_max (EQ 6-4.) Where: i_active is the scaled variable of the active phase current [Frac16] iactive is the measured active phase current [A] iphase_max is the maximal measurable phase current [A] In the application, iphase_max = 5.86A for the high-voltage platform. The other application phase current variables are scaled in the same way (desired current i_desired, discharge current i_discharge, current offsets i_phase_A_offset, i_phase_B_offset, i_phase_C_offset). 6.5.3 Electrical Angle Scaling The application electrical angle is scaled to the electrical angle in the aligned position (see Figure 6-5). For the electrical commutation angle the scaling equation is the following: ϑ on_el theta_on_el = -------------------------------ϑ aligned_el (EQ 6-5.) Where: theta_on_el [Frac16] is the scaled variable of the electrical commutation angle Designer Reference Manual 94 DRM031 — Rev. 0 Software Design For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Software Design Scaling of Quantities ϑon_el is the desired commutation angle [oel] ϑaligned_el is the electrical angle in aligned position [oel]. In the application, ϑaligned_el = 360oel The other application electrical angle variables are scaled in the same way (angle where stator and rotor poles start to overlap theta_edge). Freescale Semiconductor, Inc... A U A L θstart_to_overlap −180 ο θaligned 0 180 position ο Figure 6-5. Electrical Angle Definition 6.5.4 Speed Scaling Speed is scaled to the maximal speed of the drive. For the desired start-up speed, the scaling equation is the following: ω start_up omega_desired_startup = -------------------------ω MAX (EQ 6-6.) Where: omega_desired_startup is the scaled variable of the desired start-up speed [Frac16] ωstart-up is the desired start-up speed [rpm] ωMAX is the maximal speed of the drive [rpm] In the application, ωMAX = 3000 rpm. The other application speed variables are scaled in the same way (actual speed, omega_actual_mech, speed limits, DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Software Design For More Information On This Product, Go to: www.freescale.com 95 Freescale Semiconductor, Inc. Software Design omega_reqMAX_mech & omega_reqMIN_mech, push button speed increment, omega_increment_pb). 6.5.5 Duty Cycle Scaling Freescale Semiconductor, Inc... The duty cycle is scaled to the maximal duty cycle of the drive. For the output duty cycle the scaling equation is the following: duty_cycle output output_duty_cycle = ---------------------------------------------duty_cycle MAX (EQ 6-7.) Where: output_duty_cycle is the scaled variable of output duty cycle [Frac16] duty_cucleoutput is the desired output duty cycle [%] duty_cycleMAX is the max. applicable duty cycle [%] In the application, duty_cycleMAX = 100 % The other application duty cycles are scaled in the same way (high and low duty cycle limits for speed controller, start up output duty cycle outputDutyCycleStartup). 6.6 Velocity Calculation The actual speed of the motor is calculated from the time, TimeCaptured, captured by the on-chip Quadrature Timer between the two following edges of the position Hall sensors. The actual speed, OmegaActual is calculated according to the following equation: SpeedCalcConst OmegaActual = -------------------------------------------TimeCaptured (EQ 6-8.) where: OmegaActual is the actual speed [rpm] TimeCaptured is the time, in terms of number of timer pulses, captured between two edges of the position sensor [-] Designer Reference Manual 96 DRM031 — Rev. 0 Software Design For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Software Design Velocity Calculation SpeedCalcConst is a constant defining the relationship between the actual speed and number of captured pulses between the two edges of the position sensor The constant SpeedCalcConst is calculated as: SpeedCalcConst = 2 15 SpeedMin × ---------------------------SpeedMax (EQ 6-9.) Freescale Semiconductor, Inc... where: SpeedMin is the minimal measured speed [rpm] SpeedMax is the maximal measured speed [rpm] Minimal measured speed, SpeedMin, is given by the configuration of the sensors and parameters of the DSP on-chip timer used for speed measurement. It is calculated as: 1 -------------------------------------------- × 60 NoPulsesPerRev SpeedMin = ----------------------------------------------------------15 2 -------------------------------------- × Presc BusClockFreq (EQ 6-10.) where: NoPulsesPerRev is the number of sensed pulses of the position sensor per single revolution [-] Presc is the prescaler of the Quadrature Timer used for speed measurements BusClockFreq is the DSP Bus Clock Frequency [Hz] Maximal measured speed, SpeedMax, is selected as: SpeedMax = k × SpeedMin (EQ 6-11.) where: k is an integer constant greater than 1 Then the speed calculation constant is determined as: 60 SpeedCalcConst = BusClockFreq × ---------------------------------------------------------------------------------------------------NoPulsesPerRev × Presc × SpeedMax (EQ 6-12.) In the application: DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Software Design For More Information On This Product, Go to: www.freescale.com 97 Freescale Semiconductor, Inc. Software Design NoPulsesPerRev = 12 Hall sensor pulses per 1 revolution of the motor Presc = 128 BusClockFreq = 36*106 Hz SpeedMax = 3000 rpm Freescale Semiconductor, Inc... Then, SpeedCalcConst = 468 [rev-1] Designer Reference Manual 98 DRM031 — Rev. 0 Software Design For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Designer Reference Manual — 3-Ph. SR Motor Control with Encoder Section 7. System Setup Freescale Semiconductor, Inc... 7.1 Contents 7.2 Application Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 7.3 Application Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 7.4 Application Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 7.5 Project Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 7.6 Application Build and Execute . . . . . . . . . . . . . . . . . . . . . . . . 111 7.7 Warning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 7.2 Application Outline The system is designed to drive a 3-Ph. SR motor. The application has the following specifications: • SR motor control using Encoder for position determination • Targeted for DSP56F805EVM and for DSP56F805 Controller Board • Running on 3-Ph. SR HV Power Stage 180 W • Uses optoisolasion board for HV/LV isolation • Speed control loop • Motor mode in single direction of rotation • Minimum speed of 600 rpm • Maximum speed of 2500 rpm • Manual interface (RUN/STOP switch, UP/DOWN push buttons control, LED indication) DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Setup For More Information On This Product, Go to: www.freescale.com 99 Freescale Semiconductor, Inc. System Setup • Overvoltage, undervoltage and overcurrent fault protection • PC remote control interface (speed set-up) • PC master software remote monitor – PC master software monitor interface (applied voltage, required voltage, required and actual speed, START/STOP switch state, fault status, hardware ID) Freescale Semiconductor, Inc... – PC master software speed scope (observes actual and desired speed, currents: active, desired, discharge, output duty cycle) 7.3 Application Description The 3-Ph. SR Motor Control with Encoder Application demonstrates the switched reluctance motor control application using position sensor on the DSP56F805 processor. 7.3.1 Control Process After RESET the application enters the INIT state in MANUAL mode. When the Start/Stop switch is detected (using Start/Stop Switch or PC master command) in STOP position and there are no faults pending the STOP application state is entered. When the start command is detected (using Start/Stop switch or PC master Start button), the drive enters RUN application state - motor is started. The following start-up sequence with the rotor alignment is provided: • MOTOR_STOPPED, motor stopped • ALIGNMENT_COMMAND, alignment command accepted • ALIGNMENT_STAGE_ONE, alignment in progress - phases B&C switched on • ALIGNMENT_STAGE_TWO, alignment in progress - phase B switched on • START_UP_FINISHED, alignment finalized, motor running, start-up finalized Designer Reference Manual 100 DRM031 — Rev. 0 System Setup For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. System Setup Application Description Freescale Semiconductor, Inc... The rotor position is evaluated with encoder position sensor through timer module A of channel 0, which is set into quadrature mode. Channel 1 of the same module performs commutation call under successful comparing of CMP2. Every commutation occurrence, the CMP2 is anew loaded with recently calculated value, which is adjusted by advance angle routine considering actual speed, desired current and applied voltage across corresponding phase. The individual phase is supposed to be switched on before overlapping rotor and stator teeth. According to the control signals (Start/Stop switch, Up/Down push buttons) and PC master commands (in case of PC master control), the reference speed command is calculated using an acceleration/deceleration ramp. The comparison between the actual speed command and the measured speed generates a speed error. Based on the error, the speed controller generates desired phase current. When the phase is commuted, it is turned-on with duty cycle 100% (or Output_duty_cycle_startup during motor start-up). Then during each PWM cycle, the actual phase current is compared with the desired current. As soon as the actual current exceeds the command one, the current controller is turned-on. The procedure is repeated for each commutation cycle of the motor. The current controller generates the desired duty cycle. Finally, the 3-phase PWM SR Motor Control signals are generated. 7.3.2 Drive Protection The DC-Bus voltage, DC-Bus current and power stage temperature are measured during the control process. They are used for overvoltage, undervoltage, overcurrent and overtemperature protection of the drive. The undervoltage and overtemperature protection is performed by software while the overcurrent and overvoltage fault signal utilizes a fault inputs of the DSP. The power stage is identified using board identification. If the correct power stage is not identified, the "Wrong Power Stage" fault disables the drive operation. The line voltage is measured during application initialization. According to the detected level, the 115 VAC or 230 VAC mains is set. If the line voltage is detected out of the -15% .. +10% of nominal voltage, the "Out of the Mains Limit" fault disables the drive operation. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Setup For More Information On This Product, Go to: www.freescale.com 101 Freescale Semiconductor, Inc. System Setup If any of the above mentioned faults occur, the motor control PWM outputs are disabled in order to protect the drive, and the application enters the FAULT state. The FAULT state can be left only when the fault conditions disappear and the Start/Stop switch is toggled through the STOP position. Freescale Semiconductor, Inc... The application can run on: • External RAM or Flash memory • 3-phase SR High-Voltage Power Stage powered by 115V AC or 230V AC • Manual or PC Master Operating Mode The correct power stage and voltage level is identified automatically and the appropriate constants are set. The 3-phase SR motor control application can operate in two modes: 1. Manual Operating Mode The drive is controlled by the RUN/STOP switch. The motor speed is set by the UP and DOWN push buttons (see Figure 7-1). The actual state of the application is indicated by the user LEDs (see Figure 7-2). If the application runs and motor spinning is disabled (i.e., the system is ready), the GREEN user LED will flash at a frequency of 2Hz. When motor spinning is enabled, the GREEN user LED will be On. If a fault occurs on the power stage, the GREEN user LED will flash at a frequency of 8Hz. The actual state of the PWM outputs are indicated by PWM output LEDs. Designer Reference Manual 102 DRM031 — Rev. 0 System Setup For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... System Setup Application Description Figure 7-1. RUN/STOP Switch and UP/DOWN Buttons on DSP56F805EVM Figure 7-2. USER and PWM LEDs on DSP56F805EVM DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Setup For More Information On This Product, Go to: www.freescale.com 103 Freescale Semiconductor, Inc. System Setup Table 7-1. Motor Application States Application State Motor State Green LED State Stopped Stopped Blinking at a frequency of 2Hz Running Spinning On Fault Stopped Blinking at a frequency of 8Hz Freescale Semiconductor, Inc... 2. PC master software (Remote) Operating Mode The drive is controlled remotely from a PC through the SCI communication channel of the DSP device via an RS-232 physical interface. The drive is enabled by the RUN/STOP switch, which can be used to safely stop the application at any time. PC master software enables to set the required speed of the motor. The following PC master control actions are supported: • Set PC master mode of the motor control system • Set manual mode of the motor control system • Start the motor • Stop the motor • Set the required speed of the motor PC master displays the following information: • Required speed of the motor • Actual speed of the motor • Application status - Init/Stop/Run/Fault • DC Bus voltage level • Identified line voltage • Fault Status No_Fault/Overvoltage/Overcurrent/Undervoltage/Overheating • Identified power stage Designer Reference Manual 104 DRM031 — Rev. 0 System Setup For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. System Setup Application Description Start the PC master software window application by the executing the 3ph_srm_Encoder.pmp. Figure 7-3 illustrates the PC master software control window after this project has been launched. If the PC master software project (.pmp file) is unable to control the application, it is possible that the wrong load map (.elf file) has been selected. PC master software uses the load map to determine addresses for global variables being monitored. Once the PC master software project has been launched, this option may be selected in the PC master software window under Project/Select Other Map FileReload. Freescale Semiconductor, Inc... NOTE: Figure 7-3. PC Master Software Control Window DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Setup For More Information On This Product, Go to: www.freescale.com 105 Freescale Semiconductor, Inc. System Setup 7.4 Application Setup Freescale Semiconductor, Inc... Figure 7-4 illustrates the hardware set-ups for the 3-phase SR motor control applications. The motor’s Encoder connector attached to connector J23 on the EVM Board is not required for the motor operation. It serves only for PC master position reference. Figure 7-4. Setup of 3-Phase SR Motor Control Application Using DSP56F805EVM Designer Reference Manual 106 DRM031 — Rev. 0 System Setup For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. System Setup Application Setup The system consists of the following components: • Switched reluctance motor Type 40 V, EM Brno s.r.o., Czech Republic • Load Type SG 40N, EM Brno s.r.o., Czech Republic • Encoder BHK 16.05A1024-12-5, Baumer Electric, Switzerland • 3-ph. SR HV Power Stage 180 W: Freescale Semiconductor, Inc... – supplied as ECINLHIVSR • Optoisolation Board – ECOPT • DSP56F805 Board: – DSP56F805 Evaluation Module, supplied as DSP56F805EVM – or DSP56F805 Controller Board • The serial cable - needed for the PC master software debugging tool only. • The parallel cable - needed for the Metrowerks Code Warrior debugging and s/w loading. • Command Converter Cable - needed for the DSP56F805 Controller Board only. For detailed information, refer to the dedicated application note (see References). 7.4.1 Application Setup Using DSP56F805EVM To execute the SR Motor Control with Encoder, the DSP56F805EVM board requires the strap settings shown in Figure 7-5 and Table 7-2. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Setup For More Information On This Product, Go to: www.freescale.com 107 Freescale Semiconductor, Inc. System Setup JG6 3 1 9 6 3 3 JG10 3 7 2 4 1 1 JG14 JG12 3 2 1 JG13 8 7 2 1 JG4 1 USER 9 6 3 7 4 1 JG14 JG10 PWM JG15 Y1 J23 JG17 JG6 1 3 2 1 JG13 JG12 JTAG DSP56F805EVM 1 JG16 1 JG4 Freescale Semiconductor, Inc... JG1 JG15 JG1 JG2 1 1 1 JG18 J29 JG16 U1 JG3 JG8 JG8 1 S/N 3 U15 S4 S5 S6 GP1 S1 GP2 S2 RUN/STOP S3 P3 IRQA IRQB RESET JG7 1 JG9 JG2 1 3 J24 3 2 1 1 LED3 JG11 P1 U9 JG5 JG5 U10 P1 3 JG9 1 JG3 3 2 JG18 7 JG17 1 JG7 JG11 8 Figure 7-5. DSP56F805EVM Jumper Reference Table 7-2. DSP56F805EVM Jumper Settings Jumper Group Comment JG1 PD0 input selected as a high 1-2 JG2 PD1 input selected as a high 1-2 JG3 Primary UNI-3 serial selected 1-2, 3-4, 5-6, 7-8 JG4 Secondary UNI-3 serial selected 1-2, 3-4, 5-6, 7-8 JG5 Enable on-board parallel JTAG Command Converter Interface NC JG6 Use on-board crystal for DSP oscillator input 2-3 JG7 Select DSP’s Mode 0 operation upon exit from reset 1-2 JG8 Enable on-board SRAM 1-2 JG9 Enable RS-232 output 1-2 Designer Reference Manual 108 Connections DRM031 — Rev. 0 System Setup For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. System Setup Project Files Table 7-2. DSP56F805EVM Jumper Settings Freescale Semiconductor, Inc... Jumper Group Comment Connections JG10 Secondary UNI-3 Analog temperature input unused NC JG11 Use Host power for Host target interface 1-2 JG12 Primary Encoder input selected for quadrature encoder signals 2-3, 5-6, 8-9 JG13 Secondary Encoder input selected 2-3, 5-6, 8-9 JG14 Primary UNI-3 3-phase Current Sense selected as Analog Inputs 2-3, 5-6, 8-9 JG15 Secondary UNI-3 Phase A Overcurrent selected for FAULTA1 1-2 JG16 Secondary UNI-3 Phase B Overcurrent selected for FAULTB1 1-2 JG17 CAN termination unselected NC JG18 Use on-board crystal for DSP oscillator input 1-2 NOTE: When running the EVM target system in a stand-alone mode from Flash, the JG5 jumper must be set in the 1-2 configuration to disable the command converter parallel port interface. 7.5 Project Files • The SR motor control application is composed of the following files: • ...\3ph_srm_Encoder\srm_Encoder.c, main program • ...\3ph_srm_Encoder\3ph_srm_Encoder.mcp, application project file • ....\3ph_srm_Encoder\ApplicationConfig\appconfig.h, application configuration file • ...\3ph_srm_Encoder\SystemConfig\ExtRam\linker_ram.cmd, linker command file for external RAM • ...\3ph_srm_Encoder\SystemConfig\Flash\linker_flash.cmd, linker command file for Flash DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Setup For More Information On This Product, Go to: www.freescale.com 109 Freescale Semiconductor, Inc. System Setup • ...\3ph_srm_Encoder\SystemConfig\Flash\flash.cfg, configuration file for Flash • ...\3ph_srm_Encoder\PCMaster\3ph_srm_Encoder.pmp, PC master software file These files are located in the application folder. Freescale Semiconductor, Inc... Motor control algorithms used in the application: • ...\controller.c, .h: source and header files for PI controller • ...\ramp.c, .h: source and header files for ramp generation • ...\SrmCmt3Ph2spp.c, .h: source and header files for SR Motor commutation algorithm • ...\srmcac.c, .h: source and header files for the mechanical and the electrical quantities calculation algorithms Other functions used in the application: • ...\boardId.c, .h: source and header files for the board identification function All the necessary resources (algorithms and peripheral drivers) are part of the application project file. All the resources are copied into the following folder under the application folder: • ...\3ph_srm_Encoder_sa\src\include, folder for general C-header files • ...\3ph_srm_Encoder_sa\src\dsp56805, folder for the device specific source files, e.g. drivers • ...\3ph_srm_Encoder_sa\src\pc_master_support, folder for PC master software source files • ...\3ph_srm_Encoder_sa\src\algorithms\, folder for algorithms • ...\3ph_srm_Encoder_sa\src\bsp\, folder for the board identification function source file Designer Reference Manual 110 DRM031 — Rev. 0 System Setup For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. System Setup Application Build and Execute 7.6 Application Build and Execute Freescale Semiconductor, Inc... When building the 3-Ph. SR motor control application with encoder, the user can create an application that runs from internal Flash or External RAM. To select the type of application to build, open the 3ph_srm_Encoder.mcp project and select the target build type, as shown in Figure 7-6. A definition of the projects associated with these target build types may be viewed under the Targets tab of the project window. Figure 7-6. Target Build Selection To make this application, open the 3ph_srm_Encoder.mcp project file and execute the Make command, as shown in Figure 7-7. This will build and link the 3-phase SR Encoder Motor Control application. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Setup For More Information On This Product, Go to: www.freescale.com 111 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... System Setup Figure 7-7. Execute Make Command To execute the 3-phase SR Motor Control application, select Project\Debug in the CodeWarrior IDE, followed by the Run command. For more help with these commands, refer to the CodeWarrior tutorial documentation in the following file located in the CodeWarrior installation folder: <...>\CodeWarrior Documentation\PDF\Targeting_DSP56800.pdf If the Flash target is selected, CodeWarrior will automatically program the internal Flash of the DSP with the executable code generated during Build. If the External RAM target is selected, the executable code will be loaded to off-chip RAM. Once, the Flash has been programmed with the executable, the EVM target system may be run in a stand-alone mode from Flash. To do this, set the JG5 jumper in the 1-2 configuration to disable the parallel port, and press the RESET button. Once the application is running, move the RUN/STOP switch to the RUN position; the SR motor will be spinning. The speed can be changed by means of the UP/DOWN push buttons from its minimal value up to its maximal value. NOTE: If the RUN/STOP switch is set to the RUN position when the application starts, toggle the RUN/STOP switch between the STOP and RUN Designer Reference Manual 112 DRM031 — Rev. 0 System Setup For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. System Setup Warning positions to enable motor spinning. This is a protection feature that prevents the motor from starting when the application is executed from CodeWarrior. Freescale Semiconductor, Inc... You should also see a lighted green LED, which indicates that the application is running. If the application is stopped, the green LED will blink at a 2Hz frequency. If an undervoltage fault occurs, the green LED will blink at a frequency of 8Hz. 7.7 Warning This application operates in an environment that includes dangerous voltages and rotating machinery. Be aware, that the application power stage and optoisolation board are not electrically isolated from the mains voltage - they are live with risk of electric shock when touched. An isolation transformer should be used when operating off an AC power line. If an isolation transformer is not used, power stage grounds and oscilloscope grounds are at different potentials, unless the oscilloscope is floating. Note, that probe grounds and, therefore, the case of a floated oscilloscope are subjected to dangerous voltages. The user should be aware, that: • Before moving scope probes, making connections, etc., it is generally advisable to power down the high-voltage supply. • To avoid inadvertently touching live parts, use plastic covers. • When high voltage is applied, using only one hand for operating the test setup minimizes the possibility of electrical shock. • Operation in lab setups that have grounded tables and/or chairs should be avoided. • Wearing safety glasses, avoiding ties and jewelry, using shields, and operation by a personnel trained in high-voltage lab techniques is also advisable. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual System Setup For More Information On This Product, Go to: www.freescale.com 113 Freescale Semiconductor, Inc. System Setup Power transistors, the PFC coil, and the motor can reach temperatures hot enough to cause burns. • When powering down; due to storage in the bus capacitors, dangerous voltages are present until the power-on LED is off. Freescale Semiconductor, Inc... • Designer Reference Manual 114 DRM031 — Rev. 0 System Setup For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Designer Reference Manual — 3-Ph. SR Motor Control with Encoder Appendix A. References Freescale Semiconductor, Inc... 1. Miller, T.J.E., Switched Reluctance Motors and Their Control, Magna Physics Publishing and Clarendon Press, ISBN 0-19-859387-2, 1993 2. AN1937 3-Phase Switched Reluctance Motor Control with Encoder Using DSP56F80x, Motorola Inc., 2002 3. DSP56F80x 16-bit Digital Signal Processor, User’s Manual, DSP56F801-7UM/D, Motorola Inc., 2001 4. DSP56F800 16-bit Digital Signal Processor, Family Manual, DSP56F800FM/D, Motorola Inc., 2001 5. Motorola Embedded Motion Control 3-Phase Switched Reluctance High-Voltage Power Stage User’s Manual, MEMC3PSRHVPSUM/D, Motorola Inc., 2000 6. Motorola Embedded Motion Control 3-Phase Switched Reluctance Low-Voltage Power Stage User’s Manual, MEMC3PSRLVPSUM/D, Motorola Inc., 2000 7. DSP56F805 Evaluation Module Hardware User’s Manual, DSP56F805EVMUM/D, MotorolaInc., 2001 8. Motorola Embedded Motion Optoisolation Board User’s Manual, MEMCOBUM/D, Motorola Inc., 2000 9. DSP Parallel Command Converter Hardware User’s Manual, MCSL, MC108UM2R1 10. User Manual for PC master software, Motorola Inc., 2001 11. CodeWarrior for Motorola DSP56800 Embedded Systems, CWDSP56800, Metrowerks, 2001 DRM031 — Rev. 0 MOTOROLA Designer Reference Manual References For More Information On This Product, Go to: www.freescale.com 115 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... References Designer Reference Manual 116 DRM031 — Rev. 0 References For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Designer Reference Manual — 3-Ph. SR Motor Control with Encoder Appendix B. Glossary AC — Alternating Current. Freescale Semiconductor, Inc... ADC — Analogue-to-Digital Converter brush — A component transfering electrical power from non-rotational terminals, mounted on the stator, to the rotor. BLDC — Brushless DC motor commutation — A process providing creation of a rotation field by switching of power transistor (electronic replacement of brush and commutator). commutator — A mechanical device alternating DC current in DC commutator motor and providing rotation of DC commutator motor. COP — Computer Operating Properly timer DC — Direct Current DSP — Digital Signal Prosessor DSP56F80x — A Motorola family of 16-bit hybrid controller dedicated for motor control. DT — see “Dead Time (DT)” Dead Time (DT) — short time that must be inserted between the turning off of one transistor in the inverter half bridge and turning on of the complementary transistor due to the limited switching speed of the transistors. duty cycle — A ratio of the amount of time the signal is on versus the time it is off. Duty cycle is usually represented by a percentage. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Glossary For More Information On This Product, Go to: www.freescale.com 117 Freescale Semiconductor, Inc. Glossary Electromagnetic Interference (EMI) — Electrical interference with radio communications GPIO — General Purpose Input/Output Hall Sensors - A position sensor giving six defined events (each 60 electrical degrees) per electrical revolution (for 3-phase motor). Freescale Semiconductor, Inc... input/output (I/O) — Input/output interfaces between a computer system and the external world. A CPU reads an input to sense the level of an external signal and writes to an output to change the level on an external signal. ISR — interrupt service routines interrupt — A temporary break in the sequential execution of a program to respond to signals from peripheral devices by executing a subroutine. JTAG — Interface allowing On-Chip Emulation and Programming. LED — Light Emitting Diode logic 1 — A voltage level approximately equal to the input power voltage (VDD). logic 0 — A voltage level approximately equal to the ground voltage (VSS). PI controller — Proportional-Integral controller phase-locked loop (PLL) — A clock generator circuit in which a voltage controlled oscillator produces an oscillation which is synchronized to a reference signal. PM — Permanent Magnet PMSM - Permanent Magnet Synchronous Motor PWM — Pulse Width Modulation Quadrature Decoder — A module providing decoding of position from a quadrature encoder mounted on a motor shaft. Quad Timer — A module with four 16-bit timers. Designer Reference Manual 118 DRM031 — Rev. 0 Glossary For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc. Glossary reset — To force a device to a known condition. RPM — Revolutions per minute SCI — See "serial communications interface module (SCI)" serial communications interface module (SCI) — A module that supports asynchronous communication. Freescale Semiconductor, Inc... serial peripheral interface module (SPI) — A module that supports synchronous communication. software (SW) — Instructions and data that control the operation of a microcontroller. software interrupt (SWI) — An instruction that causes an interrupt and its associated vector fetch. SPI — See "serial peripheral interface module (SPI)." SRM — Switched Reluctance Motor SR Motor — see "SRM" timer — A module used to relate events in a system to a point in time. DRM031 — Rev. 0 MOTOROLA Designer Reference Manual Glossary For More Information On This Product, Go to: www.freescale.com 119 Freescale Semiconductor, Inc. Freescale Semiconductor, Inc... Glossary Designer Reference Manual 120 DRM031 — Rev. 0 Glossary For More Information On This Product, Go to: www.freescale.com MOTOROLA Freescale Semiconductor, Inc... Freescale Semiconductor, Inc. For More Information On This Product, Go to: www.freescale.com Freescale Semiconductor, Inc. HOW TO REACH US: USA/EUROPE/LOCATIONS NOT LISTED: Motorola Literature Distribution; P.O. Box 5405, Denver, Colorado 80217 1-303-675-2140 or 1-800-441-2447 JAPAN: Motorola Japan Ltd.; SPS, Technical Information Center, 3-20-1, Minami-Azabu Minato-ku, Tokyo 106-8573 Japan 81-3-3440-3569 Freescale Semiconductor, Inc... ASIA/PACIFIC: Motorola Semiconductors H.K. Ltd.; Silicon Harbour Centre, 2 Dai King Street, Tai Po Industrial Estate, Tai Po, N.T., Hong Kong 852-26668334 Information in this document is provided solely to enable system and software implementers to use Motorola products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document. TECHNICAL INFORMATION CENTER: Motorola reserves the right to make changes without further notice to any products 1-800-521-6274 herein. Motorola makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does Motorola assume any HOME PAGE: http://motorola.com/semiconductors liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. “Typical” parameters which may be provided in Motorola data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. All operating parameters, including “Typicals” must be validated for each customer application by customer’s technical experts. Motorola does not convey any license under its patent rights nor the rights of others. Motorola products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the Motorola product could create a situation where personal injury or death may occur. Should Buyer purchase or use Motorola products for any such unintended or unauthorized application, Buyer shall indemnify and hold Motorola and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that Motorola was negligent regarding the design or manufacture of the part. Motorola and the Stylized M Logo are registered in the U.S. Patent and Trademark Office. digital dna is a trademark of Motorola, Inc. All other product or service names are the property of their respective owners. Motorola, Inc. is an Equal Opportunity/Affirmative Action Employer. © Motorola, Inc. 2003 DRM031/D For More Information On This Product, Go to: www.freescale.com