1. Detailed DescriptionIn a DTMF signal generation, a DTMF keypad could be used for digit entry, the resultant DTMF tones are generated mathematically and added together. The values are logarithmically compressed and passed to the receiver. In a DTMF scheme, pairs of tones are used to signal the digits 0 through 9, pound(#), star(*), and the digits A, B, C and D. For each pair, one of the tones is selected from a low group of four frequencies, and the other from a high group of four frequencies. The correct detection of a digit requires both a valid tone pair and the correct timing intervals.
The matrix of frequencies used to encode the 16 DTMF symbols is shown in Figure 1. Each symbol is represented by the sum of the two frequencies that intersect the digit. The row frequencies are in a low band, below 1 kHz, and the column frequencies are in a high band, between 1 kHz and 2 kHz. The digits are displayed as they would appear on a telephone’s 4x4 matrix keypad (on standard telephone sets, the fourth column is omitted). The user should note that there are a number of different algorithms possible for generation and detection of DTMF tones; this application note simply describes one manner of doing so. Also, due to the fact that Hypersignal Block Diagram/RIDE is ever evolving, certain block functions may be replaced by newer functions, and some blocks may even become obsolete. Therefore, this application note should be considered simply a guide, to be used for whatever insights it gains the user towards their specific application.
Figure 1: DTMF Digits
2. DTMF Signal Generation
In this example, the two Sine Generators are used to generate the row and column tones which are then added together to form the DTMF. The frequencies of the two generators are controlled through the keypad, which generates the selected row and column which are used by the row and column table lookup block functions. The output of the table lookup blocks correspond to frequencies which match those in Figure 1. Using the Parameter Connect mode, the outputs of the Table Lookup blocks are connected to the Frequency parameter of each of the sine generators, allowing for a dynamic frequency control while running.
The selected tones are added together, the resultant waveform is sent to a gain block, (the level of which is controlled by a knob and gated with a keypad ‘button pressed’ value) and sent to a display for viewing. In order to allow the DTMF to be heard by the user, the generated signal is also sent to a sound card, showing an example of how fast Hypersignal Block Diagram is; the tone is actually generated/heard in real-time!
Figure 2 - Implementation of a DTMF Coding in Hypersignal Block Diagram
3. Decoding DTMF Signals
The general approach taken by this algorithm for DTMF tone detection is to take the Fourier transform of the observed signal and search for energy at the frequencies of interest. Since the algorithm is implemented by Discrete Fourier Transform (DFT). The analysis frame must be long enough to resolve the DTMF frequencies, but short enough to detect the minimum length tone. A 12.75 ms frame at a sampling rate of 8kHz is good choice.
In calculating the DFT, the Goertzel algorithm, a method for calculating any single coefficient of a DFT, is chosen over a fast Fourier transform (FFT) algorithm. There are two reasons for this. In order to obtain the required frequency resolution at an 8 kHz sampling rate, a 256-point FFT would be required. Since the algorithm for tone detection requires knowledge of the energy at only 16 frequencies, it is more efficient to execute the Goertzel algorithm for these frequencies. In addition, the Goertzel algorithm is recursive, eliminating the need to store 256 samples for the FFT for each DTMF dector. This saves both time and data memory in the simulation and the real time applications.
The Goertzel algorithm can be thought of as a second-order IIR filter for each DFT coefficient. The transfer function for the filter is:
where WN = exp(-j2π/N), and N is the length of the observation window for the DFT. The flow chart of this transfer function is shown in Figure 3.
Figure 3 - Flow Chart of the Transfer Function
Initially, the state variables of the filter are set to zero. Then, the filter is executed N times. The output at this point, yk(N), is the k’th coefficient of a length N DFT. Notice that the filter is implemented as a direct form II second-order section. The recursive part of the filter is on the left-hand side of the delay elements, and the nonrecursive part is on the right. Since only the output at time N is needed, it is only necessary to compute the nonrecursive part of the filter after the last iteration of the recursive part. A further simplification in the algorithm is made by observing that only the square of the magnitude of the DFT coefficient is needed. The nonrecursive calculation of the DFT coefficient is:
where s(N) and s(N-1) represent the value of the state variables at times N and N-1. It can be shown that:
Therefore, it is only necessary to store the value, 2cos(2πk/N), for each coefficient to be evaluated.
The implementation of a DTMF decoding in Hypersignal Block Diagram is shown in Figure 4. This application makes use of a simple DTMF Test Tone Generator, made up of two Sine Generator blocks and an Add block. DTMF decoding is done by finding the maximum row and maximum column energy. This task is performed by using 2 Four Frequency Goertzel Algorithm blocks. In each four freq. Goertzel Algorithm block, the magnitude of four frequencies can be detected simultaneously. These four magnitudes are then used by the 4-input Max function to determine the zero-based index of the winning frequency. One of the Four Frequency Goertzel Algorithm/4-input Max pair of blocks is used to determine the row index, while the other is used to determine the column index. Then the detected row index is shifted left by 2 and logically OR’ed with the column index to create a zero-based index representing the detected DTMF. Although not implemented in this example, a level detect could be implemented to discriminate against noise; in this example, the detection is always running, providing a ‘best-guess’ DTMF digit even while no valid DTMF’s are presented. One way to accomplish this would be to use the other output of the 4-input Max blocks, which are delivering the magnitudes of the detected row and column, in conjunction with a minimum energy detection algorihtm, comprised mainly of two threshold blocks.
Figure 4: The Implementation of DTMF Decoding in Hypersignal Block Diagram
4. DTMF Coding and Decoding Simulation
Figure 5: The Implementation of DTMF coding and Decoding in Hypersignal Block Diagram