## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

, MTS, Cypress Semiconductor

In many microcontroller-based systems I find it is necessary to scale the digitized ADC results, the digital value sent to a DAC, or data used by different algorithms. If you are lucky, the scaling is either a gain or an attenuation factor of 2n. If not, you will have to multiply or divide by some constant factor. In very small systems there may not be enough program area for a divide, or even a multiply, routine. This TechNote will show how data can be scaled with a series of shifts, additions, and subtractions. As shown in the equation below, any scaling factor can be represented as a series of binary values: A x = ai 2i x a = (1,0) B i To help determine the binary values for a particular scaling value, a spreadsheet has been included as a separate download on the site.

Setting the “A” value (B1) to 237 and “B” value (B2) to 64 results in a calculated scale factor of 3.703125 (D4). The spreadsheet automatically calculates the largest required binary value (B5). It also generates the binary values and calculates the error for each defined ai. For this example there are 6 terms required. They are shown as:

As

Fig. 1: Spreadsheet To Calculate 237/64 Scale Factor

Pu bl

is he d

on

EN

Suppose you have a system that requires that the data be scaled by a factor of 237/64. Open the data sheet (Fig. 1).

-G en iu s.

ne t

[+] Feedback

A x x x x = (G7 + G8 + G9 + G11 + G12) x = 2x + x + + + + B 2 8 16 64

This scale factor can be achieved with shifts and adds of the data. However this can be simplified if subtraction is also allowed. Notice that x/8 and x/16 are both set. Fig. 2 shows that they can be replaced with x/4 – x/16 (G10 – G12).

As

Pu bl

Fig. 3: Reducing Number Of Terms, Part 2

is he d

There are still six terms but now 2x, x, x/2, and x/4 are all set. As shown in Fig. 3, 2x + x + x/2 +x/4 can be simplified to 4x – x/4 (G6 – G10).

on

Fig. 2: Reducing Number Of Terms, Part 1

EN

-G en iu s.

ne t

[+] Feedback

There are now only four terms: A x x x x x x x x = 2x + x + + + + = 4x + B 2 8 16 64 4 16 64 Implementing this scale factor requires shifting the data along with one move of the data, two subtractions, and one addition. For the previous example, only four terms were needed. It is possible that exactly representing a scale factor may require an infinite number of terms. When multiplying by “A” and then dividing by “B” the accuracy is limited by the size of the data registers. However, the data itself often has limited accuracy. ADC data with a 1% accuracy surely isn’t going to need the scale factor to be much more accuracy that that, at least no more than a factor of ten. Knowing the acceptable accuracy of your data allows for only the minimum amount of calculation to scale the data.

Fig. 4: Determine Terms For SQRT(3) Scale Factor 0.01% Accuracy The original add only coefficients are shown in column J. Columns I, H, G, show the transform to get to most reduced terms in column F. The last line of the spreadsheet shows that the error is 0.0068% or 68 parts per million (ppm). The terms are: x x x x = F6 – F9 – F13 – F16 – F18 3 x = 2x 4 64 512 2048 Now accuracy better than 0.01% should be quite acceptable. But suppose you have some constraint that requires the error be less than 1ppm. This is easily be done by extending

As

Pu bl

is he d

on

EN

-G en iu s.

When dealing with three-phase power, a scale factor of the square root of three (1.732) is often required. The figure below shows that five terms are required for this scale factor: for an accuracy better than 0.01%.

ne t

[+] Feedback

the spreadsheet. Fig. 5 shows that eight lines had to be added to the spreadsheet to meet the new specification.

About The Author Dave Van Ess is an application engineer and member of technical staff at Cypress Semiconductor. He is an electrical engineer with experience in hardware, software, and analog design. Dave joined Cypress in 2000. He has eight patents for medical systems, signal processing design, and PSoC digital block enhancements. He has written numerous User Modules, application notes, and articles. He graduated sigma cum barely with his BSEE from the University of California, Berkeley, 1977. He can be contacted at dwv@cypress.com

As

With the spreadsheet provided you can easily develop the terms required for your specific scaling factor so that you can easily scale your data without the use of multiplication or divide routines.

Pu bl

To implement the scale factor with the improved accuracy specification requires three extra terms as shown in the equation below. x x x x x x x 3 x = 2x + 4 64 512 2048 8192 262144 524288

