altera dspbook

8

Upload: kevini

Post on 08-Feb-2016

37 views

Category:

Documents


0 download

DESCRIPTION

Practical guide to digital signal Processing

TRANSCRIPT

Page 1: Altera Dspbook
Page 2: Altera Dspbook

www.newnespress.com

1

Digital Signal Processing: A Practical Guide By Michael Parker, Altera Corporation

Introduction This book is intended for those who work in or provide components for industries that use digital signal processing (DSP). There is a wide variety of industries that utilize this technology. While the engineers who implement applications using DSP must be very familiar with the technology, there are many others who can benefit from a basic knowledge of its’ fundamental principals, which is the goal of this book - to provide a basic tutorial on DSP. Mathematics will be minimized and intuitive understanding maximized. This book will de-mistify many difficult concepts like sampling, aliasing, imaginary numbers, frequency response, etc., using easy to understand examples, while providing an overview of the functions and implementation used in several DSP intensive applications. This is not a blackboard offering of equations as an explanation on DSP. The reader need only be comfortable with high school level math skills. Key concepts will be emphasized. After a complete reading you will likely be able to talk intelligently with others involved in DSP centric industries and understand many of its’ fundamental concepts. OK, let’s get started… What is DSP? DSP is performing operations on a digital signal using a digital semiconductor device. Most commonly, multipliers and adders are used. If you can multiply and add, you can understand the technology. Digital circuits have become progressively cheaper and faster, as well as due to the inherent advantages of repeatability, tolerance and consistency that digital circuits have compared to analog circuits. If the signal is not in a digital form, then it must first by converted or digitized. A device called an analog to digital converter (ADC) is used. If the output signal needs to be analog, then is converted back using a digital to analog converter (DAC). As promised, mathematics will be minimized, but cannot be eliminated altogether. Some basic trigonometry and use of complex numbers is unavoidable (an early chapter introduces these using simple examples). There is also one appendix section where very basic calculus is used, but this is not essential to the overall understanding. As this 7 part series is only intended as an overview of the complete book and its chapters, you will likely have to actually purchase this book (good for me and the publisher) to gain a complete understanding. It is my goal in this series of articles to give a clear and concise summary of the book following its Table of Contents. This first part will cover Chapters 1 – 4.

Page 3: Altera Dspbook

www.newnespress.com

2

Chapter 1: Numerical Representation To process a signal digitally, it must be represented in a digital format. There are a number of different ways to represent numbers, and this greatly affects both the result and the amount of circuit resources required to perform a given operation. This chapter focuses on implementing DSP and you do not need to understand DSP fundamental concepts. Digital electronics operate on bits that form binary words. The bits can be represented as binary, decimal, octal or hexadecimal or other form. These binary numbers can be used to represent “real” numbers. There are two basic types of arithmetic used in DSP, floating point or fixed point. Fixed point numbers have a fixed decimal point as part of the number (i.e. 1234, 12.34 or 0.1234). Floating point is a number with an exponent (i.e. 1,200,000 would be expressed as 1.2 x 106). Most of the discussion focuses on fixed point numbers that are most commonly found in DSP applications and a short discussion on floating point numbers. DSP uses signed numbers that are both positive and negative numbers, but how are negative numbers represented? In signed fixed point arithmetic, the binary number representations include a sign, a radix or decimal point, and the magnitude. The sign indicates whether the number is positive or negative, and the radix (also called decimal) point separates the integer and fractional parts of the number. The sign is normally determined by the left most, or most significant bit (MSB). The convention is a zero used for positive, and one for negative. There are several formats to represent negative numbers, but the almost universal method is known as “2s complement”. This method is discussed in detail in the book. Fixed point numbers are usually represented as either integer or fractional. An integer representation, the decimal point is to the right of the least significant bit (LSB), and there is no fractional part in the number. For an 8 bit number, the range which can be represented is from -128 to +127 with increments of 1. In fractional representation, the decimal point is often just to the right of the MSB, which is also the sign bit. For an 8 bit number, the range which can be represented is from -1 to +127/128 (almost +1) with increments of 1/128. In the book, this chapter presents numerous tables, with each giving equivalent binary and hexadecimal numbers. The book will cover Integer Fixed Point Representation, Fractional Fixed Point Representation, and Floating Point Representation in depth. Chapter 2: Complex Numbers and Exponentials Complex numbers have probably been forgotten by most of us. They are important in digital communications and DSP, so you’ll need to resurrect them.

