Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ch. 10 Numerical Calculations From Valvano’s text Introduction to Embedded Systems.

Similar presentations


Presentation on theme: "Ch. 10 Numerical Calculations From Valvano’s text Introduction to Embedded Systems."— Presentation transcript:

1 Ch. 10 Numerical Calculations From Valvano’s text Introduction to Embedded Systems

2 10.1 Fixed Point Numbers Fixed point numbers are used to express non- integer values. Two parts: –Variable integer (I). –Fixed Constant (Δ). Values is product of the two parts. –Example: Dec. Fixed Point = I x 10 m for some constant m. Binary Fixed Point = Ix 2 m for some constant m

3 10.1 Cont. Precision— of a number system is the total number of distinguishable values. Resolution—of a number is the smallest difference that can be represented which is Δ for fixed point numbers. (Sometimes this is represented by units –eg mv when.001 is the resolution.)

4 Checkpoint 10.1 Give an approximation of π using the decimal fixed-point (Δ =.001) format. ANSWER: Let π be about 3.14159, then with m = 3 we have decimal fixed-point as 3141 (3.14159 x 1000).

5 Checkpoint 10.2 Give an approximation of π using the binary fixed point ( Δ= 2 -8 ). ANSWER: Again, π is about 3.14159 so if we are using binary fixed point we have the approximation, with m = 8, 3.14159 x 256 = 804. 2477, so the variable part is 804.

6 Example: 9S12 ADC The ADC is 10 bits and the range of voltages is 0 to 5 volts. Let Vin be the input voltage and N be the digital ADC output. Then Vin = 5 x N/1023 = 0.0048876 x N. The resolution is about 5/1023 which is about 5 mv (note that 2 -10 is about 10 -3 ). See Table 10.1

7 10.1 (cont.) Errors to Avoid and Order of Operations –Overflow—the result exceeds the range of the number system. Solutions: promotion and ceiling/floor –See page 90 (Chapter 3). –Drop-out—occurs after a right shift or a divide. Can be avoided by dividing last when performing multiple integer calculations.

8 10.2 Extended Precision Calculations Program 10.2 (page 372)—A 32-bit addition operation (P = N + M). This starts with the least significant byte. Program 10.3 is a 32-bit subtraction algorithm.

9 10.2.5 Table Lookup and Interpolation Example 10.4 –Design a fixed-point sin() function

10 10.3 Expression Evaluations The precision of the expression can be increased using subroutine calls. –See Program 10.14 and 10.15 (page 382)

11 10.4 IEEE Floating-Point Numbers IEEE Standard for Binary Floating-Point Arithmetic—ANSI/IEEE STD 754-1985. Most widely used format for floating point numbers.


Download ppt "Ch. 10 Numerical Calculations From Valvano’s text Introduction to Embedded Systems."

Similar presentations


Ads by Google