	    Programmer's Guide to the Kansas City Tracker
            =============================================

		8/27/89 Paul Williamson, KB5MU


For years, only the adventurous and knowledgeable ham could equip his
satellite station to automatically point the antennas at a passing
satellite.  All the equipment and software had to be home-brewed. The
Kansas City Tracker/Tuner has changed all that. The KCT is an
interface card that plugs into an IBM-compatible PC and connects to
the antenna rotator control box.  It also connects to two radios (by
serial computer interface or by up/down step controls) to control
frequency for Doppler compensation.  Now any ham can just plug in the
KCT and connect it to his antennas and radios, and be tracking
satellites (almost) effortlessly.  All the necessary software is
included.

The KCT software interfaces to the KCT hardware by means of a TSR
driver program called DRV.COM.  Higher layers of software
(including the pop-up utility OSC and various orbit calculation
programs such as Quiktrak and InstantTrack) make calls to this
software driver by software interrupts.  The definition of all the
functions supported by the driver are documented in the file
DRVSVC.DOC on the KCT distribution diskette.  All applications are
supposed to use this interface and not communicate directly with the
hardware.

But some hams just can't leave well enough alone.  We want to know
exactly what's happening inside the hardware.  We may even want to
write our own software to control the hardware directly.  I wanted
to, but I was stymied by the lack of any hardware documentation in
the KCT distribution package.  So, I took my trusty continuity
checker in hand and reverse-engineered the KCT board.  I drew a
complete schematic diagram.  This enabled me to understand exactly
how the KCT hardware works.  This document is intended to enable
other programmers to write programs that communicate directly with
the KCT hardware without having to reverse-engineer the board again.

First, a few disclaimers are in order.  The Kansas City Tracker/Tuner
is a good, reasonably-priced product that has made it practical for
many hams to have computer-controlled antenna pointing.  I do not
intend this information to be used to facilitate any attempt to clone
the board or otherwise rip off the manufacturers of the KCT.  It is
for this reason that I am not releasing the schematic diagrams for
general distribution.

I encourage you to think twice before deciding to write software that
communicates directly with the KCT software.  The designer of the KCT
has created a documented interface through the TSR driver.  By using
this interface, you are assured of compatibility, both with other
software and with other versions of the KCT hardware.  Indeed, other
hardware vendors may eventually implement drivers that are compatible
with the KCT interface standard.  Software written to communicate
with the driver will be portable to that new hardware.

Lastly, I suppose I must cover myself by stating that, while I
believe the information in this document to be correct, I cannot
provide any guarantee of its accuracy.  In particular I have no
reason to believe that this document correctly describes every
existing KCT, much less any future KCTs, since I only inspected one. 

The Kansas City Tracker/Tuner was designed by Brooks Van Pelt,
KB2CST.  It is available (quoting from an advertisement now) from
	L. L. Grace Communications Products
	41 Acadia Drive
	Voorhees, NJ  08043
	U. S. A.
L. L. Grace may be reached by telephone at (609)-751-1018 or via
Compu$erve at 72677,1107.

This document was written by Paul Williamson, KB5MU.  I would
appreciate your comments and suggestions.  I can be reached via
any of the following addresses:

	Compu$erve: 	75265,367
	Internet:	pwilliamson@qualcomm.com
                or      kb5mu@amsat.org
	Packet:		KB5MU @ KC6NZN.#SOCA.CA.USA.NA

	Snail Mail:	5331 Channing Street
			San Diego, CA 92117

Thanks go to Mike Brock, WB6HHV, for the loan of his KCT hardware.


KCT HARDWARE OVERVIEW
=====================

This description specifically describes the KCT with the Tuner
option, but without the Rotor Interface Option.  That's the only
type of board I had available for study.  I will try to note what
I presume would be different in another variation of the KCT.

I am not going to describe the physical or electrical details of the
hardware, except as it impacts the programming model.  I presume that
you have the Kansas City Tracker manual available for details of
electrical interfaces.

The KCT provides the following basic resources:

	* four output signals to command the antenna rotators to
	  turn up, down, left, and right.  A fifth signal to control
	  a rotor's brake release is included in the Rotor Interface
	  Option.

	* an analog-to-digital (A/D) converter to sense the voltages
	  returned by the position sense pots in the azimuth and
	  elevation rotors.  The converter has a two-input analog
	  multiplexer to choose between the two voltages.

	* two serial ports, for communication with computer-controllable
	  radios.  These ports are designated A and B.  This feature is
	  part of the Tuner option.

	* four output signals to command the up/down "mic click"
	  signals on radios that do not permit computer control
	  otherwise.  One up/down pair is designated port C, and
	  the other is port D.  This feature is part of the Tuner
	  option.


