# Yet Another Project Log! Magic Numbers

A project log for An Old Fashion Acoustic Modem for the iPhone

My son recently returned from a holiday in China. His biggest complaint was the blocking of FaceBook!

## The Search for Magic Numbers

I have been searching for magic numbers. Yes I use Excel to help (i.e. goal seek, solver, macros (mostly brute-force) and data tables).

## The Sample Frequency Search

Basically matching up the timer divider (i.e. Fsample = 16,000,000/64/n) and the delay number to find a correlation null at the centre frequency. We want a sample frequency that is between 7000 Hz and 10000 Hz to avoid aliasing within the telephone bandwidth and enough time for processing the signal between timer ticks. The correlation null need not be exactly zero. Here is the table for the 1170 Hz centre frequency:

The frequency number (n) is at the top and the delay number (d) is on the left. The band is from 175 Hz to 250 Hz bandwidth. I have selected a cell near the middle (sample frequency 8069 Hz and a delay of 19). I chose this cell over the others as the table for the 12125 Hz centre frequency has a matching sample frequency (delay 18):

Using the same sample frequency simplifies the low pass filter coding.

## The Search for the Perfect Bandpass Filter

Here I used a brute-force Excel macro. I decide to use three stages and wanted a pretty close match in performance for the two centre frequencies. Here are the coefficients that I found:

 Modem Answer Originate Units Fsample 8069 8069 Hz Fcentre 1170 2225 Hz Divisor 8 8 Q 1.78 2.16 Gain 1.3 1.3 A0 2 2 A1 0 0 A2 -2 -2 B1 8 -1 B2 -5 -5 Other channel suppression -29 -36 dB

When considering filter coefficients you must avoid division by using arithmetic shift right. Therefore the divisor must be a power of 2. A low divisor reduces the risk of integer overflow.

These filters should reject the other channel by about 30dB. This should be enough. Here is the answer modem (i.e. Fc = 1170 Hz) calculated response:

And the originate modem (i.e. Fc = 2125 Hz) calculated response:

Note the alias above 5000 Hz.

## The Magic Biquad Frequency Analyser

You may have noticed I have been using a really cool graphs of the bandpass frequency response. Here is where I got it from:

The guy/gal who worked this out deserves a medal!

## A BandPass Magic Number Generator

To date I have been using a brute-force (i.e. a dumb grid search) macro to find the integer parameters for my bandpass filters. If you don't know, integer problems are very hard (actually NP Complete). While it works, it is slow and being a bit of a perfectionist (it a genetic disorder) I have eventually got a quick spreadsheet method working. While it finds the best solution available, determining the quality of that solution (in practice the filter Q) is a bit difficult (there is a way but even a perfectionist can say why bother as it is a case of "take it" or "leave it" for the filter). Here is what it looks like:

I used biquad frequency response as a check:

You may be able to see that the filter Q is closer to 3.6 than the design of 2.2.

## Finally here is the answer modem simulation (the originate modem simulation is similar):

Notes:

• The blue is the input data and the red the output data.
• The green signal is after the three stage bandpass (the input signal was 1022 pp).
• The brown signal is after the lowpass filter.

## Next

Update the Arduino code the test. If all good then finish off the case.

AlanX

## Discussions 