home *** CD-ROM | disk | FTP | other *** search
/ PDA Software Library / pdasoftwarelib.iso / HP95_100 / COMM / TT / TT.ZIP / tt.txt < prev   
Encoding:
Text File  |  1994-07-19  |  3.4 KB  |  73 lines

  1. Notes on how tt works.
  2. Gary Bishop <gb@cs.unc.edu>, 19 July 1994
  3.  
  4. Touch-Tone dialing requires the simultaneous generation of two
  5. frequencies.  There are at least two approaches to doing this on the
  6. HP100 with only a PC (two-state) speaker.  One is the approach taken
  7. by ATDT which is to attempt to reproduce the envelope of the sum of
  8. the two sines by PCM.  A second approach is demonstrated by TT.
  9.  
  10. Start with the desired signal "Sin[2 Pi f1 t] + Sin[2 Pi f2 t]", and
  11. square it up.  When the desired signal is > 0, put the speaker in one
  12. state, when the desired signal is < 0, put it in the other.  Now if
  13. you think this add tons of distortion, you're right.  *BUT*, there is
  14. still plenty of energy at the key frequencies f1, and f2.  If you look
  15. at the fourier power spectrum, you'll see that the distortion products
  16. are all better than 20dB (a factor of 100) down from the energy at f1
  17. and f2.
  18.  
  19. The DTMF tones were carefully chosen to prevent harmonics and
  20. intermodulation products from interfering with the decoding process.
  21. So, if we can get enough energy at the correct frequencies, we should
  22. be able to key the decoder.
  23.  
  24. The function two_tone in the source file "tt.c", does the tone
  25. generation.  It uses another trick to avoid generating the two-sines,
  26. adding them, then testing the arithmetic sign.  The trick uses the
  27. trigonometric identity
  28.  
  29. Sin[a] + Sin[b] = 2 Sin[(a + b) / 2] Cos[(a - b)/2]
  30.  
  31. This identity changes the sum of two sines, into the product of a sine
  32. and a cosine.  Now since we are only interested in zero crossings of
  33. this function, we will assume that the product crosses zero when ever
  34. either the sine or the cosine crosses zero (of course, they could both
  35. change signs simultaneously but with relatively prime frequencies this
  36. doesn't happen often).
  37.  
  38. So, we need only determine the time for a half cycle of (f1+f2)/2 and
  39. a half cycle of (f1 - f2)/2.  At each step, in the function two-tone,
  40. the speaker state is changed, then we delay until the next zero
  41. crossing.  We keep track of the zero crossings by keeping two
  42. counters, one for (f1 + f2)/2 and one for (f1 - f2)/2.  Which ever is
  43. less is used next.  After a zero crossing, that timer is reset to the
  44. half period for its frequency.  The other timer is decremented by the
  45. delay used up, and the process repeats.
  46.  
  47. This gets us a squared-up version of the sum of two sines with no trig
  48. functions at all.
  49.  
  50. The rest of the code is just window dressing to demonstrate the
  51. concept.  Someone with more energy, and more knowledge of the PC
  52. internals should take it and make a real dialer out of it.  The
  53. calibration constants K1 and K2 were determined using stop watch
  54. timings and linear regression.  They will probably have to be tuned
  55. for another C compiler (I'm using an ancient version of Borland Turbo
  56. C).
  57.  
  58. So, how well does it work?  Not as well as I would like.  My theory is
  59. that the HP100 just isn't sufficiently loud to do the job.  If you
  60. listen to the tones generated by your keypad in another reciever, they
  61. are *REALLY* LOUD.  The hp100 doesn't even come close to the volume.
  62. So the signals are marginal at best.  If you phone handset does a good
  63. job of coupling the tones out of the hp100 and into the line, and your
  64. phone company switch is sensitive, you'll get good dialing.
  65.  
  66. This code is freely distributed and you can do with it what you like.
  67. If you make a neat dialer for the hp100lx, I think you owe it to me to
  68. give me a copy for my use.
  69.  
  70. gb
  71.  
  72.  
  73.