Motor Speed Measurement Considerations When Using TMS320C24x DSPs



Similar documents
SDLS068A DECEMBER 1972 REVISED OCTOBER Copyright 2001, Texas Instruments Incorporated

SN54165, SN54LS165A, SN74165, SN74LS165A PARALLEL-LOAD 8-BIT SHIFT REGISTERS

Controlling TAS5026 Volume After Error Recovery

Binary Search Algorithm on the TMS320C5x

Designing Gain and Offset in Thirty Seconds

Filter Design in Thirty Seconds

Current-Transformer Phase-Shift Compensation and Calibration

Using C to Access Data Stored in Program Space Memory on the TMS320C24x DSP

RETRIEVING DATA FROM THE DDC112

How To Close The Loop On A Fully Differential Op Amp

Pressure Transducer to ADC Application

CUSTOM GOOGLE SEARCH PRO. User Guide. User Guide Page 1

Analysis of Filter Coefficient Precision on LMS Algorithm Performance for G.165/G.168 Echo Cancellation

High-Speed Gigabit Data Transmission Across Various Cable Media at Various Lengths and Data Rate

Wireless Subwoofer TI Design Tests

Using C to Access Data Stored in Program Memory on the TMS320C54x DSP

Texas Instruments. FB PS LLC Test Report HVPS SYSTEM AND APPLICATION TEAM REVA

Application Report. 1 Description of the Problem. Jeff Falin... PMP Portable Power Applications ABSTRACT

August 2001 PMP Low Power SLVU051

Multi-Transformer LED TV Power User Guide. Anderson Hsiao

APPLICATION BULLETIN

Standard Linear & Logic Semiconductor Marking Guidelines

Floating Point C Compiler: Tips and Tricks Part I

Design Note DN004. Folded Dipole Antenna for CC25xx By Audun Andersen. Keywords. 1 Introduction CC2500 CC2550 CC2510 CC2511

Data sheet acquired from Harris Semiconductor SCHS067B Revised July 2003

Application Note AN107

LM5030 LM5030 Application: DC - DC Converter Utilizing the Push-Pull Topology

Data sheet acquired from Harris Semiconductor SCHS087D Revised October 2003

Signal Conditioning Wheatstone Resistive Bridge Sensors

THE RIGHT-HALF-PLANE ZERO --A SIMPLIFIED EXPLANATION

SN54HC157, SN74HC157 QUADRUPLE 2-LINE TO 1-LINE DATA SELECTORS/MULTIPLEXERS

APPLICATION NOTE BUILDING A QAM MODULATOR USING A GC2011 DIGITAL FILTER CHIP

Application Report. 1 Introduction. 2 Resolution of an A-D Converter. 2.1 Signal-to-Noise Ratio (SNR) Harman Grewal... ABSTRACT

Application Report SLVA051

AN2604 Application note

Using the Texas Instruments Filter Design Database

Data sheet acquired from Harris Semiconductor SCHS020C Revised October 2003

SN28838 PAL-COLOR SUBCARRIER GENERATOR

TI and ibiquity Introduce Industry s Lowest Cost Single-Chip AM/FM and HD Radio Baseband John Gardner Digital Radio Marketing Manager

Calculating Gain for Audio Amplifiers


SN54HC191, SN74HC191 4-BIT SYNCHRONOUS UP/DOWN BINARY COUNTERS

Using Code Coverage and Multi-event Profiler in Code Composer Studio v2.3 for Robustness and Efficiency Analyses

AN3332 Application note

SINGLE-SUPPLY OPERATION OF OPERATIONAL AMPLIFIERS

SN54F157A, SN74F157A QUADRUPLE 2-LINE TO 1-LINE DATA SELECTORS/MULTIPLEXERS

PCIe XMC x8 Lane Adapter

WHAT DESIGNERS SHOULD KNOW ABOUT DATA CONVERTER DRIFT

IMPORT/EXPORT CUSTOMER REVIEWS. User Guide. User Guide Page 1

