freebsd-skq/contrib/ntp/html/driver7.htm
1999-12-09 13:01:21 +00:00

228 lines
8.7 KiB
HTML

<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="GENERATOR" CONTENT="Mozilla/4.01 [en] (Win95; I) [Netscape]">
<TITLE>Canadian CHU Radio Modem/Audio Decoder
</TITLE>
</HEAD>
<BODY>
<H3>
CHU Audio/Modem Decoder</H3>
<HR>
<H4>
Synopsis</H4>
Address: 127.127.7.<I>u</I>
<BR>Reference ID: <TT>CHU</TT>
<BR>Driver ID: <TT>CHU</TT>
<BR>Serial Port: <TT>/dev/chu<I>u</I></TT>; 300 baud, 8-bits, no parity
<BR>Audio Device: <TT>/dev/audio</TT> and <TT>/dev/audioctl</TT>
<H4>
Description</H4>
This driver synchronizes the computer time using data encoded in radio
transmissions from Canadian time/frequency station CHU in Ottawa, Ontario.
Transmissions are made continuously on 3330 kHz, 7335 kHz and 14670 kHz
in upper sideband, compatible AM mode. An ordinary shortwave receiver can
be tuned manually to one of these frequencies or, in the case of ICOM receivers,
the receiver can be tuned automatically using the <TT>minimuf</TT> and
<TT>icom</TT> programs as propagation conditions change throughout the
day and night.
<P>This driver replaces an earlier one built by Dennis Ferguson in 1988.
The earlier driver required a special line discipline which preprocessed
the signal in order to improve accuracy and avoid errors. The new driver
includes more powerful algorithms implemented directly in the driver and
requires no line discipline. It decodes the data using a maximum-likelihood
technique which exploits the considerable degree of redundancy available
to maximize accuracy and minimize errors.
<P>While there are currently no known commercial CHU receivers, a simple
but effective receiver/demodulator can be constructed from an ordinary
shortwave receiver and Bell 103 compatible, 300-bps modem or modem chip,
as described in the <A HREF="file:///J|/ntp4/html/pps.htm">Pulse-per-second
(PPS) Signal Interfacing</A> page. The driver can be compiled to use this
modem to receive the radio signal and demodulate the data. Alternatively,
the driver can be compiled to use the audio codec of the Sun workstation
or another with compatible audio drivers. In the latter case, the driver
implements the modem using DSP routines, so the radio can be connected
directly to either the microphone on line input port.
<P>The CHU time broadcast includes an audio signal compatible with the
Bell 103 modem standard (mark = 2225 Hz, space = 2025 Hz). It consist of
nine, ten-character bursts transmitted at 300 bps and beginning each second
from second 31 to second 39 of the minute. Each character consists of eight
data bits plus one start bit and two stop bits to encode two hex digits.
The burst data consist of five characters (ten hex digits) followed by
a repeat of these characters. In format A, the characters are repeated
in the same polarity; in format B, the characters are repeated in the opposite
polarity.
<P>Format A bursts are sent at seconds 32 through 39 of the minute in hex
digits
<P><TT>&nbsp;&nbsp;&nbsp; 6dddhhmmss6dddhhmmss</TT>
<P>The first ten digits encode a frame marker (<TT>6</TT>) followed by
the day (<TT>ddd</TT>), hour (<TT>hh </TT>in UTC), minute (<TT>mm</TT>)
and the second (<TT>ss</TT>). Since format A bursts are sent during the
third decade of seconds the tens digit of <TT>ss </TT>is always 3. The
driver uses this to determine correct burst synchronization. These digits
are then repeated with the same polarity.
<P>Format B bursts are sent at second 31 of the minute in hex digits
<P><TT>&nbsp;&nbsp;&nbsp; xdyyyyttaaxdyyyyttaa</TT>
<P>The first ten digits encode a code (<TT>x </TT>described below) followed
by the DUT1 (<TT>d </TT>in deciseconds), Gregorian year (<TT>yyyy</TT>),
difference TAI - UTC (<TT>tt</TT>) and daylight time indicator (<TT>aa</TT>)
peculiar to Canada. These digits are then repeated with inverted polarity.
<P>The <TT>x </TT>is coded
<P>1&nbsp;&nbsp;&nbsp; Sign of DUT (0 = +)
<BR>2&nbsp;&nbsp;&nbsp; Leap second warning. One second will be added.
<BR>4&nbsp;&nbsp;&nbsp; Leap second warning. One second will be subtracted.
This is not likely to happen in our universe.
<BR>8&nbsp;&nbsp;&nbsp; Even parity bit for this nibble.
<P>By design, the last stop bit of the last character in the burst coincides
with 0.5 second. Since characters have 11 bits and are transmitted at 300
bps, the last stop bit of the first character coincides with 0.5 - 10 *
11/300 = 0.133 second. Depending on the UART, character interrupts can
vary somewhere between the beginning of bit 9 and end of bit 11. These
eccentricities can be corrected along with the radio propagation delay
using <TT>fudge time1</TT>.
<H4>
Debugging aids</H4>
The timecode format used for debugging and data recording includes data
helpful in diagnosing problems with the radio signal and serial connections.
With debugging enabled (<TT>-d -d -d</TT> on the <TT>ntpd </TT>command
line), the driver produces one line for each burst in two formats corresponding
to format A and B. Following is format A:
<P><TT>&nbsp;&nbsp;&nbsp; n b f s m code</TT>
<P>where <TT>n </TT>is the number of characters in the burst (0-11), <TT>b
</TT>the burst distance (0-40), <TT>f </TT>the field alignment (-1, 0,
1), <TT>s </TT>the synchronization distance (0-16), <TT>m </TT>the burst
number (2-9) and <TT>code </TT>the burst characters as received. Note that
the hex digits in each character are reversed, so the burst
<P><TT>&nbsp;&nbsp;&nbsp; 10 38 0 16 9 06851292930685129293</TT>
<P>is interpreted as containing 11 characters with burst distance 38, field
alignment 0, synchronization distance 16 and burst number 9. The nibble-swapped
timecode shows day 58, hour 21, minute 29 and second 39.
<P>When the audio driver is compiled, format A is preceded by the gain
(0-255) and relative signal level (0-9999). The receiver volume control
should be set so that the gain is near the middle of the range 0-255, which
results in a signal level near 1000.
<P>Following is format B:
<P><TT>&nbsp;&nbsp;&nbsp; n b s code</TT>
<P>where <TT>n </TT>is the number of characters in the burst (0-11), <TT>b
</TT>the burst distance (0-40), <TT>s </TT>the synchronization distance
(0-40) and <TT>code </TT>the burst characters as received. Note that the
hex digits in each character are reversed and the last ten digits inverted,
so the burst
<P>&nbsp;&nbsp;&nbsp; <TT>11 40 1091891300ef6e76ecff</TT>
<P>is interpreted as containing 11 characters with burst distance 40. The
nibble-swapped timecode shows DUT1 +0.1 second, year 1998 and TAI - UTC
31 seconds.
<P>In addition to the above, the reference timecode is updated and written
to the clockstats file and debug score after the last burst received in
the minute. The format is
<P>&nbsp;&nbsp;&nbsp;<TT> qq yyyy ddd hh:mm:ss nn dd tt</TT>
<P>where <TT>qq </TT>are the error flags, as described below, <TT>yyyy
</TT>is the year, <TT>ddd </TT>the day, <TT>hh:mm:ss </TT>the time of day,
<TT>nn </TT>the number of format A bursts received during the previous
minute, <TT>dd </TT>the decoding distance and <TT>tt </TT>the number of
timestamps. The error flags are cleared after every update.
<P>For accuracy better than the low milliseconds, the <TT>fudge time1</TT>
variable can be used to set the propagation delay and compensate for inherent
latencies in the serial port hardware and operating system. This can be
done conveniently using the <TT>minimuf</TT> program.
<H4>
Monitor Data</H4>
When enabled by the <TT>flag4</TT> fudge flag, every received timecode
burst in both format A or format B is written to the <TT>clockstats</TT>
file.
<H4>
Fudge Factors</H4>
<DL>
<DT>
<TT>time1 <I>time</I></TT></DT>
<DD>
Specifies the time offset calibration factor, in seconds and fraction,
with default 0.0.</DD>
<DT>
<TT>time2 <I>time</I></TT></DT>
<DD>
Not used by this driver.</DD>
<DT>
<TT>stratum <I>number</I></TT></DT>
<DD>
Specifies the driver stratum, in decimal from 0 to 15, with default 0.</DD>
<DT>
<TT>refid <I>string</I></TT></DT>
<DD>
Specifies the driver reference identifier, an ASCII string from one to
four characters, with default <TT>CHU</TT>.</DD>
<DT>
<TT>flag1 0 | 1</TT></DT>
<DD>
Not used by this driver.</DD>
<DT>
<TT>flag2 0 | 1</TT></DT>
<DD>
When the audio driver is compiled, this flag selects the audio input
port, where 0 is the mike port (default) and 1 is the line-in port. It
does not seem useful to select the compact disc player port.</DD>
<DT>
<TT>flag3 0 | 1</TT></DT>
<DD>
When the audio driver is compiled, this flag enables audio monitoring of
the input signal. For this purpose, the speaker volume must be set
before the driver is started.</DD>
<DT>
<TT>flag4 0 | 1</TT></DT>
<DD>
Enable verbose <TT>clockstats</TT> recording if set.</DD>
</DL>
Additional Information
<P><A HREF="file:///J|/ntp4/html/refclock.htm">Reference Clock Drivers</A>&nbsp;
<HR>
<ADDRESS>
David L. Mills (mills@udel.edu)</ADDRESS>
</BODY>
</HTML>