Page 4: Altera Dspbook

www.newnespress.com

3

A complex number has a “real” and “imaginary” part, and the imaginary part is the square root of a negative number, which is really a non-existent number. Sound weird, well it’s technically true, so it will be examined in a much more intuitive way in the book. Complex numbers are needed to define a two dimensional number plane to understand DSP. The traditional number line extends from plus infinity to minus infinity, along a single line. To represent many of the concepts in DSP, two dimensions are needed. This requires two orthogonal axes (i.e. the horizontal line is the real number line, the vertical line is the imaginary line). All imaginary numbers are prefaced by “j”, which are defined as the √-1. This is the essence of this whole chapter as shown in Figure 1.

Figure 1. A Complex Number Plane Any complex number Z has a real and imaginary part, and is expressed as X + j · Y, or just X + jY. The value of X and Y for any point is determined by the distance one must travel in the direction of each axis to arrive at the point. It can also be visualized as a point on the complex number plane, or as a vector originating at the origin and terminating at the point. There has to be a way to keep track the vertical and horizontal components. That’s where the “j” comes in. Complex Addition, Subtraction and Multiplication explanations and examples will be given in the book, as well as in-depth overviews of Polar Representation and Complex Multiplication using Polar Representation examples. Two points will be defined, Z1 and Z2. Z1 = R1 angle (Ω1) Z2 = R2 angle (Ω2) Z1 · Z2 = (R1 · R2) angle (Ω1+Ω2)

Page 5: Altera Dspbook

www.newnespress.com

4

What this means is that with any two complex numbers, the magnitude, or distance from the origin to the radius, gets multiplied together to form the new magnitude. Examples will be given in the book. Complex Conjugate This is the last example that will be covered in the book. This is a special case and will be explained why. Imaginary numbers are used to form complex numbers. They are really not so complex, and imaginary is really a very misleading description. What will be explained is to how to create a two dimensional number plane and define a set of expanded arithmetic rules to manipulate the numbers in it. Next the complex exponential which is simply the unit circle (radius = 1) on the complex number plane will be explained. The last part of this chapter involves measuring angles in radians, which is seen everywhere in DSP. The angle measurement in radians is based upon π, which is a number defined to have a value of about 3.141592 (it actually is an irrational number, with infinite number of digits, like 1/3 = 0.3333….). It takes exactly 2π radians to describe a full circle. This same concept will be examined later in sampling theory, where everything tends to wrap around or behave periodically. We can visualize this as traveling either clockwise (negative rotation) or counter clockwise (positive rotation) around the circle. There is one more DSP convention to be aware of. The real component (X was used earlier) it is usually called the “I” or “in-phase”component, and the imaginary component (used Y) is usually referred to as the “Q” or “quadrature” component. In many DSP algorithms, the digital signal processing must be performed simultaneously on both I and Q data streams, which simply represents the signal’s movement, over time, within the two dimensions of the complex number plane. Chapter 3: Sampling, Aliasing and Quantization The starting point to understand DSP is sampling, and it’s affect on the signal of interest. The ADC measures the signal at rapid intervals, called samples. A digital signal proportional to the amplitude of the analog signal at that instant is output. If a signal is sampled very fast compared to how rapidly the signal is changing, a fairly accurate sample representation of the signal is obtained, but if the sample is too slow, a distorted version of the signal is seen. Figures 2 and 3 are samplings of two different sinusoidal signals. The slower moving signal (lower frequency) can be represented accurately with the indicated sample rate, but the faster moving signal (higher frequency) is not accurately represented by the sample rate. In fact, it actually appears to be a slow moving (low frequency) signal, as indicated by the dashed line. This shows the importance of sampling “fast” enough for a given frequency signal.