TSL INTEGRATED OPTO SENSOR

Fast Logarithms on a Floating-Point Device

TSL250, TSL251, TLS252 LIGHT-TO-VOLTAGE OPTICAL SENSORS

How To Make A Two Series Cell Battery Pack Supervisor Module

SN54ALS191A, SN74ALS191A SYNCHRONOUS 4-BIT UP/DOWN BINARY COUNTERS

Managing Code Development Using CCS Project Manager

EMC6D103S. Fan Control Device with High Frequency PWM Support and Hardware Monitoring Features PRODUCT FEATURES ORDER NUMBERS: Data Brief

Design Note DN304. Cebal CCxxxx Development Tools USB Driver Installation Guide By Åsmund B. Bø. Keywords. 1 Introduction

SEO Meta Templates. Magento Extension. User Guide. SEO Meta Templates

Audio Tone Control Using The TLC074 Operational Amplifier

APPLICATION NOTE. Atmel AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Atmel AVR 8-bit Microcontroller. Introduction.


Important Notice. All company and brand products and service names are trademarks or registered trademarks of their respective holders.

µa7800 SERIES POSITIVE-VOLTAGE REGULATORS

1. Installation Instructions

A Low-Cost, Single Coupling Capacitor Configuration for Stereo Headphone Amplifiers

IrDA Transceiver with Encoder/Decoder

SEO Suite Pro. User Guide

Theory of Operation. Figure 1 illustrates a fan motor circuit used in an automobile application. The TPIC kω AREF.

QUADRO POWER GUIDELINES

bq2114 NiCd or NiMH Gas Gauge Module with Charge-Control Output Features General Description Pin Descriptions

AMC1100: Replacement of Input Main Sensing Transformer in Inverters with Isolated Amplifier

Smart Battery Module with LEDs and Pack Supervisor

Optical Implementation Using IEEE-1394.b

Signal Conditioning Piezoelectric Sensors

Simplifying System Design Using the CS4350 PLL DAC

Using the Scripting Utility in the Code Composer Studio Integrated Development Environment

LM556 LM556 Dual Timer

WAN_0240. I 2 S USB Audio Streaming INTRODUCTION IDENTIFYING THE FIRMWARE HARDWARE CONFIGURATION SOFTWARE CONFIGURATION

Monitoring TMS320C240 Peripheral Registers in the Debugger Software

IMPORT/EXPORT COUPON/SHOPPING CART RULES. User Guide. User Guide Page 1

EDI s x32 MCM-L SRAM Family: Integrated Memory Solution for TMS320C3x DSPs

Evaluating the complex configuration options of the Texas Instruments advanced fuel gauges can be

Understanding the Terms and Definitions of LDO Voltage Regulators

DUAL MONITOR DRIVER AND VBIOS UPDATE

TMS320C67x FastRTS Library Programmer s Reference

AN4646 Application note

EDI s x32 MCM-L SRAM Family: Integrated Memory Solution for TMS320C4x DSPs

Buffer Op Amp to ADC Circuit Collection

INTEGRATED CIRCUITS. NE558 Quad timer. Product data Supersedes data of 2001 Aug Feb 14

6 Output With 1 kω in Series Between the Output and Analyzer Output With RC Low-Pass Filter (1 kω and 4.7 nf) in Series Between the Output

TS555. Low-power single CMOS timer. Description. Features. The TS555 is a single CMOS timer with very low consumption:

Providing Continuous Gate Drive Using a Charge Pump

ZigBee Sensor Monitor SWRU157D 2008 Low-Power RF

ORDERING INFORMATION. TOP-SIDE MARKING PDIP N Tube SN74LS07N SN74LS07N PACKAGE. SOIC D Tape and reel SN74LS07DR

AN3252 Application note

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

DATA SHEET. PBSS5540Z 40 V low V CEsat PNP transistor DISCRETE SEMICONDUCTORS. Product data sheet Supersedes data of 2001 Jan Sep 21.