The KCT occupies four consecutive addresses in the I/O space of the
PC.  The choice of addresses is made by DIP switch as described in
the KCT instructions.  The base address may be set anywhere from
0000h to 03FCh, which is to say anywhere in the PC's decoded I/O
space.  The recommended base address is 03E0h.  I will refer to the
four I/O ports by their offsets from this base address, port 0
through port 3.  Some ports have different functions on read and
write, so I will refer to "write port 0" or "read port 1" when it is
necessary to make a distinction.

The I/O ports are assigned as follows:
			Read or
	Port Offset	Write?	Function
	-----------	---	--------
	     0          R	A/D converter status
	     0		W	A/D converter control & rotor controls
	     1		R	A/D converter data (8 bits)
	     1		W       UART port select & mic-click outputs
	     2		R&W	Port A UART
	     3		R&W	Port B UART


Refer to the following three diagrams for the bit assignments within
the registers.  

The bit assignment for write port 0 is as follows:

	Bit#	7    6    5    4    3    2    1    0 (lsb)

                |    |    |    |    |    |    |    | 
                |    |    |    |    |    |    |    |
   BRAKE REL ---+    |    |    |    |    |    |    +--- UP MOTOR
                     |    |    |    |    |    | 
  A/D SELECT --------+    |    |    |    |    +-------- DOWN MOTOR
                          |    |    |    |
   A/D LATCH -------------+    |    |    +------------- RIGHT MOTOR
                               |    |
   A/D START ------------------+    +------------------ LEFT MOTOR


Write port 1 is part of the Tuner option.  The bit assignment for
write port 1 is as follows:

	Bit#	7    6    5    4    3    2    1    0 (lsb)

                |    |    |    |    |    |    |    | 
                |    |    |    |    |    |    |    |
      UNUSED ---+    |    |    |    |    |    |    +--- UART SELECT 1
                     |    |    |    |    |    | 
      UNUSED --------+    |    |    |    |    +-------- UART SELECT 0
                          |    |    |    |
CLICK UP PORT D ----------+    |    |    +------------- CLICK UP PORT C
                               |    |
CLICK DOWN D ------------------+    +------------------ CLICK DOWN C



The bit assignment for read port 0 is as follows:

	Bit#	7    6    5    4    3    2    1    0 (lsb)

                |    |    |    |    |    |    |    | 
                |    |    |    |    |    |    |    |
      UNUSED ---+    |    |    |    |    |    |    +--- UNUSED
                     |    |    |    |    |    | 
   A/D READY --------+    |    |    |    |    +-------- UNUSED
                          |    |    |    |
  A/D SELECT -------------+    |    |    +------------- UNUSED
                               |    |
    ALWAYS 0 ------------------+    +------------------ ALWAYS 0






Controlling the Rotor Motors
============================
The rotor motors are controlled directly by the four least
significant bits in write port 0 (see diagram above).  A value of 1
turns the corresponding motor ON, and a value of 0 turns the motor
OFF.  The KCT powers up with all motors OFF, and it returns to this
value on a hardware reset.

Note that there is NO interlocking in the KCT hardware itself, so
never turn on UP and DOWN or LEFT and RIGHT at the same time.  (KCT
does suggest that the user implement interlocking in the relay
scheme, and [I think] the Yaesu/Kenpro rotors do so.)

There is also NO timeout or failsafe sequencing in the KCT hardware. 
If the software stops commanding the KCT while a motor is turned on,
that motor will stay turned on until the computer is reset or the
software resumes.

Examples:
To turn the antennas up and to the left, write a value of
xxxx1001 binary , or x6 hex, to port 0.

To stop the antennas from turning, write a value of xxxx0 binary,
or x0 hex, to port 0.

If the hardware has the rotor interface option and the rotor itself
has a brake, the scheme gets a little more complicated.  The rotor
brake is controlled by the most significant bit of write port 0.  A
value of 1 releases the brake [I think] and a value of 0 allows the
brake to turn on [I think].  Delays may be necessary between releasing
the brake and starting the motor, and between stopping the motor and
engaging the brake.

Example:
To turn the antennas up and to the left:
	write a value of 0xxx1111b to port 0 (releasing the brake)
	wait a second (say)
	write a value of 0xxx0110b to port 0 (starting the motor)
	wait until the antennas are pointed correctly
	write a value of 0xxx1111b to port 0 (stopping the motor)
	wait a second (say)
	write a value of 1xxx1111b to port 0 (engaging the brake)

Note that port 0 is shared with A/D converter control bits.


Reading the Antenna Position
============================
The A/D converter is used to read the position of the antennas.  The
A/D converter is an ADC0809.  I recommend that you get a copy of the
manufacturer's data sheet for the ADC0809 to fully understand the
interface.

