xref: /freebsd/contrib/ntp/html/audio.html (revision 416ba5c74546f32a993436a99516d35008e9f384)
19c2daa00SOllivier Robert<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
29c2daa00SOllivier Robert<html>
39c2daa00SOllivier Robert<head>
4ea906c41SOllivier Robert<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
59c2daa00SOllivier Robert<meta name="generator" content="HTML Tidy, see www.w3.org">
69c2daa00SOllivier Robert<title>Reference Clock Audio Drivers</title>
79c2daa00SOllivier Robert<link href="scripts/style.css" type="text/css" rel="stylesheet">
89c2daa00SOllivier Robert</head>
99c2daa00SOllivier Robert<body>
109c2daa00SOllivier Robert<h3>Reference Clock Audio Drivers</h3>
119c2daa00SOllivier Robert<img src="pic/radio2.jpg" alt="jpg" align="left">ICOM R-72 shortwave receiver and Sure audio mixer
12*2b15cb3dSCy Schubert<p>Last update:
13*2b15cb3dSCy Schubert  <!-- #BeginDate format:En2m -->11-Sep-2010  05:55<!-- #EndDate -->
14*2b15cb3dSCy Schubert  UTC</p>
159c2daa00SOllivier Robert<br clear="left">
169c2daa00SOllivier Robert<h4>Related Links</h4>
17*2b15cb3dSCy Schubert<script type="text/javascript" language="javascript" src="scripts/refclock.txt"></script>
18*2b15cb3dSCy Schubert<script type="text/javascript" language="javascript" src="scripts/audio.txt"></script>
199c2daa00SOllivier Robert<h4>Table of Contents</h4>
209c2daa00SOllivier Robert<ul>
21*2b15cb3dSCy Schubert  <li class="inline"><a href="#sound">Sound Card Drivers</a></li>
22*2b15cb3dSCy Schubert  <li class="inline"><a href="#short">Shortwave Radio Drivers</a></li>
23*2b15cb3dSCy Schubert  <li class="inline"><a href="#setup">Setup and Debugging Aids</a></li>
249c2daa00SOllivier Robert</ul>
259c2daa00SOllivier Robert<hr>
269c2daa00SOllivier Robert<h4 id="sound">Sound Card Drivers</h4>
279c2daa00SOllivier Robert<p>There are some applications in which the computer time can be disciplined to an audio signal, rather than a serial timecode and communications port or special purpose bus peripheral. This is useful in such cases where the audio signal is sent over a telephone circuit, for example, or received directly from a shortwave receiver. In such cases the audio signal can be connected via an ordinary sound card or baseboard audio codec. The suite of NTP reference clock drivers currently includes three drivers suitable for these applications. They include a driver for the Inter Range Instrumentation Group (IRIG) signals produced by many radio clocks and timing devices, another for the Canadian time/frequency radio station CHU and a third for the NIST time/frequency radio stations WWV and WWVH. The radio drivers are designed to work with ordinary inexpensive shortwave radios and may be one of the least expensive ways to build a good primary time server.</p>
28*2b15cb3dSCy Schubert<p>All three drivers make ample use of sophisticated digital signal processing
29*2b15cb3dSCy Schubert  algorithms designed to efficiently extract timing signals from noise and interference.
30*2b15cb3dSCy Schubert  The radio station drivers in particular implement optimum linear demodulation
31*2b15cb3dSCy Schubert  and decoding techniques, including maximum-likelihood and soft-decision methods.
32*2b15cb3dSCy Schubert  The documentation page for each driver contains an in-depth discussion on
33*2b15cb3dSCy Schubert  the algorithms and performance expectations. In some cases the algorithms
34*2b15cb3dSCy Schubert  are further analyzed, modeled and evaluated in a technical report.</p>
359c2daa00SOllivier Robert<p>Currently, the audio drivers work with with Sun operating systems and audio codecs, including SunOS 4.1.3 and Solaris from 2.6 and probably all others in between. They also work with FreeBSD from 4.1 with compatible sound card. In fact, the interface is quite generic and support for other systems, in particular the various Unix generics, should not be difficult. Volunteers are solicited.</p>
369c2daa00SOllivier Robert<p>The audio drivers include a number of common features designed to groom input signals, suppress spikes and normalize signal levels. An automatic gain control (AGC) feature provides protection against overdriven or underdriven input signals. It is designed to maintain adequate demodulator signal amplitude while avoiding occasional noise spikes. In order to assure reliable operation, the signal level must be in the range where the audio gain control is effective. In general, this means the input signal level must be such as to cause the AGC to set the gain somewhere in the middle of the range from 0 to 255, as indicated in the timecode displayed by the <tt>ntpq</tt> program.</p>
37*2b15cb3dSCy Schubert<p>The IRIG&nbsp;and WWV drivers operate by disciplining a logical clock based on the codec sample clock to the audio signal as received. This is done by stuffing or slipping samples as required to maintain exact frequency to the order of 0.1 PPM. In order for the driver to reliably lock on the audio signal, the sample clock frequency tolerance must be less than 250 PPM (.025 percent) for the IRIG driver and half that for the WWV driver. The largest error observed so far is about 60 PPM, but it is possible some sound cards or codecs may exceed that value. In any case, the configuration file command <tt>tinker codec</tt> command can be used to change the systematic offset in units of 125 PPM.</p>
38*2b15cb3dSCy Schubert<p>The drivers include provisions to select the input port and to monitor the input signal. The <tt>fudge flag 2</tt> command selects the microphone port if set to zero or the line-in port if set to one. It does not seem useful to specify the compact disc player port. The <tt>fudge flag 3</tt> command enables the input signal monitor using the previously selected output port and output gain. Both of these flags can be set in the configuration file or remotely using the <tt>ntpdc</tt> utility program.</p>
399c2daa00SOllivier Robert<h4 id="short">Shortwave Radio Drivers</h4>
409c2daa00SOllivier Robert<p>The WWV/H and CHU audio drivers require an external shortwave radio with the radio output - speaker or headphone jack - connected to either the microphone or line-in port on the computer. There is some degree of art in setting up the radio and antenna and getting the setup to work. While the drivers are highly sophisticated and efficient in extracting timing signals from noise and interference, it always helps to have as clear a signal as possible.</p>
419c2daa00SOllivier Robert<p>The most important factor affecting the radio signal is the antenna. It need not be long - even 15 feet is enough if it is located outside of a metal frame building, preferably on the roof, and away from metallic objects. An ordinary CB whip mounted on a PVC pipe and wooden X-frame on the roof should work well with most portable radios, as they are optimized for small antennas.</p>
429c2daa00SOllivier Robert<p>The radio need not be located near the computer; in fact, it generally works better if the radio is outside the near field of computers and other electromagnetic noisemakers. It can be in the elevator penthouse connected by house wiring, which can also be used to power the radio. A couple of center-tapped audio transformers will minimize noise pickup and provide phantom power to the radio with return via the building ground.</p>
439c2daa00SOllivier Robert<p>The WWV/H and CHU transmitters operate on several frequencies simultaneously, so that in most parts of North America at least one frequency supports propagation to the receiver location at any given hour. While both drivers support the ICOM CI-V radio interface and can tune the radio automatically, computer-tunable radios are expensive and probably not cost effective compared to a GPS receiver. So, the radio frequency must usually be fixed and chosen by compromise.</p>
449c2daa00SOllivier Robert<p>Shortwave (3-30 MHz) radio propagation phenomena are well known to shortwave enthusiasts. The phenomena generally obey the following rules:</p>
459c2daa00SOllivier Robert<ul>
46*2b15cb3dSCy Schubert  <li>The optimum frequency is higher in daytime than nighttime, stays high longer on summer days and low longer on winter nights.</li>
47*2b15cb3dSCy Schubert  <li>Transitions between daytime and nighttime conditions generally occur somewhat
48*2b15cb3dSCy Schubert    after sunrise and sunset at the midpoint of the path from transmitter to
49*2b15cb3dSCy Schubert    receiver.</li>
50*2b15cb3dSCy Schubert  <li>Ambient noise (static) on the lower frequencies follows the thunderstorm season, so is higher on summer afternoons and evenings.</li>
51*2b15cb3dSCy Schubert  <li>The lower frequency bands are best for shorter distances, while the higher bands are best for longer distances.</li>
52*2b15cb3dSCy Schubert  <li>The optimum frequencies are higher at the peak of the 11-year sunspot cycle and lower at the trough. The current sunspot cycle began at the minimum in late 2006 and should reach its peak in 2012.</li>
539c2daa00SOllivier Robert</ul>
54*2b15cb3dSCy Schubert<p>The best way to choose a frequency is to listen at various times over the day and determine the highest (daytime) and lowest (nighttime) frequencies that work well. Choose the frequency that works for the most number of hours in the day, usually the highest frequency. For instance, on the east coast the best compromise CHU frequency is 7335 kHz and the best WWV frequency is 15 MHz.</p>
55ea906c41SOllivier Robert<h4>Autotune Modes</h4>
56ea906c41SOllivier Robert<p>The shortwave drivers include support for an optional autotune function compatible with ICOM&nbsp;receivers and transceivers. The <tt>mode</tt> keyword of the <tt>server</tt> configuration command specifies the ICOM ID select code in decimal. A missing or zero argument disables the CI-V interface. Since all ICOM select codes are less than 128, the high order bit of the code is used by the driver to specify the baud rate. If this bit is not set, the rate is 9600 bps for the newer radios; if set, the rate is 1200 bps for the older radios. Following are the ID select codes for the known radios.</p>
57ea906c41SOllivier Robert<table width="100%" cols="6">
58ea906c41SOllivier Robert  <tr>
59ea906c41SOllivier Robert    <td>Radio</td>
60ea906c41SOllivier Robert    <td>Hex</td>
61ea906c41SOllivier Robert    <td>Decimal</td>
62ea906c41SOllivier Robert    <td>Radio</td>
63ea906c41SOllivier Robert    <td>Hex</td>
64ea906c41SOllivier Robert    <td>Decimal</td>
65ea906c41SOllivier Robert  </tr>
66ea906c41SOllivier Robert  <tr>
67ea906c41SOllivier Robert    <td>706</td>
68ea906c41SOllivier Robert    <td>0x4e</td>
69ea906c41SOllivier Robert    <td>78</td>
70ea906c41SOllivier Robert    <td>775</td>
71ea906c41SOllivier Robert    <td>0x46</td>
72ea906c41SOllivier Robert    <td>70</td>
73ea906c41SOllivier Robert  </tr>
74ea906c41SOllivier Robert  <tr>
75ea906c41SOllivier Robert    <td>706MKIIG</td>
76ea906c41SOllivier Robert    <td>0x58</td>
77ea906c41SOllivier Robert    <td>88</td>
78ea906c41SOllivier Robert    <td>781</td>
79ea906c41SOllivier Robert    <td>0x26</td>
80ea906c41SOllivier Robert    <td>38</td>
81ea906c41SOllivier Robert  </tr>
82ea906c41SOllivier Robert  <tr>
83ea906c41SOllivier Robert    <td>725</td>
84ea906c41SOllivier Robert    <td>0x28</td>
85ea906c41SOllivier Robert    <td>40</td>
86ea906c41SOllivier Robert    <td>970</td>
87ea906c41SOllivier Robert    <td>0x2e</td>
88ea906c41SOllivier Robert    <td>46</td>
89ea906c41SOllivier Robert  </tr>
90ea906c41SOllivier Robert  <tr>
91ea906c41SOllivier Robert    <td>726</td>
92ea906c41SOllivier Robert    <td>0x30</td>
93ea906c41SOllivier Robert    <td>48</td>
94*2b15cb3dSCy Schubert    <td>7000</td>
95*2b15cb3dSCy Schubert    <td>0x70</td>
96*2b15cb3dSCy Schubert    <td>113</td>
97ea906c41SOllivier Robert  </tr>
98ea906c41SOllivier Robert  <tr>
99ea906c41SOllivier Robert    <td>735</td>
100ea906c41SOllivier Robert    <td>0x04</td>
101ea906c41SOllivier Robert    <td>4</td>
102*2b15cb3dSCy Schubert    <td>R71</td>
103*2b15cb3dSCy Schubert    <td>0x1A</td>
104*2b15cb3dSCy Schubert    <td>26</td>
105ea906c41SOllivier Robert  </tr>
106ea906c41SOllivier Robert  <tr>
107ea906c41SOllivier Robert    <td>746</td>
108ea906c41SOllivier Robert    <td>0x66</td>
109ea906c41SOllivier Robert    <td>102</td>
110*2b15cb3dSCy Schubert    <td>R72</td>
111*2b15cb3dSCy Schubert    <td>0x32</td>
112*2b15cb3dSCy Schubert    <td>50</td>
113ea906c41SOllivier Robert  </tr>
114ea906c41SOllivier Robert  <tr>
115ea906c41SOllivier Robert    <td>751</td>
116ea906c41SOllivier Robert    <td>0x1c</td>
117ea906c41SOllivier Robert    <td>28</td>
118*2b15cb3dSCy Schubert    <td>R75</td>
119*2b15cb3dSCy Schubert    <td>0x5a</td>
120*2b15cb3dSCy Schubert    <td>90</td>
121ea906c41SOllivier Robert  </tr>
122ea906c41SOllivier Robert  <tr>
123ea906c41SOllivier Robert    <td>756PROII</td>
124ea906c41SOllivier Robert    <td>0x64</td>
125ea906c41SOllivier Robert    <td>100</td>
126*2b15cb3dSCy Schubert    <td>R7000</td>
127*2b15cb3dSCy Schubert    <td>0x08</td>
128*2b15cb3dSCy Schubert    <td>8</td>
129ea906c41SOllivier Robert  </tr>
130ea906c41SOllivier Robert  <tr>
131ea906c41SOllivier Robert    <td>761</td>
132ea906c41SOllivier Robert    <td>0x1e</td>
133ea906c41SOllivier Robert    <td>30</td>
134*2b15cb3dSCy Schubert    <td>R7100</td>
135*2b15cb3dSCy Schubert    <td>0x34</td>
136*2b15cb3dSCy Schubert    <td>52</td>
137ea906c41SOllivier Robert  </tr>
138ea906c41SOllivier Robert  <tr>
139ea906c41SOllivier Robert    <td>765</td>
140ea906c41SOllivier Robert    <td>0x2c</td>
141ea906c41SOllivier Robert    <td>44</td>
142*2b15cb3dSCy Schubert    <td>R8500</td>
143*2b15cb3dSCy Schubert    <td>0x4a</td>
144*2b15cb3dSCy Schubert    <td>74</td>
145*2b15cb3dSCy Schubert  </tr>
146*2b15cb3dSCy Schubert  <tr>
147*2b15cb3dSCy Schubert    <td></td>
148*2b15cb3dSCy Schubert    <td></td>
149*2b15cb3dSCy Schubert    <td></td>
150ea906c41SOllivier Robert    <td>R9000</td>
151ea906c41SOllivier Robert    <td>0x2a</td>
152ea906c41SOllivier Robert    <td>42</td>
153ea906c41SOllivier Robert  </tr>
154ea906c41SOllivier Robert</table>
1559c2daa00SOllivier Robert<h4 id="setup">Setup and Debugging Aids</h4>
1569c2daa00SOllivier Robert<p>The audio drivers include extensive setup and debugging support to help hook up the audio signals and monitor the driver operations. The documentation page for each driver describes the various messages that can be produced either in real time or written to the <tt>clockstats</tt> file for later analysis. Of particular help in verifying signal connections and compatibility is a provision to monitor the signal via headphones or speaker.</p>
157*2b15cb3dSCy Schubert<p>Connecting radios and IRIG devices to the computer and verifying correct
158*2b15cb3dSCy Schubert  configuration is somewhat of a black art. The signals have to be connected
159*2b15cb3dSCy Schubert  to the correct ports and the signal level maintained within tolerances. Some
160*2b15cb3dSCy Schubert  radios have recorder outputs which produce a microphone-level signal not affected
161*2b15cb3dSCy Schubert  by the volume control. These signals can be connected to the microphone port
162*2b15cb3dSCy Schubert  on the computer. If the radio does not have a recorder output, connect the
163*2b15cb3dSCy Schubert  headphone or speaker output to the line-in port and adjust the volume control
164*2b15cb3dSCy Schubert  so the driver indicates comfortably above the minimum specified and the AGC
165*2b15cb3dSCy Schubert  level somewhere in the middle of the range 0-255. IRIG signals are usually
166*2b15cb3dSCy Schubert  much larger than radio outputs, usually in the range to several volts and
167*2b15cb3dSCy Schubert  may even overload the line-in port. In such cases the signal is designed to
168*2b15cb3dSCy Schubert  drive a cable terminated with a 50-ohm resistor, which results in a level
169*2b15cb3dSCy Schubert  the line-in port can handle..</p>
170*2b15cb3dSCy Schubert<p>It is very easy to underdriven or overdrive the audio codec, in which case
171*2b15cb3dSCy Schubert  the drivers will not synchronize to the signal. The drivers use <tt>fudge
172*2b15cb3dSCy Schubert  flag2</tt> to enable audio monitoring of the input signal. This is useful
173*2b15cb3dSCy Schubert  during setup to confirm the signal is actually reaching the audio
174*2b15cb3dSCy Schubert  codec and generally free of noise and interference. Note that the monitor
175*2b15cb3dSCy Schubert  volume must be set before the driver is started.</p>
1769c2daa00SOllivier Robert<p>The drivers write a synthesized timecode to the <tt>clockstats</tt> file each time the clock is set or verified and at other times if verbose monitoring is enabled. The format includes several fixed-length fields defining the UTC time to the millisecond, together with additional variable-length fields specific to each driver. The data include the intervals since the clock was last set or verified, the audio gain and various state variables and counters specific to each driver.</p>
1779c2daa00SOllivier Robert<hr>
1789c2daa00SOllivier Robert<script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
1799c2daa00SOllivier Robert</body>
1809c2daa00SOllivier Robert</html>
181