You are on page 1of 48
7 rr Benha University Shoubra Faculty of Engineering Electrical Engineering Department (Communications) Digital Signal Processing 4" year — Communication 2010 - 2011 First Term Ass. Prof. Hussam Elbehiery EGYPT 2010 Pet ee ea eee eS es SEs Ee ee eet DSP Lecture 1 : Digital Signal Processing Structure AQIS [ 1. Introduction Digital signal roe DSP is one of the fastest-growing fields in modern electronics. Only a few years ago DSP techniques were considered advanced and esoteric subjects, their use limited to research labs or advanced applications such as radar identification. Today, the technology has found its way into virtually every segment of electronics. Talking toys, computer graphies, and CD players are just a few of the common examples. yp) 1.1 Fourier L two purposes: Inputs: There are three parameters { that can be sel the transform of a 2. The Need for DSP [ ‘What is digital signal processing (DSP) anyway, and why should we use it? Before discussing either the L hardwe the software, or the underlying mathematics, it's a good idea to answer these basic questions. The tm BS icra ws ote oe of itl copter poss sal. Noaly the Sas ean be handled by analog processes but, for a variety of reasons, we may prefer to handle them fal) log ee al) i i To understand the relative Geri) of analog and digital processing, it is convenient to compare the two Figure below shows two approaches to feeortliing SouinAS such as music or ‘he It works like thi: (8) Digital signal recording. Analog and digital systems ‘The playback process is just the inverse of the recording process: ignal will be considerably Each time the signal is passed on to another analog process, these adverse effects are multiplied. " Tat yr an analog system to be able to make more than two or three generations of copies. Now let's look at the as shown in Figure above (b): l s in the analog case, As in the analog case, these signals ar: — — —There-are two distinct to the digital process: first, itis far more than the analog _— process;-second, Thus, the (Potentially) "infinite > reGolution’ of the analog signal is lost. ee 3. Advantages of DSP_ viously, there must be some compensating benefit ion of recording is therefore just as accurate as the first generation. __ This fact has some interesting implications. Future generations will never really know what the Beatles sounded like, for example. The commercial analog technology of the 1960s was simply not able to accurately rd and reproduce the signals. the digital process, and indeed there are. First, The twentieth generation recording, and AS with the paintings in the Sistine Chapel, the true colors and brilliance of the original art is lost to story. the digital numbers on them arrays of numbers. As such, “There are other significant advantages to processing signals digitally. Geophysicists were one of the first /) groups to apply the techniques of signal processing. The seismic signals of interest to them are often of very low L frequency, from 0.01 Hz to 10 Hz. \ Component values must be so large that physically implementing the filter may well be impossible, Fr signals have been converted to digital numbers, however, it is a straightforward process to program a computer to perform the filtering, Other advantages to digital signals abound. For csple, DSP ean lw lags bandit inl tte ast | (Peegeey indicia, ‘A 20 kHz signal can be digitized and then sent over a 5-kHz channel. ‘The es as Jong to get through the narrower bandwidth channel, but when it comes out the other side it can be reconstructed to its full 20-kFz. bandwidth, In the same way, communications . Since the signal is sent as numbers, and then reproduced as the original signal. Modern "secure telephone" DSP systems allow this processing to be done with no detectable effect on the conversation. stored digitally are really just large 4. The General Model of a DSP System__ \. The general model for a DSP system is shown in Figure below. From a high-level point of view, a DSP system performs the following operations: — + Accepts an analog signal as an input. + Converts this analog signal to numbers. + Performs computations using the numbers, + Converts the results of the computations back into an analog signal, AtoD DtoA ate Processor {ork Program] {ata driver ____ | (EE ‘The general model for a DSP system , Optionally, different types of information can be derived from the numbers used in this process. This information may be analyzed, stored, displayed, transmitted, or otherwise manipulated. This model can be rearranged in several ways. For example, a(CD)player will not have the analog input section. A laboratory instrument may not have the analog output. The truly amazing thing about DSP systems, however, is that the model will fit any DSP application. The system could be sonar or radar system, voicemail system, video camera, or a host of other applications. The 6f the individual key elements may change, but their function will remain the same. > In signal-processing_ applications, ‘common example of an input transducer is a (microphone. Other examples are geo) () radar antennas, and infrared sensors. Generally, theeotpar of the transducer is quite small: L several milli-volt ae a (43 )Anti-aliasing Filt { 2, L The anti-aliasing filter The job of the anti-aliasing filter is a little difficult to describe ou “cones without more theoretical bac an we have developed up to this point. However, from a conceptual point of view, analog form Yo a of at least several volts for their full range input. Two of the most important Fell i4giAnalos-to Digital Converter ® As the name implies, the purpose of the analog-to-digital converter (ADC) is exonvertthe-sianl froin tS italjdata representation. Due to the physics of converter circuitry, most ADCS require inputs teristics of an ADC are the conversion rate and the resolution. The conversion rate defines how fast the ADG)can convert an analog value to a digital value. The resolution defines how close the digital number is to the actual analog value. The output of the ADC isa binary number that can be manipulated mathematically. = “Theoretically, there is nothing special about the processor. It simply performs the caleilations required for processing the signal. For example, if our DSP system is a simple amplifier, then the input value is [iterally Alisa by the gain (Gmplification) constant. In the early days of signal processing, the processor was often “ageneral-purpose mainframe computer oe As the field of DSP progressed, special high-speed processors were designed to handle the "number crunching.” Today, a wide variety-of specialized processors are dedicated to DSP-These processors are designed to achieve very high data throuehputs, using a combination of high-speed hardwarg) specialized architectures, and dedicated instruction sets. Alto these functions are designed to efficiently implement DSP algorithms. 4.6 Program Store, Data Store x A ‘The program store stores the instructions used in implementing the required DSP algoritims. In a general- purpose computer (von Neumann architecture), @atajand Etats ‘are stored together. In most DSP systems, the program is stored separately from the data, since this Siar eee acetone es ruemons Dose can bo moved on its own bus at the same time that instructions are being fetched. This architecture was developed from basic research performed at Harvard University, and therefore is generally called a Harvard architecture, Often the data bus and the instruction bis have different widths. 4.7 Data Transmissio. — DSP data is commonly tiansmitted to other(QSP)systems. Sometimes the data is stored in{bulk)form on This abi a di magnetic tape, optical dises (CDs), or other me: ability to st ransmit the data in digital form. is one of the key benefits of DSP operations. An analog signal, no matter how it is stored, will immediately begin to degrade. A digital signal, however, is much more robust since it is composed of ones and zeroes. Furthermore, the digital signal can be protected with error detection and correction codes. 4.8 Display)and User Input Not all-DSP systems have displays or user input. However, it is often Jhandy to have some visual representation of the signal. If the purpose of the system is to manipulate the signal, then obviously the user_ needs a way to input commands to the system. This ean be accomplished with a specialized keypad, a few discrete switches, ora full keyboard. — = 49 Digital-to-Analog Converter___ In many DSP systems, the Signal must be Converted back to analog formafter it has been processed. This is the function of the digital to-analog converter (DAC). Conceptually, DACs are quite straightforward: a binary number put on the input causes a corresponding voltage on the output Ones@f the key specifications of the DAC is how fast the output voltage settles to the commanded value. "The slew ratsoF the DAC should be matched to the acquisition rate of the ADC), — 4.10 Output Smoothing Filter = As the name implies, the purpose of the smoothing filter is to take the edges off the waveform coming from : DAC) This is necessary since-the waveform will have a "stair-step" shape, resulting from the sequence of "inputs applied to the/DAC)Generally, the smoothing filter js a simple low-pass system. Often, a basic ‘AObeatbe iep> F 4.11 Output Amplifier. — ‘The output amplifier-isy ly a straightforward amplifier with two main purposes. First, it matches the hhigh impedance of the DAC o the low impedance of the transducer. Second, it boosts the power to the level required. = ~ ——— 4.12 Output Transducer_ “Like the-inpat tra ome” output transducer can assume a variety of forms. Common examples are (speakers) fatennas jnd( motors 7 ® Digital Signal Processors Digital signal processing is carried out by mathematical operations. In comparison, word processing and similar programs merely rearrange stored data. This means that_computers designed for business and other J) general applications are not optimized for algorithms such as digital filtering and fourier analysis. <> Digital signal processors are microprocessors specifically designed to handle digital signal processing tdks, These devices have seen tremendous growth in the last decade, finding use in everything from cellular telephones to advanéed scientific instruments. In fact, hardware engineers use “DSP” to mean digital signal processor, just as algorithm developers use “DSP” to mean digital signal processing. — — 5.1 How DSPs Are Different from Other Microprocessors — In the 1960s it was predicted that artificial intelligence would revolutionize the way humans interact with Gomputet and other machines. It was believed that by the end of the century we would have robots cleaning our ete corn driving our cars, and voice interfaces controlling the storage and retrieval of information. fis hasn’t happened; these abstract tasks are far more complicated than expected, and very difficult to carry out with the step-by-step logic provided by digital computers. However, the last forty years have shown that computers arelextremely capable in two broad areas, (1) data manipulation, such as word processing and d sates management, and (2) mathemati al gl alation, used in science, engineering, and digital signal pro microprocessors can perform botjtasks; however, it is ea to make a'device that is cothetaed for both. here are technical tradeoffs in the hardware design, such asthe Siz8/6P the Sesion set_and how interrupts Jare handled. Even more important, there are marketing issues involved: ment and |__-manufieturing Gost, eompetitive position, product lifetime) and so on. AS a broad peel atem these factors have made traditional_microprocessors, such as the Pentium®S) primarily directed at data manipulation Similarly, DSPs are designed to perform the mathematical calculations needed in digital signal processing. Data manipulation versus mathematical calculation. Digital computers are useful for two general tasks: data manipulation and mathematical calculation. Data manipulation is based) on moving data and testing inequalities, while mathematical calculation uses multiplication and addition. thematicel caleulation uses =— Typical Applicat ‘Main Cc») Data Manipulation) Math Calculation ; Weripssin aabse | ig sg rossi eet Seog snl selene and catia =| Sipnengsraiony ‘data movement (A “> B) addition (4+B=C) Stlsetesing O4othen 9) | tuipletn Gra=C) aoe See. Digital signal processors are designed to implement tasks in parallel. This sine Gras of the Analog {) Devices SHARC DSP. All of the steps within the loop can be executed ina single clock cycle. = = ———_ ee lok Patan || Dagon ste A || BA terete cies | dies || Acie, | ea as frogram 3 oS Cp) instructions and grin Seger | ” ee | ei eas 2 i ou mabe —_ Z re g VO Costler OMA) LT stuipter k ; 7 High pet (eaten, Cai) SBE bnees) eee DSP Lecture 2 me Signal Acquisition a 1. Introduction In most practical applications, however, we will be his sig. This work is often called ine of the first things we must do when we are designing a system to handle a signal is to determine what performance is required. In other words, SEE ceteaNaet ‘The answer to this question, naturally, involves a number of issues. Some of the issues are the same ones that we would deal with when designi We must also consider some additional requirements that are specific toG3Dpystems or are strongly influenced by the fact that the signals will be é These inelude:__——"~ Stating the requirements in general terms is straightforward. We must ensure that ously, however, these are qualitative requirements. To determine these requirements explicitly requires || both theoretical understanding and practical knowledge of how a DSP system works. In the next section we will look at one of the major design requirements: the number of samples per second. _ @) Sampling Theory In the equation below, the frequency of the sine wave generated was increased by the value_of the |) frequency £YThis had the effect of increasing the number of cycles in a second—at the cost of the number of _samples per cycle. As example, there were ({6)samples per second. So, generating a frequency of 2 Hz meant That there were now only 8 samples per cycle. Similarly, if the frequency had been increased to 4 Hz, there {] would te only 4 samples pereyee. & 1a, f(t)=sin (2nft +n q wn cydes nee fh aN. =sin (2n(2)nT+0), n=0..N-1 = ra eGR EERE sin (dan), n= 0...N. ~ fmm), m0...N=1 Sam Qheg Qor sacend kehen Lon Dear SMB}. OS BTeEQuanes 6} Som rt) VY Me rt = Te sing the tools and techniques from G3is%8B gives the graph shown in figure below. The dashed line is the expected analog signal. Notice, however, that all of the discrete points have a value of 0: We puta value of into the above equation, but we got out a DC value of zero, What went wrong? {speced rao signal ‘sign gerrsted with 16 ampleseond, Aus digital Salis Bt OV. ing effect, © The answer to this question br Opel. We condo tn by slugging fs Mf othe above aan ( ‘The sine function is@yfor'a frequency offzero) and for integer multiples of@)We have therefore stumbled L. onto the answer to the question of what our maximum frequen This is a key building block in what is known as the We donot ) | wve all of the pieces to present a discussion of the Nyquist theorem, but we will shortly. << ( in the meantime, let us explore the significance of our discovery a little further. Clearly, this is another manifestation of the difference between the analog frequency and the digital frequency. Intuitively, we can think of it as follows: ,, what are the minimum number of points needed? \. For most cases>ai If we know that any two separate points are points on one cycle of a sine wave, . There is one important exception to this, however: From the example above, we saw that we get the same output from the last equation if we put in a value for ‘fof either 0 or 8 when we are using 16 samples/second. For this reason, these frequencies are said to be aliases \ of one another. — 2 i We just "proved," in a non rigorous way, that our maximum digital frequency is N/2, But what happens if we were to put in values for/greater than N/2? _ eed For example, what if we put in a value of, say, 10 for f when N = 16? The answer is that it will alias to a value of Q} just as a value of 8 aliased to a value of 0. If we keep playing at this, we soon see that we can only generate output frequencies for a range of 0 to N/2. Our digital frequency is defined as, = qT. If we substitute N/2 for fand expand this we get: We can use any other value Tt would therefore appear that we want, but [) note that we said it woul eae ly, in ‘do not think of frequency as having a sign. However, negative frequencies are possible in the real world. Remember from that discussion that there is no great mystery to anc In the case of a point on the unit circle, a negative frequency means that the 1 than counterclockwise. The sign of the frequency for a purely real or a purely in a negative value of f Since! Still, this phase point is rotating clockwise rat imaginary signal is meaningful only if there is some way to reference the phase. ‘The signals generated so far have been real, but there is no reason not to difference does make the signal unique; thus, This discussion may seem a bit esoterie, specify the performance of a DSP algorithm over the range of -n to x. The DSP system will map this range to analog frequencies by selection of the number of samples per second. The second part of demonstrating the Nyquist theorem lies in showing that what is true for sine waves will, ifwe are careful, apply to any waveform, We will do this in the section covering the Fourier series. | 3DSampling Resolution In order to generate, capture, or reproduce a real-world analog signal, we must ensure that we represent the signal with sufficient resolution. Generally, reskin wl have to characteris: tit definitely has practical significance. A common practice is to where n is the number of bits: For example, if we have 42-bit system, then the maximum resolution will be: f Binary Value | Weight | 00. ae f OL a to 10 = i i _— analog frequency, el us look at a typical example. Assume that we are designing a system to monitor an important parameter > ina control system. . Our analysis has shown us that we | must know the voltage to within . How-many bits of resolution does our system need? ® ‘The first thing to do is to express the resolution as a ratio of the minimum value to the maximum range: ‘We can now use Equation (1) to find the number of bits. In practice, we would probably try a couple of values L. of n until we found the right value. A more formal approach, however, would be to solve Equation (1) for n: = — — 1 1, +1 | Plugging in 0.005. for(Zau) into the Jast equation yields a value for n 0S Remmame eR « ‘game AEE. Therefore ve need to specify at least: its of resolution for our signal monitor. side note, most calculators do not have a log? function. The following identity is handy for suc | oe In this example, we lightly skipped over the method for determining that we needed a resolution of 0.005 volts. Sometimes determining the resolution is straightforward, but sometimes itis not. eS ee ee ee Shen I] — SS Se Bar ROS Ae evens GS Tes. DSP Lectures — Digital Filters 1. Introduction Digital filters are used for two general purposes: (1) Separation of signals that have been combined, and (2) ‘Restoration of signals that have been distorted in some way. Analog (electronic) filters can be used for these ‘same tasks; however, digital filters can achieve far superior results. 2. Digital filter Basics _ Gen Wo. SSO Spek ne Digital filters are a very iniportant part of DSP. In fa performance i ont Shake reasons that DSP has become so popular. As mentioned, electrical activity of a baby's heart (Electrogardiography (EKG) while still in the womb. The raw likely be corrupted by the breathing and heartbeat of the mother. A filter might be used to separate these signals so that they can be individually analyzed : For example, an audio recording made with poor equipment may be filtered to better represent the sound as it actually occurred. Another imple is the de-blurring of an image acquired with an improperly focused lens, or a shaky camera. problems can be attacked with either analog or digital filters. Which is better? in comparison, are to 1000 hertz, and a gain of less than 0.0002 for frequencies above 1001 hertz. The entire transition occurs within only 1 hertz. Do not expect this from an op amp circuit! ,. However, this is not the only way sampling can take place. For example, imagine {taking simultaneous readings from many of strain sensors mounted at one centimeter increments along the “ength of an aircraft wing. Many other domains are possible; however, time and space are by far the most common. When you see the term time domain in DSP, remember that it may actually refer to samples taken [ over time, or it may be a general reference to any domain that the samples are taken in. Each of these responses of these representatio1 because ey describe how the filter will react under different circumstances. The frequency response could be displayed either on a linear scale or logarithmic in decibels as in figure below. r [ displayed either on a linear scale, (c),or in decibels, (8). All possible linear filters cai’ be made in this-manner. (This should be ol — ge : jy Aswe know, of a system when In this same | manner, the is the output (also called an edge, and an . 2 ase Since the step is the integral of the impulse, the step response is the integral of the impulse response. This ‘provides two ways to find the step response: (1) Feed ste waveform into the filter and see what comes out, or (2) Integrate the impulse response. (To be mathematically correct: integration is used with continuous signals, While discrete integration, i.., a running sum, is used with discrete signals.) The frequency response can be found by taking th DF'P (using the FET algorithm) of the impulse response, — a ‘The frequency response can be plotted on a linear vertical axis, such as in (c), or on a logarithmic scale (decibels), as shown in (4 ‘Do not remember decibels? Here is a quick review. A bel (in honor of Alexander Graham Bell) means that the power is changed by a factor often. For example, an electronic circuit that has 3 bels of amplification produces an output signal with 10 x 10 x 10= 1000 times the power of the input. A decibel (AB) is one-tenth of a bel. Therefore, the decibel values of: -20dB, -I0dB, 0dB, 10dB and 20dB mean the power ratios: 0.01, 0.1,.1, 10, and 100, respectively. In other words, every ten decibels mean that the power has changed by a factor of ten. Here's the catch: you usually want to work with a signal's amplitude, not its power. For example, imagine an amplifier with 20dB of gain. By definition, this means that the power in the signal has increased by a factor of 100. Since amplitude is proportional to the square-root of power, the amplitude of the output is 10 times the ainplitude of the input. While 20dB means a factor of 100 in power, it only means a factor of 10 in amplitude. Every twenty decibels mean that the amplitude has changed by a factor of ten. In equation form: Decibels are a way of expressing a ratio between two signals. Ratios of power (P; & P2 use a different equation from ratios of amplitude (A; & Aa). q w- t B = 20g, |. The above equations use the base 10 logarithm; however, many computer languages only provide a function for the ‘base e logarithm (the natural log, written log, x or In x ). The natural log can be used by modifying the above equations: dB =4.342945 log.(P,/P;) and dB = 8.685890 loze(42/4i). Since decibels axe a way of expressing the ratio between two signals, they are ideal for describing the gain of a system, ie., the ratio between the output and the input signal. However, engineers also use decibels to specify the amplitude (or power) of a single signal, by referencing it to some standard. For example, the term:(@BV) means that the signal is being referenced to a 1 volt rms signal. Likewise, dBm indicates a reference signal producing 1 mW into a 600 ‘ohms load (about 0.78 volts rms). Ifyou understand nothing else about decibels, remember two things: Firs(34B'means thatthe amplitude is reduced 07 (and the power is therefore reduced to 0.5). Second, memorize the following conversions between ibels and amplitude ratios: 7 604B = 1000 nt 40B = 100 20dB = 10 : 0dB_ = 1 -200B = 0.1 | -40dB = 0.01 -60dB." = 0.001 [ 3. Information Representation ‘The most important part of any DSP task is understanding how information is contained in the signals you are working with, There are many ways that information can be contained in a signal. This is especially true if | the signal is manmade, For instance, consider all of the modulation schemes that have been devised: AM, FM, single-sideband, pulse-code modulation, pulse-width modulation, etc. The list goes on and on. Fortunately, there are only two ‘common for information to be represented in naturally occurring signal [ will call these: A sion represented in the time domain deseribes when something occurs and what the amplitude of | the occurrence is. For example, imagine an experiment to study the light output from the sun. The light output is measured and recorded once each second. on /) Fach sample in the signal indicates what is happening at that instant, and the level of the event. If a solar | flare occurs, the signal directly provides information on the time it occurred, the duration, the development over time, etc. Each sample contains information that is interpretable without reference to any other sample. Even if [you have only one sample from this signal, you still know something about what you are measuring. This is the | Simplest way for information to be contained in a signal, In contrast, information represented in the frequency domain is more indirect. Many things in our universe { Show periodic motion. For example, a wine glass struck with a fingernail will vibrate, producing a ringing sound; the pendulum of a grandfather clock swings back and forth; stars and planets rotate on their axis and revolve around each other, and so forth. By measuring the frequency, phase, and amplitude of this periodic { motion, information can often be obtained about the system producing the motion. Suppose we sample the sound produced by the ringing wine glass. ‘The fundamental frequency and harmonics of the periodic vibration relate to the mass and elasticity of the material. A single sample, in itself, contains no information about the periodic motion, and therefore no information about the wine glass. The information is contained in the relationship between many points in the signal ‘This brings us to the importance of the step and frequency responses. lutely Good performance in jin, and vice versa, —<<—> critical in filter design because the time domain results in poor performance in the If you are designing a filter to removeCnoisé from an signal (information represented in the time domain), the step response is the important parameter, and the fequency response is of little concer. If your task is to design a digital filter for a hearing aid (with the information in the frequency domain), the frequency response is all important, while the step response doesn't matter. Now let us look at what makes a filter optimal for time domain or frequency domain applications. {3.1 Time Domain Parameters Tt may not be obvious why the step response is of such concer in time domain filters. You may be wondering why the impulse response is not the important parameter. The answer lies in the way that the human { mind understands and processes information. Remember that the step, impulse and frequeney responses all contain identical information, just in different arrangements. The step iesponse is(usefu) in time domain analysis _ because it matches the way humans view the information contained in the signals. — For example, suppose you are given a signal of some unknown origin ) origin and asked to analyze it. The first thing you will do is divide the signal into regions of similar characteristics. You can't stop from doing this; your mind will do it ‘automatically. Some of the regions ‘may be smooth; others may have large amplitude peaks; | thers may be noisy. This segmentation is accomplished by identifying the points that separate the regions. This 4 | is where the step function comes in “ea eee cers x vision henge Wlteeteateain wanes ab an event stat jen an event Tt tells you that whatever is is somehow differ ‘om whatever is on the right. This is how the human mind views time do: | informatio: ‘step response parameters that are important in filter design are shown in figure below. t is is shown in (a) and (b). The most (more jargon) | sac er e. The step response is used to measure how well a filter { performs in the time domain. Three parameters are important: |, shown in (a) and (b), in (c) and (d), |, shown in (e) and (f). Figures (c) and (4) show the next parameter that is important: overshoot in the step response. 9 ee ¢ information contained in the time doma Se can be summed up in —_ = ing ete the filter you have used? Finally, illustrated in (e) and (1). as , because the frequency response has a phase that is a straight line. Make “sure you understand these three parameters; they are the key to evaluating time domain filters. I * | 3.2 Frequency Domain Parameters Figure below shows the four basic frequency responses, i, and it is common to see 99%, 90%, 70.7%, and 50% amplitude levels defined to be the cutoff frequency. is | A | Band-pass. ) Amplitude ‘Amplitnde Amplitude Frequency Frequency The four common frequency responses. Frequency domain filters are generally used to pass certain frequencies pass-band), while blocking others (the stop-band). Four responses are the most common: low-pass, | high-pass, band-pass, and band-reject. —— ("Figure below shows three parameters that measure how well a filter performs in the frequency domain. To _ separate closely spaced frequencies as illustrated in (a) and (b). For the pass- band frequencies to move through the filter uncaltered, “@. Lastly, displayed in (e) and (f) filters. POOR GOOD 3 Fe roor 3 alee ao a ___Amplnde (48) Sesh eoees Ample (€0) Bee ebb e es shown in (a) and (b), le, shown in (c) and (4), shown in (e) and (f) | contains little useful information. Second, filters are gl is respect. a . The frequency responses shown are for low-pass in these_parameters? First, the phase ee or on the gee of an audio ia is almost comple random, and all frequencies pass through the filter with a zero phase shift. In comparison, analog ma { 4, High-Pass, Band-Pass and Band-Reject Filters___ most discussions on filter design only give examples o} . For this reason, ‘example of spectral inversion is shown in figure below. Figure (a) shows a low-pass filter kernel called a windowed-sine. This filter kernel is 51 points in length, although many of samples have a value so small that they appear to be zero in this graph. The corresponding frequency response is shown in (b), found by adding 13 Frequency Domain Example of spectral inversion, The low-pass filter kernel in (a) has the frequency response shown in (b). A high-pass filter kernel, (©), is formed by changing the sign of each sample in (a), and adding one to the sample ‘at the center of symmetry. This action in the time domain inverts the frequency spectrum (i¢., flips it top-for bottom), as shown by the high-pass frequency response in (4). { |. This results in the high-pass filter kernel shown in (c), with the frequency response shown in (d). Spectral changing the pass-bands into stop-bands, and the stop- | bands into pas: i other words, it changes a filter from low-pass to high-pass, high-pass to low-pass, band-pass to band-reject, or band-reject to band-pass. ri Since the - frequency — are subtracted from the =e gnal, only the high frequency “components appear in the output. Tits, a high-pass filter is formed: —_ | Tia, eras) fant peal ages K : >: fn] e | x[n] — 4 yin) > 6[n] | All-pass easdery WE Webasd ooo ae It ne es : -—> ybl — for low-pass to high-pass conversion, is illustrated in Figure below. Just as before, the low-pass filter kernel in (a) corresponds to the frequency Tesponse in (b). The high-pass filter in (a). As shown in (d), / | Time Domain Frequency Domain : Canepa pant pee SSSA TEDL. Example of spectral reve 2 low. filter kernel in (a) has the frequency response shown in (b). A high-pass filter kernel, (c), [is formed by changing the sign of every other sample in (a). This action in the time domain results in the frequency domain being flipped /eft-for-right, resulting in the high-pass frequency response shown in (d). For instance, a band-pass filter can be designed by adding the two filter kernels to form a stop-pass filter, | and then use spectral inversion or spectral reversal as previously described. All these techniques work very ‘well with few surprises. ' \ || Designing a band-pass filter. As shown in (a), 4 bandpass iter canbe formed b.cxcalin a loveras eee ey This can be reduced to a single stage shown in (b). The filter kerneY of the single fystage is equal to the convolution of the low-pass and high-pass filter kernels. 10 Bandpass x{n] ——>} h,[n] *h,{o] ——> yin] x{n] andre Band-reject a ima single sage Ar x{n] ——>} hil] + bala] -}——> yin} 1 _| 5. Filter Classification 1” table below summarizes how digital filters are classified by their use and by their implementation. The use VAs previously | described, Time domain filtering is low- f something more elaborate than the four basic responses (high-pass, | pass, band-pass and band-reject) i as a way of counteracting an unwanted convolution. [ FILTER IMPLEMENTED BY: Convolution ~ Recursion { lite Sule Respond FR) Inf Inpue Response (0R))) z{ Time Domain > AS say | CMloving avers ‘Single pote) ) [ epbing D eam SS (oe) z £ 2 | Frequency Domain ie ino) [ - S| parang fequnce) indowed-sinc, (Chebyshev) 5 E] custom teal = FIR custom Iterative design { (Devenvolaton) ig See Tas — || Digital filters can be implemented in two ways, by convolution (also called finite impulse-response of FIR) ““and-by recursion (also called infinite impulse response or IIR), Filters carried out by convolution)can have far _ (better performance than filters using recursion, but execute much more slowly. — ~~ First, we will look at filters carried out by conyolution/ The moving average is used in the time domain, the windowed-sinc is used in the frequency domain, and FIR custom is used when something special is needed. To \ finish the discussion of FIR filters. A technique called FFT eonyolution, this is an algorithm for increasing the \ speed of convolution, allowing FIR filters to execute fast ii 1 Next, we look at recursive filters. The single pole recursive filter is used in the time domain, while the Chebyshev is used in the frequency domain. Recursive filters having a custom response are designed by Jiterative techniques. They will be presented with another type of iterative procedure: the neural network. ‘As shown in table above, convolution and recursion are rival techniques; you must use one or the other for ; particular application. 5.1 Moving Average Filters —— c5 The moving average is the Mmost-common filter in DSP, mainly because it is dis hon and and use. In spite of itsGimplicitYy the moving average filter is optimal for a common task: feducing) |random goise while retaining a sharp st@p response. This makes it the premier filter for time domain encoded \si . However, the moving average is the worst filter for frequency domain encoded signals, with little ‘ability to separate one band of frequencies from another. Relatives of the moving average filter include the ‘Gaussian, Blackman, and multiple-pass moving average. These have slightly better performance in the |fequency domain, at the expense of increased computation time. 2 Ns naw an | 5. Noise Reduction vs\ Step Response fy scientists and engineers feel guilty about using the moving average filter. Because it is so very y(simple, the moving average filter is often the first thing tried when faced with a problem. Even ifthe problem is | completely solved, there is still the feeling that something more should be done. This situation is truly ironic. “Not only is the moving average filter very good for many applications, it is optimal for a common problem, reducing random white noise while keeping the sharpest step response. |. Figure below shows an example of how this works. The signal in (a) is a tle baie, indom noise. In IFO (b) and (c), the smoothing action of the, moving average filter decreases the “amy ‘the random noise’ (good), but also reduces ts shag soft Sages adh Ofall the posible near firs Gat cooly BE UseL.the L moving average produces the lowest noise for a given edge sharpness. ° The amount of noise reduction isequaLio the square-root of the number of points in the average. For example, a 100-point moving average filter reduces ff the noise by a factor of (03) er) Sample momber Sanple mums [Example of a moving average filter. In (a), a rectangular pulse is buried in random noise. In (b) and (c), this signal is filtered with 11 and 51 point moving average filters, respectively. As the number of points in the filter increases, the noise becomes lower; however, the edges becoming less sharp. The moving average filter is the optimal solution for this problem, providing the lowest noise possible for a given edge sharpness. To understand why the moving average is the best solution, imagine we want to design a filter with fixed (edge sharpness. For example, let us assume we fix the edge sharpness by specifying that there are eleven points ifthe rise of the step response. This requires that the filter kerne] have eleven points. The optimization question is: how do we choose the eleven values in the filter kernel to minimize the noise {jon the output signal? Since the noise we are trying to reduce is random, none of the input points is special; each is just as noisy as its neighbor is.__ Therefore, it is useless to give preferential treatment to any one of the input points by assigning it a larger { jeoefficient in the filter kernel. The lowest noise is obtained when all the input samples are treated equally, ie, Lithe moving average filter. eee Teter 3B | I ( 2-Windowed-Sinc Filters . " to au are used to separate one yf frequencies from another. They are ver stabl ise produce few and can be pushed to incredible performance levels. These exceptional frequency domain characteristies are obtained at the expense of poor performance in the time domain, including excessive ripple and overshoot in the step response-When carried out by standard convolution, windowed-sine filters are easy to program, but slow fo execute.(FFT ean be used to dramatically improve the computational speed of ‘these filter —ee ent ee Figure below illustrates the idea behind the windowed-sine filter. In (a), the frequency response of the ideal low-pass filer is shown, All frequencies below the cutoff frequency, f., are passed with unity amplitude, while all higher frequencies are blocked) The pass-band is perfectly-flat, the attenuation in the stop-band is infinite, and the transition between the two is infinitesimally small. a Time Domain Frequency Domain [EBettemor pene) | i | i ate Wed T Derivation of the windowed-sinc filter kernel. The frequency response of the ideal low-pass filter is shown in (a), with the corresponding filter kernel in (b), a sinc function. Since the sine is infinitely long, it must be truncated to be used in a computer, as shown in (c). However, this truncation results in undesirable changes in the frequency response, (d). The solution is to multiply the truncated-sine with a smooth window, (e), resulting in the windowed-sinc filter kernel, (f). The frequency response_of the windowed-sinc, (g), is smooth and well behaved. These figures are not to scale. ua 14 | DSP Lecture 4 DSP Engineering Application 1. Audio Processing Audio processing covers many divers) areas me prominent: es Geta all involved in presenting sound to human listeners. Three such as in audio compact dises, jother name for telephone networks, ‘where computers generate and recognize human voice patterns. While these applications have different goals and problems, they are linked by a common umpire: the [ human(ea?, Digital signal processing has produced revolutionary changes in these and other areas of audio processing. io { through the interface, USE a (low acoustic pressure-and high particle velocity resulting from low density and high Compressibility), pile aid ns sg esbanialiousanee. In less technical terms, it requires more effort, | to wave your hand in water than it does to wave it in air. This difference in mechanical impedance results in “most of the sound being reflected at an aitiliquid interface. |. Human ‘ey { listeners “about the width of a person at 10 meters. This directional information is obtained in two separate ways. |, First, frequencies above about 1 kllz.are strongly shadowed by the head. In other words, the ear nearest the | sound receives a stronger signal than the ear on the opposite side of the head. ‘The second clue to directionality i thatthe ear onthe far side of the head hears the sound slightly later than the near ear, due to its greater aistaice from the source. Based on a typical head size (about 22 cm) and the | speed of sound (about 340 meters per second), an angular discrimination of three degrees requires a timing precision of about 30 microseconds. Since this timing requires the volley principle, this clue to directionality is predominately used for sounds less than about 1 Elz. =) |. While human hearing can determine the direction a sound is fro mapas is because there are few clues available in a sound wave that can provide this infor in hearing weakly perceives that . Echo content is another weak clue to distance, providing a perception of the room size. | ~ For example, sounds in a large auditorium will contain echoes at about 100 millisecond intervals, while 10 | milliseconds is typical for a small office. Some species have solved this ranging problem by using active sonar. For example, bats and dolphins produce clicks and squeaks that reflect from nearby objects. () By measuring the interval between transmission and echo, these animals can locate objects with about Lem Liesolution. Experiments have shown that some humans, particularly the blind, can also use active echo ocalization to a small extent, The ear is very accustomed to hearing a fundamental plus harmonics. If a listener is presented with the combination ofa 1 KHz and 3 kHz sine wave, they will report that it sounds natural and pleasant. If sine waves _ of] KHz and 3.1 kHz are used, it will sound objectiosiable. ‘This is the basis of the standard niusical)scalé, as illustrated by the piano keyboard in Figure below. Striking the farthest left key on the piano produces a fundamental frequency of 27.5 hertz, plis harmonies at 55, zo __J)110, 220, 440, 880 hertz, ete. (there are also harmonics between these frequencies, but they aren't important for this discussion). These harmonies correspond to the fundamental frequency produced by other keys on the Keyboard. Specifically, every seventh white key is a harmonic of the far left key. That is, the eighth key ftom [Vthe left has a fundamental frequency ofS5yher!z; the 15th key has a fundamental frequeney of 110 hertz, etc. Being harmonics of each other, these keys sound similar when played, and are harmonious when played in unison. For this reason, they are al! called the note, A. In this same manner, the white key immediate right.of { leach 4 is called a B, and they are all harmonics of each other. This pattern repeats for the seven notes: A, B, C, “D, E, F, and G: ‘The temgctuyp)means 8 factor of pea aneuenc. On the piano, one octave comprises eight white keys, and the entire keyboard spans a little over seven oct f corresponding to about octave to the left, and two octaves to the right of the piano keyboard. Since octaves are based on doubling the frequency © every fixed number of keys, they ate a lagaridimie representation of frequency. This is important because audio yinformation is generally distributed in this same way. For example, as much audio information is carried in the octave between 50 hertz and 100 hertz, as in the octave between 10 kHz and 20 kHz. Even though the piano only covers about £0% of the frequencies that yhumans can hear (4 KElz out of 20 kHz), it can produce more than 70% of the audio information that humans [ can perceive (7 out of 10 octaves). oe oe Likewise, the highest frequency a human can detect drops from about 20 kHz to 10 kHz over the course of an adult's lifetime. However, this is only a loss of about 10% of the hearing ability (one octave out of ten). As | shown next, this logarithmic distribution of information directly affects the required sampling rate of audio signals. { PT aT ‘ DCDEFG GCoEFG ACOEFG BCDEFS reyes perere ge | amsie Asie ions moi) Awone Ato Amo Aan l cate ee The keyboard of the piano is a logarithmic frequency scale, with the fundamental frequency doubling after every seven White keys. These white keys are the notes: 4, B. C, D, E, F and G. | 1.1 Sound Quality vs. Data Rate When designing a digital audio system there are two questions that need to be asked: ' (1) How good does it need.to sound? (2) What data rate can be tolerated? ‘The answer to these questions usually results in one of three categories. First, { categories. L High fidelity music systems sample fast enough (44.1 kHz), and with enough precision (16 bits), that they can capture virtually all of the sounds that humans,Are capable of hearing. This magnificent sound quality ‘comes at the price ofa high data rate, 44.1 kHz x 16 bits = 706k bits/sec, This is pure brute force. 2 le, with little notic evten | Siping | Nemter | Datars | conmene t Benewah | SHEET | ee’ [neg | o | gh ty mie suiato | atta | sen | rom | sictneen tema siny (lap an sitar [ (eam 2) ane mekees ‘ranpbns qui pene | 2oouinte | tax | anie | 96k | cxotgeen utr tet I ee | eee Suan t (witrcompandsg) | 200tiet0 | sitiz | att | om | nen ape toes sake SER mee! | l spechenccissbyLicen | 2opsste | ste | ize | ak | vor percomresn ‘elive cong Sakic eSice Vega see j - ]] etait eroding itn eigen mtn alge egensts ara io gn opi te poids mingling heal number of bits per sample. This can be broken into three categories, high fidelity music (706 Kbits/sec), [telephone quality speech (64 Kbits/sec), and compressed speech (4 Kbits/sec). l 12 Tigh Fidelity Audio a [ “Digital audio was brought to the world by the compact Yaser dise) or CD. This was a revolution in music; ‘the sound quality of the CD system far exceeds older systems, suchas records and tapes. DSP has been at the forefront of this technology. Figure below illustrates the surface of a compact laser disc, such as viewed through { a high-power microscope. (reflective of light), , the opposite of a phonograph record. _phonograph records spin at a fixed rate, such as 33, 45 or 78 rpm). During playback, an optical sensor detects if the surface is reflective or non reflective, generating the corresponding binary information. {) As shown by the geomet in Fgue above, the CD stores about 1 bit per yn, comesponing to 1 million Lbits per mm, This is about the same feature size used in integrated circuit cuit & manufacturing, and for a good reason. One ofthe properties of light is that it eanot be fesused to smaller than f shout oneal weg 3 ince both integrated circuits and laser disks are created by optical — t ins, the iness of light below 0.3 Am limits how small of features can be used. Compact dise surface. Micron size pits are burned into the surface of the CD to represent ones and zeros. | This results in a data density of 1 bit per um’, or one million bits per mm. 3 \.2. Image Processing » Images are a description of how a parameter _v: ver For-example, standard visual images result from light intensity variations across a two-dimensional plane. However, light is not the only parameter used in scientific imaging. For example, it cic. These exotic images are usually converted into conventional pictures (ie., light images), so that they can be evaluated by the human eye. 21 Digital Image Structure , where 0 is black, 255 is white, and the intermediate values are shades of gray. A “typical” digital image is composed of about 500 rows by 500 columns. eae This is the image quality encountered in television, personal computer applications, and general scientific | [research. Images with fewer pixels, say 250 by 250, are regarded as having unusually poor resolution. Images ‘with more than 1000 by 1000 pixels are considered exceptionally good. This is the quality of the best computer graphics, high-definition television <7 One second of digital audio requires about eight kilobyres. In comparison, one second of television requires about eight megabytes, Transmitting a 500 by 500 pixel image over a 33.6 kbps modem requires nearly a minute! Jumping to an image size of 1000 by 1000 quadruples these problems, It is common for 256 gray levels (quantization levels) to be used in image processing, corresponding to a single byte per pixel. An image presented to a human observer will not be improved by using more than 256 levels. However, some images need to be stored with more than 8 bits per pixel. Colum Row f Digital image structure. This example image is the planet_Venus, as viewed in reflected microwaves. _ Digital images are represented by a two-dimensional array of numbers, each called a pixel. In this image, the array is 200 rows by 200 columns, with each pixel a number between 0 to 255. When this image was acquired, — { the value of each pixel corresponded to the level of reflected microwave enerey. A grayscale image is formed by assigning each of the 0 to 255 values to varying shades of gray, —— 7 f fixing these three colors generates all possible colors that the human Ueye can perceive. A single byte is frequently used to store each of the color intensities, allowing the image to capture a total Color is very when the goal is to { present the viewer with a true picture of the world, such as in television and still photography. However, this is “ nsually not how images are used in Science and engineering. The purpose here is to analyze a two-dimensional __signal by using the human visual system as a tool. Black and white images are sufficient for this | Diagram of an electronic _camera rn. s ‘a mechanical device that changes the effective diameter of the(len3.) The most common imaging sensor in present day cameras is the [ CCD, a two-dimensional array of light sensitive elements. Sh nose coe the ‘serial output .. Put another way, . Typical camera lenses have an’ t "This results in a typical electronic camera having a dynamic range “ofa few hundred thousand. Clearly, the same camera and lens assembly used in bright sunlight will be useless ona dark night. : . 2 od Scotian? f lume Architecture of the CCD. to keep the This means that all . Forests [tine [tines | tine SY inesss | erica. | tine? | tins | horizontal syne pulses Composite video; Thé NISO)video signal consis [[ftame containing 480 10 486 Tnes of video. Each frame and the other containing the even lis 's of 30 complete frames_(images) per second, with each oken into twoWlields))one containing the odd lines hlgaby . (The horizontal axis of the above | figure is not drawn to scale.) 7 l This is usually in the form of an electronics card that plugs into a computer, and connects to a camera through a coaxial cael Aer > aot I 2.3 Brightness and Contrast Adjustme: yeresanisanlioes. For example, a white rabbit running across a snowy field has poor contrast, while a J black dog against the same white background has good contrast. | “Increasing the brightness makes every pixel in the image becomes lighter. In comparison, increasing the contrast makes the light areas become lighter, and the dark areas become darker. These images show the effect { Jof misadjusting the brightness and contrast. 2.4 Linear Image Processing of these two, since images have their information encoded domain rather than the frequency domain. jin the spat J ion,etc. These procedures are carried. out by convolving the original image with an ‘appropriate filter kernel, producing the filtered image. “A serious problem with image convolution is the ppgnormous: number of calculations that need to be performed, often resulting in unacceptably long execution [Jiines. Two. impotant teshnigues for redding the exeeulion time are also described: convolution by Spray PT comtuon, 2.4.1 Convolution Image convolution works in the same way as one-dimensional convolution. For instance, images ¢an be f .e., sealed and shifted delta functions. Likewise, linear systems are Ua : that is, by their impulse responses. As you should expect, the ‘output image from a system is equal to the input image convolved with the system's impulse response. The two- [dimensional delta function is an image composed of all zeros, except for a single pixel at: row = 0, column \ which has a value of one. For now, assume that the row and column indexes can have both positive and negative values, such that the Tone is centered in a vast sea of zeros. When the delta function is passed through a linear system, the single point will be .change<. ina SOCAN LEE ly thing that cap happen to a point is that it spreads out, the impulse respon: c point spread fanstion (@S3) image iprocessing jargon. 2.4.2 FFT Convolution - Even though the Fourier transform is slow, it is still the fastest way to convolve an image with a large filter “kernel. For example, convolving a 512 x 512 image with a 50 x 50 PSF is about 20 times faster using ‘the EET compared with conventional_convolution. FFT convolution works for one-dimensional signals. The two- [dimensional version is a simple extension. We will demonstrate FFT convolution with an example, an algorithm to locate a predetermined pattern in an image. Suppose we build a system for inspecting one-dollar bills, such as might be used for printing quality control, counterfeiting detection, or payment verification in a vending machine. As shown in Figure below, a 10 x 100 pixel image is acquired of the bill, centered on the portrait of George Washington. The goal is to search this image for a known pattern, in this example, the 29x29 pixel image of the face. |. The problem is this: given an acquired image and a known pattern, what is the most effective way a F ol @ matched filter) it i | 100 pixels r a : 29 pinels — I 2 4 : 2 it Si by Target age to be searched ‘Target detection example. The problem is to search the 100x100 pixel image of George Washington, (a), for the target pattern, (b), 29x29 pixel face. The optimal solution is correlation, which can be carried out by convolution. << 2.5 Special Tunaging Techniques__— There are fo image processing. First, ways to ng. First, ways to characterize the . This describes thet i dbject must be to be seen in an image. Second, th is examined, exi a an techniques are introduced, These are noi erations used to manipulate binary images (where each pixel is either black cor white). Fourth, the remarkable technique of computed tomography is described. This has revolutionized ‘medical diagnosis by providing detailed images of the interior of the human body. /e i: ., . 25,1 Signal -to- Noise Rati object That is, the ‘contrast of the object (Le., the signal) must overcome the image noise. This can be broken into EWO Classes: Figure below illustrates an experiment to measure the eye's ability to detect weak signals. Depending on the observation conditions, the human eye can detect a minimum contrast of 0.5% to 5%. In other words, humans can distinguish about 20 to 200 shades of gray between the blackest black and the whitest white. The exact number depends on a variety of factors, such as the brightness of the ambient lightning, the distance between the two regions being compared, and how the grayscale image is formed (video monitor, photograph, halftone, etc.) conta 50% 40% 90N KOK RS Contrast detection. The human eye can detect a minimum contrast of about 0,5 to 5%, depending on the ‘observation conditions. 100% contrast is the difference between pure black and pure white. = Minimum detectable SNR. An object is visible in an image only if its contrast is large enough to overcome the random image noise. In this ai the three aa a SNRs of 2.0, 1.0 and 0.5 (oer eS ‘Gaara mater {] Inthe figure below we see the image noise. Random noise in images takes two general forms. In (a), the \ amplitude of the noise remains constant as the signal level changes. This is typical of electronic noise. In (b), the amplitude of the noise increases as the square-root of the signal level. This type of noise originates irom the — detection of a small number of particles, such as light photons, electrons, or x-rays Sree ish 4. Constant amplitude nose ellen 2.5.2 Morphological Image Processing ‘The identification of objects within an image can be a very difficult task. ee ED Ret “fo cng eevee imag in «inary nag in which each pixel is restricted to a value of either 0) or a techniques used on these binary images go by such vu bapa, comeaiy ans ant “moxpholosical image processing (fom the Greek word moiphe, meaning shape or form). ¢ foundation of morphological processing is in the mathematically rigorous field of set theory; however, ‘this level of sophistication is seldom needed. Most morphological algorithms are simple logic operations and very ad hoc. In other words, cach application requires a custom solution developed by trial-and-error. This is usually more of an art than a science. are used in the processing of binary images: eas dion, ‘gure (a) shows an example binary image. Figures (b) to (e) show the result of applying se operations to the image in (a). eee Oia A “‘Dration &. Opening &. Closing. Binary skeletonization: The binary image of a fingerprint, (a), contains ridges that are many pixels wide. The skeletonized version, (b), contains ridges only a single pixel wide. xa ete Sena gt . 3.Data Compression ___— ‘The more information being dealt with, the more it costs. In spite of this, most digital data are not stored in ‘the most compact form. Rather, they are stored in whatever way makes them easiest to use, such as: ASCII text fom word processors, binary code that can be executed on a computer, individual samples from @ data acquisition system, etc. - Typically, these easy-to-use encoding methods require data files about twice as large as actually needed to represent the information. Data compression is the general term. for the various algorithms and_p developed to address this problem. actness, a n prog g for data compression. The first three are simple encoding techniques, called: The last two are elaborate procedures that have established themselves as industry standards; Run-Length Encoding _ ;> ” Data files frequently contain fhe same Character repeated many times in a row. For example, text files use { \imultiple spaces to separate sentences, indent paragraphs, format tables and charts, etc. Digitized signals can “iso have runs of the same value, indicating that the signal is not changing. For instance, an image of the ‘nighttime sky would contain long runs of the character or characters representing the black background, [oe Likewise, digitized music might have a long run of zeros between Gongs) Run-length encoding isa simple ‘method of compressing these types of files. c ‘file: zero to indicate that compression is occurring followed by the number Of zeros in the run. original data steam: 17 8 54000975 1604529 0000367008 sunlength encoded: 17 8 5403 975 160 145230 53670 2 8 3.2. Huffman Encoding This method is named after D.A. Huffman, who developed the procedure in the 1950s. Figure below shows a histogram of the byte values from a large ASCII file. More thart 96%)of this file consists of only 31 characters: the lower case letters, the space, the comma, the period, and the carriage return. This observation can. Fe used to make an appropriate compression scheme for this file. To start, we will assign each of these 31 common characters a five bit bingry code: 00000 ="all, 0000) = "b", 00010 = "c", etc. [he last of the five bit codes, 11111, will be a flag indicating that the character being transmitfed is not one of the 31 common characters. The next eight bits in the file indicate what the character is, according to the standard ASCII assignment. These results in 4% of the 10 characters in the input file requiring 5+8=|3 bits. The idea is to assign frequently used characters fewer bits, “and seldom used characters more bits. In this example, the average number of bits required per original character ist 0.96 x 5 + 0.04 x13 = 5.32 -in other words, an overall compression ratio oft $ bits/5.32 bits, or about 1.5: 1. = ees ‘ASCII codes. This is a long established standard for allowing letters and numbers to be represented in digital form, . Even though only 128 codes are defined, ASCII characters are usually stored as a full byte (8 bits) 2h geRSSY a hs wed So Gen ties, math pysymbols, and various geometric pattems; however, this i not stan Many of the control characters (0 to | [31 are based on older communications networks, and are not applicable to computer technology. ml a a f 1 start heading BE 6s 7 {] 2 Sanofest rd & 2 8 8 5 coforese He Gt we 4 Sed stamh %$ 8 Bike a 3 Sauy HR 8 2 ite i 3 slnowedge oe % OF 102 f a | 5 Sl been 3 RG Me tl & backspace 4 oR ios 3. hoa af Bt 1st god 5 jo lnc feed pe ees ey ij E Hwuuhtone 2 + BG | bese 2S RE iat 15 Gorge = a3 om | im goug 13 Shine 6 ia No lon & 13 shitn $i Bo ile 13 Si ite ore Ho BF ibs é Gj Secu oY 8 1S “ood ig Gveceenels 3020 Ra : 19 de control 3 a 33S Mss ¥ pevcouds 24. Bt list | | Rmomee 8300 BG yw + — t_ eh ale 2b. ey * wae HS chdwmitbiock 53.7 @ W U9 w peas i Gea % 30 om Xt ; 3 tdotmeum = YO 3 Sistine a 2 L 27 escape 33 a f if % Gielen = a | a 125 ' 30 Keowsmrar = > ok iB = } Mites GF 8 aw yp, The encoding table assigns each of the seven letters used in this example a variable length binary code, { ‘based on its probability of occurrence. The original data stream composed of these 7 characters is translated by this table into the Huffman encoded data. Since each of the Huffman codes is a different length, the binary data f need to be regrouped into standard 8-bit bytes for storage and transmission, l original data stream: CEGADE REAM Example Encoding Table_ Ietor | probabilty | Hoffnan code ra >) Huffinan encoded: 0010 0001 000011 1 0011 000010 O1 0001 1+ A i we \ v y J T D | 063 | oon E | ‘059 | 0001 |) srouped into bytes: 00100001 00001110 01100001 c0100011- F | 201s | 090010 { et ree eee G| ‘1 | oooont i | DSP Lecture 5 | Tools for working with DSP & DSP Future 1. Introduction DSP techniques became feasible only when computers were commonly used on a large scale. Therefore, Jthe computer is an extremely important tool for studying, designing, and testing systems based on DSP | techniques. For a variety of reasons, this fact was largely ignored by academic courses on DSP in previous years. This fis changing, as today even the humblest freshman is likely to have access to computer power that NASA could L have only dreamed about 10 or 15 years ago. Academic departments are no longer constrained to dealing with only the analytical approaches to developing a DSP curriculum. l 2. DSP Learning Software _ [ It is becoming more common for books on DSP to come with some type of programming support. The least useful examples of this are simple listings of C code. This code can be helpfil to study and can often be used as a basis for starting a DSP application. On the other hand, code of this type is generally limited in its ‘sophistication. The code is rarely written for a specific compiler or operating system, and therefore is not likely to contain any graphical or display output. On the other hand, it is relatively simple, and is not intended for developing DSP applications in a | demanding production environment. Some of this software provides a great deal of capability, but often at the expense of understandability or ease of use. = aa DSP learning software is available from many sources other than just_books. Commercial training | programs, university BBSs, and the BBSs of the DSP processor vendors are often good sources. [ 3. Spreadsheets ‘A number of general-purpose software tools are useful for studying and developing DSP systems. The first, of these is the spreadsheet. The examples using spreadsheets are done with Microsoft Excel though most | modem spreadsheets will work just as well. fe Pees ‘The main use of spreadsheets is in setting up simple series and then manipulating them, The results of these manipulations are then easily graphed. It is possible to do very complicated operations with spreadsheets, but it can quickly become more trouble than it is worth. For example, implementing an FIR or an IIR is possible with a spreadsheet, but it requires considerable effort. =. On the other hand, a spreadsheet is a great way to see what happens when you multiply two sine waves together on a point -by- point basis, or for studying what happens when sine waves are added together. It's a very convenient way, for example, of getting a feel for the Fourier series. eee 4. Programming Languages {) Almost any programming language can be used for studying DSP. For actually producing DSP “applications, however, there are three basic choices: assémibly language, C, and FORTRAN. !t is quite common to use assembly language to produce working applications. Generally, however, coding_in-assembly_is-not recommended for studying DSP, or for the early phases of DSP development, due to the tediousness of the programming and the relative difficulty of being able to visualize the algorithm when it is expressed in assembly code. Another difficulty with assembly language programming is that it requires_an intimate knowledge of the particular processor being used. Further, depending upon the development environment, assembly language programming can be difficult to debug and experiment with. Chas become the de facto standard for programming DSP applications and is therefore a natural selection for any type of DSP work. In fact, itis quite common to develop DSP algorithms in a user-friendly environment (such as Borland’s C/C++, or Microsoft's Visual C/C++), and then port the application over to the DSP system for the final implementation, Currently, C environments for DSP chips generally follow the ANSD standards. Work is underway, however, that would expand the ANSI C standard to include support of DSP-specific needs. Interestingly, the object oriented nature of C++ makes it generally less useful for DSP applications. Interest is growing in using C++ for DSP applications, however, and as the language becomes familiar to. more programmers, we may see an increase in DSP applications based on C+ +. FORTRAN bas lost much of its application base to C pver the last several years. It is also fairly rare to find aFORTRAN compiler on a PC. For these reasons, the general use of FORTRAN is declining. It is, however, by no means a dead language. Further, a great deal of early program development in DSP was done in FORTRAN. C: FORTRAN code is simpler to read and write, and ‘While these are the three most common working languages for DSP applications, other languages should ‘not be overlooked for studying or developing DSP applications Probably the best choice, in many regards, is Basie, While Basie is often considered a programmer training language, it has been used in a wide variety of sophisticated applications. Modern Basic languages offer sophisticated error handling, easy graphic implementation, structured program development, and other sophisticated attributes. For working in the Windows environment, Microsoft's Visual Basic™ is one practical way to write programs without enduring an extremely long learning curve. It offers a combination of simple basic programming, an object-oriented interface to Windows, and an affordable price tag. 5. General Mathematical Tools ‘A number of good general-purpose mathematical tools are available. Unfortunately, they tend to be(uily) expensive. If they are available, however, they are an invaluable aid in studying DSP. Like the other tools discussed so far, these tools automate the frustratingly tedious computations involved in DSP techniques. They have another significant advantage over the other tools discussed so far: they ean symbolically evaluate analytical expressions ‘A good le of this is the (IR)Here, both symbolic and-arithmetical computations were carried out using by MathSoft. Other popular tools include MatLab™ by Math Works and Mathematica™ by Wolfram Research. _ 7 Generally, these tools come with optional modules that provide DSP-specific functions. Like any software tool, some effort is required to learn how to use these products effectively. It must also be Kept in mind that ¢ these tools can unload much of the work involved in developing a DSP application, but they cannot unload the creative part of the design. Nor can they be expected to catch system design errors, or to provide good results if they are fed bad dat These responsibilities still reside With the design engineer. As always, it to have a firm Most of these tools are available in versions that will ran on UNL ‘based PCs, Some versions are available for the Macintosh computer, but thes€ are often inferior to the versions available for other two U platforms. | 6. Software/Hardware Development Packages _ There are some things to keep in mind about evaluation units, however. These systems are generally designed to be sold at or below cost to vendor. As such, they generally don't offer a great deal of flexibility. The analog /O is typically limited, and often some of the processor resources (such as interrupts, internal memory, etc.) are devoted to supporting the evaluation configuration, Evaluation units are generally limited to providing assembly language development tools. More sophisticated systems are typically available under the heading of development systems. Typically, compilers, source level debuggers, assemblers, and Host PC interface software are provided. A particularly ‘useful feature of many of these systems is the included library of software routines. Depending upon your application, these libraries may more than pay for the whole development system by shortening design and coding time. sis es aa 7. In-circuit Emulators Another tool available for developing applications is the in-circuit emulator. The emulator is an electronic pod with the same pin-out as the target processor. The pod)is connected to a PC or UNIX workstation, where the development software resides. Emulators-are useful when the actual product hardware already exists. ‘The emulator is plugged into the target hardware instead of the DSP processor, allowing programs to be downloaded to the target system. The pod emulates the processor, but it also provides complete visibility into the operation of the system. In-circuit emulators are invaluable(aid3 for developing embedded applications. They often greatly shorten. the hardware and software debug time. Unfortunately, emulators ate also fairly)expensive. They start at around $5,000, and go up to $30,000 or more. oan 8. World Wide Web In the last few years the World Wide Web ews) Yhas become a major too! for researching a wide variety oftopics. The material on the Web that relates to DS f topics. at relates e, varied, and rather dynamic. As with using the Web to find about any subject, the problem is to find th that has what you are looking for The tools for searching the Web are the search h_engines, Magellan, Yahoo, and InfoSeek are a few examples. each 9. DSP and the Future One of the continuing themes is that learning DSP techniques can sometimes seem intimidating. This is not so much that the actual techniques are particularly difficult, but the difficulty often lies in the fact that the ‘techniques are, for the most part, purely mathematical. When we set out to learn about analog Filters--a simple LC circuit. The circuit physically exists, so we can approach it from a physics point of view. We can imagine the currents flowing, the various potentials. We can see these things on an oscilloscope. Only when we need to compute specific values for components must we tum to algebra. Or, if our application requires more detailed analysis, we can bring higher mathematics into play:and work with the differential equations that describe the behaviors of the components. oe When we turn to DSP techniques it initially seems like we lose this "big picture." Instead, we are faced with obscure integrals, unfamiliar summations, and expressions that are intuitive only to professional —mmathematicians. As we gain some experience, however, some interesting insights evolve. Among these are the facts that many of the concepts from physics and electrical engineering carry over. Frequency is still frequency (though we have to deal withthe digital frequency), the same relationships between the frequency domain and time domain still hold, and so forth. In fact, we quickly find that the digital domait amuch simpler than the [ analog domain, _ ential equations are replaced with simpler difference equations. We are largely removed from the real-world constraints of specific component values, parasitic effects, and the like. This does not mean that no | real craftsmanship goes into producing a workable DSP system, but the digital approach is almost always simpler to implement from a conceptual point of view. The hardware may or may not be simpler, but geting a digital system to do what we want is usually simpler than getting an analog system to respond the way we want. [ ‘This fact, combined with the fact there are some operations that simply are not practical in the analog domain, ensure that DSP techniques will continue to take over a larger and larger percentage of applications. Even a modem analog-based cellular phone, for example, still contains a significant amount of digital circuitry. | ‘The rapid acceptance of DSP techniques is having a snowball effect. Twenty years ago DSP was an esoteric practice largely confined to Ph.D.s. Today, virtually all engineers and a significant percentage of technicians will have at least some exposure to DSP. As the price continues to fall for DSP components, more and more Dbcojectsace betty bused ero und thers’ Incaddew shore’ years, jrolictenoyiia DSP will mtaely be a advats it will be a requirement of almost any technical position. _ Not all of the gains in DSP applications will place a burden on the typical design engineer. A good example is the modern modem chip. These specialized devices are practical marvels of signal processing, and yet designing them into a product requires only a rudimentary understanding of communications theory. The DSP ‘expertise is largely buried in the silicon. For some applications, this trend will continue, Obviously, for these types of products, only the chip designer must be a true expert in DSP As embedded applications grow, however, the need for a greater | understanding of DSP techniques will continue to grow as well. Finally, the thought I would like to leave with Ujou is that DSP can honestly be fun: The resources of the modern desktop computer make it possible to ensily and rapidly experiment with the ideas bebind digital signal processing. Once you get past the seemingly formidable nature of the techniques, DSP algorithms are often quite simple and easy to implement. Remember, even though we live in an analog world, the future is digital! 10. DSP Vendors 10.1 Mathematical Tool Vendors MathSoft Ine (makers of MathCAD) 101 Main Street ‘Cambridge, MA 02142 (800) 6284223 e-mail: sales-info@mathsoftxom Web address: www,mathsoftxom Math Works, In. (makers of MatLab) 24 Prime Park Way Natick.MA 01760 { (08) 653.1415 | e-mail info@mathvvorks.com Web address: ww.mathworks.com Wolfram Research, Ine. (makers of Mat | 1o0 ‘rade Center Drive Champaign, IL 61820 (800) 441 -6284 /-)e-mail: info@wolfram.com ie | Web address: wow. wolfiam,com (10.2 DSP Chip Vendors Ariel Corporation (headquarters) 2540 Route 130 Craribury,NJ 08512 | fax:(609)860-1155 x © email: ariel@ariel.com [']Analog Devices | 1 Technology Way Norwood, MA 02062 (617}461-3881 | Web address: worwanalog.com at&t Microelectronics 555 Union Blvd. [ Dept. ALS00404200 AUentown, PA 18103 (800) 372-2447 Web address: www.att.com ‘Motorola DSP Division {6501 William Cannon Dr. W “Austin, TX 78735 | Gitys 2050 Motorola Semiconductor Products Sector | [Communications & Advanced Consumer Technology Group Austin, Texas e-mail: dsphelp@dsp-spsmot.com Web address: www mot.com/SPS/DSP NEC Electronies 475 Ellis Street Mountain View, CA 94039 \Pentek, Ine. 55 Walnut Street Norwood, NJ 07648 { )fax: @01) 767-3994 ‘ e-mail: rodver@pentek.com > Texas Instruments, Semiconductor Group | [P.0. Box 1712208 © Denver, CO 80217 (800) 477-8924 [) Web address: won Check out TTS ot com ie DSPLab at www.dsplab.com ‘White Mountain DSP, Inc. Suite 433 131 DW Highway Nashua, NH 03060-5245 fax: (603) 882-2655 a [ | e-mail: info@wmdsp.com 10.3 Board-level Products + Communication Automation & Control, Ine 1642 Union Blvd. Suite 200 Allentown, PA 18103, CSPI (VME boards) 40 Linnel Circle BiUerica, MA 01821 (800)325-3110 Data Translation (PC, PCI) 100 Locke Drive Marlboro, MA 01752 (508)481-3700 e-mail: Info@datx.com Web address: yrvw.dats.com DSP Research, Inc. (PC, PCI) 1095 East Duane Avenue Suite 203, ‘Sunnyvale, CA 94086 (408) 73-1042 National Instruments (PC) (6504 Bridge Point Parkway Austin, TX 78730 (800) 443-3488 e-mail: info@natinst.com ‘Web address: www.natinst.com SONITEC International Inc. (PC) 14 Mica Lane Wellesly, MA 02181 (617) 235-6824 White Mountain DSP (PC) 131 DW Highway Suite 433 Nashua, NHI 03060-5245 (603) 883-2430 11. Useful Magazines and Other Publications Communication Automation & Control, Inc. 1642 Union Boulevard, Suite 200 ‘AUentown, PA. 181034585 (610) 776.6669 e-mail: sales@cacdspxom ‘Web address: ynww.cacdsp.com Communication Systems Design ‘Monthly, devoted to communications, multimedia, and DSP. FREE to qualified engineers. (415) 905-2200 Web address: www.csdmag:com 7 | ‘Communications Week | CP publication with lots of graphics (516)562-5000 jwutechweb.cmp.com/ew/eurrent | Computer Design Monthly, articles on computer design, DSP, embedded { systems, ete. FREE to qualified engineers (603)891-0123 Web address: wurw computer-design.com DSP and Multimedia Technology Bi-monthly, paid circulation, (415) 969-6920 eww nahin | IEEE Signal Processing Magazine TEEE’s flagship magazine for DSP and signal processing issues. ‘Available to IEEE members and non-members. (212) 705-7900 Personal Engineering and Instrumentation News Mark Sullivan writes a DSP column for this magazine, He provides downloadable source code on the Web at www.access.digex.net/—dalek, Tech Central | (Online product mart devoted to DSP, embedded systems, machine vision, and other areas. Registration required. ‘Web address: www.techeentral.com | Tech Online “Another online product mart. Web address: www.techonline.com ‘Amateur Radio DSP Page Web address: wwrw.tapr.ora/dsp/index. htm Been eek al DSP Exercises r : ee f 2 -L Wat are the disadvantages to the digital process? [2 Since the signal is sent as numbers, it can be (Easily — Difficulty ~ Possibly) encrypted. l | 3. The advantage of the analog process (Simple ~ less RAM ~ More RAM), 4- What are the most important characteristics of an ADC in the DSP systems? analog process can take on virtually an infinite number of values within the signal's ''s. Analog signal LU dynamie range (Right Fase. bette 6- The resolution ih DSP efines ae - a 7- The output of the Reusdong) is quite small: (micro-volts to milli-volts - micro-volts to volts - milli-volts to |) vots) a) [ 8- The slew rate of the DAG should be matched to the acquisition rate of the ADC, (Right ~ False). __o Motors (Output —Input None) transdugg. U-= | 10- The resolution ofthe signal have two characteristic: (~ ae = [ L1- If.we put in a value for fin the Nyquist theorem, of either 0 or 8 when we are using 16 3amples/second, the frequencies said to be (Aliases ~ Not aliases) of one another. -) scale or ( 12-The frequency response could be displayed either on a ( -) in decibels 13-The parameters for evaluating frequency domain performance in the digital filter are (——--—-—----, . [ yand |= Binary value Weight 000 7 007 7 010 7 1 7 100 7 101 a 110 a 1 ? 15- Analog filters are (Cheap, Fast, and have a large dynamic range in both amplitude and frequency). Digital ‘filters, in comparison, are (Vastly superior - Low superior) in the level of performance that can_be achieved), [16+ The step response can be found by (discrete integration) of the impulse response. While the frequency response can be found from the impulse response by using the (Fast Fourier Transform). 17- Information is contained in the signals where we are working with in (Time domain — Frequency domain — Both). 18- The parameters for evaluating time domain performance in the digital filter are (— =) 19- Draw a block diagram of spectral reversal for the designing of a band-reject filter? 20- There are two methods for the low-pass to high-pass conversion: | 21- Draw a block diagram of spectral reversal for the designing of a band-pass filter? _ 2D One of the properties of light is that it cannot be focused to smaller than about one-half wavelength, as (0.3 L um— 0.8 pm —3.5 pum). /-23- In the compressed speech, where (reducing — increasing) the data rate is very important and some |) unnaturalness in the sound quality can be tolerated. [24- One of the properties of light is that it cannot be focused to smaller than about one-half wavelength, as (0.3 ym — 0.8 pm—3.5 um). 25- The hardware used for analog-to-digital conversion of video signals is called a (frame grabber ~ frame splitter — frame generator). //26- In grey scale images, each pixel has a value of (0t0255 - 128t0-128 ~ 01064). 27- There are two important techniques for reducing the execution time in the line image processing, (-~ ). j)28 In the Run-Length Encoding, each run of zer --, and — is replaced. by (two ~ three ~ four) characters in the compressed file. | 29- Bach frame is broken into two fields, bne containing the (odd ~ even ~ al) lines and the other containing the (even — odd —all) lines. | 30- In the High fidelity music, the sound quality is of the greatest importance and almost (high - any - low) data rate will be acceptable. {/31- The hardware used for analog-to-digital conversion of video signals is called a (frame grabber ~ frame (splitter — frame generator). l 32-(- ----) are the main five techniques of data) compressic { ipression. _ | 33- Most of the DSP tools available in versions that will run on UNIX workstations and on Windows-based PCs. (Right — wrong). ns when you multiply two sine waves together on a point -by- Lisa. Spreadsheet is a great way to see what hay point basis. (Right — wrong).

You might also like