Page 6: Altera Dspbook

www.newnespress.com

5

Figure 2. Sampling a low frequency signal (arrows indicate sample instants)

Figure 3. Sampling a high frequency signal (same sample instants) The dashed blue line shows how the sampled signal will appear if the sample dots and smooth out the signal are connected. Notice that since the actual (red solid line) signal is changing so rapidly between sampling instants, this movement is not apparent in the sampled version of the signal. The sampled version actually appears to be a lower frequency signal than the actual signal. This effect is known as aliasing. Quantifying how fast to sample accurately represents a given signal. Understanding exactly what is happening when aliasing occurs is also needed. A detailed description of how aliasing can be useful is covered in the book. Nyquist Sampling Rule To prevent mistaking a fast changing signal for a slow moving signal, always sample at least twice as fast as the frequency of the signal that is of interest. Some margin is needed to assure that sampling is done at a rate that is more than twice as fast as the signal. Looking at the example in the book provides an interesting scenario.

Page 7: Altera Dspbook

www.newnespress.com

6

To summarize, whenever there is a sampled signal, you cannot really be sure of its frequency. But if the rule was followed - that the signal was sampled at more than twice the frequency of the signal, then the sampled signal will really represent the same frequency as the actual signal prior to sampling. The critical frequency, which is the signal must not ever exceed, is one half of the sampling frequency. This is called the Nyquist frequency. This rule is fully explained in the book, if the rule is followed, then the aliasing phenomenon can be avoided. In the next chapter, signals and sampling in the frequency (or spectral) domain will be represented by plotting the signal spectrum, the X axis will represent increasing frequency as shown in Figure 4.

Figure 4. Plotting the Signal Spectrum along the X axis Represents Increasing Frequency Thus far, the most important effects of sampling have been covered, but there is one remaining issue related to sampling that is quantization, which deals with the “noise”introduced by the limits of the numerical precision being worked with. This is where quantization comes into play and it is explained in detail in the book. Chapter 4: Frequency Response Once we have a sampled digital signal, we are ready to perform digital signal processing on this signal. In chapter 3, we touched on representing the signal in the frequency domain. Usually, the goal is to modify the signal’s frequency representation. This is normally performed using a filtering function. This is probably the most fundamental of DSP functions. A telephone ringer is an example used in the book. In this chapter, you need to understand the concept of frequency response. Then in the next chapter, we will develop a way to relate a filter’s frequency and time response. First, let’s begin with an intuitive way to understand the frequency response of a filter. From the last chapter, we learned that a complex exponential signal can be created, which is just a positive or negative frequency rotation about the unit circle (radius =1). Furthermore, when the

Page 8: Altera Dspbook

www.newnespress.com

7

frequency of the complex exponential reaches the Nyquist frequency, the maximum frequency which can be represented for a given sampling rate has been reached. A complex exponential signal is fully explained in the book as well as re-examing the frequency response. ************************************************************************** Chapters 5 – 8 of Digital Signal Processing: A Practical Guide covering Finite Impulse Response (FIR) Filters, Windowing, Decimation and Interpolation and Infinite Impulse Response (IIR) Filters will be covered in the next installment of this book here in DSP DesignLine in late November or sign up for the RSS Feed on DSP DesignLine. Digital Signal Processing: A Practical Guide is being published by Elsevier Science & Technology Books - Newnes Press and will be available for purchase at ESC Silicon Valley, being held at the San Jose Convention Center on April 26 - 29, 2010. Order on line at: www.elsevierdirect.com/9781856179218 You can also save 20% when pre-ordering this book by entering the following promotional code at checkout- 97521.