Hi All,
mke_et wrote:
. . . he did a DTMF decoder in a Z80 device by doing (lets see if I get this right) a slice out of a 'sliding window fourier transform'.
I thought about an FFT when this thread was opened, but I don't have any code that might help, so I didn't post.
This is a valid approach, and it is the approach I would take if I had to do DTMF. In operation, eight of the FFT's bins could be either full or empty, depending on whether the corresponding tone was present or not. The challenges are not trivial for a S08, although it would be child's play for a DSP.
First, to satisfy Nyquist criteria, you would need to sample at 3.3khz or higher (the highest tone is 1633hz). That would be a sample approximately every 300 microseconds. But you would need an anti-aliasing filter that cuts-off at half the sampling rate, so the sampling rate would need to be faster than 3.3khz to allow room for the filter's roll-off. The sharper the filter, the lower the sampling rate can be.
Then, because the minimum separation between two tones is 73hz (between 697hz and 770hz), you would need at least a 128-point FFT. A 256-point FFT would be more discriminating, and may be necessary, depending on the sample rate. That would be about 1000 multiplications per 256-point FFT, plus the bit-reversed addressing and the trigonometry. The trig and bit-reversed addressing could be done with tables.
I don't know what a 'sliding window' is, but it could be some form of optimization that enabled the Z80 to pull this off. I have only used rectangular windows and Hanning windows. I would use a rectangular window in this situation, just to avoid additional multiplications.
The process might be:
- Gather 256 samples.
- Perform the FFT on the 256 samples.
- Check for peaks in the eight bins that correspond to the eight DTMF frequencies.
- Decode any peaks into the appropriate keys.
The algorithm could easily be expanded to detect the four busy-signal and dial-tone frequencies, but the number of samples may have to be increased to 512, as the 440hz and 480hz tones are only 40hz apart.