X8 Option 2 - Technology

Transcription:

Application Report SPRA771 - August 2001 Motor Speed Measurement Considerations When Using TMS320C24x DSPs Shamim Choudhury DCS Applications ABSTRACT The TMS320C24x generation of DSPs provide appropriate internal hardware for interfacing with low-cost, external-speed sensors for motor speed measurement applications. The periodic output signal from the speed sensor is applied to the capture input pin of the DSP and the signal s period is measured. This information is then used to calculate the motor speed. However, this calculation of motor speed depends on several system parameters. These parameters affect the scaling and normalization factors that must be used in the speed calculation routine for accurate measurements. This application report, therefore, gives an analysis of the speed measurement system to show the effect of system parameters on the calculated speed. The choice of appropriate scaling and normalization factors for a given system is also discussed. Finally, code examples are given to show the software implementation of the speed calculation routine. Contents 1 Motor Speed Measurements.......................................................... 2 2 Effect of System Parameters on Speed Calculations................................... 3 2.1 Case1........................................................................... 3 2.2 Case 2.......................................................................... 4 2.3 Case 3.......................................................................... 5 3 Speed Calculation from Period Measurements......................................... 6 4 Code Examples...................................................................... 7 4.1 Case 1.......................................................................... 7 4.2 Case 2.......................................................................... 8 List of Figures Figure 1. Speed Measurement With a Sprocket............................................... 2 Figure 2. Calculation of Speed............................................................. 6 Figure 3. 32-Bit/16-Bit Division............................................................. 6 TMS320C24x is a trademark of Texas Instruments. All trademarks are the property of their respective owners. For a complete list of TI DSP devices, go to the TI web site at http://www.ti.com 1

1 Motor Speed Measurements Low-cost shaft sprockets, having multiple teeth, are widely used with the Hall effect gear-tooth sensor for motor speed measurements. Figure 1 shows some of the physical details of a sprocket that affect the speed measurement. The Hall effect sensor generates a square-wave output signal every time a tooth rotates within its proximity. If the sprocket has n teeth, then the resultant pulse rate is n pulses per revolution. The Hall effect sensor output is fed directly to the C24x Capture input pin. This unit captures the value of its base timer counter on either the rising or falling edges (whichever is specified) of the Hall effect sensor output. The captured value is then stored in a variable for later use in speed calculation. We will call this variable time_stamp. During the implementation of the software for the speed calculation, for every time a new value of time_stamp becomes available the current value is first saved in a variable. Let us call this variable time_stamp_old. Then the new value is loaded in another variable, which we will call time_stamp_new. The two values are then compared and, thus, the tooth-to-tooth period (t 2 t 1 ) value is calculated. In order to reduce jitter or period fluctuation, an average of the most recent n period measurements can be performed each time a new pulse is detected. t 1 t t t 2 t 1 sec t 2 360 25 14.4 25 teeth 25 n1 2 t n radsec Figure 1. Speed Measurement With a Sprocket From the two consecutive time_stamp values, the difference between the captured values is calculated as, time_stamp_new time_stamp_old Then the time period in seconds is given by t t 2 t 1 K P where K P is the prescaler value for the capture unit time base. is the CPU clock period in seconds. CPU clock is used as capture unit time base with user selectable prescaler K P. From Figure 1, the angle in radian is given by 2 n C24x is a trademark of Texas Instruments. 2 Motor Speed Measurement Considerations When Using TMS320C24x DSPs