is he d

on

Fig. 5: Determine Terms For SQRT(3) Scale Factor, Better Than 1ppm Accuracy

EN

-G en iu s.

ne t

[+] Feedback

An engineer by training, a poet by temperament, an outlaw in Nebraska, and a heck of a nice guy, Dave has worked in many different industries. His work experience includes test and measurement equipment, measurement and control systems for high-energy physics research, and underwater acoustical transmitters and receivers deployed in open sea and artic ice fields. Electrons fear him! Women revere him!

As

Pu bl

is he d

on

EN

-G en iu s.

ne t

[+] Feedback

- Perseus-vs-QS1R
- 7
- Sample
- 574
- Doc 1
- Anaanalog to digital atmega 32 a
- Built-in Self-Calibration and Digital-Trim Technique for 14-Bit SAR ADCs Achieving ±1 LSB INL - 2015
- 2004 David
- SCF2_DFL.ASM
- AUTOMATED BLINDS
- CanSat_section4_rev3
- IEEE - Analog Circuit Design
- 0098_001
- Assignment 1 report.docx
- Alc Sol Man Ch07[1]
- AD7730 _ EngineerZone.pdf
- IRJET-Microcontroller Based Three Phase Fault Analysis for Temporary and Permanent Fault
- ME 402
- A Smart Indoor Irrigation System
- Microcontroller Based Data Acquisition and Supervision
- uni-kl_adc-review_jan03_5782[1].pdf
- an023
- Monitor N740
- LISY300
- Lecture Adcs
- NTGS3446-D
- AN1636.pdf
- B0409
- Wireless Intelligent Bed Sensing System
- ADC

- Flex Based Glove System for Dumb People
- Design of Low Power, High Speed 3-Bit Pipelined ADC
- Effective Low Voltage Wireless Charging System with an Active Matching Circuit for AIMD'S
- Biomedical Parameter Transfer Using Wireless Communication
- Automatic Water Distribution System
- Embedded Based Colour Recognition
- tmp840C
- UT Dallas Syllabus for taught by (bpg101020)
- Microcontroller Based Sign Language Glove
- UT Dallas Syllabus for ee7326.501.08f taught by James Hellums (hellums)
- Digital Thermometer
- UT Dallas Syllabus for taught by (bpg101020)
- Automatic Water Management in Drip Irrigation
- Measurement of Parameters of Different Analog Circuits through Android app
- tmpE43
- UT Dallas Syllabus for ee7327.501 06f taught by James Hellums (hellums)
- Desining and FFT Analysis of Sigma Delta Converter using Spice
- Smart Greenhouse System
- A comprehensive study on Implementing of 10bit Two step Flash ADC
- Implementation of Blood Warmer Before Transfusion Process using Microcontroller At89s52
- Simulation of 3 bit Flash ADC in 0.18μmTechnology using NG SPICE Tool for High speed Application

- Design and Implementation of a Programmable Truncated Multiplier
- Implementation of Vedic Multiplier in Image Compression Using Discrete Wavelet Transform (DWT) Algorithm
- Design and Simulation of Radix-8 Booth Encoder Multiplier for Signed and Unsigned Numbers
- Stealing Keys from PCs using a Radio
- Design of 16 X 16 Vedic Multiplier
- tmpB208.tmp
- Video Math Tutor
- Design Approach of High Performance Arithmetic Logic Unit Using Pipelined Multiplier Based on Vedic Mathematics
- Evaluating Broadband Adoption
- High Speed Multiplier Design with Column/Row Bypass Method and Tabulation Multiplication
- Compare "Urdhva Tiryakbhyam Multiplier" and "Hierarchical Array of Array Multiplier"
- tmp1295.tmp
- Design of Efficient High Speed Vedic Multiplier
- IEEE-754 compliant Algorithms for Fast Multiplication of Double Precision Floating Point Numbers
- UT Dallas Syllabus for cs6305.501 05s taught by Ivor Page (ivor)
- Video Math Tutor
- Implementation and Performance Analysis of a Vedic Multiplier Using Tanner EDA Tool
- Tmp 4047

Sign up to vote on this title

UsefulNot usefulClose Dialog## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

Close Dialog## This title now requires a credit

Use one of your book credits to continue reading from where you left off, or restart the preview.

Loading