Disclaimer: This document was part of the First European DSP Education and Research Conference. It may have been written by someone whose native language is not English. TI assumes no liability for the quality of writing and/or the accuracy of the information contained herein. Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP Authors: S. Grainger, M. Allan, T. Westwood, R. Champaneri ESIEE, Paris September 1996 SPRA323 IMPORTANT NOTICE Texas Instruments (TI) reserves the right to make changes to its products or to discontinue any semiconductor product or service without notice, and advises its customers to obtain the latest version of relevant information to verify, before placing orders, that the information being relied on is current. TI warrants performance of its semiconductor products and related software to the specifications applicable at the time of sale in accordance with TI’s standard warranty. Testing and other quality control techniques are utilized to the extent TI deems necessary to support this warranty. Specific testing of all parameters of each device is not necessarily performed, except those mandated by government requirements. Certain application using semiconductor products may involve potential risks of death, personal injury, or severe property or environmental damage (“Critical Applications”). TI SEMICONDUCTOR PRODUCTS ARE NOT DESIGNED, INTENDED, AUTHORIZED, OR WARRANTED TO BE SUITABLE FOR USE IN LIFE-SUPPORT APPLICATIONS, DEVICES OR SYSTEMS OR OTHER CRITICAL APPLICATIONS. Inclusion of TI products in such applications is understood to be fully at the risk of the customer. Use of TI products in such applications requires the written approval of an appropriate TI officer. Questions concerning potential risk applications should be directed to TI through a local SC sales office. In order to minimize risks associated with the customer’s applications, adequate design and operating safeguards should be provided by the customer to minimize inherent or procedural hazards. TI assumes no liability for applications assistance, customer product design, software performance, or infringement of patents or services described herein. Nor does TI warrant or represent that any license, either express or implied, is granted under any patent right, copyright, mask work right, or other intellectual property right of TI covering or relating to any combination, machine, or process in which such semiconductor products or services might be or are used. Copyright © 1997, Texas Instruments Incorporated TRADEMARKS TI is a trademark of Texas Instruments Incorporated. Other brands and names are the property of their respective owners. CONTACT INFORMATION US TMS320 HOTLINE (281) 274-2320 US TMS320 FAX (281) 274-2324 US TMS320 BBS (281) 274-2323 US TMS320 email dsph@ti.com Contents Abstract ........................................................................................................................... 7 Product Support on the World Wide Web .................................................................... 8 Background..................................................................................................................... 9 Software Algorithm......................................................................................................... 9 Simulation Results ....................................................................................................... 15 Experimental Setup ...................................................................................................... 16 Algorithm Implementation ........................................................................................... 18 Experimental Results ................................................................................................... 20 Summary ....................................................................................................................... 23 Future Work................................................................................................................... 23 References .................................................................................................................... 23 Figures Figure 1. Figure 2. Figure 3. Figure 4. Figure 5. Figure 6. Figure 7. Schematic Representation of the Algorithm ....................................................... 9 Algorithm Flowchart.......................................................................................... 13 Experimental Setup .......................................................................................... 17 Motor BEMF Magnitude.................................................................................... 20 Normalized BEMF ............................................................................................ 21 Permanent Magnet Flux Linkage...................................................................... 21 Calculated Position and Error........................................................................... 22 Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP Abstract This application report presents the theory and practice of implementing a closed-loop sensorless commutation scheme for a trapezoidal brushless DC motor. The implementation consists of a PC-hosted Texas Instruments (TITM) TMS320C25 digital signal processor (DSP). The TMS320C25 functions as a coprocessor running an algorithm to determine the phase voltage switching points. This solution uses the DSP as an alternative to the bulky, temperature sensitive, hall-effect sensors traditionally used. The proposed future works suggests the algorithms successfully used with the TMS320C25 may yield even faster sampling rates with use of TI’s TMS320C30 DSP. This document was part of the first European DSP Education and Research Conference that took place September 26 and 27, 1996 in Paris. For information on how TI encourages students from around the world to find innovative ways to use DSPs, see TI’s World Wide Web site at www.ti.com. Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP 7 SPRA323 Product Support on the World Wide Web Our World Wide Web site at www.ti.com contains the most up to date product information, revisions, and additions. Users registering with TI&ME can build custom information pages and receive new product updates automatically via email. 8 Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP SPRA323 Background A brushless DC motor (BLDCM) is one in which the commutation function normally performed by the brushes and commutator in a traditional DC motor is replaced with an electronic equivalent. This electronic circuit must switch phase voltages on and off at particular instants related to the position of the motor’s rotor. A trapezoidal BLDCM has a trapezoidal flux distribution and is supplied with square wave voltages or currents. For a 3-phase, 2-pole trapezoidal motor, as used in this case, a switching point occurs every 60° but it is necessary to determine this point to within approximately ±2°.1 Software Algorithm For a motor running at speed, the rotor position is most easily deduced from the motor’s back EMF (BEMF); that is, the voltage induced in the phase windings by the action of the rotating magnetic field. With a typical trapezoidal BLDCM there is always one phase not energized. The voltage of this phase can be measured directly. However, as this voltage is proportional to speed, this method cannot be used for startup and slow speed operation. Ertugrul and Acarnley have proposed a more sophisticated method of determining the rotor position as shown schematically in Figure 1 and described below.1 2 Although they used this algorithm to determine the rotor position of a sinusoidal BLDCM in real time, they did not use it to control the motor commutation. Figure 1. Schematic Representation of the Algorithm2 i1i CURRENT ESTIMATION 1 POSITION CORRECTION & POSITION ESTIMATION & PREDICTION CURRENT ESTIMATION 2 FLUX LINKAGE CORRECTION 2 i 3 v 1 v 2 v 3 ∫ INTEGRATOR Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP 9 SPRA323 A commonly used electrical motor model is: vp = ipR + dΨ( i k θ ,Ψ ) f (1) dt where: p = phase number k = total of phases vp = applied phase voltage ip = phase current R = phase resistance Ψ = phase flux linkage ik = current out of all phases θ = rotor position Ψf = flux linkage due to rotor time t = time Expressing this in terms of separate component parts: { v p = ip R + I ∂Ψ dik ∂Ψ dθ ∂Ψ dΨ f + + ∂ik dt ∂θ dt ∂Ψ f dt 14243 123 14243 III II (2) IV where: I II = resistive voltage drop = inductive voltage drop III IV = motional BEMF = voltage change due to reluctance Assuming negligible reluctance effect and negligible nonlinearities due to saturation, the coil and mutual inductances are constant. Therefore: * * * v1 = i1 R + L1,1i1 + M 1,2 i1 + M 1,3i1 + e1 * * * v 2 = i2 R + M 2,1i2 + L2,2 i2 + M 2,3i2 + e1 { 14444244443 * * * v 31 = i3 R + M 3,1i3 + M 3,2 i3 + L3,3i3 + e{1 I 10 II (3) III Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP SPRA323 where: I II III = = resistive voltage drop self and mutual induced BEMF = motional BEMF M* = mutual inductance L* = coil self inductance Substituting the coil self inductance and mutual inductance with an effective inductance, L, and applying a star connection where i1 + i2 + i3 = 0: v1 = i1 R + Li1 + e1 : v2 = i2 R + Li2 + e2 { { v3 = i3 R + Li3 + e{3 I II (4) III where: I II = = resistive voltage drop self and mutual induced BEMF III = motional BEMF L = coil self inductance This equation forms the heart of the algorithm. Expression III can be rewritten as: e=w dΨm( Θeff ) dΘ (5) where: e = normalized BEMF ϖ = phase inductance Θ = rotor angle Θeff = effective rotor angle for a phase From (1) and (4) we can express the flux linkage as: Ψp = Li p + Ψmp Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP (6) 11 SPRA323 where: Ψp = total phase flux linkage L = phase inductance ip = phase current Ψmp = phase flux linkage due to magnet From (1) we can also derive: t Ψ(t ) = ∫ [v (t ) − Ri (t )].dt (7) It can be shown that if changes of current and angle are small: ∆Ψ p = ∂Ψp ∂i ∆i p + ∂Ψp ∂Θ p ∆Θ (8) This equation describes how total flux linkage changes with respect to small changes of phase current and angle. We can set one variable to zero to calculate the other by applying superposition theory as follows: ∂Ψ p ∂i = L, and ∂Ψ p ∂Θ = ep this gives us: ∆Θ p = − L ∆i p ep ∆Ψp = e p ∆Θ (9) (10) As well as electrical equations (9) and (10), the algorithm also uses a second order mechanical equation of motion. Assuming that the load of the motor can be expressed as a system containing torque losses due to friction, torque due to a linear load, and moments of inertia, we have: d 2θ e dθ I Te = [ J + B e + T1 ] 2 P dt dt 12 (11) Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP SPRA323 where: J B = moment of inertia = viscous friction constant Te = resulting torque T1 = constant torque Θ p = rotor angle = no. of pairs of poles The above formulae are used in the algorithm (see Figure 2). Figure 2. Algorithm Flowchart Start Flux linkage estimation Rotor Positon estimation Current error calculation Rotor postiton correction Flux linkage correction Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP 13 SPRA323 To summarize, the algorithm consists of the following steps: 1) Estimate the total phase flux linkage using equation (7). 2) Estimate rotor position using the mechanical equation of motion (10). 3) Calculate current error by comparing measured current with that calculated using equation (6). 4) Correct position estimate using equation (9). 5) Correct flux linkage estimate using equation (10). 14 Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP SPRA323 Simulation Results As part of a continuing study by Allan into applying integrated motor design to optimize motor performance, Weber & Munzenmay developed an implementation of the algorithm written in C and run on a PC.3 4 Motor voltage and current data was collected from PSpice models and an experimental trapezoidal motor. This data was then used offline to determine rotor position as the algorithm could not run sufficiently fast to operate online and in real time. As the offline simulation proved successful, a test setup using a fast DSP has now been designed to fully prove the algorithm running in real-time. In addition, the motor commutation is to be controlled in a closed loop. This study also differs from Ertugrul and Acamley’s work in that a trapezoidal motor is to be used. The nature of the trapezoidal motor currents makes this a more difficult task for the algorithm than for the sinusoidal case. Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP 15 SPRA323 Experimental Setup The experimental setup includes a TI TMS320C25 16-bit fixed point DSP coprocessor card with the following components: q q q q q q q q q 8K words RAM 12-bit 100 kHz analogue-to-digital converter (ADC) 4 TTL digital inputs 4 TTL digital outputs 4 anti-aliased analogue inputs Programmable gain amplifier Dual 12-bit digital-to-analog (DAC) converters 3 16-bit timer/counter channels 16-bit 512 word FIFO interface to the host PC Other equipment includes: q q q q 120 MHz Pentium host PC 3 current interfaces External multiplexer/attenuator Optical shaft encoder motor drive circuitry Figure 3 shows the experimental setup. The multiplexer presents the motor phase currents and voltages to the coprocessor’s ADC. The inverter is driven by the coprocessor’s digital outputs. 16 Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP SPRA323 Figure 3. Experimental Setup Coprocessor ADC input Host PC Inverter control intputs BLDCM Multiplexer Inverter Motor v,1 Motor Power Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP 17 SPRA323 Algorithm Implementation The algorithm was initially coded using the TI C cross compiler, but this proved to be too slow for motor operation above a few rpm. This was primarily due to the use of floating point variables. The algorithm was then coded using the TI cross assembler, which allowed operation up to around 3000 rpm. The DSP internal timer was set to provide interrupts every 167 µs. This rate was chosen because it gives 2° accuracy at 2000 rpm. Conversion of the seven ADC channels (3 phase currents, 3 phase voltages, and the starpoint voltage) takes 70 µs and the calculations takes approximately 90 µs. On receiving a timer interrupt, the DSP proceeds to initiate seven ADC conversions using polling to eliminate any interrupt timing overheads. The various calculations are then performed. The flux estimation based on equation (7) is carried out using the simple integration algorithm: Ψp ( k ) = T (v p ( k ) = Ri p ( k ) ) + Ψp ( k −1) (12) where: Ψp ( k ) = flux at time k T = sampling interval v p( k ) = phase voltage at time k R = phase resistance i p( k ) = phase current at time k Ψp ( k −1) = flux at time k-1 To calculate the rotor position estimate directly from the mechanical equation of motion (11) requires considerable processing time. Because this is a second order function it can be approximated by a second order polynomial: θ = at 2 + bt + c By fitting this polynomial to position data at k − 2 , k − 1 and k , the position at time k + 1 can be predicted. Let t = 0 at time k − 2 : 18 Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP SPRA323 θ k −2 = c θ k −1 = aT 2 + bT + c θ k = 4aT 2 + 2bT + c θ k +1 = 9aT 2 + 3bT + c Solving: θ k +1 = 30 k − 30 k −1 + θ k −2 (13) To obtain the current error, equation (6) is rearranged and subtracted from the measured current to give: ∆i p = i p − Ψmp − Ψp L (14) The permanent magnetic flux linkage, Ψmp is obtained from a look up table. The rotor position and flux linkage corrections are calculated from equations (9) and (10). The BEMF value, e p , is obtained from a look up table. The above calculations are carried out three times, once per phase, resulting in three position values. These values are averaged to provide the final position estimate. This final position estimate is used to determine when to switch the motor phase voltages. This is done by writing the appropriate bit pattern to the digital outputs. These outputs drive power transistors in the inverter module. Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP 19 SPRA323 Experimental Results As implemented, the algorithm requires the motor BEMF to be available from a look up table. The BEMF is normalized against speed to keep the table within reasonable proportions. This approach is only valid if the BEMF magnitude is linearly proportional to motor speed. This was tested by driving the test motor mechanically from another motor and measuring the BEMF at the motor phase winding terminals. Figure 4 shows the results and confirm that the BEMF is approximately linear over the proposed speed range from 1000 rpm to 3000 rpm. Figure 4. Motor BEMF Magnitude 2.5 ♦ ♦ ♦ 2 ♦ BEMF (V) 1.5 ♦ 1 ♦ ♦ 0.5 0 0 1000 2000 3000 4000 Speed (rpm) By dividing the BEMF at any one speed by the speed, the normalized BEMF can be obtained. This was done and the normalized BEMF was stored in a table at one value per degree of rotation (see Figure 5). 20 Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP SPRA323 Figure 5. Normalized BEMF 1.00E-02 BEMF 5.00E-03 0.00E-00 0 90 180 270 -5.00E-03 -1.00E-02 Rotor position (degrees) The permanent magnet flux linkage required by the current error formula is also obtained from a look up table. Integrating the normalized BEMF data, as shown in Figure 6, produced the look up table. Figure 6. Permanent Magnet Flux Linkage -1.00E-02 Flux (Webers) -1.00E-02 -1.00E-02 0 90 180 270 -1.00E-02 -1.00E-02 Rotor position (degrees) Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP 21 SPRA323 With the motor-specific data in place, the rotor position algorithm could be tested. This was done by running the motor up to a constant speed of 2000 rpm using traditional hall effect sensors to provide commutation information. Once the motor reached a stable speed, the commutation function was taken over by the DSP. The motor continued to operate normally. The calculated rotor position and position error are shown in Figure 7. Figure 7. Calculated Position and Error _______Position . . . . . . . . . .Error 400 4 2 300 250 0 200 -2 150 100 Error (degrees) Calculated position (degrees) 350 -4 50 -6 0 Time (7.5ms/div) Although the algorithm is designed to operate over a wide speed range, including start up, this could not be shown to operate correctly. The failure to operate at start up appears to be caused by instability in the current error calculation section, brought on by spikes in the measured phase currents. 22 Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP SPRA323 Summary Although the algorithm functions correctly under certain stable operating conditions, problems remain. Most importantly, while it is possible to start the motor open loop, it is desirable that the algorithm operate at start up. Additionally, the algorithm has an inherent limitation in that the initial position of the rotor must be known before start up. This is necessary to provide the correct initial values to the position prediction polynomial and ensure that the correct initial values are retrieved from the BEMF and flux tables. Future Work The possibility of filtering any sudden changes in the current error needs to be examined. Additionally, the stability of the algorithm under step changes in load and speed must be fully explored. Finally, there would be advantages in coding the algorithm for a floating point DSP, such as the TMS320C30. A significant increase in processing speed would allow for faster sampling rates. Coding of experimental algorithm changes would be made much simpler as variable scaling (due to the fixed point nature of the TM5320C25) would not be required. References 1 N. Ertugrul; Position Estimation and Performance Prediction for Permanent Magnet Motor Drives; PhD Thesis, University of Newcastle upon Tyne, 1993 2 P.P. Acamley, N. Ertugrul; "Rotor Position Estimation In PM Motors"; ICEM 1992 3 M. Allan, I, Kemp, T. Westwood, B. Pitches; "Application Flexible Design Strategies For Power Electronic Drives"; PCIM ’90, Munich, West Germany, June 25-29, 1990 4 M. Weber, M. Munzenmay; A Signal Processing Approach To Position Measurement In Electrical Machines; Diploma Thesis, Glasgow Caledonian University, January 1996 Sensorless Control of a Trapezoidal Brushless DC Motor Using the TMS320C25 DSP 23