Z80 Single Board Computer Project

Z80 Space-Time Productions Single Board Computer

p8279 Programmable Keyboard / Display Interface

The p8279 is a really versatile chip that combines a matrix keyboard or sensor input port and buffer with a 16 character display driver. From the arrangement of this chip, I believe it was designed to help the 8080 CPU to take on the world of Point-Of-Sale giving an easy connection between a keypad for input and a way to display numbers out to the world without the overhead of driving a video interface.

There are essentially two halves of the p8279. The first half is the keyboard input portion. The second half is the display output portion. Both portions share the Scan Lines, which can create configuration impacts. The Scan Lines can be set as "Encoded", where they produce a 4-bit up count, or as "Decoded" where one of the 4 lines goes low to create the row select. This mode hampers the display capacity of the chip.

Keyboard Input
The keyboard can be configured as a matrix of 4 x 8 key contacts ("Decoded"), where as afore mentioned, the Scan Lines SL0, SL1, SL2 and SL3 are pulled low one at a time. Each Scan Line selects a row and the intersecting column of keys is then read into the RL0 - RL7 inputs, called Return Lines.

For many industrial control situations or for small computer interfaces, a 4 x 8 matrix is often adequate and you may use any number of keys from 1 to 48. To branch this out to a fuller keyboard, the p8279 must be put in an "encoded" keyboard mode and a 3-to-8 decoder IC will be needed. The natural selection for this job is the 74LS138. The active high enable at G1 will need to be pulled up using a resistor to 5 volts, and the \G2A and \G2B inputs will need to be pulled low to ground.

[An additional option is to tie one of the 74LS138 enable inputs so that it is either enabled off an I/O port, or by a locking key switch on a console if a lockout function is needed.]

Although there are some other creative options for interfacing keyboards, switches, keypads and other sensors to this chip, these are probaby the more common modes.


Display Options

The display of the p8279 can be set to 4, 8 or 16 characters. It can also be split into upper and lower nybbles so that 4-bit to 7-segment decoders can be used and each character thus enabled to drive 2 digits. These digits can be driven so they are hexadecimal [00 thru $FF] or BCD [00-99] per each character byte in the display buffer.

When the p8279 is set to a Decoded 1-of-4 keyboard method, your display is also limited to 4 columns. This can be ideal if you are lighting up the switch just depressed, however if you are needing a larger display, you may have to opt for encoded output for the SL lines, and use decoders to pick off both the keyboard columns as well as the character displays. This wastes lines of keyboard input, but allows you to use small matrix keypad with the larger number of characters for the display.

Here's an example of a simple 4 x 8 display. Note there is no decoding, however the p8279 doesn't source or sink enough current to directly drive displays, so transistors are used to source current to the LED's or lamps, and the heroic ULN2803 hi-current inverter is used to invert the "1" outputs of the p8279 so that a "1" causes that particular LED or lamp to come on.

Using the afore mentioned 74LS138 to provide a 1-of-8 active LOW output, the display can be brought out to 8 columns, giving 64 possible led's, lamps, or segments that can be driven.


The Original Space-Time Productions Keypad and Display

Here is the original "Master Micro Terminal" which was created for the MCB. It interfaced a membrane type keypad which contained all the monitor functions and was overlayed by the hex values 0 thru F. The display provided an 8-character output using 7-segment displays. Because the individual segments was driven by the A-OUT0-3 and B-OUT0-3 outputs of the p8279, some alphabetic characters could be displayed. So a prompt like "PC= _ _ _ _" could be accomplished. From looking at the power connector, it appears it might possibly have been placed over the top of the MCB power connection and stacked there, with the 26-pin ribbon connector tying the display into the J connector for the p8279 on board the MCB.


The original Space-Time Productions keypad / display.
Click on image for larger.


Layout for the Master Micro Terminal.
Click on image for larger.

The MCB used a specific monitor rom placed in IC-21 to drive this display. Here is a disassembly of that monitor:
8279 Monitor Program.
This file appears in the Download section as well.


My Z80 Computer Control Panel Using p8279

This portion of the project was to replace the very sad looking original panel, with its hand-sawed hole for the LCD display. It also had a hole in the front for the original 3-1/2" diskette drive (mounted vertically...), which I had covered with translucent tape. This poor thing did its job for several years now, but it's high time for retirement.
The old panel...
The original panel.

