% -*- Mode:Text -*- 

\chapter{Video output}

\section{Color subcarrier frequency}

The \ntsc\ color subcarrier frequency, $f_c$, is specified as
 $$
	f_c=F_c\equiv3,579,545\ {\rm Hz},
 $$
 \noindent or approximately 3.58 MHz. The corresponding period, $t_c$, is
 $$
	t_c=T_c\equiv279.3651\ {\rm nsec},
 $$
 \noindent or approximately 280 nsec. Here is a table of the color
subcarrier's first few multiples and submultiples.

 $$
 \begin{array}{|r|r|r|}\hline
	\multicolumn{3}{|c|}{\rm \ntsc\ color\ subcarrier\ multiples}\\\hline\hline
	 k 	& kt_c\ {\rm (nsec)}	& f_c/k\ {\rm (MHz)}\\\hline\hline
	1/4	& 69.841\,2	& 14.318\,180\,000	\\\hline
	1/3	& 93.121\,7	& 10.738\,635\,000	\\\hline
	1/2	& 139.682\,5	& 7.159\,090\,000	\\\hline
	1	& 279.365\,1	& 3.579\,545\,000	\\\hline
	2	& 558.730\,2	& 1.789\,772\,500	\\\hline
	3	& 838.095\,3	& 0.894\,886\,250\\\hline
	4	& 1\,117.460\,5	& 0.447\,443,125	\\\hline
 \end{array}
 $$

Commercial color crystals have a typical tolerance of a few tens ppm
(``parts per million'').  The phase of the color oscillator in a color
monitor is designed to be reset to that of the broadcast color
subcarrier at the beginning of every scan line. Because of this
design, it is reasonable to presume that the monitor will track a
broadcast color subcarrier that deviates a few tens of ppm (or perhaps
even hundreds of ppm) from the crystal's nominal frequency.
See Brooktree's data sheet for the Bt858 (Rev. R), page 17, for more details.


\section{Horizontal scan frequency}\sectlabel{horz-freq}

An \ntsc\ {\em frame} consists of two interlaced {\em fields} of
 $$
	N_v=262{1\over2}
 $$
	lines each, for a total of 525 lines per frame. Fields are
produced at a nominal rate of 60/sec. Less than ideal regulation of a TV set's
power supply leads to ``hum bars'' on the screen.\footnote
	{A monitor's poorly regulated power supplies results in ``hum
bars'' at line frequency (60 Hz in the U.S.) on the screen. The idea
behind a nominal vertical rate of 60 fields/sec is to match the
line frequency, so as to keep the hum bars stationary and thus
much less noticeable.  

The \ntsc{} choice of $f_h=15,734.264$ in color mode (see \eq{fh}) yields
a field rate of 59.940\,053/sec. The ensuing extremely slow rolling
of the hum bars across the screen is practically unnoticeable.

With modern, well-regulated monitors, hum bars are not an issue, and
designers feel free to drop the 60 Hz constraint in favor of other
design goals.  For instance, the IBM-PC monochrome mode uses 70 Hz to reduce
visual flicker, and the IBM-PC CGA mode uses 60 Hz even
in Europe, where the line frequency is 50 Hz.}
	leading to a nominal horizontal
scanning frequency of 15,750 kHz. The actual horizontal frequency for
{\em color} broadcasting, as specified by the \ntsc\ standard,
is slightly lower, namely,
 \begin{equation}\label{eq.fh}
	F_h\equiv15.734264\ \mathrm{kHz},
 \end{equation}
 \noindent corresponding to a horizontal period
 $$
	T_h=63.555563\ \mathrm{usec}.
 $$

\medskip
{\small {\sc Note:} \quad
With these choices for $t_c$ and $t_h$, there are exactly
 \begin{equation}\label{eq.nc}
	N_c\equiv227{\textstyle1\over2}
 \end{equation} color subcarrier cycles in one horizontal line. Thus the
phase of the color-subcarrier reference (as embodied, for instance, in
the color burst) is made coherent with horizontal-scan timing.
Specifically, the color phase alternates by $180^\circ$ on successive
scan lines.  This coherent alternation has some desirable
consequences.  First of all, it virtually cancels out on the screen the
intensity ripple due to residual color subcarrier in the luminance
channel.  Moreover, it nulls the chrominance power spectrum at
multiples of $f_h$, whereas the luminance spectrum has a maximum at
those frequencies; the result is an interleaving of the luminance and
chrominance ``combs.''  Neither effect is strictly essential to the
working of the \ntsc\ color mechanism, and in fact the Bt858 chip
allows one to set $n_c$ to values different than $N_c$.

}%end \small


