Chapter 17 Goertzel Algorithm Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 2 Learning Objectives  Introduction.

Slides:



Advertisements
Similar presentations
Chapter 19 Fast Fourier Transform (FFT) (Theory and Implementation)
Advertisements

Chapter 17 Goertzel Algorithm
Chapter 7 Linear Assembly
Chapter 11 Interfacing C and Assembly Code
Chapter 14 Finite Impulse Response (FIR) Filters
Chapter 17 DTMF generation and detection Dual Tone Multiple Frequency
Chapter 15 Infinite Impulse Response (IIR) Filters
DFT & FFT Computation.
Digital Filter Banks The digital filter bank is set of bandpass filters with either a common input or a summed output An M-band analysis filter bank is.
Chapter 18 Discrete Cosine Transform. Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Chapter 18, Slide 2 Learning Objectives  Introduction.
Chapter 16 Adaptive Filters
TMS320C6000 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Architectural Overview.
Lecture 6 Programming the TMS320C6x Family of DSPs.
TMS320C6000 Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2004 Architectural Overview.
TMS320C6000 Architectural and Programming Overview.
Chapter 14 Finite Impulse Response (FIR) Filters.
TMS320C6000 Architectural Overview.  Describe C6000 CPU architecture.  Introduce some basic instructions.  Describe the C6000 memory map.  Provide.
ACHIZITIA IN TIMP REAL A SEMNALELOR. Three frames of a sampled time domain signal. The Fast Fourier Transform (FFT) is the heart of the real-time spectrum.
0 - 1 © 2010 Texas Instruments Inc Practical Audio Experiments using the TMS320C5505 USB Stick “Sine Waves” Texas Instruments University Programme Teaching.
Chapter 8: The Discrete Fourier Transform
Lecture #17 INTRODUCTION TO THE FAST FOURIER TRANSFORM ALGORITHM Department of Electrical and Computer Engineering Carnegie Mellon University Pittsburgh,
Dual Tone Multi-Frequency System Michael Odion Okosun Farhan Mahmood Benjamin Boateng Project Participants: Dial PulseDTMF.
MM3FC Mathematical Modeling 3 LECTURE 10 Times Weeks 7,8 & 9. Lectures : Mon,Tues,Wed 10-11am, Rm.1439 Tutorials : Thurs, 10am, Rm. ULT. Clinics : Fri,
Chapter 15 Infinite Impulse Response (IIR) Filters.
Introduction SYSC5603 (ELG6163) Digital Signal Processing Microprocessors, Software and Applications Miodrag Bolic.
Chapter 19 Fast Fourier Transform (FFT) (Theory and Implementation)
Chapter 11 Interfacing C and Assembly Code. Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 11, Slide 2 Learning Objectives 
Chapter 7 Linear Assembly. Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 7, Slide 2 Learning Objectives  Comparison of programming.
Unit 7 Fourier, DFT, and FFT 1. Time and Frequency Representation The most common representation of signals and waveforms is in the time domain Most signal.
Discrete Time Periodic Signals A discrete time signal x[n] is periodic with period N if and only if for all n. Definition: Meaning: a periodic signal keeps.
Designs and Implementation Ring Detector circuit Design: Ring Detector circuit Design:
Fast Fourier Transforms
Discrete-Time and System (A Review)
1 Chapter 8 The Discrete Fourier Transform 2 Introduction  In Chapters 2 and 3 we discussed the representation of sequences and LTI systems in terms.
“TMS320C5505 USB Stick Teaching Materials”
Motivation Music as a combination of sounds at different frequencies
Fourier series. The frequency domain It is sometimes preferable to work in the frequency domain rather than time –Some mathematical operations are easier.
Digital Signal Processing – Chapter 10
Zhongguo Liu_Biomedical Engineering_Shandong Univ. Chapter 8 The Discrete Fourier Transform Zhongguo Liu Biomedical Engineering School of Control.
Ch.5 Fixed-Point vs. Floating Point. 5.1 Q-format Number Representation on Fixed-Point DSPs 2’s Complement Number –B = b N-1 …b 1 b 0 –Decimal Value D.
Real time DSP Professors: Eng. Julian S. Bruno Eng. Jerónimo F. Atencio Sr. Lucio Martinez Garbino.
Lecture 10a Infinite Impulse Response (IIR) Filters.
Z TRANSFORM AND DFT Z Transform
EEE 503 Digital Signal Processing Lecture #2 : EEE 503 Digital Signal Processing Lecture #2 : Discrete-Time Signals & Systems Dr. Panuthat Boonpramuk Department.
Digital Signal Processing
Copyright © 2003 Texas Instruments. All rights reserved. DSP C5000 Chapter 17 DTMF generation and detection Dual Tone Multiple Frequency.
Fast Fourier Transforms. 2 Discrete Fourier Transform The DFT pair was given as Baseline for computational complexity: –Each DFT coefficient requires.
Lecture 09b Finite Impulse Response (FIR) Filters
ECSE436 Tutorial Assembly and Linear Assembly Laurier Boulianne.
بسم الله الرحمن الرحيم Digital Signal Processing Lecture 14 FFT-Radix-2 Decimation in Frequency And Radix -4 Algorithm University of Khartoum Department.
Discrete Fourier Transform
1 Chapter 8 The Discrete Fourier Transform (cont.)
Chapter 7 Linear Assembly
DIGITAL SIGNAL PROCESSING ELECTRONICS
3.1 Introduction Why do we need also a frequency domain analysis (also we need time domain convolution):- 1) Sinusoidal and exponential signals occur.
Lab 4 Application of RTOS
FFT-based filtering and the
Fast Fourier Transforms Dr. Vinu Thomas
Algorithm An algorithm is a finite set of steps required to solve a problem. An algorithm must have following properties: Input: An algorithm must have.
Lecture #17 INTRODUCTION TO THE FAST FOURIER TRANSFORM ALGORITHM
Chapter 17 Goertzel Algorithm
Chapter 8 The Discrete Fourier Transform
Z TRANSFORM AND DFT Z Transform
Lecture 18 DFS: Discrete Fourier Series, and Windowing
Chapter 9 Computation of the Discrete Fourier Transform
Chapter 12 Software Optimisation
Chapter 8 The Discrete Fourier Transform
Chapter 8 The Discrete Fourier Transform
Lecture #17 INTRODUCTION TO THE FAST FOURIER TRANSFORM ALGORITHM
Chapter 15 Infinite Impulse Response (IIR) Filters
Presentation transcript:

Chapter 17 Goertzel Algorithm

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 2 Learning Objectives  Introduction to DTMF signaling and tone generation.  DTMF tone detection techniques and the Goertzel algorithm.  Implementation of the Goertzel algorithm for tone detection in both fixed and floating point.  Hand optimisation of assembly code.

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 3Introduction  The Goertzel algorithm is mainly used to detect tones for Dual Tone Multi- Frequency (DTMF) applications.  DTMF is predominately used for push- button digital telephone sets which are an alternative to rotary telephone sets.  DTMF has now been extended to electronic mail and telephone banking systems in which users select options from a menu by sending DTMF signals from a telephone.

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 4  In a DTMF signaling system a combination of two frequency tones represents a specific digit, character (A, B, C or D) or symbol (* or #).  Two types of signal processing are involved:  Coding or generation.  Decoding or detection.  For coding, two sinusoidal sequences of finite length are added in order to represent a digit, character or symbol as shown in the following example. DTMF Signaling

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 5 DTMF Tone Generation  Example: Button 5 results in a 770Hz and a 1336Hz tone being generated simultaneously #0* A B C D 1209Hz1336Hz1477Hz1633Hz 697Hz 770Hz 852Hz 941Hz #0* A B C D Freq (Hz) Output Click on a button

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 6 DTMF Tone Generation  Click on keypad to generate the sound #0* A B C D 1209Hz 1336Hz 1477Hz 1633Hz 697Hz 770Hz 852Hz 941Hz #### 0000 **** AAAA BBBB CCCC DDDD Freq (Hz) Output

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 7  Detection of tones can be achieved by using a bank of filters or using the Discrete Fourier Transform (DFT or FFT).  However, the Goertzel algorithm is more efficient for this application.  The Goertzel algorithm is derived from the DFT and exploits the periodicity of the phase factor, exp(-j*2  k/N) to reduce the computational complexity associated with the DFT, as the FFT does.  With the Goertzel algorithm only 16 samples of the DFT are required for the 16 tones (\Links\Goertzel Theory.pdf). \Links\Goertzel Theory.pdf\Links\Goertzel Theory.pdf DTMF Tone Detection

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 8  To implement the Goertzel algorithm the following equations are required: Goertzel Algorithm Implementation  These equations lead to the following structure:

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 9 Goertzel Algorithm Implementation

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 10  Finally we need to calculate the constant, k.  This value of this constant determines the tone we are trying to detect and is given by: Goertzel Algorithm Implementation  Where:f tone =frequency of the tone. f s =sampling frequency. N is set to 205.  Now we can calculate the value of the coefficient 2cos(2*  *k/N).

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 11 Goertzel Algorithm Implementation FrequencykCoefficient(decimal)Coefficient(Q15) x479C x x4090* x4A70* x5EE7* x63FC* x68AD* x6D02* * The decimal values are divided by 2 to be represented in Q15 format. This has to be taken into account during implementation. N = 205 fs = 8kHz

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 12 Q n = x(n) - Q n-2 + coeff*Q n-1 ; 0  n<N = sum1+ prod1 Goertzel Algorithm Implementation Where: coeff = 2cos(2  k/N)  The feedback section has to be repeated N times (N=205). FeedbackFeedforward

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 13 |Y k (N) | 2 = Q 2 (N) + Q 2 (N-1) - coeff*Q(N)*Q(N-1) Goertzel Algorithm Implementation Where: coeff = 2*cos(2*  *k/N)  Since we are only interested in detecting the presence of a tone and not the phase we can detect the square of the magnitude: FeedbackFeedforward

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 14 Goertzel Algorithm Implementation void Goertzel (void) { static short delay; static short delay_1 = 0; static short delay_2 = 0; static int N = 0; static int Goertzel_Value = 0; int I, prod1, prod2, prod3, sum, R_in, output; short input; short coef_1 = 0x4A70;// For detecting 1209 Hz R_in = mcbsp0_read();// Read the signal in input = (short) R_in; input = input >> 4; // Scale down input to prevent overflow prod1 = (delay_1*coef_1)>>14; delay = input + (short)prod1 - delay_2; delay_2 = delay_1; delay_1 = delay; N++; if (N==206) { prod1 = (delay_1 * delay_1); prod2 = (delay_2 * delay_2); prod3 = (delay_1 * coef_1)>>14; prod3 = prod3 * delay_2; Goertzel_Value = (prod1 + prod2 - prod3) >> 15; Goertzel_Value <<= 4; // Scale up value for sensitivity N = 0; delay_1 = delay_2 = 0; } output = (((short) R_in) * ((short)Goertzel_Value)) >> 15; mcbsp0_write(output& 0xfffffffe);// Send the signal out return; } ‘C’ code

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 15 Goertzel Algorithm Implementation.def _gz.sect"mycode" _gz.cproc input, coeff, count, mask2.reg delay1, delay2, x, gzv.reg prod1, prod2, prod3, sum1, sum2 zero delay1 zero delay2 loop:ldh *input++, x mpy delay1, coeff, prod1 shr prod1, 14, prod1 sub x, delay2, sum1 mv delay1, delay2 add sum1, prod1, delay1 [count] sub count,1,count [count] b loop mpy delay1, delay1, prod1 mpy delay2, delay2, prod2 add prod1, prod2, sum1 mpy delay1, coeff, prod3 shr prod3, 14, prod3 mpy prod3, delay2, prod3 sub sum1,prod3, sum1 shr sum1, 15, gzv.return gzv.endproc Linear assembly (fixed-point)

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 16 Goertzel Algorithm Implementation.def _gz.sect"mycode" _gz.cproc input1, coeff, count, mask2.reg delay1, delay2, x, gzv,test,y.reg prod1, prod2, prod3, sum1, sum2 zero delay1 zero delay2 loop:ldw *input1++, x mpysp delay1, coeff, prod1 subsp x, delay2, sum1 mv delay1, delay2 addsp sum1, prod1, delay1 [count] sub count,1,count [count] b loop mpysp delay1, delay1, prod1 mpysp delay2, delay2, prod2 addsp prod1, prod2, sum1 mpysp delay1, coeff, prod3 mpysp prod3, delay2, prod3 subsp sum1,prod3, sum1.return sum1.endproc Linear assembly (floating-point)

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 17 Hand Optimisation  Implementation of: Q n = [(coeff*Q n-1 )>> 14 + x(n)] - Q n Cycle LDH MPYSHR ADD SUB MV MV Q n-2 =Q n-1 Q n-1 =Q n

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 18 Hand Optimisation  Implementation of: Q n = [(coeff*Q n-1 )>> 14] + [x(n) - Q n-2 ] Cycle LDH MPY SHR ADD SUB MV Q n-2 =Q n-1 Q n-1 =Q n

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide LDH MPY SHR ADD SUB MV Hand Optimisation  Now let us consider adding a second iteration.  When can we start the “MPY” of the second iteration? Q n = [(coeff*Q n-1 )>> 14] + [x(n) - Q n-2 ]

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide LDH MPY SHR ADD SUB MV Hand Optimisation  We have to wait until the add has finished as the result of iteration 1 is one of the inputs to the multiply performed in iteration 2. Q n = [(coeff*Q n-1 )>> 14] + [x(n) - Q n-2 ] MPY

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide LDH MPY SHR ADD SUB MV Hand Optimisation  The other instructions then follow in the same order. MPY SHR ADDSUBMV  Finally the load of x[1] must have occurred before the sub, therefore the load must take place in cycle 5. LDH

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 22 Goertzel Algorithm Implementation  Hand optimised assembly (fixed-point): ; PIPED LOOP PROLOG LDH.D1T1 *A0++(4),A3 || [ A1] SUB.L1 A1,0x1,A1 [ A1] B.S1 loop NOP 1 ; PIPED LOOP KERNEL loop: MPY.M2 B4,B5,B6 [ A1] SUB.L1 A1,0x1,A1 || LDH.D1T1 *A0++(4),A3 MV.L1X B4,A4 || SUB.D1 A3,A4,A3 || SHR.S2 B6,0xe,B4 || [ A1] B.S1 loop ADD.L2X A3,B4,B4

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 23 Testing the Implementation  The input signal is modulated with the square magnitude and sent to the codec.  Therefore when the frequency of the input signal corresponds to the detection frequency, the input tone appears at the output. PCDSK Signal Gen Osc/Spec Analyser

Dr. Naim Dahnoun, Bristol University, (c) Texas Instruments 2002 Chapter 17, Slide 24 Goertzel Code  Code location:  Code\Chapter 17 - Goertzel Algorithm  Projects:  Fixed Point in C:\Goertzel_C_Fixed\  Fixed Point in C with EDMA: \Goertzel_C_Fixed_EDMA\  Fixed Point in Linear Asm:\Goertzel_Sa_Fixed\  Floating Point in Linear Asm:\Goertzel_Sa_Float\

Chapter 17 Goertzel Algorithm - End -