where n is the number of teeth in the sprocket. Then the speed, in radian/sec, and the normalized speed N are calculated as t 2 nt 2 n K P N max 1 2 1 Here, max is the maximum value of, which occurs when =1. Therefore, max 2 The corresponding maximum speed, N max in rpm, that can be measured is calculated as N max 60 2 Effect of System Parameters on Speed Calculations TMS320C24x generation of DSPs provides different CPU clock frequencies and different clock prescaler values for it s capture units. These will affect the software implementation of the speed measurement algorithm. Also, depending on the number of teeth in the sprocket and the actual maximum speed of the motor being used, the implementation of the speed measurement algorithm needs simple modifications for accurate calculation of motor speed. In this section a few examples are provided to show the necessary modifications for correct measurement of motor speed. 2.1 Case1 For a system based on 20MHz CPU clock ( = 50 x 10 9 sec), K P = 32 and n = 25, the normalized speed N, when normalized with respect to maximum measurable speed is N 2(25000) 1 where the maximum measurable speed, in rad/sec, is max 2 2(25000) This corresponds to a maximum speed of 1,500,000 rpm that can be measured using this system. Now, in any practical implementation the maximum motor speed will be significantly lower than this maximum measurable speed. So, for example, if the motor used has a maximum operating speed of 23,000 rpm, then the calculated speed can be expressed as a normalized value with a base value of normalization of at least 23,000 rpm. If we choose this base value of normalization as 23,438 rpm (the reason for the choice of such a value is explained later), then the corresponding base value of normalization, in rad/sec, is max1 23438 2 2(390) 60 Therefore, the scaled normalized speed is calculated as N1 2(390) 64 64 N Motor Speed Measurement Considerations When Using TMS320C24x DSPs 3

This shows that the scaling factor, in this case, is 64. Notice that for this system having a maximum measurable speed of 1,500,000 rpm, the choice of a base speed of 23,438 rpm results in a scaling factor of 64 (= 1500000/23438). With this scaling factor, the above multiply operation can also be implemented simply by left shifting N by 6 bits. While the multiply operation can be performed in either way, the latter results in faster execution time. Now the maximum value of the scaled normalized speed N1 is 1. When expressed as a Q15 number, this maximum value of N1 is 32,767 (7FFFh). Therefore, in this case the maximum value of N is 32767/64 when expressed in Q15. Now, during the software implementation, this is saved as a 16-bit number. So for the maximum accuracy of ω N, while avoiding an overflow condition, it should be expressed in Q21. This maximum value of N, in Q21, is 32,767. The speed, in rpm, is calculated as N 1 23438 N1 23438 64 Note that when the motor runs at it s maximum speed of 23,000 rpm, the measured value of will be at its minimum. This minimum value will be = 65 for this system (fastest time for 1 rev = 65x25x32x50x10 9 sec = 0.0026 sec). 2.2 Case 2 If the system parameters remain the same as in case 1 but the motor used has a maximum operating speed of 5500 rpm, then we have, as before, and N max 2(25000) 1 2 2(25000) Now, assume that we normalize the calculated speed with respect to a base value of 5859 rpm. The corresponding base value of normalization, in rad/sec, is max2 5859 2 2(98) 60 Therefore, the scaled normalized speed is calculated as N2 2(98) 256 256 N This shows that the scaling factor in this case is 256. Here again, the choice of the base value of 5859 rpm results in the scaling factor of 256 (= 1500,000/5859). With this value the multiply operation can also be performed by left-shifting N by 8 bits, which saves computation time. Again, the maximum value of the scaled normalized speed N2 is 1. In Q15, this is 32767 (7FFFh). Therefore, in this case, the maximum value of N is 32767/256 in Q15. So, for maximum accuracy of N while avoiding an overflow condition, it should be expressed in Q23. This maximum value of N, in Q23, is 32767. The speed, in rpm, is calculated as N 2 5859 N2 5859 256 4 Motor Speed Measurement Considerations When Using TMS320C24x DSPs

