2
0

README_fdmdv.txt 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. README_fdmdv.txt
  2. David Rowe
  3. Created March 2012
  4. Introduction
  5. ------------
  6. A 1400 bit/s Frequency Division Multiplexed Digital Voice (FDMDV) modem
  7. based on [1]. Used for digital audio over HF SSB.
  8. The FDMDV modem was first implemented in GNU Octave, then ported to C.
  9. Algorithm development is generally easier in Octave, but for real time
  10. work we need the C version. Automated units tests ensure the
  11. operation of the Octave and C versions are identical.
  12. Quickstart
  13. ----------
  14. $ cd codec2-dev
  15. $ ./configure && make
  16. $ cd src
  17. 1. Generate some test bits and modulate them:
  18. $ ./fdmdv_get_test_bits test.c2 1400
  19. $ ./fdmdv_mod test.c2 test.raw
  20. $ play -r 8000 -s -2 test.raw
  21. 2. Two seconds of test frame data modulated and sent out of sound device:
  22. $ ./fdmdv_get_test_bits - 2800 | ./fdmdv_mod - - | play -t raw -r 8000 -s -2 -
  23. 3. Send 14000 modulated bits (10 seconds) to the demod and count errors:
  24. $ ./fdmdv_get_test_bits - 14000 | ./fdmdv_mod - - | ./fdmdv_demod - - demod_dump.txt | ./fdmdv_put_test_bits -
  25. Use Octave to look at plots of 1 second (1400 bits) of modem operation:
  26. $ cd ../octave
  27. $ octave
  28. octave:1> fdmdv_demod_c("../src/demod_dump.txt",1400)
  29. 4. Run Octave simulation of entire modem and AWGN channel:
  30. $ cd ../octave
  31. $ octave
  32. octave:1> fdmdv_ut
  33. 5. NOTE: If you would like to play modem samples over the air please
  34. convert the 8 kHz samples to 48 kHz. Many PC sound cards have
  35. wildly inaccurate sample clock rates when set to 8 kHz, but seem to
  36. perform OK when set for 48 kHz. If playing and recording files you
  37. can use the sox utility:
  38. $ sox -r 8000 -s -2 modem_sample_8kHz.raw -r 48000 modem_sample_48kHz.wav
  39. For real time applications, the fdmdv.[ch] library includes functions to
  40. convert between 48 and 8 kHz sample rates.
  41. References
  42. ----------
  43. [1] http://n1su.com/fdmdv/FDMDV_Docs_Rel_1_4b.pdf
  44. [2] http://n1su.com/fdmdv/
  45. [3] http://www.rowetel.com/blog/?p=2433 "Testing a FDMDV Modem"
  46. [4] http://www.rowetel.com/blog/?p=2458 "FDMDV Modem Page" on David's web site
  47. C Code
  48. ------
  49. src/fdmdv_mod.c - C version of modulator that takes a file of bits and
  50. converts it to a raw file of modulated samples.
  51. src/fdmdv_demod.c - C version of demodulator that takes a raw file of
  52. modulated samples and outputs a file of bits.
  53. Optionally dumps demod states to a text file which
  54. can be plotted using the Octave script
  55. fdmdv_demod_c.m
  56. src/fdmdv.h - Header file that exposes FDMDV C API functions. Include
  57. this file in your application program.
  58. src/fdmdv.c - C functions that implement the FDMDV modem.
  59. src/fdmdv-internal.h - internal states and constants for FDMDV modem,
  60. shouldn't be exposed to application program.
  61. unittest/tfdmdv.c - Used to conjunction with unittest/tfdmdv.m to
  62. automatically test C FDMDV functions against
  63. Octave versions.
  64. Octave Scripts
  65. --------------
  66. (Note these require some Octave packages to be installed, see
  67. octave/README.txt).
  68. fdmdv.m - Functions and variables that implement the Octave version of
  69. the FDMDV modem.
  70. fdmdv_ut.m - Unit test for fdmdv Octave code, useful while
  71. developing algorithm. Includes tx/rx plus basic channel
  72. simulation.
  73. Typical run:
  74. octave:6> fdmdv_ut
  75. Eb/No (meas): 7.30 (8.29) dB
  76. bits........: 2464
  77. errors......: 20
  78. BER.........: 0.0081
  79. PAPR........: 13.54 dB
  80. SNR.........: 4.0 dB
  81. It also outputs lots of nice plots that show the
  82. operation of the modem.
  83. For a 1400 bit/s DQPSK modem we expect about 1% BER for
  84. Eb/No = 7.3dB, which corresponds to SNR = 4dB (3kHz
  85. noise BW). The extra dB of measured power is due to the
  86. DBPSK pilot. Currently the noise generation code
  87. doesn't take the pilot power into account, so in this
  88. example the real SNR is actually 5dB.
  89. fdmdv_mod.m - Octave version of modulator that outputs a raw file.
  90. The modulator is driven by a test frame of bits. This
  91. can then be played over a real channel or through a
  92. channel simulator like PathSim. The sample rate can be
  93. changed using "sox" to simulate differences in tx/rx
  94. sample clocks.
  95. To generate 10 seconds of modulated signal:
  96. octave:8> fdmdv_mod("test.raw",1400*10);
  97. fdmdv_demod.m - Demodulator program that takes a raw file as input,
  98. and works out the bit error rate using the known test
  99. frame. Can be used to test the demod performs with
  100. off-air signals, or signals that have been passed
  101. through a channel simulator.
  102. To demodulate 2 seconds of the test.raw file generated
  103. above:
  104. octave:9> fdmdv_demod("test.raw",1400*2);
  105. 2464 bits 0 errors BER: 0.0000
  106. It also produces several plots showing the internal
  107. states of the demod. Useful for debugging and
  108. observing what happens with various channels.
  109. fdmdv_demod_c.m - Takes an output text file from the C demod
  110. fdmdv_demod.c and produces plots and measures BER.
  111. Useful for evaluating fdmdv_demod.c performance.
  112. The plots produced are identical to the Octave
  113. version fdmdv_demod.m, allowing direct comparison of
  114. the C and Octave versions.
  115. tfdmdv.m - Automatic tests that compare the Octave and C versions of
  116. the FDMDV modem functions. First run unittest/tfdmdv, this
  117. will generate a text file with test vectors from the C
  118. version. Then run the Octave script tfdmdv and it will
  119. generate Octave versions of the test vectors and compare
  120. each vector with the C equivalent. Its plots the vectors
  121. and and errors (green). Its also produces an automatic
  122. check list based on test results. If the Octave or C modem
  123. code is changed, this script should be used to ensure the
  124. C and Octave versions remain identical.
  125. Modelling sample clock errors using sox
  126. ---------------------------------------
  127. This introduces a simulated 1000ppm error:
  128. sox -r 8000 -s -2 mod_dqpsk.raw -s -2 mod_dqpsk_8008hz.raw rate -h 8008
  129. TODO
  130. ----
  131. [ ] implement ppm measurements in fdmdv_get_demod_stats()
  132. [ ] try interfering sine wave
  133. + maybe swept
  134. + does modem fall over?
  135. [ ] try non-flat channel, e.g. 3dB difference between hi and low tones
  136. + make sure all estimators keep working
  137. [ ] test rx level sensitivity, i.e. 0 to 20dB attenuation
  138. [ ] make fine freq indep of amplitude
  139. + use angle rather than imag coord
  140. [ ] document use of fdmdv_ut and fdmdv_demod + PathSim
  141. [ ] more positive form of sync reqd for DV frames?
  142. + like using coarse_fine==1 to decode valid DV frame bit?
  143. + when should we start decoding?
  144. [ ] more robust track/acquite state machine?
  145. + e.g. hang on thru the fades?
  146. [ ] PAPR idea
  147. + automatically tweak phases to reduce PAPR, e.g. slow variations in freq...
  148. [ ] why is pilot noise_est twice as big as other carriers