I have seen (and you have, too) a number of Z-80 Single Board Computers that are cheesy and have very abbreviated "monitor" functions only with a hexadecimal keyboard on them. While these may be able to do some interesting jobs and teach basics of microprocessors, they are weak applications which strangle a rather powerful microprocessor. The displays on these machines are usually little more than 7-segment memory-location/contents displays that allow the user to hand-enter programs byte-at-a-time, have a small keypad that must be scanned by the microprocessor code, taking up valuable time. They have little I/O capabilities and even smaller areas for program memory. These computers put extreme limits on what can eventually be done with them.

You have to remember that the Z-80 was the chip that pioneered CP/M and brought some of the first real applications such as word processing, spreadsheets, and database programs to life in computer systems. The book for the movie 2010: Odyssey Two was written by Arthur C. Clarke on a Kaypro, a full-up professional computer system whose heart was a Z-80 microprocessor. These applications made full usage of the Z-80 and there have been many carry-overs from this operating system that became the basis for DOS, and a full suite of applications. This was the not-so-feeble beginnings of what would become today's computing systems.

I determined that after all the time and research I had put in, that my Space-Time Productions Z-80 wasn't going to end up as one of those rudimentary computers. While I'm not ready to turn this into another CP/M system, there was a compromise to be struck between an elementary monitor program and a full operating system.

Because many of my applications for this computer are I/O driven, I wanted some type of user interface so that I could perform some of the basic functions needed, but wanted to incorporate the more elaborate LCD display and keypad.

The purpose of this was two-fold:

  • To put the focus of the computer's control at its own front panel.
  • To reduce and eventually remove the Z-80's dependency on an attached TTY terminal or PC "Hyperterminal" hookup.

The first step of this is to take all the monitor functions to the front panel. This will leave the Serial Port A only as a Load/Save resource. I intend to, at some point, to either create some sort of storage format that will use RS-232 serial data. Motorola has a similar device for their PageBridge paging base station, but stores to 3.5" diskettes from serial data.

While this seems like a practical plan, I think at some point I will have figured out how to incorporate an IDE hard drive to the system by then. Another project for much farther down the road.

In the meantime, using the non-volatile ram, it will be practical to "Pre-Load" all the needed programs and just run them from the front panel as required. Since there is no need for data recording and storage of this type, the current condition of the computer should be usable for some time to come.


Design begins

I started fresh with a blank 3U standard rack-mount panel (again, salvage r us). It is 1/8" thick aluminum, and already had the holes for rack-mounting. I love this fact, but hopefully I won't ever be forced to rack mount it - I'm hoping it will be my desktop companion forever. By the way, the cabinet has rubber feet on the bottom.

Among my many blessings - a huge salvage operation (translated "Dumpster Dive") resulted in a wonderful gathering of LED-lit push-button switches. These have internal flat LED's with surface-mount resistors. You can apply +5 Volts directly to the contacts - they glow brightly, but pull an average 115mA each indicator. There are:

  • 36 Orange push-button/indicators
  • 9 Green indicators
  • 9 Red indicators


I also have a big rocker switch that came in a box of parts I got as a parting gift for my 18 years of work in the Biomedical field, which was a spare part for an Amsco Instrument Sterilizer. It's a beauty. The original power switch has always been on the back of the cabinet, and it's a pain to reach back there to turn it on and off. So my new design brings the power forward to the front of the machine where it belongs.

So I sat down to CAD and drew up the design I wanted for my new panel, using these switch dimensions. I printed it out full-size, with dimension marks, etc.
Click HERE to see the CAD graphic.

I gave the blank panel and the drawing to a friend of mine at work during the Spring of 2005. He said it would take about 2 hours to machine all the holes for the switches. I expected it the following Monday.

Six Months Later
After all hope has been lost, and I have spent weeks pining for my poor lost aluminum panel. One morning late October I come in to find the blank panel lying in my chair at work. It is a thing of great beauty to me, has metal burrs hanging off of many switch holes. He tells me that I'm going to have to hand-file each hole, since the corners are rounded by the cutting process, my switches are perfectly square. Over the course of several evenings after the kids went to bed, I filed them out, one by one, and sure enough the switches pop in smooth as silk.