Note that in this case, when the motor runs at it s maximum speed of 5500 rpm, the minimum value measured for will be = 273. This means that the fastest time for 1 revolution is, 273 x 25 x 32 x 50 x 10 9 sec (= 0.01092 sec). 2.3 Case 3 Now, if we have a different system based on 20MHz CPU clock ( = 50 x 10 9 sec), K P = 4, and n = 25, then the normalized speed is N 2(200000) 1 where the maximum measurable speed used for the above normalization, in rad/sec, is max 2 2(200000) Now, assume that the motor used has a maximum operating speed of 5000 rpm. If we normalize the calculated speed with respect to the same maximum value of 5000 rpm, then the corresponding base value of normalization, in rad/sec, is max3 5000 2 60 2(83) Therefore, the scaled normalized speed is calculated as N3 2(83) 2400 2400 N In this case, the calculated scaling factor is 2400. Here again, the maximum value of N3 is 1. In Q15, this is 32767 (7FFFh). Therefore, the maximum value of N in this case is 32767/2400 when expressed in Q15. So for maximum accuracy of N while avoiding an overflow condition, it should now be expressed in Q26. This maximum value of N, in Q26, is 27961. The speed, in rpm, is calculated as N 3 5000 N3 5000 2400 Note that in this case when the motor runs at it s maximum speed of 5000 rpm, the measured minimum value of will be = 2400. This means the fastest time for 1 revolution is, 2400 x 25 x 4 x 50 x 10 9 sec (= 0.012 sec). For all the three cases discussed above, it is evident that the scaled normalized speeds N1, N2, and N3 are all represented as Q15 numbers. Because of this and the choice of the system parameters, the normalized speed N (speed normalized with respect to maximum measurable speed) should be represented in different Q formats to achieve maximum accuracy. Once N is represented in a particular format for maximum accuracy, the range of speed calculation will be limited to the corresponding chosen base speed of normalization. For example, to achieve maximum accuracy for the speed range in Case 3 (normalized with respect to 5000 rpm), if N is expressed in Q26, then the maximum speed that can be calculated is 5000 rpm. However, if N is expressed in Q21, then the maximum speed that can be calculated is 23438 rpm (when appropriate values are selected for the maximum speed and the scaling factor). However, this also means that the ability to calculate the speed in a wider range is achieved by compromising the accuracy of speed calculation at the lower speed range. Motor Speed Measurement Considerations When Using TMS320C24x DSPs 5

3 Speed Calculation from Period Measurements The capture unit in the C24x allows accurate time measurement (in multiples of clock cycles and defined by a prescaler selection) between events. In this case the events are selected to be the rising edge of the incoming pulse train. What we are interested in here is the delta time between events. To implement this, Timer 1 is allowed to free run with a user-selectable prescaler K P and a CPU clock with a time period of sec. The delta time, in scaled clock counts, is calculated as shown in Figure 2. FFFFh f(t) 1 T Case 1 f(t 2 ) f(t 1 ) f(t 2 ) f(t 1 ) 2 Case 2 f(t 2 ) f(t 1 ) 1 f(t 2 ) f(t 1 ) 0 t1 t2 t1 t2 t Note: only true if t 2 t 1 T Figure 2. Calculation of Speed In Figure 2, the vertical axis f(t) represents the value of the timer counter, which is running in continuous up count mode and resetting when the period register = FFFFh. Note that two cases need to be accounted for: the simple case where the timer has not wrapped around and where it has wrapped around. By keeping the current and previous capture values, it is easy to test for each of these cases. Once the value of is known, the speed is calculated using the appropriate equations explained before. In order to maintain high precision in the calculation for the full range of motor speeds, a 32-bit/16-bit division is performed, as shown in Figure 3. 1 period 7FFFFFFF(Q31) speed(q31 32bit) period(q0) Speed = Q31...... 31 30 16 s i i i i i i i 15 1 0 f f f f f f f f sign fraction Figure 3. 32-Bit/16-Bit Division After the division is performed, the result will be a 32-bit value in Q31 format. This value is subsequently scaled to a 16-bit, Q15 format. 6 Motor Speed Measurement Considerations When Using TMS320C24x DSPs

