Initial import from FreeBSD RELENG_4:
[games.git] / contrib / ntp / html / driver6.htm
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
2 <html>
3 <head>
4 <meta name="generator" content="HTML Tidy, see www.w3.org">
5 <title>IRIG Audio Decoder</title>
6 </head>
7 <body>
8 <h3>IRIG Audio Decoder</h3>
9
10 <hr>
11 <h4>Synopsis</h4>
12
13 Address: 127.127.6.<i>u</i> <br>
14 Reference ID: <tt>IRIG</tt> <br>
15 Driver ID: <tt>IRIG_AUDIO</tt> <br>
16 Audio Device: <tt>/dev/audio</tt> and <tt>/dev/audioctl</tt> 
17
18 <p>Note: This driver supersedes an older one of the same name,
19 address and ID which required replacing the original kernel audio
20 driver with another which works only on older Sun SPARCstation
21 systems. The new driver described here uses the stock kernel audio
22 driver and works in SunOS 4.1.3 and Solaris 2.6 versions and
23 probably all versions in between. The new driver requires no
24 modification of the operating system. While it is generic and
25 likely portable to other systems, it is somewhat slower than the
26 original, since the extensive signal conditioning, filtering and
27 decoding is done in user space, not kernel space.</p>
28
29 <h4>Description</h4>
30
31 This driver supports the Inter-Range Instrumentation Group (IRIG)
32 standard time distribution signal using the audio codec native to
33 some workstations. This signal is generated by several radio
34 clocks, including those made by Arbiter, Austron, Bancomm, Odetics,
35 Spectracom and TrueTime, among others, although it is often an
36 add-on option. The signal is connected via an optional attenuator
37 box and cable to either the microphone or line-in port. The driver
38 receives, demodulates and decodes the IRIG-B and IRIG-E signal
39 formats using internal filters designed to reduce the effects of
40 noise and interference. 
41
42 <p>This driver incorporates several features in common with other
43 audio drivers such as described in the <a href="driver7.htm">Radio
44 CHU Audio Demodulator/Decoder</a> and the <a href="driver36.htm">
45 Radio WWV/H Audio Demodulator/Decoder</a> pages. They include
46 automatic gain control (AGC), selectable audio codec port and
47 signal monitoring capabilities. For a discussion of these common
48 features, as well as a guide to hookup, debugging and monitoring,
49 see the <a href="audio.htm">Reference Clock Audio Drivers</a>
50 page.</p>
51
52 <p>The IRIG signal format uses an amplitude-modulated carrier with
53 pulse-width modulated data bits. For IRIG-B, the carrier frequency
54 is 1000 Hz and bit rate 100 b/s; for IRIG-E, the carrier frequenchy
55 is 100 Hz and bit rate 10 b/s. While IRIG-B provides the best
56 accuracy, generally within a few tens of microseconds relative to
57 IRIG time, it can also generate a significant load on the processor
58 with older workstations. Generally, the accuracy with IRIG-E is
59 about ten times worse than IRIG-B, but the processor load is ten
60 times less.</p>
61
62 <p>The program processes 8000-Hz mu-law companded samples using
63 separate signal filters for IRIG-B and IRIG-E, a comb filter,
64 envelope detector and automatic threshold corrector. Cycle
65 crossings relative to the corrected slice level determine the width
66 of each pulse and its value - zero, one or position identifier. The
67 data encode 20 BCD digits which determine the second, minute, hour
68 and day of the year and sometimes the year and synchronization
69 condition. The comb filter exponentially averages the corresponding
70 samples of successive baud intervals in order to reliably identify
71 the reference carrier cycle. A type-II phase-lock loop (PLL)
72 performs additional integration and interpolation to accurately
73 determine the zero crossing of that cycle, which determines the
74 reference timestamp. A pulse-width discriminator demodulates the
75 data pulses, which are then encoded as the BCD digits of the
76 timecode. The timecode and reference timestamp are updated once
77 each second with IRIG-B (ten seconds with IRIG-E) and local clock
78 offset samples saved for later processing. At poll intervals of 64
79 s, the saved samples are processed by a trimmed-mean filter and
80 used to update the system clock.</p>
81
82 <p>Infinite impulse response (IIR) filters are used with both
83 IRIG-B and IRIG-E formats. An 800-Hz highpass filter is used for
84 IRIG-B and a 130-Hz lowpass filter for IRIG-E. These are intended
85 for use with noisy signals, such as might be received over a
86 telephone line or radio circuit, or when interfering signals may be
87 present in the audio passband. The driver determines which IRIG
88 format is in use by sampling the amplitude of each filter output
89 and selecting the one with maximum signal. An automatic gain
90 control feature provides protection against overdriven or
91 underdriven input signal amplitudes. It is designed to maintain
92 adequate demodulator signal amplitude while avoiding occasional
93 noise spikes. In order to assure reliable capture, the decompanded
94 input signal amplitude must be greater than 100 units and the codec
95 sample frequency error less than 250 PPM (.025 percent).</p>
96
97 <p>The program performs a number of error checks to protect against
98 overdriven or underdriven input signal levels, incorrect signal
99 format or improper hardware configuration. Specifically, if any of
100 the following errors occur for a timecode, the data are rejected.
101 Secifically, if any of the following errors occur for a time
102 measurement, the data are rejected.</p>
103
104 <ol>
105 <li>The peak carrier amplitude is less than 100 units. This usually
106 means dead IRIG signal source, broken cable or wrong input
107 port.</li>
108
109 <li>The frequency error is greater than &plusmn;250 PPM (.025
110 percent). This usually means broken codec hardware or wrong codec
111 configuration.</li>
112
113 <li>The modulation index is less than 0.5. This usually means
114 overdriven IRIG signal or wrong IRIG format.</li>
115
116 <li>A frame synchronization error has occured. This usually means
117 wrong IRIG signal format or the IRIG signal source has lost
118 synchronization (signature control).</li>
119
120 <li>A data decoding error has occured. This usually means wrong
121 IRIG signal format.</li>
122
123 <li>The current second of the day is not exactly one greater than
124 the previous one. This usually means a very noisy IRIG signal or
125 insufficient CPU resources.</li>
126
127 <li>An audio codec error (overrun) occured. This usually means
128 insufficient CPU resources, as sometimes happens with Sun SPARC
129 IPCs when doing something useful.</li>
130 </ol>
131
132 Note that additional checks are done elsewhere in the reference
133 clock interface routines. 
134
135 <p>Unlike other drivers, which can have multiple instantiations,
136 this one supports only one. It does not seem likely that more than
137 one audio codec would be useful in a single machine. More than one
138 would probably chew up too much CPU time anyway.</p>
139
140 <h4>IRIG-B Timecode Format</h4>
141
142 The 100 elements of the IRIG timecode are numbered from 0 through
143 99. Position identifiers occur at elements 0, 9, 19 and every ten
144 thereafter to 99. The control function (CF) elements begin at
145 element 50 (CF 1) and extend to element 78 (CF 27). The
146 straight-binary-seconds (SBS) field, which encodes the seconds of
147 the UTC day, begins at element 80 (CF 28) and extends to element 97
148 (CF 44). The encoding of elements 50 (CF 1) through 78 (CF 27) is
149 device dependent. This driver presently decodes the CF elements,
150 but does nothing with them. 
151
152 <p>Where feasible, the IRIG signal source should be operated with
153 signature control so that, if the signal is lost or mutilated, the
154 source produces an unmodulated signal, rather than possibly random
155 digits. The driver will automatically reject the data and declare
156 itself unsynchronized in this case. Some devices, in particular
157 Spectracom radio/satellite clocks, provide additional year and
158 status indication in the format:</p>
159
160 <pre>
161      Element   CF        Function
162      -------------------------------------
163      55        6         time sync status
164      60-63     10-13     BCD year units
165      65-68     15-18     BCD year tens
166 </pre>
167
168 Other devices set these elements to zero. 
169
170 <h4>Performance</h4>
171
172 The mu-law companded data format allows considerable latitude in
173 signal levels; however, an automatic gain control (AGC) function is
174 implemented to further compensate for varying input signal levels
175 and to avoid signal distortion. For proper operation, the IRIG
176 signal source should be configured for analog signal levels, NOT
177 digital TTL levels. 
178
179 <p>The accuracy of the system clock synchronized to the IRIG-B
180 source with this driver and the <tt>ntpd</tt> daemon is 10-20 <font
181 face="symbol">m</font>s with a Sun UltraSPARC II and maybe twice
182 that with a Sun SPARC IPC. The processor resources consumed by the
183 daemon can be significant, ranging from about 1.2 percent on the
184 faster UltraSPARC II to 38 percent on the slower SPARC IPC.
185 However, the overall timing accuracy is limited by the resolution
186 and stability of the CPU clock oscillator and the interval between
187 clock corrections, which is 64 s with this driver. This
188 performance, while probably the best that can be achieved by the
189 daemon itself, can be improved with assist from the PPS discipline
190 as described elsewhere in the documentation.</p>
191
192 <h4>Monitor Data</h4>
193
194 The timecode format used for debugging and data recording includes
195 data helpful in diagnosing problems with the IRIG signal and codec
196 connections. With debugging enabled (-d on the ntpd command line),
197 the driver produces one line for each timecode in the following
198 format: 
199
200 <p><tt>00 1 98 23 19:26:52 721 143 0.694 47 20 0.083 66.5
201 3094572411.00027</tt></p>
202
203 <p>The first field containes the error flags in hex, where the hex
204 bits are interpreted as below. This is followed by the IRIG status
205 indicator, year of century, day of year and time of day. The status
206 indicator and year are not produced by some IRIG devices. Following
207 these fields are the signal amplitude (0-8100), codec gain (0-255),
208 field phase (0-79), time constant (2-20), modulation index (0-1),
209 carrier phase error (0&plusmn;0.5) and carrier frequency error
210 (PPM). The last field is the on-time timestamp in NTP format. The
211 fraction part is a good indicator of how well the driver is doing.
212 With an UltrSPARC 30, this is normally within a few tens of
213 microseconds relative to the IRIG-B signal and within a few hundred
214 microseconds with IRIG-E.</p>
215
216 <h4>Fudge Factors</h4>
217
218 <dl>
219 <dt><tt>time1 <i>time</i></tt></dt>
220
221 <dd>Specifies the time offset calibration factor, in seconds and
222 fraction, with default 0.0.</dd>
223
224 <dt><tt>time2 <i>time</i></tt></dt>
225
226 <dd>Not used by this driver.</dd>
227
228 <dt><tt>stratum <i>number</i></tt></dt>
229
230 <dd>Specifies the driver stratum, in decimal from 0 to 15, with
231 default 0.</dd>
232
233 <dt><tt>refid <i>string</i></tt></dt>
234
235 <dd>Specifies the driver reference identifier, an ASCII string from
236 one to four characters, with default <tt>IRIG</tt>.</dd>
237
238 <dt><tt>flag1 0 | 1</tt></dt>
239
240 <dd>Not used by this driver.</dd>
241
242 <dt><tt>flag2 0 | 1</tt></dt>
243
244 <dd>Specifies the microphone port if set to zero or the line-in
245 port if set to one. It does not seem useful to specify the compact
246 disc player port.</dd>
247
248 <dt><tt>flag3 0 | 1</tt></dt>
249
250 <dd>Enables audio monitoring of the input signal. For this purpose,
251 the speaker volume must be set before the driver is started.</dd>
252
253 <dt><tt>flag4 0 | 1</tt></dt>
254
255 <dd>Enable verbose <tt>clockstats</tt> recording if set.</dd>
256 </dl>
257
258 <h4>Additional Information</h4>
259
260 <a href="refclock.htm">Reference Clock Drivers</a> <br>
261 <a href="audio.htm">Reference Clock Audio Drivers</a> 
262
263 <hr>
264 <a href="index.htm"><img align="left" src="pic/home.gif" alt=
265 "gif"></a> 
266
267 <address><a href="mailto:mills@udel.edu">David L. Mills
268 &lt;mills@udel.edu&gt;</a></address>
269 </body>
270 </html>
271