Well, after buying Equipment Gray primer and Krylon Flat Black, I decided the best way to do this is to go ahead and sand this booger all the way down to the metal. I didn't take very long, and I was glad to have my filter mask hanging around - that paint dust gets everywhere. So I sanded the textured paint off and got it down to a bare metal.

Now, I have to be totally honest and up-front - it was a huge temptation to just leave the shiny aluminum as the finish. I mean, it looked incredible and the gray switches looked good against it. I was trying to think of something to coat in with to preserve that shine. And then I remembered that I had sent my dear sweet Teresa to Walmart 15 miles away in Abilene to grab the primer and flat black paint for me. So, I used my best judgement - and started priming the surface gray.

It took all weekend to paint this thing; All Saturday to spray 3 light coats of primer, giving it several hours in between coats [I found out this is VERY important for adhering to the aluminum surface]. I was blessed to have plenty of sunshine and little wind so I could let it dry on the back patio on this Fall day.

Next, the flat black Krylon is sprayed on in 4 very light coats, giving it several hours between coats to thoroughly dry. The result it incredible, sorry the picture hardly does it justice. It is a very smooth and clean spray without glitches.

One thing I can tell you from past experience - this process looks wonderful, but as I demonstrated on the backside just for grins - a screwdriver or any tool can put a very visible scratch on the surface. And you won't be able to paint back over it, either - the gouge into the primer will be visible even when re-sprayed. Best to sand lightly with a fine grade of sandpaper, and start the final coats again.

Monday morning, I snapped the switches all in. It looks amazing. Then I sat it on some discarded bubble-wrap to keep the paint from getting chipped while I solder the switches up.

Click for larger

Click for larger

This is the keyboard inserts transparency.

In addition to the 32 keys + shift and control, I also have 8 indicator lamps tied to I/O port $68 of the 8255. This is actually a left-over from the first panel which had 8 small green LED's tied to this port that I could used to rotate bits back and forth and other such nonsense. I decided since I had the indicators it would be useful in diagnosing things (e.g. echo the status of an input port over to $68 to see when a bit, switch, or status bit makes a transition). Since I didn't want green indicators with just "7" and "0" on them, I decided that during normal monitor functions, they could be used to show what command is in progress. This makes sense, and provides a little eye-candy for the user while also giving the D7 thru D0 bit numbers for quick conversion to hex, octal, etc.