The ADC0809 includes an 8-input analog multiplexer on its input.  The
KCT hardware only uses two of them.  Input 0 is the vertical sense
voltage, and input 1 is the horizontal sense voltage.  The other six
inputs are grounded.  The conversion is referenced to ground on the
low side and regulated (by a local 7805 three-terminal regulator) +5
volts on the high side.  Thus, the output is a code from 0 to 255,
with 0 representing 0 volts and 255 representing +5 volts.  There is
no facility on board for adjusting this range, so adjustments must be
made at the rotor control box to match this range as closely as
possible.

The program must command the A/D converter to do a conversion, then
wait until the conversion has completed.  It may then (and at any
future time until another conversion is started) read the result
directly from port 1.  The EOC (end of conversion) signal from the
A/D converter may be read at bit 6 of port 0.  EOC goes low (0)
shortly after conversion begins, and goes high (1) again when the
conversion is completed.  The delay will be 64 A/D clock cycles,
measured from the last write of the command sequence.  Since the A/D
is clocked by the PC bus clock divided by 16, this works out to 1024
cycles of the PC bus clock, or about 215 uS on a 4.77MHz PC.

Three signals in write port 0 control the A/D converter:
	A/D SELECT
	A/D LATCH
and	A/D START.

SELECT controls which voltage is converted.  0 selects the vertical
(elevation) sense voltage, and 1 selects the horizontal (azimuth)
sense voltage.  The rising edge of LATCH signals the A/D converter to
latch the SELECT bit.  A positive-going pulse on START commands the
A/D converter to begin its conversion.

To start the conversion, four writes are necessary.  To convert the
vertical voltage:
	write x000xxxx to port 0
	write x010xxxx to port 0
	write x011xxxx to port 0
	write x000xxxx to port 0

To convert the horizontal voltage,
	write x100xxxx to port 0
	write x110xxxx to port 0
	write x111xxxx to port 0
	write x100xxxx to port 0

Note that write port 0 is shared with rotor motor control bits.

Along with EOC, read port 0 contains the last value of the SELECT
bit.  After a conversion has been completed, you can use this bit to
tell which voltage was converted (provided you don't corrupt the bit
when writing to write port 0 for other purposes).  Note that the
four unused bits in read port 0 are not pulled up, so their values
are indeterminate.  The two always-0 bits are just that, but they
might be commandeered for some new feature in a future version of the
KCT.

Controlling the Radios Via Serial Ports
=======================================
The KCT with Tuner option provides two 2651 Programmable
Communications Interface (or UART, for Universal Asynchronous
Receiver/Transmitter) chips.  The Port A chip is addressed at port 2
of the KCT, and the Port B chip is addressed at port 3.  The UART is
clocked with its standard frequency of 5.0688 MHz using a dedicated
crystal oscillator module.  Again, I strongly recommend that you get
a copy of the manufacturer's data sheet for the 2651 to fully
understand the interface.

Only the rx data input and tx data output are connected.  All
handshaking input lines on the UART are grounded, and no handshaking
output lines are connected to anything.

The Tx Ready and Rx Ready signals from both UARTs are connected
together and connected to the PC interrupt line selected by the DIP
switches.  The DIP switches can select any interrupt from 2 to 7.
The default DIP switch setting for KCT software is NO INTERRUPTS SELECTED.
Apparently the KCT software resorts to polling the UARTs to avoid the
compatibility hassles that come with using interrupts.

Each UART contains four read/write registers.  The program must set
the two least significant bits of write port 1 to the desired port
address within the UART before reading or writing the UART.  Note
that the two bits are reversed, so that the port addresses you might
assume from reading just the 2651 documentation are incorrect.
Port assignments, in terms of the value to be written to port 1,
are as follows:

	Port	Read function		Write function
	----	-------------		--------------
	 0	read RX data		write TX data
	 1	read mode registers	write mode registers
	 2	read status register	(not relevant to asynch mode)
	 3	read command register	write command register

The details of these registers and of programming the 2651 PCI are
beyond the scope of this document.  Please obtain a copy of the data
sheet on the 2651 for details.  It is made by Signetics and National.


Controlling the Radios Via Mic Click Interface
==============================================
The mic click (up/down button) interface of the KCT is controlled by
four bits in write port 1.  These four bits are driven through open
collector INVERTERS.  Since I don't know what the polarities and
timing specs are for mic-click interfaces of various radios, I can't
give you any more specific information on how to command radios this
way.  I suggest you measure what the KCT software does, and do that. 
Unless, of course, you can find a specification for what your radio
wants on the mic-click signals.
