home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / FAQSYS18.ZIP / FAQS.DAT / DRIGSB.DOC < prev    next >
Text File  |  1996-01-04  |  19KB  |  393 lines

  1. Documentaion for SBDSP - SoundBlaster APT Demodulation Program
  2.  
  3. This program and documentation are the property of the Dallas Remote Imaging
  4. Group (BBS 214 394 7438).   If it is used on other systems, this copyright
  5. notice must be kept in this documentation.   This program may NOT be sold or
  6. marketed in any form.  All rights are reserved by the Dallas Remote Imaging
  7. Group (1992).
  8.                                Dallas Remote Imaging Group
  9.                                PO BOX 117088
  10.                                Carrollton, Texas  75011-7088
  11.                                BBS 214-394-7438
  12.                                FAX 214-492-7747
  13. Rev DRG5193Beta
  14.                 
  15. ----------------------------
  16.  
  17. Introduction:
  18.  
  19. The SoundBlaster and SoundBlaster Pro audio I/O cards from Creative
  20. Labs, Inc.  are very popular accessories found in many IBM PC compatible
  21. computer systems.  Although the boards are usually used only to provide
  22. music and sound output for computer games, they also support audio input
  23. into the computer.  The standard SoundBlaster supports mono audio I/O
  24. and is available in the $100 price range.  The Pro model supports stereo
  25. and adds a CD/ROM (SCSI) interface.  It costs around $250 dollars.
  26.  
  27. The boards can digitize sound at high speed and, using one of the
  28. computer's DMA (direct memory access) channels, transfer the sound
  29. samples directly into computer memory.    Once in memory the sound samples
  30. are written to disk.  It is this ability to digitize and record sound
  31. that enables the SoundBlasters to be used for the reception and decoding
  32. of APT satellite signals.
  33.  
  34. The output of a radio receiver tuned to an APT signal is just a 2400 Hz
  35. audio tone.  As the satellite scans the earth and clouds,  it varies the
  36. amplitude of the tone in proportion the the brightness of the area that
  37. it is currently observing.
  38.  
  39. -------
  40. What it does:
  41.  
  42.  
  43. If you viewed the contents of the .VOC sample file produced by the
  44. SoundBlaster VREC program with your favorite image processing program,
  45. it would not look at all like a weather satellite photo.  The .VOC file
  46. is like an exposed roll of film.  Its contents must first be "developed"
  47. before you can view the image.    The process of "devloping" the .VOC
  48. file contents into a weather satellite image is called DEMODULATION.
  49.  
  50. Demodulation converts the recorded values of the samples of the 2400 Hz
  51. APT sine wave into their corresponding pixel values.  The desired image
  52. pixel values actually represent the amplitude of each peak in the
  53. APT sine wave signal.
  54.  
  55. Signal sampling theory states that if you are to do anything meaningful
  56. with a digitally sampled signal then you must sample the signal at least
  57. twice as fast as the highest frequency component of the signal.  The
  58. 2400 Hz APT signal needs to be sampled at least 4800 times a second.
  59. Because the APT signal is not a constant tone,    it has freqency
  60. components much beyind 2400 Hz.  Also the laws of thermodynamics (and
  61. life) say that nothing is perfect as theory predicts and you really need
  62. to sample at a higher rate.
  63.  
  64. If we sample the APT signal at exactly 4 times its 2400 Hz
  65. carrier frequency (i.e at 9600 samples per second), each input sample
  66. will be eactly 90 degrees (360/4) in phase apart from its adjacent
  67. samples.  Using the following trigonometry identities it turns out to be
  68. particularly easy to accurately demodulate the APT samples:
  69.  
  70.    cos(x) = sin(90-x)
  71.    sin(x)*sin(x) + cos(x)*cos(x) = 1
  72.  
  73. By substituting the first equation into the last equation we get:
  74.  
  75.    sin(x)*sin(x) + sin(90-x)*sin(90-x) = 1
  76.  
  77. Because each recorded sample of the 2400 Hz APT sine wave is 90
  78. degrees apart from the next sample we can calculate the pixel value as:
  79.  
  80.    pixel = sqrt((sample[t]*sample[t]) + (sample[t-1]*sample[t-1]))
  81.  
  82. The demodulation program just needs to read the .VOC sample file, throw
  83. away the file header information,  adjust the samples for clock/DMA
  84. rate errors and DC offsets, calculate the pixel values from adjacent
  85. pairs of sample values,  scale the results to values from 0 to 255, and
  86. finally write the resulting pixel values to the image file.
  87.  
  88. This could be a very time consuming process when you consider that a
  89. typical 14 minute capture has about 8 million input samples and that
  90. multiples, adds, and square roots are all operations that take lots
  91. of CPU time.  This is particularly true if floating point arithmetic is
  92. used.
  93.  
  94. To make the demodulation program run very quickly a table of all 65536
  95. possible combinations of adjacent 8-bit sample values is pre-computed
  96. according to the above formula.  All the demodulation software then has
  97. to do in order to convert the recorded APT samples into their pixel
  98. values is look up the proper table entry.  No time consuming floating
  99. point arithmetic need be used once the demodulator table has been built.
  100.  
  101. Reading and writing 8 megabyte files is always a time consuming process.
  102. By always reading and writing the sample and image files in multiples of
  103. 512 bytes, the demodulation software takes full advantage of the
  104. behavior of the DOS file system.
  105.  
  106.  
  107. -------
  108. Problems,  problems,  problems:
  109.  
  110.  
  111. Although the SoundBlaster is quite good at adding a little zip to the
  112. odd computer game,  it is far from being a precision signal processing
  113. system.   Using the SoundBlaster card for APT reception presents many
  114. problems.  Fortunately software techniques may be used to overcome
  115. the problems and yield APT images that rival the best commercial
  116. systems.
  117.  
  118. Using the SoundBlaster for APT demodulation presents two main types
  119. of problems:
  120.      1) Sample inaccuacies and offsets
  121.      2) Clock rate and missing sample errors
  122.  
  123.  
  124.  
  125. Sampling a perfect sine wave with a perfect board in a perfect world
  126. should yield a series of samples with an average sample value of zero.
  127. Unfortunately the SoundBlaster circuitry usually adds a small DC offset
  128. to the recorded sample values.    This DC offset can cause noise and
  129. "beat" patterns to appear in the demodulated image file.
  130.  
  131. To remove the effects of any DC offset in the sample values, the
  132. demodulation software calculates the average sample value in each block
  133. of input samples.  This sample bias is then subtracted from each input
  134. sample.
  135.  
  136. The demodulation program is currently a bit paranoid about things and
  137. re-calculates the sample bias for each input block.  It would be a
  138. bit faster to calculate the value for only the first block.  If the
  139. input level to the SoundBlaster board is properly adjusted, the sample
  140. value offset does not seem to change between blocks.
  141.  
  142.  
  143.  
  144. For easy demodulation of the APT signal we need to sample at 9600
  145. samples per second.  If the resulting image is to be properly
  146. synchronized to the satellite data this needs to be EXACTLY 9600 samples
  147. per second.  PRECISELY EXACTLY 9600 samples per second.  How exact?
  148. A typical fourteen minute satellite pass requires an accuracy of around
  149. one part per 10 million...  9600.0000 samples per second.
  150.  
  151. Typically a satellite scans one line of pixels every 1/2 second (120
  152. lines per minute).  At a sample rate of 9600 samples per second, a 14
  153. minute satellite pass generates about 8 megabytes of data.  If the
  154. sample clock rate is only accurate to a mere one part per million, the
  155. resulting image will be skewed 8 pixels from top to bottom.  Although 8
  156. pixels of skew across of screen of 4800 pixel lines is only about a .1
  157. percent skew, it is noticeable if you are looking for it or are wanting
  158. to do some quantitative analysis of the satellite orbit from the doppler
  159. bow.
  160.  
  161. How accurate is the SoundBlaster clock you ask?  It turns out the
  162. closest that you can set the sample rate is around 9620 samples per
  163. second...  an accuracy of around one part in a few hundred...  not even
  164. close.    To make matters worse the clocks on any two SoundBlaster boards
  165. can easily differ by parts per thousand.  Clock errors of this magnitude
  166. cause the image to appear like a TV set that has lost sync.  The image
  167. is an unreadable mess of slanted bars.
  168.  
  169. The DMA circuitry on the SoundBlaster boards can automatically transfer
  170. blocks of up to 32768 signal samples into the computer's memory without
  171. using any CPU time.  Once a block of samples has been DMAed into memory,
  172. the recording software starts DMAing the next block of samples into
  173. another memory area.  While the second block of samples is being
  174. received, the recording software writes the first block to the
  175. computer's hard disk.  The process alternates in a ping-pong fashion
  176. between reading samples into one buffer while writing the other buffer's
  177. data to disk.
  178.  
  179. Unfortunately a few signal samples are lost in the time between the end
  180. of one DMA block and the startup of the next DMA block.  To make matters
  181. worse the number of samples lost depends on the computer system's CPU
  182. type and clock rate.  Faster systems loose fewer pixels between blocks.
  183. Also number of pixels lost seems to depend upon whether the block is an
  184. ODD or EVEN numbered block.
  185.  
  186. Fortunately it is possible to compensate for the errors in the clock
  187. rate and the samples lost between DMA blocks.  The demodulation program
  188. compensates for the pixels lost betwwen DMA blocks by duplicating the
  189. last few samples of each DMA block.  The user can independently specify
  190. the number of samples to add to (or even remove from) the odd and even
  191. numbered DMA blocks with the /O and /E command line parameters.
  192.  
  193. The sample clock rate error is compensated for in two stages.  The first
  194. stage is the coarse adjustment factor.    This factor causes every n'th
  195. input sample to be removed (or duplicated).  By throwing away
  196. every 601'st sample, the 9620 samples per second that the SoundBlaster
  197. produces is cut down to ABOUT 9600 samples per second.    The coarse
  198. adjustment factor can be changed by using the /C command line parameter.
  199.  
  200. The second clock rate adjustment factor is the fine tuning factor.  It
  201. is used to zero in the exact timing value.  It adjusts out any
  202. residual skew in the image caused by variations in individual
  203. SoundBlaster board clock generators.  The fine adjustment factor
  204. works just like the coarse adjustment factor.  It causes every n'th
  205. input sample to be removed (or duplicated).  It may be specified with
  206. the /F command line parameter.
  207.  
  208.  
  209. -----------------------------
  210. Doing it:
  211.  
  212.  
  213. The first step is to connect your satellite receiver to the microphone
  214. input of the SoundBlaster.  You must be very careful to set the
  215. amplitude of the receiver output low enough so that it does not
  216. overdrive the SoundBlaster.  If you overdrive the card its automatic
  217. gain control (AGC) circuitry will attempt to compensate.  This will
  218. cause streaking in the resulting images.
  219.  
  220. To properly set the receiver level use the VEDIT2 program supplied with
  221. the SoundBlaster card.    Select the SCAN INPUT item from the RECORD menu.
  222. This will show a graphical representation of the input signal.    While
  223. monitoring a good satellite pass adjust the receiver level until none of
  224. the signal peaks touch the top or bottom margins of the graph.    Leave a
  225. little safety margin (1/8 inch) just to be safe.
  226.  
  227.  
  228. Once the receiver level has been set,  the next step is to record a
  229. satellite pass to disk.  This is done with the VREC program supplied
  230. with the SoundBlaster card.
  231.  
  232. For the SoundBlaster Pro use the command:
  233.    vrec c:cap /a:mic /m:mono /f:low /s:9620 /l:15 /t:840
  234.  
  235. where:
  236.    c:cap - is the name of the file that you want to write the samples.
  237.        Remember the sample file will be quite large.  Around 600 Kb
  238.        per minute of recording.  In this case the samples will be
  239.        written to the file C:\CAP.VOC
  240.  
  241.    /a:mic  - selects the MICROPHONE input.
  242.  
  243.    /m:mono - selects MONO recording.
  244.  
  245.    /f:low  - sets the LOWPASS recording filter.
  246.  
  247.    /s:9620 - sets the recording sample rate to 9620 samples per second.
  248.          Note the if you ask for values less that /S:9619 the VREC
  249.          program rounds the value down to around 9500 samples per
  250.          second.  /S:9620 is the smallest value that actually
  251.          selects a sample clock greater than 9600 Hz.
  252.  
  253.    /l:15   - sets the microphone level to full open.  Use the receiver
  254.          output level control to adjust the recording level.
  255.          (I don't think this is what this does or is necessary
  256.          any more.    It is left over from early attempts to get
  257.          rid of hum in the image caused by a bad cable)
  258.  
  259.    /t:840  - says to record for 840 seconds (14 minutes).  This value
  260.          can be adjusted to whatever length is desired.
  261.  
  262.  
  263. After a satellite pass has been recorded and written to disk as a .VOC
  264. sound sample file,  the next step is to demodulate the .VOC sample file
  265. into an image file.  Use the command:
  266.  
  267.    sbdsp c:cap.voc c:cap.img
  268.  
  269. This will read the recorded sample file C:CAP.VOC and write the
  270. resulting image to the file C:CAP.IMG  (remember that these files will
  271. be about 8 Megabytes EACH).  If you do not specify the output file name,
  272. the demodulation program will ask if it is OK to write the output image
  273. over the data in the .VOC file.  This is a VERY time consuming process,
  274. but can be useful if you are short on disk space.  Note that if you
  275. choose to overwrite the input data file,  you cannot experiment with the
  276. various timing adjustments or interrupt the demodulation program.
  277.  
  278.  
  279. Once the input file has been demodulated you can use your favorite
  280. image processing program (such as IMDISP, APTCAP, or SATVIEW) to view
  281. the resulting image.  The file written by the demodulation program is
  282. raw binary 8-bit gray scale image.  Each line is 4800 pixels wide.  A 14
  283. minute pass has 1680 scan lines. (Because of the timing adjustments, etc
  284. the output image may be short a few lines).
  285.  
  286. ---
  287. Tweaking in the timing:
  288.  
  289. What you should see is the APT image complete with the normal "doppler
  290. bow" curve.  The curve in the image is due the speed of light.  Since
  291. light travels at 186,000 miles per second, each pixel of image shift in
  292. the doppler bow (1/9600 of a second) represents about 19.4 miles of
  293. satellite movement relative to the receiver.
  294.  
  295. As the satellite approaches the receiver the radio signal has to travel
  296. less and less distance to reach the receiver.  As the satellite moves
  297. away the radio signal takes longer and longer to reach the receiver.
  298. The point in the doppler bow where the curve changes slope
  299. is the closest point of approach of the satellite pass.
  300.  
  301. In a properly adjusted image,  the shape of the doppler bow curve
  302. should appear symmetrical about the closest point of satellite approach.
  303. If the image is slanted more towards the left or right, or appears like
  304. a TV image that has lost sync then you will need to adjust one or
  305. more of the timing adjustment factors.
  306.  
  307. (For further information, contact the software developers at:
  308. Dallas  Remote Imaging Group BBS - 214-394-7438  FAX 214 492 7747
  309. Usually only the fine timing adjustment (/F) needs to be set.  To get an
  310. idea of the magnitude of the adjustment needed, count or estimate the
  311. number of pixels that the image slants.  (Hint:  use the pan and zoom
  312. features of your image display program.  If your display program
  313. re-sizes the image to fit the screen, remember to count pixels in the
  314. FILE, not those on the screen).  Divide the total file size by the
  315. number of pixels that the image slants from top to bottom.
  316.  
  317.    adjustment factor = (file size / pixels of image slant)
  318.  
  319. The more the severe image slant is, the SMALLER the timing adjustment
  320. factor value.  Subtle image slants are typically corrected with large
  321. valued adjustment factors (say 50,000 - 500,000).  Adjustment factors in
  322. the thousands would be used for images that slant a good portion of the
  323. width of the screen.  Even more severe slants first should be corrected
  324. by tweaking the /C (coarse) timing adjustment.
  325.  
  326. Images that slant to the left use a positive adjustment count.
  327. Images that slant to the right use a negative adjustment count.
  328.  
  329.     ->|      |<- estimate the number of pixels of image slant
  330.       |      |
  331.       |       ----------        ----------
  332.       |     /           /       \           \
  333.       |   /  image   /             \     image     \
  334.       | /       /               \       \
  335.       | ----------             -----------
  336.        Use /F+value            Use /F-value
  337.  
  338.  
  339. The loss of pixels between DMA sample blocks shows up as small
  340. periodic jags in the image of a pixel or so every 6-8 scan lines.
  341. Experiment with the /O and /E command line options may be to minimize
  342. these remaining jaggies.  For these options,  larger values produce
  343. greater effect.  The maximum DMA adjustment factor possible is +/- 255.
  344. Only + values should be needed here.  The software supports - values
  345. just in case...
  346.  
  347.  
  348. The image may look OK except for one or more large and sudden shifts or
  349. discontinuities.  These shifts usually occur on systems with slower hard
  350. drives or CPU's.  The cause is usually the excessive time it takes DOS
  351. to extend or otherwise allocate disk space as it writes the .VOC file.
  352. If this occurs in your images, it can usually be fixed by recording the
  353. sample file to a freshly "defragmented" disk.  Use a disk optimizer
  354. program like Norton Utilities or PC Tools to pack the sample file hard
  355. disk drive before running the VREC recording program.
  356.  
  357.  
  358. Once the proper timing adjustment factors have been determined for a
  359. particular computer, they should not need to be changed (except possibly
  360. for a drift in the SoundBlaster sample clock rate with temperature).
  361. A batch file can be created that will automatically use the appropriate
  362. timing factors.
  363.  
  364. --------
  365. Development team at:
  366. Dallas Remote Imaging Group
  367. PO BOX 117088
  368. Carrollton, Texas 75011-7088
  369. FAX 214 492 7747
  370. ================================================================================
  371.  ============================================================================
  372.  
  373.              DALLAS REMOTE IMAGING GROUP BBS    =====>>  214-394-7438
  374.                                          FAX             214-492-7747
  375.                                        VOICE             214-394-7325
  376.  
  377.              DEDICATED TO SATELLITE IMAGERY, SATELLITE TRACKING, NASA,
  378.                           DIGITAL SIGNAL PROCESSING, IMAGE PROCESSING,
  379.                           AMATEUR RADIO, AND ELECTRONIC INTELLIGENCE
  380.  
  381.     PCBoard SUPPORTS 6 Lines (USR Dual Standard V.32bis V.42 24 hrs. Daily)
  382.  
  383.           E-MAIL FOR Weather Satellite Report and InterNet UUCP News Groups
  384.                                                                       
  385.               ON-LINE HAMCALL APPLICATION - LOOKUP HAM CALLSIGNS
  386.               On-Line SATTRAK Satellite Tracking Routines
  387.               On-Line SHOP Satellite Resource Center - On-line Ordering
  388.               On-Line BALLTRAK  Balloon Launch and Tracking Program
  389.  
  390.          THOUSANDS OF IMAGE FILES OF SATELLITE IMAGE AND NASA VOYAGER IMAGES
  391.          SATELLITE TRACKING PROGRAMS, IMAGE PROCESSING, DSP, ATV, SSTV, FAX
  392.  ============================================================================
  393.