4 Code Examples Two code examples for speed calculation are presented here to illustrate the software implementation of the three cases explained before. It is assumed that the difference in captured values is saved in the variable called event_period. 4.1 Case 1 SPEED_SCALER_.set 64 RPM_MAX_.set 23438 ;Max rpm value. Base value for normalization ;Init variables: LDP #speed_scaler SPLK #SPEED_SCALER_, speed_scaler SPLK #RPM_MAX_, rpm_max.. ;Calculate speed, i.e. speed = 1/period ;Numerator (i.e. 1) is in Q31 format ;Phase 1 LACC #07FFFh ;Load Numerator Hi RPT #15 SUBC event_period SACL speed_hi XOR speed_hi OR #0FFFFh ;Load Numerator Lo ;Phase 2 RPT #15 SUBC event_period SACL speed_lo LACC speed_lo ADDH speed_hi ;Result is in Q31 in 32 bit format ;End of 32bit/16bit division. The result is in ACC, in Q31, 32 bit format. RPT #5 SFL ;Q37 SACH speed_prd_max ;Q21 SPM 0 LT speed_prd_max ;Q21 MPY speed_scaler ;Q0*Q21 PAC ;Q21 RPT #2 SFL ;Q24 SACH speed_prd,7 ;Q15, speed_prd= speed_scaler*speed_prd_max LT speed_prd ;Q15 MPY rpm_max ;Q0 PAC SACH speed_rpm,1 ;Q0 Motor Speed Measurement Considerations When Using TMS320C24x DSPs 7

4.2 Case 2 In this case, the initialization and the division part remains the same. If the user also wants to use the same code for a wider speed range (0~23438 rpm) in a different application, then the only change needed here is in the max speed and the scaling factor (as explained before). However, if maximum accuracy is desired for this speed range (0~5000 rpm), then the normalized speed needs to be expressed in Q26. In that case, the later part of the code changes as shown below. SPEED_SCALER_.set 2400 RPM_MAX_.set 5000 ;Max rpm value. Base value for normalization ;Init variables: (Same as before) ;Calculate speed, i.e. speed = 1/period (Same as before) ;End of 32bit/16bit division. The result is in ACC in Q31, 32 bit format. RPT #10 SFL ;Q42 SACH speed_prd_max ;Q26 SPM 0 LT speed_prd_max ;Q26 MPY speed_scaler ;Q0*Q26 PAC ;Q26 SACH speed_prd,5 ;Q15, speed_prd= speed_scaler*speed_prd_max LT speed_prd ;Q15 MPY rpm_max ;Q0 PAC SACH speed_rpm,1 ;Q0 8 Motor Speed Measurement Considerations When Using TMS320C24x DSPs

IMPORTANT NOTICE Texas Instruments and its subsidiaries (TI) reserve the right to make changes to their products or to discontinue any product or service without notice, and advise customers to obtain the latest version of relevant information to verify, before placing orders, that information being relied on is current and complete. All products are sold subject to the terms and conditions of sale supplied at the time of order acknowledgment, including those pertaining to warranty, patent infringement, and limitation of liability. TI warrants performance of its products 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. Customers are responsible for their applications using TI components. In order to minimize risks associated with the customer s applications, adequate design and operating safeguards must be provided by the customer to minimize inherent or procedural hazards. TI assumes no liability for applications assistance or customer product design. TI does not 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 products or services might be or are used. TI s publication of information regarding any third party s products or services does not constitute TI s approval, license, warranty or endorsement thereof. Reproduction of information in TI data books or data sheets is permissible only if reproduction is without alteration and is accompanied by all associated warranties, conditions, limitations and notices. Representation or reproduction of this information with alteration voids all warranties provided for an associated TI product or service, is an unfair and deceptive business practice, and TI is not responsible nor liable for any such use. Resale of TI s products or services with statements different from or beyond the parameters stated by TI for that product or service voids all express and any implied warranties for the associated TI product or service, is an unfair and deceptive business practice, and TI is not responsible nor liable for any such use. Also see: Standard Terms and Conditions of Sale for Semiconductor Products. www.ti.com/sc/docs/stdterms.htm Mailing Address: Texas Instruments Post Office Box 655303 Dallas, Texas 75265 Copyright 2001, Texas Instruments Incorporated