Freescale Semiconductor Application Note Document Number: AN3301 Rev. 0, 08/2006 Design of a PMSM Servo System Using the 56F8357 Device by: Charlie Wu Freescale Semiconductor, Inc. Tempe, Arizona 1 Introduction A servo system is commonly used in a positioning application which requires high instantaneous torque response, lower torque ripple, a wide adjustable speed range and excellent speed regulation, such as NC machine tools, industrial robots, and other automated (printing, packaging, food, and textile) equipment. In many types of AC motors, a Permanent Magnet Synchronous Motor (PMSM) has been considered a better fit for a servo application because the PMSM offers the advantage of low rotor inertia, high efficiency, efficient heat dissipation structure, and reduced motor size. Moreover, the elimination of brushes reduces noise and suppresses the need for brush maintenance. This application includes a digital servo system with a Permanent Magnet AC Synchronous Motor and is based on Freescale’s 56F8357 device. The software design Incorporates the Processor ExpertTM (PE) system. Contents 1 2 3 4 5 6 7 8 © Freescale Semiconductor, Inc., 2006. All rights reserved. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 56F8357 DSC Advantages and Features . . . . . . . . . . . . 2 Target Motor Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.1 Permanent Magnet Synchronous Motor (PMSM) . . 5 3.2 Digital Control of PMSM . . . . . . . . . . . . . . . . . . . . 13 Servo Control System . . . . . . . . . . . . . . . . . . . . . . . . . . 27 4.1 System Concept . . . . . . . . . . . . . . . . . . . . . . . . . . 27 4.2 Servo Control Drive Concept. . . . . . . . . . . . . . . . . 28 4.3 Servo Control Process. . . . . . . . . . . . . . . . . . . . . . 29 System Hardware Design . . . . . . . . . . . . . . . . . . . . . . . 30 5.1 Hardware Structure . . . . . . . . . . . . . . . . . . . . . . . . 30 5.2 56F8357EVM Board . . . . . . . . . . . . . . . . . . . . . . . 30 5.3 Main Power Circuit . . . . . . . . . . . . . . . . . . . . . . . . 31 5.4 PWM Driver Circuit . . . . . . . . . . . . . . . . . . . . . . . . 32 5.5 DC Voltage and Phase Current Sample Circuit. . . 33 5.6 Position and Speed Sensing . . . . . . . . . . . . . . . . . 34 5.7 Overcurrent Protection Circuit . . . . . . . . . . . . . . . . 35 5.8 LCD Display Circuit . . . . . . . . . . . . . . . . . . . . . . . . 36 5.9 Manual Operating Circuit. . . . . . . . . . . . . . . . . . . . 37 5.10 Power Supply Circuit . . . . . . . . . . . . . . . . . . . . . . . 38 System Software Organization . . . . . . . . . . . . . . . . . . . 38 6.1 Main Module Description . . . . . . . . . . . . . . . . . . . . 39 6.2 ADC Interrupt Module Description. . . . . . . . . . . . . 40 6.3 Position Interrupt Module Description . . . . . . . . . . 41 6.4 Button Interrupt Module Description . . . . . . . . . . . 42 Software Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 7.1 Core Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 7.2 Interface Modules . . . . . . . . . . . . . . . . . . . . . . . . . 50 User Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 56F8357 DSC Advantages and Features The concept of the application includes a position closed-loop PM synchronous drive, with a speed closed-loop using a Vector Control technique. It serves as an example of a PM synchronous motor control design using a Freescale Digital Signal Controller (DSC). This document includes the system design concept, hardware implementation and software design. 2 56F8357 DSC Advantages and Features The 56F8357 is well suited for digital motor control, combining the DSP’s calculation capability with the MCU’s controller features on a single chip. This device offers such dedicated peripherals as Pulse Width Modulation (PWM) modules, an Analog-to-Digital Converter (ADC), Timers, communication peripherals (SCI, SPI, CAN), on-board Flash and RAM. The 56F8357 provides the following peripherals: • Two Pulse Width Modulators (PWMA & PWMB), each with six PWM outputs, three Current Sense inputs, and four Fault inputs; fault tolerant design with dead time insertion, supporting both center- and edge-aligned modes • 12-bit Analog-to-Digital Converters (ADCs), supporting two simultaneous conversions with dual four-pin multiplexed inputs; the ADC can be synchronized by PWM modules • Two Quadrature Decoders (Quad Dec0 & Quad Dec1), each with four inputs, or two additional Quad Timers, A & B • Two dedicated general purpose Quad Timers totaling six pins: Timer C with two pins and Timer D with four pins • CAN 2.0 A/B module with two-pin ports used to transmit and receive • Two Serial Communication Interfaces (SCI0 & SCI1), each with two pins, or four additional GPIO lines • Serial Peripheral Interface (SPI), with configurable four-pin port, or four additional GPIO lines • Computer Operating Properly (COP) timer • Two dedicated external interrupt pins • Up to 76 GPIO lines • External reset pin for hardware reset • JTAG/On-Chip Emulation (OnCE) • Software-programmable, Phase Lock Loop-based frequency synthesizer for the core clock • Large-capacity memory (256KB Program Flash, 4KB Program RAM, 8KB Data Flash, 16KB Data RAM, 16KB Boot Flash), combined with the on-board 128KB external Program Data SRAM In addition to the fast Analog-to-Digital converter and the 16-bit quadrature timers, the most interesting peripheral, from the PM synchronous motor control point of view, is the Pulse Width Modulation (PWM) module. The PWM module offers a high degree of freedom in its configuration, allowing efficient control of the PM synchronous motor. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 2 Freescale Semiconductor 56F8357 DSC Advantages and Features The PWM has the following features: • Three complementary PWM signal pairs, or six independent PWM signals • Complementary channel operation • Dead time insertion • Separate top and bottom pulse width correction via current status inputs or software • Separate top and bottom polarity control • Edge-aligned or center-aligned PWM signals • 15 bits of resolution • Half-cycle reload capability • Integral reload rates from 1 to 16 • Individual software-controlled PWM outputs • Mask and swap of PWM outputs • Programmable fault protection • Polarity control • 20mA current sink capability on PWM pins • Write-protectable registers The PM synchronous motor control utilizes the PWM block set in the complementary PWM mode, permitting generation of control signals for all switches of the power stage with inserted dead time. The PWM block generates three sinewave outputs mutually shifted by 120°. The Analog-to-Digital Converter (ADC) consists of a digital control module and two analog sample and hold (S/H) circuits. ADC features include: • 12-bit resolution • Maximum ADC clock frequency is 5MHz with 200ns period — Single conversion time of 8.5 ADC clock cycles (8.5 x 200ns = 1.7µs) — Additional conversion time of 6 ADC clock cycles (6 x 200ns = 1.2µs) — Eight conversions in 26.5 ADC clock cycles (26.5 x 200ns = 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 • Ability to sequentially scan and store up to eight measurements • Ability to simultaneously sample and hold two inputs • Optional interrupts at end of scan, if an out-of-range limit is exceeded, or at zero crossing • Optional sample correction by subtracting a preprogrammed offset value • Signed or unsigned result • Single-ended or differential inputs Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 3 56F8357 DSC Advantages and Features The application utilizes the ADC block in simultaneous mode and sequential scan. It is synchronized with PWM pulses. This configuration allows the simultaneous conversion within the required time of required analog values, all phase currents, voltage and temperature. The quadrature timer is an extremely flexible module, providing all services relating to timed events. It has the following features: • Four 16-bit counters/timers in each timer module • Ability to count up/down • Cascadable counters • Programmable count modulo • Maximum count rate equals peripheral clock/2 when counting external events • Maximum count rate equals peripheral clock when using internal clocks • Count once or repeatedly • Counters are preloadable • Counters can share available input pins • Each counter has a separate prescaler • Each counter has capture and compare capability The PM Synchronous Motor vector control application utilizes four channels of the quadrature timer module for position and speed sensing. A fifth channel of the quadrature timer module is set to generate a time base for speed sensing and a speed controller. The Quadrature Decoder provides decoding of position signals from a Quadrature Encoder mounted on a motor shaft. It has the following features: • Includes logic to decode quadrature signals • Configurable digital filter for inputs • 32-bit position counter • 16-bit position difference counter • Maximum count frequency equals the peripheral clock rate • Position counter can be initialized by software or external events • Preloadable 16-bit revolution counter • Inputs can be connected to a general purpose timer to aid low-speed velocity The PM Synchronous Motor vector control application utilizes the Quadrature Decoder connected to Quad Timer A. It uses the decoder’s digital input filter to filter the encoder’s signals, but does not make use of its decoding functions, freeing the decoder’s digital processing capabilities to be used by another application. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 4 Freescale Semiconductor Target Motor Theory 3 Target Motor Theory 3.1 Permanent Magnet Synchronous Motor (PMSM) The PMSM is a rotating electrical machine with a classic 3-phase stator like that of an induction motor; the rotor has surface-mounted permanent magnets (see Figure 1). Stator Stator winding (in slots) Shaft Rotor Air gap Permanent magnets Figure 1. PMSM — Cross Section In this respect, the PMSM is equivalent to an induction motor, in that the air gap magnetic field is produced by a permanent magnet, so the rotor magnetic field is constant. PM Synchronous Motors offer a number of advantages in designing modern motion control systems. The use of a permanent magnet to generate substantial air gap magnetic flux makes it possible to design highly efficient PM motors. 3.1.1 Electrical Equations u SA = V cos(ωe ⋅ t ) u SB = V cos(ωe ⋅ t − u SC = V cos(ωe ⋅ t − 2π ) 3 Eqn. 1 4π ) 3 To create the rotating stator flux, the commonly applied phase voltages present a phase shift of 120° electrical from one to another that takes into account the mechanical 120° angle between coils. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 5 Target Motor Theory A one-phase electrical equation can be written: u = Z ⋅ i = Ri + dΨ d = Ri + ( Li + Ψm (θ )) dt dt Eqn. 2 where: Ψm corresponds to the amplitude of the natural magnetic flux of the permanent magnets The term d Ψm (θ ) dt corresponds to the back EMF (induced voltage) and can also be written: dΨm (θ ) ⋅ ωe dθ where: ωe corresponds to the electrical speed If the machine is assumed to be sinusoidal, the induced voltage has the following form: ⎡ ⎤ ⎢ ⎥ sin( θ ) e E ( θ ) ⎡ a ⎤ ⎢ 2π ⎥ E = ⎢⎢ Eb (θ ) ⎥⎥ = −ωe ⋅ Ψm ⎢sin(θ e − )⎥ = ωe ⋅ Ψm ⋅ [K (θ e )] 3 ⎥ ⎢ ⎢⎣ Ec (θ ) ⎥⎦ 4 ⎢sin(θ − π )⎥ e 3 ⎦⎥ ⎣⎢ Eqn. 3 A part of the electrical power delivered to the motor is transformed in Joule losses, another part is going to the energy stored in the magnetic field and the last part is transformed into mechanical energy (torque production). In a PMSM, torque is expressed by: Te = p ⋅ [I s ] ⋅ Ψm ⋅ [K (θ e )] t Eqn. 4 where: p is the number of pole pairs Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 6 Freescale Semiconductor Target Motor Theory It can be proven that the best method to produce a constant torque is to drive a sinusoidal motor by sinusoidal currents. Te = pΨm ( I a ⋅ K a (θ ) + I b ⋅ K b (θ ) + I c ⋅ K c (θ )) Eqn. 5 If: i SA = I s sin(ω e ⋅ t ) 2π ) 3 4π = I s sin(ω e ⋅ t − ) 3 i SB = I s sin(ω e ⋅ t − i SC yields: Te = p ⋅ Ψm ⋅ I s (sin 2 (ωt ) + sin 2 (ωt − 4π 3 2π ) + sin 2 (ωt − )) = p ⋅ Ψm ⋅ I s 3 3 2 Eqn. 6 It shows that Field Oriented Control (FOC) enables continuous control of the torque demand without ripples if it is fed by 3-phase sinusoidal currents. 3.1.2 Mechanical Equations The torque created by the energy conversion process is then used to drive mechanical loads. Its expression is related to mechanical parameters via the fundamental law of dynamics as follows: ∑T = J Giving: J Kd dω dt Eqn. 7 = rotor inertia = viscosity coefficient Tl = load torque wm = mechanical speed J dω m + K d ωm + Tl = Te dt Eqn. 8 As the torque is composed of time- and electrical position-dependent parameters, its efficient and accurate control is not easy with standard methods. A real-time implrmentation of the FOC algorithm with a 56F8357 device overcomes this issue. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 7 Target Motor Theory 3.1.3 Space Vector Definition The model used for vector control design can be understood by using space vector theory. The 3-phase motor quantities (such as voltages, currents, magnetic flux, etc.) are expressed in terms of complex space vectors. Such a model is valid for any instantaneous variation of voltage and current and adequately describes the performance of the machine under both steady-state and transient operation. The complex space vectors can be described using only two orthogonal axes, so the motor can be considered a two-phase machine. Using a 2-phase motor model reduces the number of equations and simplifies the control design. Assume isa, isb, and isc, the line-to-neutral currents of the symmetrical machine, are balanced at any instant. i sa + i sb + i sc = 0 Eqn. 9 Define the stator current space vector as follows: 2 i s = k ( i sa + ai sb + a i sc ) Eqn. 10 Where: α and α2 are the spatial operators α = e j2π/3 α2 = e j4π/3 k is the transformation constant, chosen as k=2/3 Figure 2 shows the stator current space vector projection. β phase- b is β Figure 2. Stator Current Space Vector Projection Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 8 Freescale Semiconductor Target Motor Theory The space vector defined by Equation 10 can be expressed utilizing the two-axis theory. The real part of the space vector is equal to the instantaneous value of the direct-axis stator current component, isα; its imaginary part is equal to the quadrature-axis stator current component, isβ. Thus, the stator current space vector in the stationary reference frame attached to the stator can be expressed as: i s = i sα + ji sβ Eqn. 11 In symmetrical 3-phase machines, the direct and quadrature axis stator currents isα and isβ are rotational quadrature-phase (2-phase) current components, which are converted from the actual 3-phase stator currents as follows: 1 1 i sα = k ⎛ i sa – --- i sb – --- i sc⎞ ⎝ 2 ⎠ 2 Eqn. 12 3 i sβ = k ------- ( i sb – i sc ) 2 Eqn. 13 where: k=2/3 is a constant The space vectors of other motor quantities (voltages, currents, magnetic fluxes etc.) can be defined in the same way as the stator current space vector. For a description of the PMSM, the symmetrical 3-phase smooth-air-gap machine with sinusoidally distributed windings is considered. The voltage equations of stator in the instantaneous form can then be expressed as: u SA = R S i SA + d ψ d t SA Eqn. 14 u SB = R S i SB + d ψ d t SB Eqn. 15 u SC = R S i SC + d ψ d t SC Eqn. 16 where: uSA, uSB and uSC are the instantaneous values of stator voltages iSA, iSB and iSC are the instantaneous values of stator currents ψSA, ψSB, ψSC are instantaneous values of stator flux linkages, ψSA relates to phase SA, ψSB relates to SB, and ψSC relates to SC Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 9 Target Motor Theory Due to the large number of equations in the instantaneous form, (Equation 14, Equation 15, and Equation 16), it is more practical to rewrite the instantaneous equations using a two-axis theory (Clarke transformation). The PMSM can be expressed as: where: α,β uSα,β u Sα = R S i Sα + d Ψ d t Sα Eqn. 17 u Sβ = R S i Sβ + d Ψ d t Sβ Eqn. 18 Ψ Sα = L S i Sα + Ψ M cos ( Θ r ) Eqn. 19 Ψ Sβ = L S i Sβ + Ψ M sin ( Θ r ) Eqn. 20 dω p 3 = --- --- p ( Ψ Sα i Sβ – Ψ Sβ i Sα ) – T L dt J 2 Eqn. 21 = = the stator orthogonal coordinate system the stator voltage iSα,β = the stator current ΨSα,β = the stator magnetic flux ΨM = the rotor magnetic flux RS = the stator phase resistance LS = the stator phase inductance ω / ωF = the electrical rotor speed / fields speed p J TL = = = the number of poles per phase the inertia the load torque Θr = the rotor position in a,b coordinate system Equation 17 through Equation 21 represent the model of PMSM in the stationary frame α, β fixed to the stator. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 10 Freescale Semiconductor Target Motor Theory Besides the stationary reference frame attached to the stator, motor model voltage space vector equations can be formulated in a general reference frame, which rotates at a general speed, ωg. If: a general reference frame is used with direct and quadrature axes x,y rotating at a general instantaneous speed ωg=dθg/dt, as shown in Figure 3 where: θg is the angle between the direct axis of the stationary reference frame (α) attached to the stator and the real axis (x) of the general reference frame then: Equation 22 defines the stator current space vector in general reference frame: i sg = i s e y – jθ g Eqn. 22 = i sx + ji sy β x g Figure 3. Application of the General Reference Frame The stator voltage and flux-linkage space vectors can be similarly obtained in the general reference frame. Similar considerations hold for the space vectors of the rotor voltages, currents and flux linkages. The real axis (rα) of the reference frame attached to the rotor is displaced from the direct axis of the stator reference frame by the rotor angle, θr. As shown, the angle between the real axis (x) of the general reference frame and the real axis of the reference frame rotating with the rotor (rα) is θg-θr in the general reference frame, so the space vector of the rotor currents can be expressed as: i rg = i r e –j ( θg – θr ) = i rx + ji ry Eqn. 23 where: i r is the space vector of the rotor current in the rotor reference frame Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 11 Target Motor Theory The space vectors of the rotor voltages and rotor flux linkages in the general reference frame can be similarly expressed. The motor model voltage equations in the general reference frame can be expressed by transformations of the motor quantities from one reference frame to the general reference frame. The PMSM model is often used in vector control algorithms. The aim of vector control is to implement control schemes which produce high dynamic performance and are similar to those used to control DC machines. To achieve this, the reference frames may be aligned with the stator flux-linkage space vector, the rotor flux-linkage space vector, or the magnetizing space vector. The most popular reference frame is the reference frame attached to the rotor flux linkage space vector, with direct axis (d) and quadrature axis (q). After transformation into d-q coordinates, the motor model as follows: u Sd = R S i Sd + d Ψ – ω F Ψ Sq d t Sd Eqn. 24 u Sq = R S i Sq + d Ψ + ω F Ψ Sd d t Sq Eqn. 25 Ψ Sd = L S i Sd + Ψ M Eqn. 26 Ψ Sq = L S i Sq Eqn. 27 dω p 3 = --- --- p ( Ψ Sd i Sq – Ψ Sq i Sd ) – T L dt J 2 Eqn. 28 Below base speed, isd = 0, so Equation 28 can be reduced to the following form: dω p 3 = --- --- p ( Ψ M i Sq ) – T L dt J 2 Eqn. 29 As Equation 29 shows, torque is dependent and can only be controlled directly by the current isq . Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 12 Freescale Semiconductor Target Motor Theory 3.2 Digital Control of PMSM In adjustable-speed applications, Permanent Magnet Synchronous Motors (PMSMs) are powered by inverters. The inverter converts DC power to AC power at the required frequency and amplitude. A typical 3-phase inverter is illustrated in Figure 4. Figure 4. 3-Phase Inverter The inverter consists of three half-bridge units where the upper and lower switches are controlled complementarily, meaning when the upper one is turned on, the lower one must be turned off, and vice versa. Because the power device’s turn-off time is longer than its turn-on time, some dead time must be inserted between the time when one transistor of the half-bridge is turned off, and its complementary device is turned on. Output voltage is created by either a Pulse Width Modulation (PWM) using a look-up table or Space Vector Pulse Width Modulation (SVPWM) technique. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 13 Target Motor Theory 3.2.1 PWM Technique The PWM technique is shown in Figure 5, where an isosceles triangle carrier wave is compared with a fundamental-frequency sine modulating wave, and the natural points of intersection determine the switching points of the power devices of a half bridge inverter. The 3-phase voltage waves are shifted 120° to each other and, thus, a 3-phase motor can be supplied. Generated Sine Wave PWM Carrier Wave 1 0 ωt -1 PWM Output T 1 (Upper Switch) PWM Output T 2 (Lower Switch) 1 0 ωt 1 0 ωt Figure 5. Pulse Width Modulation Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 14 Freescale Semiconductor Target Motor Theory 3.2.2 SVPWM Technique The basic principle of the standard Space Vector Modulation Technique can be explained with the help of the power stage schematic diagram shown in Figure 6. Figure 6. Power Stage Schematic Diagram The top and bottom switches are working in a complementary mode; i.e., if the top switch, “SAt”, is ON, then the corresponding bottom switch, “SAb”, is OFF, and vice versa. Because value 1 is assigned to the ON state of the top switch and value 0 is assigned to the ON state of the bottom switch, the switching vector, [a, b, c]T, can be defined. Creating such a vector allows numerical definition of all possible switching states. Phase-to-phase voltages can then be expressed in terms of these states: ⎡U AB ⎤ ⎡1 − 1 0⎤ ⎡a ⎤ ⎢U ⎥ = U ⎢ ⎥⎢ ⎥ DCBus ⎢0 1 − 1⎥ ⎢b ⎥ ⎢ BC ⎥ ⎢⎣U CA ⎥⎦ ⎢⎣− 1 0 1⎥⎦ ⎢⎣ c ⎥⎦ Eqn. 30 where: UDCBus is the instantaneous voltage measured on the DCBus Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 15 Target Motor Theory Assuming that the motor is ideally symmetrical, it’s possible to write a matrix equation that expresses the motor phase voltages: ⎡U a ⎤ ⎢U ⎥ = U DCBus ⎢ b⎥ 3 ⎢⎣U c ⎥⎦ ⎡2 − 1 − 1⎤ ⎡a ⎤ ⎢− 1 2 − 1⎥ ⎢b ⎥ ⎢ ⎥⎢ ⎥ ⎢⎣− 1 − 1 2⎥⎦ ⎢⎣ c ⎥⎦ Eqn. 31 In a 3-Phase power stage configuration, shown in Figure 6, eight switching states (vectors), which are detailed in Figure 7, are possible. These states, together with the resulting instantaneous output line-to-line and phase voltages, are listed in Table 1. Table 1. Switching Patterns and Resulting Instantaneous Line-to-Line and Phase Voltages a b c Ua Ub Uc UAB UBC UCA Vector 0 0 0 0 0 0 0 0 0 O000 1 0 0 2UDCBus/3 -UDCBus/3 -UDCBus/3 UDCBus 0 -UDCBus U0 1 1 0 UDCBus/3 UDCBus/3 -2UDCBus/3 0 UDCBus -UDCBus U60 0 1 0 -UDCBus/3 2UDCBus/3 -UDCBus/3 -UDCBus UDCBus 0 U120 0 1 1 -2UDCBus/3 UDCBus/3 UDCBus/3 -UDCBus 0 UDCBus U240 0 0 1 -UDCBus/3 -UDCBus/3 2UDCBus/3 0 -UDCBus UDCBus U300 1 0 1 UDCBus/3 -2UDCBus/3 UDCBus/3 UDCBus -UDCBus 0 U360 1 1 1 0 0 0 0 0 0 O111 The quantities of direct-α and quadrature-β components of the 2-phase orthogonal coordinate system, describing the 3-phase stator voltages, are expressed by the Clarke Transformation, arranged in a matrix form. 1 1 ⎤ ⎡U ⎤ ⎡ a ⎡U α ⎤ 2 ⎢1 − 2 − 2 ⎥ ⎢ ⎥ = U ⎢ ⎥ ⎢U ⎥ 3 3 ⎥⎢ b ⎥ ⎣ β ⎦ 3 ⎢0 − ⎢U ⎥ ⎢⎣ 2 2 ⎥⎦ ⎣ c ⎦ Eqn. 32 The 3-phase stator voltages, Ua, Ub, and Uc, are transformed via Clarke Transformation into quantities of direct-α and quadrature-β components of the 2-phase orthogonal coordinate system. The transformation results are listed in Table 2. Table 2. Switching Patterns, Space Vectors and α, β Voltage Components a b c Uα Uβ Vector 0 0 0 0 0 O000 1 0 0 2UDCBus/3 0 U0 1 1 0 UDCBus/3 UDCBus/ 3 U60 0 1 0 -UDCBus/3 UDCBus/ 3 U120 0 1 1 -2UDCBus/3 0 U240 0 0 1 -UDCBus/3 UDCBus/ 3 U300 1 0 1 UDCBus/3 UDCBus/ 3 U360 1 1 1 0 0 O111 Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 16 Freescale Semiconductor Target Motor Theory Figure 7 graphically depicts possible basic switching states (vectors). It is clear that there are six non-zero vectors, U0, U60, U120, U180, U240, U300, and two zero vectors, O111, O000, available for switching. Therefore, the principle of standard Space Vector Modulation resides in applying appropriate switching states for a certain time, thus generating a voltage vector identical to the reference vector. Figure 7. Basic Space Vector of the Space Vector Modulation Technique Figure 8. Projection of the Reference Voltage Vector in Sector I Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 17 Target Motor Theory Referring to the theory of SVMPWM, an objective of the Standard Space Vector Modulation is an approximation of the reference stator voltage vector, US, with an appropriate combination of the switching patterns composed of basic space vectors. This objective is shown in Figure 8 and Figure 9. The stator reference voltage vector, US, is phase-advanced by 30o from the direct-α and thus might be generated with an appropriate combination of the adjacent basic switching states U0 and U60. Figure 9. Detail of the Reference Voltage Vector Projection in Sector I These figures also indicate the resulting direct-α and quadrature-β components for basic space vectors U0 and U60. In this case, the reference stator voltage vector, US, is located in Sector I and, as previously mentioned, can be generated with the appropriate duty-cycle ratios of the basic switching states U60 and U0. The principal equations concerning this vector location are: T = T60 + T0 + Tnull Eqn. 33 T T U S = 60 ⋅ U 60 + 0 ⋅ U 0 T T where; T60 and T0 are the respective duty-cycle ratios for which the basic space vectors U60 and U0 should be applied within the time period T. Tnull is the course of time for which the null vectors O000 and O111 are applied. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 18 Freescale Semiconductor Target Motor Theory Duty-cycle ratios can be calculated with Equation 34: T60 ⋅ U 60 ⋅ sin 60 0 T uβ T uα = 0 ⋅ U 0 + T tan 600 uβ = Eqn. 34 Considering that normalized magnitudes of basic space vectors are |U60| = |U0| = 2/ √3 and by substitution of the trigonometric expressions sin60o and tan60o by their quantities 2/ √3 and √3, respectively, Equation 33 and Equation 34 can be rearranged for the unknown duty-cycle ratios T60/T and T0/T: T60 = uβ T T0 1 = ⋅ ( 3 ⋅ uα − u β ) T 2 Eqn. 35 Sector II is depicted in Figure 10. In this particular case, the reference stator voltage vector, US, is generated by the appropriate duty-cycle ratios of the basic switching states, U60 and U120. The basic equations describing this sector are: T = T120 + T60 + Tnull US = T120 T ⋅ U120 + 60 ⋅ U 60 T T Eqn. 36 where: T120 and T60 are the respective duty-cycle ratios for which basic space vectors U120 and U60 should be applied within the time period T. Tnull is the course of time for which the null vectors O000 and O111 are applied. These resultant duty-cycle ratios are formed from the auxiliary components termed “A” and “B”. The graphical representation of the auxiliary components is shown in Figure 11. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 19 Target Motor Theory Figure 10. Projection of the Reference Voltage Vector in Sector II Figure 11. Detail of the Reference Voltage Vector Projection in Sector II Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 20 Freescale Semiconductor Target Motor Theory The equations describing those auxiliary time-duration components are: sin 30 0 A = 0 sin 120 uβ Eqn. 37 sin 600 B = sin 600 uα Eqn. 38 Equation 37 and Equation 38 have been formed using the Sinus Rule. These equations can be rearranged for the calculation of the auxiliary time-duration components “A” and “B”. This is done simply by substituting the trigonometric terms sin30°, sin120°, and sin60⎦ by their numerical representations 1/2, √3/2 and 1/√3, respectively. 1 ⋅ uβ 3 B = uα A= Eqn. 39 The resulting duty-cycle ratios, T120/T and T60/T, are then expressed in terms of the auxiliary time-duration components defined by Equation 40: T120 ⋅ U120 = A − B T T60 ⋅ U 60 = A + B T Eqn. 40 With the help of these equations and also considering normalized magnitudes of basic space vectors to be |U120| = |U60| = 2/ √3, the equations expressed for the unknown duty-cycle ratios of basic space vectors T120/T and T60/T can be written: T120 1 = ⋅ (u β − 3 ⋅ uα ) T 2 Eqn. 41 T60 1 = ⋅ (u β + 3 ⋅ uα ) T 2 Eqn. 42 The duty-cycle ratios in remaining sectors can be derived using the same approach. The resulting equations will be similar to those derived for Sector I and Sector II. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 21 Target Motor Theory These definitions depict duty-cycle ratios of basic space vectors for all sectors: • Three auxiliary variables: — X = uβ — Y= 1/2 (uβ + √3 z uα ) — Z= 1/2 (uβ - √3 z uα ) • Two expressions: — t_1 — t_2 which generally represent duty-cycle ratios of basic space vectors in the respective sector. For example, t_1 and t_2 represent duty-cycle ratios of basic space vectors U60 and U0 for the first sector; t_1 and t_2 represent duty-cycle ratios of basic space vectors U120 and U60 for the second sector and so on. For each sector, the expressions t_1 and t_2 are listed in Table 3 in terms of auxiliary variables X, Y and Z. Table 3. Determination of the Expressions t_1 and t_2 for All Sectors Sectors U0, U60 U60, U120 U120, U180 U180, U240 U240, U300 U300, U0 t_1 X Z -Y -X -Z Y t_2 -Z Y X Z -Y -X For the determination of auxiliary variables X, Y and Z, the sector number is required. This information can be obtained by several methods. One approach requires the use of a modified Inverse Clark Transformation to transform the direct-α and quadrature-β components into a balanced 3-phase quantity, uref1, uref2 and uref3, used for straightforward calculation of the sector number, to be shown in Figure 13 and Figure 14. u ref 1 = u β u ref 2 = u ref 3 = − u β + 3 ⋅uα Eqn. 43 Eqn. 44 2 − u β − 3 ⋅uα Eqn. 45 2 The modified Inverse Clark Transformation projects the quadrature-uβ component into uref1, as shown in Figure 12 and Figure 13; voltages generated by the conventional Inverse Clark Transformation project the direct-uα component into uref1. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 22 Freescale Semiconductor Target Motor Theory Figure 12 depicts the direct-uα and quadrature-uβ components of the stator reference voltage vector US that were calculated by equations uα = cos ϑ and uβ = sin ϑ, respectively. Figure 12. Direct-uα and Quadrature-uβ Components of the Stator Reference Voltage The Sector Identification Tree, shown in Figure 14, can be a numerical solution of the approach shown in Figure 13. Figure 13. Reference Voltages uref1, uref2 and uref3 Figure 14. Identification of the Sector Number Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 23 Target Motor Theory It should be pointed out that, in the worst case, three simple comparisons are required to precisely identify the sector of the stator reference voltage vector. For example, if the stator reference voltage vector resides according to the one shown in Figure 8, the stator reference voltage vector is phase-advanced by 30° from the direct axis, which results in positive quantities of uref1 and uref2 and a negative quantity of uref3; refer to Figure 13. If these quantities are used as inputs to the Sector Identification Tree, the product of those comparisons will be Sector I. Using the same approach identifies Sector II, if the stator reference voltage vector is located as shown in Figure 10. The variables t1, t2 and t3, representing switching duty-cycle ratios of the respective 3-phase system, are found by the following equations: t1 = T − t _1− t _ 2 2 Eqn. 46 t 2 = t1 + t _ 1 Eqn. 47 t3 = t 2 + t _ 2 Eqn. 48 where: T is the switching period t_1 and t_2 are duty-cycle ratios of basic space vectors, given for the respective sector Table 3 and Equation 46, Equation 47, and Equation 48 are specific solely to the standard Space Vector Modulation technique; consequently, other Space Vector Modulation techniques will require deriving different equations. The next step is to assign the correct duty-cycle ratios, t1, t2, and t3, to the respective motor phases. This is a simple task, accomplished in view of the position of the stator reference voltage vector; see Table2-4. Table 4. Assignment of the Duty-Cycle Ratios to the Corresponding Motor Phase Sectors U0, U60 U60, U120 U120, U180 U180, U240 U240, U300 U300, U0 pwm_a t3 t2 t1 t1 t2 t3 pwm_b t2 t3 t3 t2 t1 t1 pwm_c t1 t1 t2 t3 t3 t2 The most popular power devices for motor control applications are Power MOSFETs and IGBTs. A Power MOSFET is a voltage-controlled transistor. It is designed for high-frequency operation and has a low voltage drop, so it has low power losses. However, the saturation temperature sensitivity limits the MOSFET application in high-power applications. An insulated-gate bipolar transistor (IGBT) is a bipolar transistor controlled by a MOSFET on its base. The IGBT requires low drive current, has fast switching time, and is suitable for high switching frequencies. The disadvantage is the higher voltage drop of a bipolar transistor, causing higher conduction losses. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 24 Freescale Semiconductor Target Motor Theory 3.2.3 Vector Control of PMSM Vector control is an elegant method to control a Permanent Magnet Synchronous Motor (PMSM), in which a field-oriented theory controls space vectors of magnetic flux, current, and voltage. It is possible to set up the coordinate system to decompose the vectors into a magnetic field-generating function and a torque-generating function. The structure of the motor controller (vector control controller) is then almost the same as for a separately-excited DC motor, which simplifies the control of PMSM. This vector control technique was developed specifically to achieve a similarly dynamic performance in PMSMs. In this method, the stator current’s field-generating and torque-generating functions must be broken down to able to separately control the magnetic flux and the torque. In order to do so, the rotary coordinate system must be connected to the rotor magnetic field; this system is generally called a “d-q coordinate system”. The transformation from rotary to stationary coordinate systems demands very high CPU performance. The Freescale 56F8357 device is well suited for use in a vector control algorithm. 3.2.4 Block Diagram of Vector Control Figure 15 shows the application’s software modules and hardware. A detailed description of both aspects follows. ia and ib are measured with a current sensor. The Clarke transformation is applied to determine the stator current projection in a two-coordinate non-rotating frame. The Park coordinate transformation is then applied to obtain this projection in the d, q rotating frame. The stator phase current’s d, q projections are then compared to their reference values i*q and i*d (set to 0) and corrected by mean of PI current controllers. The outputs of the current controllers are passed through the inverse Park transformation and a new stator voltage vector is applied to the motor using the Space Vector Modulation technique. Figure 15. Software Modules Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 25 Target Motor Theory 3.2.5 Servo Control of PM Synchronous Motor Sa , Sb , Sc U α ,U β DC Bus Ripple Compensation Inverse Park Transformation d, q - α ,β PI Controller id + + i q* _ PIM U DCBus PI Controller _ i d* = 0 SVPWM Generator iq PMSM ia ib Clarke, Park Transformation a, b, c - α , β - d , q Position Encoder θ PI Controller _ + PI Controller Anti-Hunt _ + θ ref n M/T Figure 16. PMSM Servo Control Scheme The PMSM servo control scheme is illustrated in Figure 16. The controller has an inner loop of current regulation using vector control and an outer loop of hybrid speed and position regulation. The main idea of servo control is: 1. Calculate the position error of the required position and the actual position, returned by the position interrupt program. After Anti-Hunt processing, the position PI controller generates a required speed by the position error. 2. Calculate the speed error of the desired speed and the actual speed as the input of the speed PI controller. The output of the speed PI controller is the desired current component. 3. Calculate the actual currents in the d, q coordinate system. The current’s PI controllelr compares the required currents to generate the desired output voltages. 4. Incorporated with the DCBus voltage ripple elimination algorithm, the SVPWM then generates the PWM signal to drive the servo motor. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 26 Freescale Semiconductor Servo Control System 4 Servo Control System 4.1 System Concept The motor servo control system is designed to drive a 3-phase Permanent Magnet Synchronous Motor (PMSM) in a servo system. The application meets the following performance specifications: • Vector control of a PMSM using the quadrature encoder as a position and speed sensor • Targeted for the 56F8357EVM • Runs on a 3-phase PMSM control development platform at 36V DC • The control technique incorporates: — Vector Control with position closed-loop and speed closed-loop — Rotation in both directions — Starts from any motor position with rotor alignment — Minimum speed of 5rpm — Maximum speed of 600rpm at input power line 36V DC • Manual interface includes: — Start/Stop switch — Position/speed switch, — Set value/actual value display switch — Up/Down push button control — LED indicator — Power supply — Alarm — Position/speed — Run/stop • PC master software control interface includes: — Motor start/stop — Speed set up • PC master software remote monitor • Overvoltage, undervoltage, overcurrent fault protection Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 27 Servo Control System The PM synchronous drive introduced here is designed to power a PMSM with a quadrature encoder. Its specifications are detailed in Table 5. Table 5. System Specifications Motor Characteristics Drive Characteristics 4.2 Motor Type 4 poles, 3-phase, star-connected, PMSM Speed Range 8600rpm (195V rated line voltage) Maximum Electrical Power 201W Phase Voltage 3*195V Phase Current 1A Speed Range < 1000rpm Input Voltage 36V DC Maximum DCBus Voltage 36V DC Control Algorithm Position/Speed Closed-Loop Control Optoisolation Required Servo Control Drive Concept A standard system concept is used with this drive. The system incorporates the following hardware: • 3-phase PMSM development platform • Feedback sensors for: — Position (Quadrature Encoder) — DCBus voltage — Phase currents • 56F8357EVM The drive can be controlled in two different operating modes: • In the Manual operating mode, the required position or speed is set by the Start/Stop switch and the Up/Down push buttons. Position/Speed control is selected by the Position/Speed switch. • In the PC master software operating mode, the required position or speed and Start/Stop switch are set by the PC. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 28 Freescale Semiconductor Servo Control System Permanent Magnet AC Synchronous Motor Servo System Line AC PIM Module AC PMSM DC Clear Udc GPIO PE Driver PE Driver PE Driver Application Control Display Control PE Driver Fault Protection Position_required Speed_required Position_required Positon PI Controller Speed_required Speed_actual Position_actual Current d PI Controller U_AlphaBeta_Comp.alpha U_AlphaBeta_Comp.beta PE Driver PE Driver PE Driver SVPWM waveform Modulation U_DQ.q_axis U_AlphaBeta.alpha SinCos.sine SinCos.cosine i_AlphaBeta. beta theta_actual_el i_abc.PhaseA i_AlphaBeta. alpha Forward Park Transformation a,ß-d,q Position & Speed Sensing DC-bus ripple Compensation U_AlphaBeta.beta U_DQ.d_axis i_dq. q_axis i_dq. d_axis Quadrature Decoder Break Control Inverse Park Transformation d,q-a,ß i_dq_required.d_axis ADC pwm.PhaseA pwm.PhaseB pwm.PhaseC PE Driver u_dc_bus i_dq_required.d_axis Current q Speed PI PI Controller Controller PWM GPIO u_dc_bus GPIO Is_a SCI Hardware Faults Isb Set Real LED LCD Isa Position Start Up Down Speed Stop Is_b PC Master Forward Clark Transformation a,b-a,ß i_abc.PhaseB Current Sensing Prosessing Figure 17. PMSM Servo System Control Scheme 4.3 Servo Control Process The servo control scheme of the PMSM is illustrated in Figure 17. The controller has an inner loop of current regulation using vector control, and an outer loop of hybrid speed and position regulation. When the Start command is accepted (using the Start/Stop Switch or the PC master software command), the required position is calculated according to the Up/Down push buttons or PC master software commands. Proceeding through an acceleration/deceleration ramp, the reference speed is calculated according to the error between the required position and the actual measured position. The reference speed is put to the speed controller. The actual speed is calculated from the pulses of the Quadrature Encoder. The comparison between the required speed command and the actual measured speed generates a speed error. Based on the error, the speed controller generates a current, i_dq_required.q_axis, which corresponds to torque. A second part of the stator current, i_dq_required.d_axis, which corresponds to flux, is given by the Field-Weakening Controller. Simultaneously, the stator currents Is_a and Is_b are measured and transformed from instantaneous values into the stationary reference frame, and consecutively into the rotary reference frame d-q (Park—Clarke transformation). Based on the errors between the required and actual currents in the rotary reference frame, the current controllers generate output voltages U_DQ.q_axis and U_DQ.d_axis (in the rotary reference frame d-q). The voltages U_DQ.q_axis and U_DQ.d_axis are transformed back into the stationary reference frame. After DCBus ripple elimination, they are recalculated to the 3-phase voltage system, which is applied to the motor. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 29 System Hardware Design Besides the main control loop, the DCBus voltage and the motor phase current are measured during the control process. They are used to protect the drive from overvoltage, undervoltage and overcurrent. If any of these faults occur, the motor control PWM outputs are disabled in order to protect the drive, and the fault state of the system is displayed by the on-board LED. This dual-loop structure ensures a fast torque response by using vector control, high position accuracy with the position controller, and fast tracking performance with hybrid (speed and position) control. The structure is also important to secure the stability of the system. 5 System Hardware Design 5.1 Hardware Structure The 56F8357-based servo system hardware structure is shown in Figure 18. The hardware comprises a 56F8357EVM board, a power electronics board and one PMSM servo motor with an optical encoder. The power electronics board integrates with the Intelligent Power Module (IPM) and PWM power drivers, voltage, current sensing and protection circuits, position detection circuits, LCD/LED display circuits and power supply circuit. R S 2 3 2 PC Master Control Display 12 bit A/D Voltage Current LCD/LED Display SERVO CONTROL SVPWM Generator G P I O Up speed Down speed PIM Drive Module FOC PI PI Run/Stop P W M Speed PI Position Freescale 56F8357EVM T I M E R D E C O D E R Quadrature PMSM Figure 18. PMSM Servo System Control Structure 5.2 56F8357EVM Board (see the EVM Reference Manual) Freescale’s 56F8357EVM board has been used in this application; for details see the 56F8357 Evaluation Module User Manual. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 30 Freescale Semiconductor System Hardware Design 5.3 Main Power Circuit A PIM P549-A-PM is the chosen power stage. One PIM includes one 3-phase input rectifier, one brake chopper, and one 3-phase inverter IGBT + FRED with open emitter. The structure is shown in Figure 19. When the system is supplied with DC power, it’s connected as shown in Figure 20. In this structure, the +36V DC power supply is connected between pins 18 and 5. Pin 4 is connected to the brake circuit. A brake resistor is connected between pins 18 and 20. Six PWM drive signals come from the PWM drive circuit. The DC voltage and two output phase currents are sampled and sent to the 56F8357. Figure 19. PIM Structure 1K 12 13 PWMOUT1 A_CENTER R37 2K R39 14 15 PWMOUT3 B_CENTER 3K 16 17 PWMOUT5 C_CENTER 8 7 6 5 OPT11 TLP559 33/100R 4 20 50/5W 1 2 3 4 BR R42 330 T G1 E1 G3 E3 G5 E5 S R G2 E2 G6 E6 BR DB P2 18 P1 19 R40 JP22 N2 5 N1 3 PIM-P549-A-PM R38 NTC2 2 R36 NTC1 1 IBIN IAIN +15(V) NPN 2S2412KR G4 E4 21 22 23 6 7 PWMOUT6 8 9 PWMOUT4 10 11 PWMOUT2 UDCIN +3.3V EARTH Main Circuit Figure 20. Main Circuit Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 31 System Hardware Design 5.4 PWM Driver Circuit A simple and reliable gate drive circuit based on a high-and-low side driver; an IC IR2110 is used. In this circuit, only one +15V power supply is needed to control the six IGBT inverters. Once the system is reset or if a hardware error occurs, an error protection signal is produced. The error signal will block all PWM signal outputs in hardware. The driver circuit for one side is shown in Figure 21. +15(V) R16 8 7 3 6 4 5 C22 0.1uF/63V C21 47uF/25V SD1 2 2 R17 10k 1 1 OPT4 TLP559 330 EARTH VDD1 +3.3V 2 7 R18 3 6 R19 10k 330 4 5 +15(V) OPT6 TLP559 8 +3.3V 2 7 R20 3 6 R21 10k 4 5 +15(V) D18 1N4148 R30 DIODE PWMOUT1 22 A_CENTER 0.1uF/400v C37 R31 2 2 0.1uF/25v HFA25TB60 D12 C36 0.1uF/25V 22 D13 PWMOUT2 D19 DIODE 2 C35 7 6 5 4 3 2 1 1 1 LIN1 EARTH 1 VDD1 HIN1 SD1 LIN1 VSS1 IR2110 HO Vb Vs NC VCC COM LO C26 0.1uF/63V C25 47uF/25V +15(V) D9 NC VDD HIN SD LIN VSS NC VSS1 2 330 JP18 HIN1 EARTH 1 1 8 9 10 11 12 13 14 C24 0.1uF/63V C23 47uF/25V 2 ERROR PWM1 PWM2 8 1 1 +15(V) OPT5 TLP559 1N4148 One Phase Driver Figure 21. One Phase PWM Driver Circuit Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 32 Freescale Semiconductor System Hardware Design 5.5 DC Voltage and Phase Current Sample Circuit A DC voltage sample circuit is shown in Figure 22. DC voltage is sensed by a voltage transducer, LEM (LV28-P) supplied with +15V. Through a voltage follower circuit and a simple voltage divider circuit, the voltage signal is sent to the 56F8357’s A/D port. In this system, the LEM’s power resistor is 3.6K, the LEM’s primary side current is 10mA, the secondary output current is 25mA, and the sampling resistor is 100Ω, creating a maximum input voltage of 36V, which is converted into a 2.5V output voltage to the A/D port. UDCIN R45 5K C51 R46 30k/8w -15V R52 10k R50 2.2K +15V JP24 +15V 1 7 1 3 4 5 -15V U1 UDC_INPUT 3 6 LEM-U 2 R47 OP07 200.1%.0.5W R49 R51 10k -15V R54 10K D24 DIODE U4B 2 1 2.2K C49 0.1uF 6 3 7 UDC A/D 5 8 GROUND R53 10K U4A 8 4 UDCOUT 2.5V C50 0.024uF 4 2 10nF LM358 LM358 R55 4.7K +15V Voltage Detect D25 DIODE Figure 22. DCBus Voltage Detection Circuit The output phase current sample circuit is shown in Figure 23. The phase current is sensed by a current voltage transducer, LEM (LA28-NP). The LEM scale is 5A, the primary maximum input current is 1.65/5 * 10 = 3.3mA, the secondary output current is 1.65/5 * 25 = 8.25mA, and the sampling resistor is 300Ω, creating a maximum voltage of 2.475V. Through a follower circuit and a simple divider circuit, the maximum voltage to the A/D port is 2.475/2 + 2.5/2 = 2.4875V and the minimum voltage is -2.475/2 + 2.5/2 = 0.0125V. R65 JP25 LEM-IA-5A IAIN +2.5V 5K C54 11 -15V 12 +15V +15V R59 2.2K -15V U2 IA_INPUT 3 R61 6 2 R56 200.1%.0.5W OP07 R63 10K C53 0.024uF R58 10K 2.2K C52 0.1uF D26 DIODE 10nF U5B 4 13 R60 10k 1 7 IAOUT 1 2 3 4 5 7 8 9 10 6 6 U5A 2 7 1 5 IA A/D 3 LM358 8 4 8 LM358 R62 10K R64 5K D27 DIODE IA OverCurrent Detect IA -15V +15V +2.5V Phase Current Detect Figure 23. Phase Current Detection Circuit The voltage signal obtained is sent to the 56F8357’s A/D port. The sensed voltage and current signals are also used as hardware and software protection signals, such as undervoltage, overvoltage and overcurrent. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 33 System Hardware Design 5.6 Position and Speed Sensing When the motor rotates, each channel of the embedded optical encoder supplied with +5V DC generates 1024 pulses and one index pulse per mechanical revolution. Through the quadruple differential line receiver, IC 26LS32, the differential signals of A+ and A-, B+ and B-, Z+ and Z- are converted to signal A, B and Z. These signals are connected to the controller’s quadrature decoder port with optical coupler isolation. The position/speed detection circuit is shown in Figure 24. 3.3V 1 A OPT1 TLP559 8 2 7 3 6 4 R5 330 5 R8 1.9k JP1 11 10 9 8 7 6 5 4 3 2 1 C_CENTER IBOUT IAOUT +5V GND A+ AB+ BZ+ Z- 3.3V GND +5V JP4 1 2 3 4 5 6 7 8 +5V 12 HEADER 16 15 14 13 12 11 10 9 1 OPT2 TLP559 8 B 2 7 3 6 4 R6 330 5 R9 1.9k 1 2 5 7 9 11 13 3 4 6 8 10 12 14 B A Z 74HC14 26LS32 3.3V +3.3V +5V JP3 PR JP5 1 2 3 4 5 6 7 8 9 C1 0.01uF 1 OPT3 TLP559 8 Z 2 7 3 6 4 R7 330 5 R10 1.9k Position/Speed Detect Figure 24. Position/Speed Detection Circuit Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 34 Freescale Semiconductor System Hardware Design 5.7 Overcurrent Protection Circuit To protect the system, an overcurrent signal is produced when an overcurrent fault is detected and the related LED is lighted. An ERROR signal created with the signals of BR and RESET is used to block the PWM signals. The circuit is shown in Figure 25. In this circuit, TL431 provides a comparison of benchmark voltage. A dual d-type positive-edge-triggered flip-flop IC 74LS74 locks the error signal. This signal will be cleared when the “clear” button is pressed. R95 R94 10K R93 5K +15V 2K +3.3V 1 1 3 4.3V CHK-+REF +3.3 V 0.1uF ·¢¹â±¨¾¯µÆ +15(V) D31 IN4148 + 100 IA IA D32 IN4148 C58 1uF 7 LM311 R78 10K JP29 4 3 2 1 1 R77 100 U7 3 4 CHK+ 2 -15V D33 IN4148 10 11 12 13 1PRE 1CLK 1D 1CLR 2PRE 2CLK 2D 2CLR +15V 1Q 1Q 2Q 2Q 5 R87 +3.3V 1K R88 10k 6 9 8 IERROR 74LS74X2 -4.3ERROR 10K R83 2 R82 100 R8410K 3 7 LM311 1 + 5 IERROR 4 BR C60 10uF/25V 6 R85 10K 74LS08 C61 0.1uF D36 TL431 2 3 U1C CHK--REF -4.3V clear S2 CLR 1 74LS08 U1B -15V 10uF/10V 2 3 4 C62 U1A U8 R81 100 C59 1uF 5 6 8 CHK- + D30 IN4148 +4.3VERROR 2 R79 10K R76 R80 3K 5 10uF/10V 6 8 C64 D35 LED 2 C63 1 2 TL431 D37 ERROR 10 R86 33K 8 9 D34 IN4148 RESET 74LS08 1 +3.3V 15V R92 5K R91 10K R90 R89 10K 2K Over Current Protect Figure 25. Overcurrent Protection Circuit Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 35 System Hardware Design 5.8 LCD Display Circuit The LCD Display circuit is shown in Figure 26. In this system, an 8-bit LCD displays the set/actual speed/position value. An octal bus transceiver, IC 74ls245, changes the bus voltage from 3.3V to 5V. An 8-bit Parallel-Out Serial-In Shift Register, 74F164, saves the I/O port. C67 0.1uF JP35 +5(V) +5(V) 19 1 E DIR B0 B1 B2 B3 B4 B5 B6 B7 R96 10K 1 2 3 4 5 6 7 8 9 18 17 16 15 14 13 12 11 +5(V) 10K resistor bank +5(V) 14 0.01uF C65 A0 A1 A2 A3 A4 A5 A6 A7 GND 10 +5(V) 2 3 4 5 6 7 8 9 VCC 20 D0 D1 D2 D3 +5(V) JP32 JP31 74LS245 1 2 8 +5(V) 9 A Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7 B CLK MR C66 0.01uF 7 LCD Display AD0 AD1 AD2 AD3 AD4 AD5 AD6 AD7 VSS VDD VO RS R/W E DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 LEDK LEDA 16PINLCD JP34 JP33 3 AD0 4 AD1 5 AD2 6 AD3 10AD4 11AD5 12AD6 13AD7 74F164 +5(V) 1 2 3 4 5 6 AD0 7 AD1 8 AD2 9 AD310 AD411 AD512 AD613 AD714 15 16 1 2 3 4 5 6 7 8 9 10K resistor bank Figure 26. LDC Display Circuit Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 36 Freescale Semiconductor System Hardware Design 5.9 Manual Operating Circuit In the manual operating mode, the position/speed setting can be operated by pressing the UP or DOWN push button. The RUN/STOP switch starts or stops operation; a red LED is lighted when the system is running. During operation, the LCD can display the actual value or the set value. The selection is carried out by the LCD select switch. Another switch also selects position/speed. When the related LED is lighted, the system operates in servo control; otherwise, it operates in speed control. The manual operating circuit is shown in Figure 27. +3.3V S111 1 D555 1 2 R1111 2 P/S select GND P/S +3.3V R11 S1 1k LCD Set/Actual value +3.3V S1 Run/Stop 1 D5 1 +3.3V JP6 220 POSITION 1 2 3 4 5 6 7 8 9 DOWN UP S3 S2 10K resistor bank 2 up R11 2 220 Run C22 0.1uF down C23 0.1uF GND RUN/STOP Run/Stop Up Down P/S LCD Figure 27. Manual Operating Circuit Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 37 System Software Organization 5.10 Power Supply Circuit In this system, a multi-group switch power supply provides one +36V DC, one +24V DC, one +5V DC and one ±15V DC. +15V also produces a +12V with via a linear voltage regulator for the EVM supply and +2.5V (Max 6225) for the A/D sample circuit. Another +15V is obtained from +24V via a linear voltage regulator (LM7815), which provides the power for the IR2110. The power supply circuit is shown in Figure 28. D1 +15V JP1 D2 -15V GND +15V EARTH +24V GND +5V EARTH +36V R2 C22 0.1uF 6K D3 GROUND LED JP14 10K D4 10UF 2K D4 FUSE 2K 8 7 6 5 I.C. I.C. OUT TRIM +2.5V R15 C13 + MAX6225 10K UDC GND +3.3V JP16 L7815CV +15(V) 2 + C15 +24V EARTH + C9 10uF/10V C14 0.1uF 3 1 3 2 + C7 2200uF/10V 10UF GND UDCIN FUSE2 JP90 spx1117 C12 1uF I.C. IN NR GND R4 LED C22 0.1uF 1 2 3 4 +15V C11 + LED R4 1 GND R3 C22 0.1uF C22 0.1uF C6 0.1uF 1 GND 2 +12V 3 C4 C5 GND 4 0.1uF2200uF/25V HEADER 4 + C3 2200uF/25V 0.1uF LED JP? +12V 2 + C2 6K PowerSouse +5V 1 3 R1 C22 0.1uF 1 2 3 4 5 6 7 8 9 JP9 L7812CV LED 2200uF/50V C16 0.1uF C17 0.1uF + C18 2200uF/25V C10 0.1uF GND EARTH Power Supply Figure 28. Power Supply 6 System Software Organization The program SERVOPMSM.C contains three main modules: • The Main module • The ADC Interrupt module • The Position Interrupt module Additionally, the Button Response Interrupt executes the manual setting and the LCD interrupt performs the LCD display. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 38 Freescale Semiconductor System Software Organization 6.1 Main Module Description After a processor reset, the main module performs the following tasks: • 56F8357 set up: — Core — Watchdog — Clocks — ADC — SCI — General Purpose IO — Quadrature Decoder — PWM • Variables initialization: — Default values • Interrupt source selection and enable • Rotor position alignment • LCD and LED displays • Waiting loop During the waiting loop, communication is performed between the 56F8357 and the PC master software. The 56F8357 communicates via its asynchronous serial port to the COM port of a PC. The user can send commands and update variables via this RS-232 link with RXD and TXD interrupt. The flowchart is shown in Figure 29. Start Initialization Enable Interrupt Application Control PC master Software/Manual Control Run/Stop Control Alignment Control Position/Speed Loop Control Up/Down Control LED Indication Control LCD Display Control Brake Control Figure 29. Main Module Flowchart Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 39 System Software Organization 6.2 ADC Interrupt Module Description The ADC Interrupt module performs the entire FOC algorithm. The tasks are: • Sensing DC voltage and 2-phase currents • Calculatin g the sine and cosine value of the present rotor position • Clarke Park transformation • Calculating PI • Inverse Park transformation • Compensating for DCBus ripple • Realizing SVPWM • Outputting PWM In this application, a PWM frequency of 8kHz has been chosen. The current sampling period is 125µs and the interrupt priority is high. A flowchart of the ADC Interrupt module is shown in Figure 30. ADC Interrupt Analog Sensing Processing Currents Sensing-ia, ib Voltage Sensing-DCBus Fault Sin, Cos Generation Current Control Currents Transformation (a, b, c, to d, q) Current d PI Regulator Current q PI Regulator Voltage Transformation (d, q, to α, β) DCBus Ripple Compensation SVPWM Module Sets Duty Circle Fault Control Undervoltage Overvoltage Overcurrent PWM Output Return Figure 30. ADC Interrupt Module Flowchart Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 40 Freescale Semiconductor System Software Organization 6.3 Position Interrupt Module Description The position interrupt module detects speed and position. The main tasks are: — Measuring Position and speed — Position PI controller calculation, which outputs a desired speed — Anti-hunt processing — Speed PI controller calculation which outputs a desired current In this application, the speed and position sampling period is 2ms; the interrupt priority is high. A flowchart is shown in Figure 31. Position Time Interrupt Position Measure Processing Speed Calculation Processing N Servo Control Sin, Cos Generation Y Position Control Anti-Hunt Processing Position PI Regulator Speed Control Speec PI Regulator Speed Ramp Control Return Figure 31. Position Interrupt Flowchart Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 41 System Software Organization 6.4 Button Interrupt Module Description “UP” and “DOWN” buttons increase or decrease the speed/position setting value in the Manual Operating Mode. The two ExInts interrupts respond to the operation; the interrupt priority is medium. The interrupt flowchart is shown in Figure 32. Button Interrupt N Servo Control Y Increasing Position Setting Increasing Speed Setting Return Figure 32. Button Interrupt Flowchart 6.4.1 LCD Interrupt Module A Processor ExpertTM (PE) bean, TimeInt, is used for LCD display. The interrupt period is 10ms and the interrupt priority is low. The LCD Interrupt flowchart is shown in Figure 33. LCD Interrupt Servo Control Display Speed Setting Value Display Position Setting Value Store Actual Value Store Setting Value Store Setting Value Store Actual Value LCD Display Retun Figure 33. LCD Interrupt Flowchart Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 42 Freescale Semiconductor Software Modules 7 Software Modules Processor Expert (PE) offers a wide variety of beans. In this system, the core modules and interface modules also use beans. 7.1 Core Modules The core modules execute the FOC’s varied tasks and include: • Co-ordinate Transformations: Clarke-Park and Inverse Park • Transformation from α, β to d-q coordinates and backwards • Generation of sine and cosine with a look-up table • Variable stator voltage vector generation: Space Vector Modulation (SVM) algorithm • DC ripple compensation • Speed regulation, current regulation, position regulation • Speed ramp • Position alignment • Anti-Hunt processing 7.1.1 Clarke Transformation Figure 34 shows how the 3-phase system is transformed into a 2-phase system. β phase-b isβ isb is -measured isα isa isc -measured α phase-a -calculated phase-c Figure 34. Clarke Transformation Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 43 Software Modules To transfer the graphical representation into mathematical language: ⎡ 1 ⎤ 1 ⎡a ⎤ ⎢1 − 2 − 2 ⎥ ⎢ ⎥ ⎡α ⎤ ⎥⋅ b ⎢β ⎥ = K ⎢ 3 3⎥ ⎢ ⎥ ⎣ ⎦ ⎢ ⎢⎣ 0 2 − Eqn. 49 ⎢c ⎥ 2 ⎥⎦ ⎣ ⎦ In most cases, the 3-phase system is symmetrical, which means that the sum of the phase quantities is always zero. ⎛ ⎝ 1 ⎞ 2 ⎠ 1 2 3 2 α = K⎜a − b − c⎟ = a + b + c = 0 = K a Eqn. 50 The constant “K” can be freely chosen and equalizing the 〈-quantity and a-phase quantity is recommended. Then: α =a⇒K = 2 3 Eqn. 51 The Clarke-Park transformation can be fully defined: ⎡2 ⎡α ⎤ ⎢ 3 ⎢β ⎥ = ⎢ ⎣ ⎦ ⎢0 ⎣⎢ 7.1.2 1 1 ⎤ − ⎥ ⎡a ⎤ ⎡1 0 0 ⎤ ⎡a ⎤ 3 3 ⋅ ⎢b ⎥ = a + b + c = 0 = ⎢ 1 1 ⎥ ⋅ ⎢b ⎥ 1 1 ⎥ ⎢ ⎥ 0 − ⎢ ⎥ ⎢ ⎥ ⎥ ⎢c ⎥ − 3 3 ⎦ ⎢⎣ c ⎥⎦ ⎣ ⎦ ⎣ 3 3 ⎦⎥ − Eqn. 52 Transformation from α, β to d-q Coordinates and Backwards Vector control is performed entirely in the d-q coordinate system to make the control of PM synchronous motors elegant and easy. Of course, this requires transformation in both directions and the control action must be transformed back to the motor side. First, establish the d-q coordinate system: ΨM = ΨMα + ΨMβ sin θ Field = cos θ Field = ΨMβ ΨM ΨMα ΨM Eqn. 53 Eqn. 54 Eqn. 55 Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 44 Freescale Semiconductor Software Modules Then transform from α, β to d-q coordinates: ⎡d ⎤ ⎡ cos ϑField ⎢ q ⎥ = ⎢− sin ϑ ⎣ ⎦ ⎣ Field sin θ Field ⎤ ⎡α ⎤ ⋅ cos θ Field ⎥⎦ ⎢⎣ β ⎥⎦ Eqn. 56 Figure 35 illustrates this transformation. β q ΨMβ ΨM d θ Field ΨMα α Figure 35. Establishing the d-q Coordinate System (Park Transformation) The backward (Inverse Park) transformation (from d-q to α, β) is: ⎡α ⎤ ⎡cos θ Field ⎢ β ⎥ = ⎢ sin θ Field ⎣ ⎦ ⎣ − sin θ Field ⎤ ⎡d ⎤ ⋅ cos θ Field ⎥⎦ ⎢⎣ q ⎥⎦ Eqn. 57 In the PE library, the cptrfmPark, cptrfmClarke, cptrfmClarkeInv, and cptrfmParkInv functions of the MC_ClarkePark bean can calculate the Clarke-Park and Inverse Park transformations. The cptrfmClarke function transforms a 3-phase rotating coordinate system into a 2-phase rotating coordinate system. The cptrfmPark function transforms a 2-phase rotating coordinate system into a 2-phase stationary coordinate system. The cptrfmClarke and cptrfmPark functions’ inverse functions, cptrfmClarkeInv and cptrfmParkInv, respectively, perform inverse transformations. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 45 Software Modules 7.1.3 Generation of Sine, Cosine with a Look-up Table The Park and Park-1 transformation use the value of the rotor electrical position to handle the stator current vector projection in a rotating frame. To obtain both sine and cosine from the electrical angle, a sine look-up table, mcgenSineTable256, is used. The table contains 256 words to represent sine values of electrical angles in the range [0—360°]. As a result: qe’s resolution is limited to 360/256 = .40625° qe = electrical angle / 360° (with qe in the range [0—FFFh]) qe varies from 0 to 4095 (See Section 5.6, “Position and Speed Sensing” for additional information about position sensing) As only 256 words are available to represent this range, qe is divided by 16 and stored into the variable index that will be used to address the look-up table. NOTE To calculate the cosine value of the electrical angle, add 90° to qe 7.1.4 Variable Stator Voltage Vector Generation: Space Vector Modulation Algorithm The MC_SpaceVectorMod bean provides six usable PWM modes. The svmAlt algorithm is used in this system. A Space Vector Modulation is adopted, with nulls that are formed from states O000 in even sectors and O111 in odd sectors. The center-aligned PWM output is used at same time. The SetRatio15 of the PWMMC bean is adopted to output PWM. 7.1.5 DC Ripple Compensation To eliminate the influence of DCBus voltage ripples on the generated PWM waveforms, the DC ripple compensation algorithm is used to compensate for the amplitude of the α and β components of the stator reference voltage vector, US. These imperfections are eliminated as shown in the following equations: ⎧ Index ∗ U α ⎪ U α = ⎨ u _ dcbus ⎪⎩sign(U α ) ∗1.0 ∗ if Index ∗ U α < u _ dcbus 2 Eqn. 58 otherwise Where: Index must be within a fractional range and positive: 0 < Index < 1. The value depends on the modulation technique; i.e., for Space Vector Modulation techniques and Injection of the Third Harmonic, it is equal to 0.866025. Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 46 Freescale Semiconductor Software Modules The y = sign (x) function is defined as follows: ⎧ 1.0 y=⎨ ⎩− 1.0 if x ≥ 0 otherwise Eqn. 59 Where: x = Uα, Uβ are input duty-cycle ratios U*α, U*β are output duty-cycle ratios. In this system, the svmElimDCBusRip bean is adopted to compensate for DC voltage ripple. 7.1.6 Speed Regulation, Current Regulation, Position Regulation PI control is applied in speed, current, and position control. The expression of PI control is: ⎡ 1 u (t ) = K P ⎢e(t ) + TI ⎣ t ⎤ ∫ e(t )dt ⎥⎦ 0 Eqn. 60 Where: u(t) is the controller’s output signal e(t) is the controller’s input error signal KP is proportional factor T1 is the integral time constant If the sampling period, T, is small enough, the discrete PI expression can be written: k ⎡ ⎤ u ( k ) = K P ⎢e ( k ) + K I ∑ e ( j ) ⎥ j =0 ⎣ ⎦ Eqn. 61 Where: k is the sampling order number u(k) is the controller’s output at the sampling time k. e(k) and e(k-1) are input errors at time k and k-1, respectively Integral factor KI = T/T1. The proportional term and the integral term, respectively, are responsible for error sensibility and for the steady state error. The incremental form of the PI algorithm is expressed as: Δu (k ) = u (k ) − u (k − 1) = K P [e(k ) − e(k − 1)] + K I e(k ) Eqn. 62 Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 47 Software Modules One limit of the PI algorithm is that during normal operation, a large reference variation or disturbance may occur, resulting in saturation and overflow of the regulator variables and output. If uncontrolled, this kind of nonlinearity damages the system’s dynamic performance. One solution is to add a correction of the integral component to the previous structure. The improved PI algorithm is: e( k ) = r ( k ) − y ( k ) Eqn. 63 u (k ) = x(k − 1) + K P e(k ) Eqn. 64 uout = u (k ) Eqn. 65 if u (k ) > U max , uout = U max Eqn. 66 if u (k ) < U min , uout = U min Eqn. 67 x(k ) = x(k − 1) + K I e(k ) + K C (uout − u (k )) Eqn. 68 The integral term: Where: Integral correction factor Kc = KI / KP The PItype1_asmSc provided by the PE library is used to calculate the PI controller output for speed, current, and position. 7.1.7 Speed Ramp To decrease speed vibration, the speed ramp uses rampGetValue of the MC_Ramp bean to find the acceleration/deceleration function. The ramp generation chart is shown in Figure 36. If the Requested Value is greater than Actual Value, rampGetValue returns Actual Value + Increment Up until the maximum (Requested Value) is reached, at which point, it returns Requested Value. If the Requested Value is less than Actual Value, rampGetValue returns Actual Value - Increment Down until the minimum (Requested Value) is reached, at which point it returns Requested Value. Figure 36. Ramp Generation Chart Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 48 Freescale Semiconductor Software Modules 7.1.8 Position Alignment After reset, the rotor’s position is unknown. Vector control requires zero position, where the rotor is aligned to the d axis of the d-q coordinate system before a motor begins running, so the rotor must be aligned. The position is first set to zero, independent of the actual rotor position; the value of the Quadrature Encoder does not affect this setting. The Id current is then set to align rotor. The rotor is now aligned to the required position. After rotor stabilization, the Quadrature Encoder is reset to the zero position, the Id current is set back to zero, and alignment is complete. The rotor position is shown in Figure 37. Alignment is executed only once during the first transition from the Stop to the Run state of the Run/Stop switch. β q unknown rotor position (not aligned) zero rotor position (aligned) θ Field = 0 ΨM α d Figure 37. Rotor Alignment The TimeDate bean is used for rotor alignment. The rotor alignment period setting is 5s, and rotor alignment is accomplished during this period. Once the time is reached, the onAlarm function signals to denote the completion of rotor alignment. 7.1.9 Anti-Hunt Processing Special attention is required when the motor reaches the required position, since the rotor will very likely oscillate (hunt). A variable-gain anti-hunt algorithm is developed. As shown in Figure 38, the speed and position regulators’ PI gains are kept normal when the position error is large. When the position error is small enough (in region 1 or 3), the gains should be gradually reduced. Once the rotor enters the anti-hunt window (region 2), the gains are reset to zero. This approach has effectively avoided the rotor oscillation at the stand-still position. 1 2 3 P,I Gains X Position Figure 38. Anti-Hunt PI gain Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 49 Software Modules 7.2 Interface Modules Interface modules are lowlevel routines that convert real word data into suitable numerical counterparts. The interface modules include: 7.2.1 Current, Voltage Sensing Sensing modules directly handle the hardware interface via the integrated peripherals; see Figure 23. Two LEMs (current-voltage transducer) sense the phase currents. The LEM converts the current information from phase a and b into voltage information. The voltage variety range is limited to [0—2.5V] to meet the input range of the 56F8357‘s ADC input voltage specification. Figure 39 illustrates the Current Sensing Scale Translation. Phase current Binary +5A 3102 0A 1551 -5A 0 Figure 39. Current Sensing Scale Translation GetChanValue of the ADC bean calculates a 15-bit sampling value. The sampling value subtracts the value corresponding to zero to find the actual value. These values are stored separately in i_abc.PhaseA, i_abc.PhaseB, and u_dc_bus. 7.2.2 Electrical Position and Mechanical Speed The embedded encoder of this application generates 1024 pulses per mechanical revolution. The A, B, and Index quadrature signals from the position detection circuit (Figure 24) are shown in Figure 40. These signals are sent to the quadrature decoder port of the controller. The QuadratureDecoder bean converts the 1024p/c signal to 4096p/c. GetCounters retrieves the real time position and count difference. With these values, mechanical speed is calculated by the T method. The Index signal also defines the zero position per rotation to count the position pulse. 1 0 4095 4094 1 0 4095 4094 Phase A Phase B Index One revelution Figure 40. Quatrature Encoder Signals Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 50 Freescale Semiconductor User Interface 8 User Interface PC master software is programmed as the user interface to control motor and display variables. VBScript programs the HTML control interface. Figure 41 illustrates the PC master software interface. Figure 41. PC Master Software Control Interface Possible user commands, setting values, and actual values are displayed on the right half of the interface window. The commands include: • Start motor • Stop motor • Increase setting value (UP) • Decrease setting value (DOWN) • PC master software control • Selection of position control/speed control • Position alignment Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 51 User Interface The setting values include: • Absolute position setting • Increment position setting • Mechanical speed setting • Real-time speed value display • Real-time position value display The variables which the waveform could display are listed on the left part of the interface. These variables could be defined in software. Real-time waveforms are illustrated in Figure 42, Figure 43, Figure 44, and Figure 45. Figure 42. Speed Response Waveform from 210rpm to 1000rpm Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 52 Freescale Semiconductor User Interface Figure 43. Position Control Response Waveform (Speed Limitation is 800rpm) Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 53 User Interface Figure 44. Id and Iq Waveform (200rpm) Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 54 Freescale Semiconductor User Interface Figure 45. Id and Iq Waveform (speed from 200rpm to 1000rpm) Design of a PMSM Servo System Using the 56F8357 Device, Rev. 0 Freescale Semiconductor 55 How to Reach Us: Home Page: www.freescale.com E-mail: [email protected] USA/Europe or Locations Not Listed: Freescale Semiconductor Technical Information Center, CH370 1300 N. Alma School Road Chandler, Arizona 85224 +1-800-521-6274 or +1-480-768-2130 [email protected] Europe, Middle East, and Africa: Freescale Halbleiter Deutschland GmbH Technical Information Center Schatzbogen 7 81829 Muenchen, Germany +44 1296 380 456 (English) +46 8 52200080 (English) +49 89 92103 559 (German) +33 1 69 35 48 48 (French) [email protected] Japan: Freescale Semiconductor Japan Ltd. Headquarters ARCO Tower 15F 1-8-1, Shimo-Meguro, Meguro-ku, Tokyo 153-0064 Japan 0120 191014 or +81 3 5437 9125 [email protected] Asia/Pacific: Freescale Semiconductor Hong Kong Ltd. Technical Information Center 2 Dai King Street Tai Po Industrial Estate Tai Po, N.T., Hong Kong +800 2666 8080 [email protected] For Literature Requests Only: Freescale Semiconductor Literature Distribution Center P.O. Box 5405 Denver, Colorado 80217 1-800-441-2447 or 303-675-2140 Fax: 303-675-2150 [email protected] Document Number: AN3301 Rev. 0 08/2006 Information in this document is provided solely to enable system and software implementers to use Freescale Semiconductor 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. Freescale Semiconductor reserves the right to make changes without further notice to any products herein. Freescale Semiconductor makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does Freescale Semiconductor assume any 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 that may be provided in Freescale Semiconductor 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. Freescale Semiconductor does not convey any license under its patent rights nor the rights of others. Freescale Semiconductor 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 Freescale Semiconductor product could create a situation where personal injury or death may occur. Should Buyer purchase or use Freescale Semiconductor products for any such unintended or unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor 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 Freescale Semiconductor was negligent regarding the design or manufacture of the part. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. © Freescale Semiconductor, Inc. 2006. All rights reserved. RoHS-compliant and/or Pb-free versions of Freescale products have the functionality and electrical characteristics as their non-RoHS-compliant and/or non-Pb-free counterparts. For further information, see http://www.freescale.com or contact your Freescale sales representative. For information on Freescale’s Environmental Products program, go to http://www.freescale.com/epp.