The HP9800 keyboards are controlled by circuitry on the {\bf Keyboard 
Encoder} PCB mounted on the underside of the keyboard itself. The HP9810 
and HP9820 keyboards do not use conventional mechanical keyswitches; they 
use a rather unusual device based on PCB tracks forming a pair of pulse 
transformers, which will be described shortly. This device was not really 
suitable for machines where 2 keys may be pressed together so the HP930, 
which has a shift key, uses normal keyswitches.

Since all 3 keyboards are different, I shall cover them in separate 
sections, but first\ldots

\section{HP9810/HP9820 `keyswitch'}
Under each key of the HP9810 or HP9820 keyboard is a pulse transformer 
formed from spiral copper tracks on the PCB. The transformer has 2 
windings, each consisting of a pair of spirals, one on each side of the 
PCB, connected by vias. When a current pulse is sent through one winding 
(the primary), a voltage is induced in the other winding (the secondary).

On the bottom of the plastic key plunger there is a metal disk. When the 
key is pressed, this disk is brought close to the transformer windings on 
the PCB. It absorbs energy from the primary winding and therefore 
reduces the induced voltage in the secondary windings.

The transformers are connected in pairs by the PCB tracks. The primary -
windings of each pair are connected in series, as are the secondaries, 
but in one pair, one of the windings is reversed. Therefore, when a 
current pulse is sent through the primary pair, the induced voltages in 
the secondary pair oppose each other and the resultant voltage is close 
to zero. When one of the keys is pressed, the transformer under that key 
produces almost no output, so the resulting voltage from the pair consists 
of that produced by the other key's transformer. The polarity of the 
output voltage pulse depends on which key of the pair is pressed. Of 
course if both keys in the pair are pressed simultaneously, there is, 
again no output voltage, but as I mentioned above, this design of 
keyboard is not suitable for applications which require several keys to 
be pressed at the same time.

The primary pairs are arranged in an electrical matrix with a diode in 
series with each pair to prevent sneak paths. All the secondary winding 
pairs are connected in series to form the 'Sense Loop'. The {\bf Keyboard 
Encoder} PCB mounted under the keyboard itself scans the matrix by 
sending a current pulse through each pair of primary windings in turn, 
and looks for an induced voltage in the sense loop. Which key is pressed 
is determined by which matrix location causes a voltage to be induced, 
and the polarity of this voltage.

\section{HP9810 keyboard}
The keyboard is scanned by circuitry on the {\bf Keyboard Encoder} PCB. A 
master clock signal is provided by the free-running oscillator U6a and 
U6f. When no key is pressed, {\bf KeyIn/} is high, so U4c is enabled and 
the clock is fed to the scan counter. This is a 7 bit ripple counter made 
from the D-type flip-flops in U10, U11, U13 and U14a. 

The master clock signal is looped through 2 pins on the cable edge
connector and applied (as {\bf ClkIn}) to the monostable U8a. The output of
this turns on the transistor Q5, providing a current pulse to drive the
matrix of transformers. This current is fed through a loop of wire so that
it can be monitored by a clip-on current probe -- but since I do not own
such an instrument, I can't say what the pulse should look like. 

Bits 1 ad 2 of the counter are decoded by the NAND gates in U1. Each gate
has an associated PNP row driver transistor Q1\ldots Q4, which feeds the
current pulse from Q5 into one of the matrix rows. The keyboard column 
lines are connected to the decoder U9, which grounds one of them based on 
the top 4 bits of the scan counter. Thus the keyboard matrix locations 
are selected in turn, and 2 current pulses sent through each pair of 
transformer primaries.

The sense loop is transformer-coupled to the the comparator device U12. 
Due to the fact that the ends of the secondary winding of the coupling 
transformer are in antiphase, the 2 sections of U12 respond to 
opposite-polarity pulses in the sense loop. These sections are enabled by 
the LSB of the scan counter and its inverse. When the output of U12 
goes high, the scan counter contents identifies the key uniquely, the 
LSB distinguishing between the 2 keys at the same matrix location.

The output of U12 triggers the monostable U8b (enabled by {\bf RowDrv/}) 
causing {\bf Key} to go high and {\bf Key/} to go low. 
The latter reduces the threshold on the comparator U12, providing 
hysteresis. {\bf Key/} is looped to {\bf KeyIn} on the cable connector so 
that when a key is pressed, U4c is inhibited, halting the scan counter 
at that key's location. Thus the monostable U8b is continually 
retriggered, since the pressed key location is fed with 
current pulses on each keyboard master clock cycle.

{\bf KeyIn}, which is simply the {\bf Key} output from U8b after being
looped through the cable connector asserts the {\bf KeyDn/} interrupt line
via U16a. It also enables the output gates (e.g. U7a) so the scan counter
contents can be read into the processor I/O register. When the key is
released, U8b times out, removing the interrupt signal and allowing the
keyboard scan to resume. NAND gate U15 detects when the `Stop' key is
pressed and provides a reset signal to peripheral devices. 

The output of the HP9810 keyboard is, of course, the 7 bit contents of 
the scan counter. The keyboard matrix is wired so that all the 
`programmable' functions produce keycodes with the MSB clear, whereas 
keycodes with the MSB set correspond to system control keys that cannot 
be stored in a user program. Thus 6-bit wide RAM is sufficient for 
storing user programs.

The LEDs on the HP9810 keyboard are very simple. The top 8 bits of the 
processor I/O register are latched in U2 and U3 by {\bf LEDStb} from the 
{\bf I/O Interface} PCB. The LEDs are connected (with suitable series 
resistors) between the outputs of these latches and the +5V rail. Six of 
the 10 LEDs are independently controlled, the remaing 4 form 2 pairs (Run 
and Program; Float and Fix), each controlled by 1 bit of the latch. In 
either such pair one or other of the LEDs is always on. 

\section{HP9820 keyboard}
The HP9820 {\bf Keyboard Encoder} PCB is similar to that in the HP9810 
machine. A master clock is formed by U8a and U8f. The output of this, 
{\bf ClkOut} is looped through the cable connector whereupon it becomes 
{\bf ClkIn}, and when no key is pressed, it clocks the 7 bit scan 
counter via U5c. The scan counter is, as before, a ripple counter made 
from the 7 D-type flip-flops in U11, U12, U7 and U15a.

{\bf ClkIn} also triggers the monostable U10a, providing {\bf RowDrv} to 
a PNP transistor. As in the HP9810, bits 1 nd 2 of the scan counter are 
decoded by the 4 NAND gates in U4, each of which drives one of the 
keyboard row driver transistors, feeding the current pulse onto a 
keyboard row line. Since the HP9820 keyboard has more column lines than 
that of the HP9810, the column selection decoder requires 2 devices, U2 
and U3.

The sense comparator circuitry based round U14 again follows the same 
pattern as that in the HP9810. When the pressed key is detected, the 
output of U14 triggers the monostable U10b, which as before reduces the 
threshold on U14. The outputs of U10b are looped through the cable 
connector to become {\bf KeyIn} and {\bf KeyIn/}. The latter halts the 
scan counter by inhibiting U5c. {\bf KeyIn} asserts the {\bf KeyDn} 
interrupt via U13d. The processor can set U15b using {\bf LEDStb} to 
remove this interrupt signal and allow other interrupt to be detected, 
U15 is automatically cleared again when the key is released, ready for 
the next keypress.

U5b enables the data output buffers when a key is pressed and when the 
{\bf CO} peripheral address outputs from the I/O register contain 
$1100_2$. The outputs buffers, such as U9a, feed the scan counter contents 
to the I/O register data inputs. As in th case of the HP9180, the NAND 
gate U16 detects the `Stop' key being pressed and asserts the peripheral 
reset signal.

\section{HP9830 keyboard}
The HP9830 uses a conventional matrix of mechanical keyswitches, so the 
{\bf Keyboard Encoder} PCB is somewhat different to those in the other 
machines.

A free-running master clock is formed by U5f and U5a and buffered by U5c. 
The clock is divided by 2 by the first section of counter U2, and thus 
the outputs of U6c and U6d form a non-overlapping 2-phase clock. When no 
key is pressed, U10a is clear, so the clock at the output of U6d is gated 
to the 7-bit scan counter formed from U1 and the rest of U2..

The lower 4 bits of this counter are decoded by U4 and U17, which
therefore ground each of the {\bf KC} keyboard column lines in turn. The
higher 3 bits of the scan counter select one of the {\bf KR} row lines
using multiplexer U3. Pressing a key connects a row line to a column line;
when the location of the pressed key is addressed by the scan counter,
the selected output of the column decoder grounds the active input of U3
through the closed keyswitch, and so the {\bf Key} signal goes high and
{\bf Key/} goes low. {\bf Key/} triggers monostable U10a, enabled by the
clock at the output of U6c, stopping the scan counter. {\bf Key} triggers
the debouncing monostable network U10b and U11 and the output of U13c
goes high. 

This asserts the {\bf KeyDn} interrupt signal via U9c. U14b can be set by 
the processor using {\bf LEDStb} to disable the U9c and allow other 
interrupts to be checked for, in the same was as in the HP9820. 

To read the keycode, the {\bf CO} peripheral select outputs of the I/O 
register are set to $1100_2$. This causes the output of U15a to go high. 
Thus (since the output of U13c is high), the output buffers such as U8b 
are enabled by U15b, feeding the scan counter to the inputs of the I/O 
register. The shift key grounds the input of U16f, thus causing its output 
to go high, and this is transfered to bit 7 of the I/O register via U7a.

The {\bf STP} peripheral reset signal is asserted by U9d when the key is 
pressed in row 7 (U12b output is high) and row 1 (U16e output is high). 
This is, of course. the `Stop' key.

The 'Rewind' key is directly connected to the rewind flip-flop on the {\bf 
Tape Controller} PCB, it is not processed by the {\bf Keyboard Encoder}.

The power-on indicator on the front of the HP9830 is simply a filament 
lamp powered from the 5V rail with a 22$\Omega$ series resistor. Anybody 
who understands the rest of the machine will have no problems with this.
