Académique Documents
Professionnel Documents
Culture Documents
Learning Objectives
DTMF signaling and tone generation. DTMF signal generation DTMF tone detection techniques and the Goertzel algorithm. Implementation of the Goertzel algorithm for tone detection on DSP
ESIEE, Slide 2
Introduction
Dual Tone Multi-Frequency (DTMF) is a widespread used signalling system: telephone services use commonly key strokes for options selection DTMF is mainly used by touch-tone digital telephone sets which are an alternative to rotary telephone sets. DTMF has now been extended to electronic mail and telephone banking systems It is easily implemented on a DSP as small part of the tasks.
Copyright 2003 Texas Instruments. All rights reserved.
ESIEE, Slide 3
DTMF Signaling
In a DTMF signaling system a unique combination of two normalized frequency tones Two types of signal processing are involved:
For coding, two sinusoidal sequences of finite duration are added in order to represent a digit.
ESIEE, Slide 4
ESIEE, Slide 5
Tones Generation
Dual tone generation can be done with 2 sinewave sources connected in parallel. Different method can be used for such implementation:
10 Digits are sent per second. Sampling is done via a codec at 8Khz Each tone duration must be >40msec and a spacing of 50ms minimum between two digits is required
Copyright 2003 Texas Instruments. All rights reserved.
ESIEE, Slide 6
ESIEE, Slide 7
Tone generation of a DTMF is generally based on two programmable, second order digital sinusoidal oscillators, one for the low fl the other one for the high fh tone. Two oscillators instead of eight reduce the code size. Coefficient and initial conditions are set for each particular oscillation
+ +
Z-1 Low freq Z-1
+ y(n)
+
Z-1
High freq Z-1
ESIEE, Slide 8
2 pole resonator filter with 2 complexe poles on the unit cercle (unstable)
Output signal: Y(n)= -a1y(n-1)-y(n-2)
H ( z)
b0 1 a1 z 1 a2 z 2
b0 A sin(0 ) a1 2 cos(0 ) a2 1
Initial conditions:
Y(-1)=0 Y(-2)=-A sin(0)
ESIEE, Slide 9
Frames of data stream of 120 samples (15msec) long contain either DTMF tone samples or pause samples. The encoder is either in idle mode, not used to encode digits or active and generates DTMF tones and pauses The sine equation is implemented in assembly language:
Mov Mpym sub Add ||delay Mov a1/2, T1 *AR1+,T1,AC0; *AR1-<<#16,AC0,AC AC0,AC1 *AR1 rnd(hi(AC1)),*AR1 ; coded in Q15 ;AR1 y(n-1); AR1+1 y(n-2) ;AC1= a1/2*y(n-1)-y(n-2) ; AC1= a1*y(n-1)-y(n-2) ;y(n-2)=y(n-1) ;y(n-1)=y(n)
ESIEE, Slide 10
ESIEE, Slide 11
Goertzel algorithm is the more efficient detection algorithm for a single tone. To detect the level at a particular frequency the DFT is the most suitable method:
X( k)
m N -1 m 0
x(m).e
j 2km N
If the length of the signal is N, the recursionfor N - 1time is : w k (n) x(n) 2 cos(2f k / f s ) wk (n 1) wk (n 2) X (k ) wn ( N 1) e j 2f k / f s ) wk ( N 2) Magnitude squared is then : X(k) wn ( N 1) 2 cos(2f k / f s ) wk ( N 1).wk ( N 2) wk ( N 2)
2 2 2
Complex formula
For 8 frequencies
Calculate X2(k) for 8 freq
Output Digit
ESIEE, Slide 14
The value of k determines the tone we are trying to detect and is given by:
fk k N fs
ESIEE, Slide 15
Where: fk = frequency of the tone. fs = sampling frequency. N is set to 205. Then we can calculate coefficient 2cos(2**k/N).
Copyright 2003 Texas Instruments. All rights reserved.
Coefficient (decimal) 1.703275 1.635585 1.562297 1.482867 1.163138 1.008835 0.790074 0.559454
Coefficient (Q15) 0x6D02* 0x68AD* 0x63FC* 0x5EE7* 0x4A70* 0x4090* 0x6521 0x479C
Where: a1= 2cos(2k/N) and N=205 This gives 205 MACs+ 205 ADD The last computation gives the energy of the tone and is done with: 2 SQRS and one multiplication
C code
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; ESIEE, Slide } 18 Copyright 2003 Texas Instruments. All rights reserved.
ESIEE, Slide 20
Algorithm Core
STM RPTB PORTR LD SUB MAC MAC delay STH
Loop
; AccH=x(n) ;A=x(n)-w(n-2) ;A=x(n)-w(n-2)+alphaw(n-1) ;A=x(n)-w(n-2)+2alphaw(n-1) ;w(n-2)=w(n-1) tap delay ;w(n-1)=w(n) tap delay ;end of loop
ESIEE, Slide 21
Energy calculation
LD *AR2,16,A MPYA *AR2MPY *AR2,A LD *AR3,T MPYA A SUB A,1,B ;A=w(N-1) ;T=w(N-1) B=w(N-1)^2 ;A=w(N)*w(N-1) ;T=alphap ;A=alphap*w(N)*w(N-1) ; substract with a left shift to ;obtain 2alphap ; B=w(N-1)^2-2alphap*w(N)*w(N-1) ;T=w(N) ;B=w(N-1)^2-2alphap*w(N)*w(N-1)+w(N)^2 ;save to Y ;copy output level
ESIEE, Slide 22
Universal Multifrequency Tone Generator and detector (UMTG) This software module developed by SPIRIT Corp. for the TMS320C54x and TMS320C55X platform It can be used into embedded devices for generating various telephone services used in intelligent network systems Or as a simple tone generator for custom applications It is fully compliant with TMS Algorithm standard rules See SPRU 639 and SPRU 638 AN
Follow on Activities
ESIEE, Slide 24