[PS - I found a Windows font that looks very similar to the pixelation font on the HD44780 LCD display, so I used it to create the large numbers on the green indicators so it wouldn't look cheesy.]

As of December 23, 2005 I have accomplished:

  • Installed all the hardware and interface.
  • Created Monitor with RST's including the 8279.
  • Started coding the new Monitor using 8279 and LCD, move Stack and params up to $4010-$42FF.

Still left to do:

  • Complete and test the new Monitor Rom.
  • Order in a new ULN2803 8 output driver for TTL (I accidentally got a ULN2804 for CMOS...)
  • Modify BASIC so that it can print to both Hyperterminal and the LCD by setting bits in the IOFLAG byte.
  • Replace the static ram at $3000-$3FFF with a 2732 Eprom.

My application, I chose to run the SLn lines thru a ULN2003 Inverter/Driver. The outputs of this I pulled high with a 1K resistor, and this fed the base of a TIP121 transistor. This transistor acts as the floodgate for +5V to be switched onto the row of the switches/indicators. In the normal state, the "high" from the 8279 unselected row is inverted. That low from the ULN2003 keeps the base of the TIP121 transistor from switching on and delivering current to drive that row. When the row is selected, the low is inverted, the ULN2003 goes into "open collector" mode, the 1K pulls the base high, and the TIP121 passes the 5Volts onto that particular row. I determined if all 8 output bits were set, the entire row would pull 8 x 115mA - nearly 1 full Amp, so I needed a transistor to cooly switch that amount of current without sweating. So there are 4 of these circuits, one for each SL pin of the 8279. Again, see the schematics page for this circuit.

That pretty well wraps up the hardware. See the schematics on the Hardware menu, sheet 7.


Software

The next challenge is to handle this fine array of keys. Until this point in time, all the user inputs to the Space-Time Productions Z-80 computer have been by way of Hyperterminal on my PC talking to the Serial A port of the Z-80. Only a few switches on the avionics panels have been used for much other than to test-drive the avionics panel itself. I have disassembled and heavily commented the 8279.BIN file that Ron Weiss sent me for use with the 8279 version of the computer. So, I'm not in unfamiliar territory at all (yet - ha).

8279 Operating System Rom
Once again, here is the original 8279 software Monitor for this board, if you are interested in reading all my hash marks.

The main part of the keypad is set up as a 4x8 array. The 8279 outputs row strobes (active low) on pins SL0, SL1, SL2, and SL3. This "low" provides the ground needed to detect a key-contact closure on the column inputs to the 8279 (R0 thru R7), which are pulled "high" by internal resistors. So my keys are in an 8X by 4Y cartesian grid. As you can calc, this gives a total of 32 keys. Not very many functions. But the 8279 has that taken care of. There are additional inputs for SHIFT and CONTROL keys. This allows for several layers of functions for each key:

  • The key by itself
  • Shift + the key
  • Control + the key
  • Shift + Control + the key

This gives a total of 4 x 32 possible switch combinations = 128 possible codes. This code is read back in the data word where:

  • D7 - Control key - "1" when pin is open, switch must close to GND
  • D6 - Shift key - "1" when pin is open, switch must close to GND
  • D5, D4, D3 - is the SL # [000,001,010,011]
  • D2, D1, D0 - is the three-bit representation of the column of the key 0-7

In my application (4x8 matrix), D6 bit will always be "0", so I wanted to rotate that bit out of the value. Also, in order to create a table that command vectors can be loaded from I did this:

;------------------------------------------------------------------------------
; RST 30H Service routine: Wait on 8279 for Keyboard character
; - The rotates chase the S2 (D5, always $00) line out of the byte,
; - leaving it rotated one position to the left, doubling the key value.
; - This can be added directly to HL pointing to the command table
; - to get the key vector.
;------------------------------------------------------------------------------
RX8279   CALL   CK8279     ; Get 8279 status, Z if queue empty
         JR     Z,RX8279   ; Loop until key is down
         IN     A,($78)    ; Get the key value
         OR     A          ; CY = 00
                           ; CY D7 D6 D5 D4 D3 D2 D1 D0
                           ; ---------------------------
         RLA               ; CT SH 00 S1 S0 R2 R1 R0 CY
         RLA               ; SH 00 S1 S0 R2 R1 R0 CY CT
         RLA               ; 00 S1 S0 R2 R1 R0 CY CT SH
         RRCA              ; SH SH S1 S0 R2 R1 R0 CY CT
         RRCA              ; CT CT SH S1 S0 R2 R1 R0 CY
         RET               ; And return
;------------------------------------------------------------------------------

With this code in place, the keys give results from $00 to $FE, skipping the value in between (because D0 always equals "0" after the code runs). This way I can use A to offset the value of the start of the vector table. Add the key value directly into HL using some command like:
LD     HL,KEYTABLE  ; Start of key process vectors
LD     D,$00
LD     E,A  ; Add the value to DE.
ADD    HL,DE  Create the index pointer
PUSH   HL  ; And save it on the Stack
RET        ; RET pops HL into the Program Counter and jumps to the key processing routine.

; NORMAL KEYS
; 0E 0C 0A 08 06 04 02 00
; 1E 1C 1A 18 16 14 12 10
; 2E 2C 2A 28 26 24 22 20
; 3E 3C 3A 38 36 34 32 30
;-------------------------
; SHIFT + KEY
; 4E 4C 4A 48 46 44 42 40
; 5E 5C 5A 58 56 54 52 50
; 6E 6C 6A 68 66 64 62 60
; 7E 7C 7A 78 76 74 72 70
;-------------------------
; CONTROL + KEY
; 8E 8C 8A 88 86 84 82 80
; 9E 9C 9A 98 96 94 92 90
; AE AC AA A8 A6 A4 A2 A0
; BE BC BA B8 B6 B4 B2 B0
;--------------------------
; CONTROL + SHIFT + KEY
; CE CC CA C8 C6 C4 C2 C0
; DE DC DA D8 D6 D4 D2 D0
; EE EC EA E8 E6 E4 E2 E0
; FE FC FA F8 F6 F4 F2 F0
;--------------------------

I am currently using a version of monitor that I configured specifically for the 8279 being used in conjunction with the 2x40 character LCD display.
It's available HERE. It is very hardware specific for my machine.