资源描述
Click to edit Master title style,Click to edit Master text styles,Second level,Third level,Fourth level,Fifth level,Sept 05,*,CS3291:,D,igital,S,ignal,P,rocessing,Barry Cheetham,Section 1: Introduction,Signal,: time-varying measurable quantity,whose variation normally conveys information.,Quantity,often a voltage obtained from some transducer,e.g. a microphone.,It is useful to define two types of signal:,Continuous time (analogue),Discrete time,Analogue signals,: continuous functions of time (t) measured in,seconds. Exist for all values of t in range -,to +,.,Examples:,(i) 5sin(62.82t) : sine-wave of frequency 62.82 radians/second ( 10 Hz),0 : t 0,(ii),u(t,) =, step-function signal.,1 : t,0,Graph of analogue signal against time gives continuous waveform,:,t,Voltage,0.1,-0.1,5,t,Voltage,1,Discrete-time signals,: exist only at discrete points in time.,Often obtained by,sampling,an analogue signal,i.e. measuring its value at discrete points in time.,Sampling points separated by equal intervals of T seconds.,Given analogue signal,x(t,),xn,= value of,x(t,) when t =,nT,.,Sampling process produces a sequence of numbers:, ., x-2, x-1, x0, x1, x2, . ,Referred to as ,xn, or the sequence,xn, .,Sequence exists for all integer n in the range -,to,.,Examples of discrete time signals:,(i),., -4, -2,0, 2, 4, 6, .,sequence whose nth element,xn, is defined by :,xn, = 2n.,Underline sample corresponding to n = 0.,(ii), ., -4.75, -2.94,0, 2.94, 4.75, 4.76, .,sequence with,xn, = 5 sin(62.82t) with t=,nT,and T=0.01.,(iii), ., 0, ., 0. 0,1, 1, 1, ., 1, .,“ unit step ” sequence whose nth element is:,0 : n 0,un, =,1 : n,0,Discrete time signals represented graphically as shown for example (i):,n,xn,1 2 3 4,-3 -2 -1,2,-,-2-,clear all;,T = 0.01;,% sampling interval (seconds),% Generate 80 samples of a 10 Hz sine-wave of amplitude 5,% Need 5 sin(2*pi*10*t) with t=nT for n=1,2, . 200,for,n=1:80,s(n) = 5 * sin(2 * pi * 10 * n * T);,end,;,plot (s);,MATLAB demonstration1,To generate & plot 80 samples of a sine-wave:,0,10,20,30,40,50,60,70,80,-5,0,5,Discrete time signals often generated by,ADC,devices.,Produce binary numbers from sampled voltages or currents.,Accuracy determined by word-length of ADC device,i.e. number of bits available for each binary number.,Quantisation,: Truncating or rounding sampled value to nearest available binary number,Resulting sequence of,quantised,numbers is a,digital signal,. .,Digital signal is discrete time signal with each sample,digitised for arithmetic processing.,Signal Processing:,Analogue signals processed by circuits consisting of resistors, capacitors, inductors, transistors & operational amplifiers.,Digital signals processed using programmed computers, microcomputers or special purpose digital hardware.,Examples of the type of processing that may be carried out are:,(i) amplification or attenuation.,(ii) filtering : e.g. filtering out some unwanted part of the signal.,(iii) rectification : making waveform purely positive.,(iv) modulation : multiplying signal by another signal,e.g. a high frequency sine wave.,clear all;,fs = 8000;,%sampling rate in Hz,T = 1/fs;,% sampling interval (seconds),% Generate 10000 samples of 500 Hz sine-wave:-,for,n=1:10000,s(n) = 4000 * sin(2 * pi * 500 * n * T);,end,;,% Store in a non-formatted (binary) file:-,OFid=fopen(,newsin.pcm,wb,);,fwrite(OFid, s,int16,);,fclose(,all,);,MATLAB demo2: Store 500 Hz sine-wave block in file,MATLAB demo 3: Amplify sine-wave,clear all;,%Input from file:-,fs = 8000;,% sampling rate in Hz,IFid=fopen(,newsin.pcm,rb,);,Insin = fread(IFid,int16,);,%Amplify by 6 dB:-,for n=1:10000,Outsin(n) = 2 * Insin(n);,end;,% Output to a file,OFid=fopen(,newop.pcm,wb,);,fwrite(OFid, Outsin,int16,);,fclose(,all,);,clear all;,%Input speech from a file:-,fs = 8000;,% sampling rate in Hz,IFid=fopen(,operamp.pcm,rb,);,Inspeech = fread(IFid,int16,);,%Design FIR digital filter:-,fc = 1000;,% cut-off frequency in Hz,a b = fir1(20, fc/(0.5*fs) );,freqz(a,b);,%Process speech by filtering:-,Outspeech = filter(a, b, Inspeech);,% Output speech to a file,OFid=fopen(,newop.pcm,wb,);,fwrite(OFid, Outspeech,int16,); fclose(,all,);,MATLAB Demo4 Filtering speech,0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,-1000,-800,-600,-400,-200,0,Normalized Frequency (,p,rad/sample),Phase (degrees),0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,-100,-80,-60,-40,-20,0,Normalized Frequency (,p,rad/sample),Magnitude (dB),IFid=fopen(,newop.pcm,rb,);,speech = fread(IFid,int16,);,maxamp = max(abs(speech);,SOUND(speech/maxamp,8000,16);,fclose(,all,);,MATLAB Demo5: Listen to speech in a file,clear all;,%Input from file:-,fs = 8000;,% sampling rate in Hz,IFid=fopen(,newsin.pcm,rb,);,Insin = fread(IFid,int16,);,%Full-wave recify:-,for n=1:10000,Outsin(n) = abs ( Insin(n) ) ;,end;,% Output to a file:-,OFid=fopen(,newop.pcm,wb,);,fwrite(OFid, Outsin,int16,);,fclose(,all,);,MATLAB demo6 : Rectify sine-wave,for n=1:10000,Outsin(n) = 2*Insin(n);,end;,for n=1:10000,Outsin(n)=abs(Insin(n);,end;,Outsin = abs(Insin);,Outsin = 2*Insin;,Using MATLAB more efficiently,Slow,Faster,MATLAB exercise 1: Modulation,Generate 320 samples of a 50 Hz sine wave sampled at 8kHz and multiply this by by a 1kHz sine wave sampled at 8kHz.,Plot the resulting waveform,MATLAB exercise 2 : Simulate POTS speech quality,A plain old fashioned telephone transmits speech between 300Hz & 3 kHz. Design & implement high- & low- filters to allow the effect of the band-width restriction to be assessed by listening.,clear all; fs = 8000;,T=1/fs;,for,n=1:320,s50(n) = sin(2*pi*50*n*T);,end,;,figure(1); plot (s50);,for,n=1:320,smod(n) = s50(n)*sin(2*pi*1000*n*T);,end,;,figure(2); plot (smod);,Solution to MATLAB Exercise 1,0,50,100,150,200,250,300,350,-1,-0.8,-0.6,-0.4,-0.2,0,0.2,0.4,0.6,0.8,1,% A solution for MATLAB Exercise 2,clear all;,%Input speech from a file:-,fs = 8000;,% sampling rate in Hz,IFid=fopen(,operamp.pcm,rb,);,Inspeech = fread(IFid,int16,);,%Design FIR band-pass digital filter:-,fU = 3000;,% upper cut-off freq Hz,fL = 300;,% lower cut-off freq,a b = fir1(100, fL/(0.5*fs) fU/(0.5*fs) );,freqz(a,b);,%Process speech by filtering:-,Outspeech = filter(a, b, Inspeech);,% Output speech to a file,OFid=fopen(,newop.pcm,wb,);,fwrite(OFid, Outspeech,int16,); fclose(,all,);,WARNING,If you do experiments and listen to the output generated, be careful not to expose yourself to high levels of sound.,Avoid listening to sinusoids except at very low volume using speakers (Do not use headphones for sine-waves).,Avoid the use of headphones with such experiments.,Do not risk damage to your hearing.,And/or falling out with your,neighbours,.,Applications of DSP:,Real time processing :,A mobile phone contains DSP processor fast & powerful enough to perform the mathematical operations required to filter digitised speech as it is being received.,Non real time processing:,A PC can perform DSP processing on a stored recording of music & can take as much time as it needs to complete this processing.,Non real time DSP useful in its own right; e.g for MP3 compression.,Also used to simulate software for real time DSP systems before they are built into special purpose hardware, say for a mobile phone.,Simulated DSP systems may be tested with stored segments of speech.,Real time DSP often uses ,fixed point, microprocessors since they,consume less power & are less expensive than ,floating point, devices.,A fixed point processor deals with all numbers as integers.,Numbers often restricted to a word-length of only 16 bits.,Overflow can occur with disastrous consequences to sound quality.,If we avoid overflow by scaling numbers to keep them small in amplitude,we lose accuracy as,quantisation,error is larger proportion of the value.,Fixed point DSP programming can be quite a difficult task.,When we use a PC for non real time DSP, we have,floating point,operations available with word-lengths that are larger than 16 bits.,This makes the task much easier.,When simulating fixed point real time DSP on a PC, we can restrict,programs to integer arithmetic, & this is useful.,Examples of signals commonly processed in digital form:,Speech, as encountered in telephony, for example.,Biomedical signals such as heart signals & “brain waves”.,Sound & music.,Video & images.,Radar & sonar signals.,Advantages of DSP:,More & more signals are being transmitted & stored in digital form so it makes sense to process them in digital form also.,DSP systems can be designed & tested in simulation using PCs.,Accuracy pre-determined by word-length & sampling rate.,Reproducible as every copy of DSP system will perform identically.,Characteristics of system will not drift with temperature or ageing.,Availability of advanced VLSI technology.,DSP systems can be reprogrammed without changing hardware.,Products can be updated via Internet.,DSP systems can perform functions that would be extremely difficult or impossible in analogue form; e.g.,adaptive filtering,speech recognition.,Disadvantages of digital signal processing,:,DSP designs can be expensive especially for high bandwidth signals where fast analogue/digital conversion is required.,Design of DSP systems can be extremely time-consuming & a highly complex and specialised activity. There is an acute shortage of computer science and electrical engineering graduates with the knowledge and skill required.,Power requirements for digital processing can be high, thus making it unsuitable for battery powered portable devices. Fixed point processing devices are available which are simpler than floating point devices and less power consuming. However the ability to program such devices is a particularly valued and difficult skill.,Some processes, e.g. amplification, & filtering, are,linear,.,Processes may also be,time-invariant,.,Processes which are both,linear,&,time-invariant,are,LTI,.,Consider,impulse-responses,of such LTI systems.,Leads to,frequency-response,&,system function,These come from the,Fourier,Laplace,and,z-transforms, and are all related to,convolution,.,These concepts allow us to:,(i) analyse effects of LTI systems on,analog,& digital signals,(ii) understand & employ design methods for such systems.,GAIN,FREQUENCY,1,f,C,Gain-response of a low-pass filter may be derived from its frequency-response,Modern signal processing often programmed on DSP microprocessors which are fast enough to compute each output in real time.,Consider how a DSP processor differs from a Pentium IV ?,Analogue signals must be converted into digital form and vice-versa.,Effects of sampling, ADC & DAC studied in this course.,Also the Fast Fourier transform (FFT) & its many applications,including spectral estimation.,Summary of Course Objectives:-,1 Importance of DSP, its jargon, & meaning of real time processing. Advantages/disadvantages.,Analogue, discrete time & digital signals.,Sampling & quantisation in general terms.,2. Brief review of analogue & digital signal processing systems,Transfer function and frequency-response of an analogue filter.,Low-pass and band-pass analogue filters.,Butterworth low-pass gain response approximation.,3. Discrete LTI signal processing systems.,Recursive & non-recursive difference equations.,Signal flow-graphs & their implementation by computer programs.,Impulse-response for discrete time systems.,FIR & IIR type digital filters.,Stability and causality. Time-domain convolution.,Frequency response & DTFT. Gain and phase responses.,Linear phase and group delay. Inverse DTFT.,Use of MATLAB for analysing the frequency-response of digital filters.,4. Design of FIR digital filters by windowing method & alternative methods.,5: Introduction to z-transforms & IIR type discrete time filters,System function, H(z), as z-transform of impulse response.,Relationship between system function, difference equation, signal flow-graph & software implementation of FIR and IIR type digital filters.,Poles and zeros & distance rule.,Design of a digital IIR notch filter and a resononator by pole/zero placement. Application to these filters to sound recordings.,6: Design of IIR type digital filters using analogue filter approximations,Derivative approximation & bilinear transformation & other methods .,7: Digital processing of analogue signals and other data,Sampling theory, aliasing, effect of quantisation and, sample and hold reconstruction. Oversampling to simplify analogue filters.,8. Introduction to the DFT,Relation to DTFT. Inverse DFT. Effects of windowing & frequency domain sampling. Implementation by the FFT algorithm (FFT).,Use of DFT and FFT for spectral estimation.,9. Use of MATLAB for implementing digital filters & FFT.,Background knowledge needed:-,Basic maths ( complex numbers, Argand diagram, modulus & argument, differentiation, simple integration, sum of an arithmetic series, complex roots of unity, factorisation of quadratic equation, De Moivres Theorem, exponential function, natural logarithms).,Experience with any high-level computer programming language.,Material from the 2nd Yr Course CS2232: Signals & Systems useful.,Recommended Book:,1. S.W. Smith, Scientist and Engineers Guide to Digital Signal Processing California Tech. Publishing, 2nd ed., 1999, available complete at:,Problems:,1. Why do we call continuous time signals “analogue”.,2. When could you describe a SIGNAL as being linear?,3 Give a formula for an analogue signal which is zero until t=0 and then becomes equal to a 50 Hz sine wave of amplitude 1 Volt.,4. Given that u(t) is an analogue step function, sketch the signal u(t)sin(2.5,t).,5. If u(t)sin(5,t) is sampled at intervals of T=0.1 seconds, what discrete time signal is obtained? What is the sampling frequency?,6. What is the difference between a discrete time signal and a digital signal?,7. Define (i) amplification, (ii) filtering, (iii) rectification and (iv) modulation.,8. From the types of signals listed as being commonly processed by DSP, choose one & describe a form of DSP processing which may usefully be applied to it.,9. Are there advantages of DSP other than those listed.,10. Give one further possible disadvantage of DSP?,11. What is meant by “fixed point” and “floating point”?,12. What does the term “filter” normally mean to a Computer Scientist? Explain the terms “analogue filter” and “digital filter”.,13. What is meant by the term “real time” in DSP?,14. Think of an application of DSP where the processing of a digitised analogue signal need not be carried out in real time?,15. There are many applications of DSP where the digital signal being processed is not obtained by sampling an analogue signal. Give some examples.,16. Give modulus &argument of the complex numbers: 3+4j and -3e,4j,. Plot these numbers on an Argand diagram & calculate the distance between them.,17. Analogue signal: x(t) = 4 cos(,t) is passed through a circuit that differentiates,it with respect to t. Give formula for output. Plot amplitude & phase of the,sinusoid obtained against,in range 0 to 20 radians/second.,18. Analogue signal: x(t) = 4 cos(,t) is passed thro circuit that integrates it with respect to t. Give formula for output & plot its amplitude & phase against,.,19. Sum the geometric series: 1 + e,-j,+ e,-2j,+ e,-3j,+ + e,-Nj,.,20. Sum the infinite geometric series: 1 + 0.9e,-j,+ 0.81e,-2j,+ 0.729e,-3j,+ ,21. Show that 1 + e,-j,= 2e,-j,/2,cos(,/2) and hence plot the modulus & argument of this complex number against,in the range 0 to,.,22. Find the roots of: x,2,+ 0.9 x + 0.81 = 0 in polar (modulus & argument) form.,23. The Fourier series for a periodic signal x(t) with period,radians/s can be written in 3 forms: cos & sin form, amplitude & phase form & exponential form. If x(t) = 1+sin,t-(1/2) cos(2,t)-(1/3)sin(3,t) +(1/4)cos(4,t) +(1/5)sin(5,t)- convert this to each of the other two forms.,24. Fourier transform of analogue signal x(t) is complex function of frequency,(in radians/second) referred to in many textbooks as X(j,). Some books call this X(,) & most Comms books use,f,(freq in Hertz) rather than,. Give formulae for analogue Fourier transform & its inverse using these 3 forms of notation.,25. Show that if x(t) is real, then X(-j,) = X*(j,) or in other notation X(-,) = X*(,) or X(-f) = X*(f). Why do we need negative frequencies?,26. An nth order analogue Butterworth low-pass filter has the gain-response:,G(,) = 1 /,(1 + (,/,C,),2n,). Show that its gain is 0 dB at,=0 & -3 dB at,=,C,. Show that gain at,= 10,C,for 6th order Butt low-pass filter is -120 dB.,27. Given sinusoid of frequency, if filter A attenuates it by 20 dB & filter B amplifies it by 50 dB, is it true that if x(t) is passed thro filter A and the output from filter A is passed through filter B, the overall gain would be 30 dB?,
展开阅读全文