\section{Square pixels and all that}

The \ntsc\ TV image has a nominal aspect ratio of 3:4. Without going
into details, it takes approximately 80 usec to horizontally traverse
on the {\sc crt} screen a distance equal to the spacing between lines,
corresponding to a pixel rate of approximately 12.6 MHz.  A mode of
operation where discrete pixels are produced at such rate is called
{\em square pixel}.

Whether or not one seeks to have square pixels, it is of course
desirable to have the pixel time, $t_p$, be a submultiple (by an
integer $n_p$) of the horizontal period, so as to maintain coherency
betweend pixel rate and color subcarrier frequency on the time-scale of
one scan line. For square pixels,
an appropriate choice for $n_p$ is
 $$
	n_p=n_\#\equiv 780,
 $$
 \noindent which yields
 $$
	t_\#=T_h/n_\#=81.4814\ \mathrm{nsec}
 $$
 \noindent and
 $$
	f_\#=12.272727\ \mathrm{MHz}.
 $$
 \noindent (In other words, the horizontal period $t_h$ will be equal
to $227$ color subcarrier periods {\em and} to 780 pixel periods.)
We shall call this choice of parameters {\em square pixel} \ntsc.
\memo{Revise and update this section; especially the number 227}

\medskip

In square-pixel \ntsc, color and pixel clock rates are
commensurable over a scan line; however, they are essentially incommensurable
in the short term (one has 3.428\,571 pixels per color cycle).  This
may lead to Moir\'e patterns and similar ``beats'' between the two
rates; specifically, with an image consisting of a uniform
pattern of rather fine vertical stripes, one may end up seeing, as an
artifact, some coarser-pitched vertical banding.


\section{The Bt858}

In the Brooktree Bt858 chip, the frequency $f_c$ of the color
subcarrier (``FSK'' in the specs) is derived from the pixel clock
frequency $f_p$ (``FCLK'') by means of a digital rate multiplier. The
actual frequency ratio $f_c/f_p$ is determined by the contents of
three registers, namely, the horizontal pixel count $n_p$ (``HCOUNT''),
a coarse-tuning parameters $p1$ (``P1''), and a fine-tuning parameter
$p2$ (``P2''), as follows
 \begin{align}
\ntsc{}:\quad {f_c\over f_p} &= {1\over2048}(p_1+{1\over4n_p}p2),\\
\pal{}:\hfill\quad {f_c\over f_p} &= {1\over2048}(p_1+{67/625\over4n_p}p2).
 \end{align}

The horizontal frequency, $f_h$, is just the pixel clock frequency divided by
the number of pixel clocks per line, or
 $$
	f_h = {f_p\over n_p}.
 $$

The targets for $f_c$ and $f_h$ are, of course, the nominal \ntsc\ color
carrier frequency and the nominal \ntsc\ horizontal frequency,
that is
 \begin{align}
	\eqlabel{fc-targ}f_c &\approx F_c\equiv 3.579545\ \mathrm{MHz},\\are
	\eqlabel{fh-targ}f_h &\approx F_h\equiv 15.734264\ \mathrm{kHz},
 \end{align}
	with $\approx$ denoting equality to within a few tens or hundreds parts
per million (depending on the desired level of conformance with the standards).

Moreover, it is highly desirable that there be 227.5 (or, at any rate, an
integer-and-a-half number of) color clock periods per line (\cf{horz-freq}).
To maintain this exact gearing ratio, one cannot exactly satisfy both
\eq{fc-targ} and \eq{fc-target}. Moreover, if $f_p$ is given, it needs some
luck to satisfy both of these equations while maintaining the required
gearing ratio.


With the current version of the {\sc cam}-8 controller (the card that sits
on the SBus), the {\sc cam}-8 clock is the same as the SBus clock;
with the current version of the box interface (the card in slot 0),
the pixel clock is 1/2 the {\sc cam}-8 clock. Thus, at present,
 $$
	f_p={1\over2}f_{\rm SBus}.
 $$

\medskip

\memo{to be completed}


\section{Bt478/Bt858 programming}

Programming sequence for the Bt858 for \step\ \ntsc\ output.
The same programming sequence works for the Bt478, which simply ignores
command register data (code 110).

\figonecol[!b]{bt858init}{\ttbox{fig/bt858init.tt}}{Bt858 initialization sequence.}
