VT202/1303 Keyboard Fix Revisited

This is a long technical post. There’s probably only one reason to read it: you have a Lexitron with a broken keyboard. I’m not going to polish it much, but I leave it here just for you!

I spent a lot of time creating a teensy replacement for the microcontroller in the keyboard.  One of the great challenges was to work out the key codes sent from the keyboard to the 8085.  This was very time-consuming and there were some that I never really cracked.

With the arrival of working keyboards, I could just swap out the original for one of the working units. Buuut the teensy solution actually provides a mechanism to move data from a modern PC to the Lexitron and that’s handy.  Also, I guess I’d like to just close the loop!

I can now sniff the communication between the 8085 and the keyboard microcontroller.  Because the keyboard appears to be just another device on the 8085 bus the data is transmitted as a parallel byte.  This would be easy to sniff with a logic analyser, but not so easy with an oscilloscope.  I thought my Analogue Discovery 2 might be sufficient for this task.

Two Different Keyboard Types

One of the VT202 units uses the same Cortron Keyboard as the VT1303.  The other uses a Digitran keyboard which looks quite different but seems to be entirely compatible with the Cortron.  The Digitran sound is not as loud.

Revisit Operation

Keyboard Pinout

PinNameFunction
1+5V 
2+5V 
3GND 
4GND 
5NC 
6GND 
7Strobe_LThis line indicates activity on the keyboard.  It is asserted for 5us when a key is pressed and for 10us when a key is released.   The strobe is not asserted when a front panel switch is changed.  It is not asserted when the shift key is pressed.  It is asserted for spec shift.
8D5 
9D6 
10GND 
11D7 
12D4 
13Kbd_Read_LThis line causes the keyboard to put data on to the 8085 bus.   The read occurs about 100us after the strobe is asserted. A0 is low.  Scan code?   A second read occurs about 8us after the first.  A0 is high. Switch state?   This strobe is asserted a couple of times every 10ms (approx.)  
14Screen OnThis also appears in the status register.
15A0This selects the data that is read by the 8085 – either the keycode or the status of the front panel switches.
16Kbd_Write_LThis strobe is asserted about 5us after Read is asserted in response to the Strobe.   This strobe is asserted every 10ms (approx.)  
17Reset? 
18GND 
19D3 
20D2 
21D1 
22D0 
23-15V 
24-15V 
25+15V 
26+15V 

Character Register

Bits 6:0 = Character number

Bit 7 = Shift

Status Register:

Bits 1:0 = Print Spacing

Bit 2 = Pitch

Bit 3 = Screen Spacing

Bit 4 = Not used (input pulled up)

Bit 5 = Key pressed

Bit 6 = Screen On/Off

Bit 7 = Autorepeat (although it doesn’t seem to be used)

Command Register:

Bit 0 = Key click

Bit 1 = Type Through LED

Bit 2 = Select LED

Bit 3 = Continuous Typing LED

Bit 4 = Write LED state (Bits 1, 2 & 3)

Bit 5 = Acknowledge

Bit 6 = Bell (Not supressed by volume control)? Under CP/M this is sent when Select is pressed.  Select causes an alarm chime (not volume controlled). 

Bit 7 = Unknown

Adjustable volume applies to key strokes.  Alarms have a fixed volume.

Word Processing Program Behaviour

Periodic

Once every 10ms or so the program reads the status register and writes the Command Register. 

Keystroke

When a key is hit the keyboard alerts the uP by asserting Strobe_L for 5us.  The program responds by reading the character, reading the status register, and then writing 32 to the Command Register.  This seems to be an acknowledgement. If there is a LED change or sound then that will be sent a few milliseconds later.

The key release is also acknowledged with a command write which can update the LED state and sound a bell but I think does neither.  

The unit only autorepeats on space, backspace, dash, underline, and full stop.  This auto repeat is convoluted.  It involves resending a specific character after the wait time has elapsed.  This triggers the software to autorepeat.  It looks like the bit 6 of the status word is set at the same time.  This is set by an output from the microcontroller (Pin 29).  Although the original keyboard does this it does no appear necessary.

CharacterOriginal OutputAutorepeat Output
Space80112
Dash103119
Underline231247
Full stop26122
Backspace110126

I can’t see any obvious pattern in these numbers.   They just are.

CP/M Behaviour

Periodic

Once every 10ms or so the program reads the status register. 

Keystroke

When a key is hit the keyboard alerts the uP by asserting Strobe_L for 5us.  The program responds by reading the status register, reading the character, and then writing the Command Register – it can acknowledge, set LEDs, or make a sound.

The key release is also acknowledged but the LED data is not repeated.  There is no periodic write The key release is also acknowledged with a command write which can update the LED state and sound a bell but I think does neither.  

CP/M autorepeats on most keys but not Spec Shift or Sel. It initiates a beep on each auto repeated character.   

CP/M politely ignores the autorepeat shenanigans that the keyboard does for the word processing program.

In CP/M lots of keys are defined as function keys that can be changed using the config program.  The config can also control auto repeat and key click. 

Select is a caps lock key.

My Current Keyboard Code

The current routine that I have for sending a character to the 8085 sets up the character and then takes then asserts the strobe (indirectly) for 1ms.  It then sets up another character (usually zero).

The real thing asserts the strobe for 5 or 10us.  Both the key register and the status register are read within about 100us of the strobe.  The Command Register is then written.  This may be the trigger to clear the key but maybe not.  I previously concluded that the key needed to be nulled but I’m not sure why it does.

My implementation autorepeats on all keys except “mode” keys like Spec Shift and Margin Set.  The actual unit does not autorepeat, although the software does under some circumstances.

I’ve treated Spec Shift and Margin Set as special cases because they are used in combination with other keys.  Certainly, autorepeat doesn’t apply.  CP/M treats Margin Set as a normal function key. 

This means that the effect of these keys is application specific.  Eg in CP/M the Spec Shift key is used to create control keys eg Ctrl-C to do a soft boot.  In the word processing program it has no effect on the letter c.  Spec Shift does not beep.

Shift really is different.  No key code is sent with just the shift key, and the character that is sent is modified if a shift key is pressed.  When shift is pressed the most significant bit is set.  This applies to all keys including Spec Shift and Margin Set.

The various reads and writes change a little with CP/M.  CP/M still reads the front panel switches but I have no idea what it does with the state. Similarly, the LEDs have no apparent function. 

Under CP/M Select behaves like a caps lock.  The shift is done in software.

Observations

Key hit

Close up of subsequent reads and write.

With the autorepeat:

The regular status read (word processor software):

Revised Keyboard Code

The keyboard code has been substantially reworked based on the observations that were possible using the logic analyser function of the Analogue Discovery 2.

  • Autorepeat has been removed except to the extent required by the word processing program.
  • Each key press and release is transferred to the 8085.
  • The timings have been changed to better match the real keyboard.
  • Only one key is checked and processed on each pass of the main loop so that commands are less likely to be missed.
  • All sounds are generated only at the request of the 8085.  There are no automatically generated sounds.
  • An additional signal was discovered that is set when a command is written and is cleared when the command has been read.
  • A few missing key codes were found.

Things like Spec Shift, Set Margin, and Select now work as advertised (as far as I can tell).

The code works on the VT1303 and the VT202.  It works with the word processing programs and with both the VT1303 CP/M and the VT202 CP/M.

Mapping

The transmitted codes can be read straight off the data lines (see waveform pics above).

Circuitry

https://www.pjrc.com/store/teensypp.html

The mapping from the microcontroller to the teensy are shown in this table:

uC Pin NruC Pin NameTeensy Pin NrSignal NameComment
1T0   
2XTAL1   
3XTAL2   
4RESET_L   
5SS   
6INT_LD4uC_New_Command 
7EA   
8RD_L   
9PSEN_L   
10WR_L   
11ALE   
12DB0C0DB0Data bus for the keyboard.
13DB1C1DB1 
14DB2C2DB2 
15DB3C3DB3 
16DB4C4DB4 
17DB5C5DB5 
18DB6C6DB6 
19DB7C7DB7 
20VSSGND  
21P20F6LED_TypeThru 
22P21F5LED_Unused 
23P22F4LED_Select 
24P23   
25PROG   
26VDD   
27P10B0Column0Keyboard Column
28P11B1Column1 
29P12B2Column2Also drives a status register input to indicate that the current key has been pressed.
30P13B3Column3Also indicates when an autorepeat could be started.
31P14B4Row0Keyboard Row
32P15B5Row1 
33P16B6Row2 
34P17B7PulserThis creates an opportunity for a pulse at E7
35P24F3LED_ContType 
36P25D3uC_Rd_LEnables command register so it can be read via Port C.
37P26D2uC_GotOne_Loud_LLoud Beep for Alarms
38P27D1uC_GotOne_Adj_LAdjustable beep for key presses
39T1E7uC_SenseSenses when a key is down
40VCC+5V  

Dick Smith System 80

The System 80 is an attempt, largely successful, to create a machine compatible with the TRS-80 Model I.

Terry Stewart has done a wonderful job of documenting the System 80. Everything that you could ever want to know about it is there. I’ll just focus on my own experience.

I bought this machine from a colleague, Scott, at the Adelaide Retro Computing Group back in 2020. My recollection is that he had collected a number of computers from a seller. This one was outside his interests, so he offered it for sale. I was happy to take it; i never expected to have such an opportunity.

The machine came with an expansion unit and a floppy disk drive. The expansion unit, X4010, has a three slot S-100 backplane. It provides 32k of memory, a disk controller, RS232 port and printer port.

The machine can run any of the myriad of operating systems that were created for the TRS-80 Model 1. Similarly, it can load programs from cassette, just as the TRS-80 Model I can.

This particular machine is an early version with no tape level meter. It has a keyboard modification that replaces one of the shift keys with backspace and tab keys.

It came with a soft plastic dust cover. Instead of protecting the unit, it caused a lot of unsightly “melts” in the plastic. There were also several other issues to work through.

The computer is badged as a “third generation computer” but, as far as i can work out, it would normally be considered a fourth generation computer. Perhaps the usage of the term changed. Or perhaps it is the only example of “underselling” in the computer industry.

System 80 Inspection & Power Up

The system, as it arrived, looked like this:

I set the monitor aside as a separate project. It had very crude and broken mod that held a sheet of coloured perspex over the screen. I will eventually add that back.

The main unit was in good shape. I just reseated the main RAM.

To judge from the date codes, it was made in 1981 when I was still at high school.

This machine uses an old school linear supply. I inspected it and reformed the power supply capacitors by bring up the supply voltage slowly with a variac.

Two new keys where the second shift key was. The sideways A is the tab key.

Switch added at the top of the pic. Shift changed to backspace. Backspace to clear.

With power (and a kludge for the video cable) it came to life.

The plastic had melted against the soft plastic dust cover. It looked pretty awful.

I had to make some compromises. I used a combination of acetone and wet & dry paper to get it back to an acceptable finish. It may be possible to do better.

I crafted, and then glued on, a replacement door latch. It failed, so i had a second go and that is still holding several years later. To be fair, i don’t use the cassette deck very much.

The tape unit itself was gummed up, but after a clean and lube, it seemed like it might work.

System 80 Expansion Unit

There were two different types of expansion units for the System 80. This is the early one with the S-100 bus.

The first card connects to the System 80 via a 50 pin interface. It also provides the floppy, parallel and RS232 ports. I particularly like the termination networks that have been added to several of the ICs.

The second card provides 32k of RAM. There was one faulty RAM chip.

The power supply unit is the same as the computer. I reformed the caps with a variac.

There is one spare slot for an additional card but the case is not great for adding additional I/O and there’s no obvious mechanism for adding more memory beyond the current RAM/ROM.

System 80 Floppy Drive Unit

The system came with a matching Floppy Drive Unit that connects to the expansion unit. It uses an MPI B51 40 track single sided drive.

I gave it the routine clean and lube, but it would not read disks. Drive speed was good.

Configuration was preset:

I located a service manual on the net and that was very helpful for fault-finding.

I convinced myself that the differential amplifier (CA3054) in the read circuit was cactus and replaced it. With this, the system booted. Alas, it wouldn’t format disks.

Breaking out the CRO and checking the signals on the drive interface showed there were no index pulses. In an unexpected twist, it turned out that the disks i was using were not sufficiently opaque. Is that even possible?

It appears so from the traces; the voltage in the top picture never gets high enough to flip the comparator, whereas in the second picture, with a different disk, it does.

I checked over and over. It’s fine with five other brands, so I’ll call it good enough.

It lasted about a week before it stopped reading from disks.  Perhaps it had an intermittent problem and the original differential amp didn’t fix it. 

With the scope, I was able to see differential signals going into the LM311 comparator, but nothing coming out.  I replaced the comparator and i was back in business.

I made up a few disks and had a play!

I also had no trouble setting up a gotek as a drive. I just powered it off the real drive and connected with a custom cable. It has to be set to drive 1.

System 80 Monitor

The System 80 came with a Thorn 7433 black & white TV that was used as a monitor. It had had a couple of homebrew additions.

The first was a composite video input, so modulation/demodulation is redundant.

The second was a green screen, which was appropriately agricultural. The mount has broken and in any case is too rough even for my low standards.

It seems to be working fine.

I have removed the mount, and rubbed back the glued areas. It’s currently awaiting paint and then i’ll attempt to mount some coloured perspex that looks a little more appealing.

Pulsar 7500 Computer

This computer is not what it seems.

Inside the IBM PC style enclosure are 5 little big boards – one of which acts as a master to control drives and printers. The monitor is an IBM terminal, which is much younger than the computer.

The other four little big boards support 4 users via serial terminals. Each of these is connected back to the master via a serial line. These cards all run Turbodos. Each provides 64kB of memory for running CP/M programs.

The master provides access to a floppy disk drive and a SCSI hard disk – emulated with a SCSI2SD.

The construction is a bit rough and ready!

Pulsar 7500 Initial Power Up and Fault Finding

I connected it up to a serial terminal, but I couldn’t get anything out of any external serial port.  The hard disk did not spin, so it may be a lost cause.

I had no boot disks for the floppy disk, although i thought it may be possible to create some from the 8″ disk collection. Many of the disks were related to Pulsar – both CP/M and TurboDOS.

Working in the case was a little cumbersome, so I pulled the system right down to the boards:

It consists of:

  • 1x Master LBB with STD and Floppy Drive Interfaces
  • 4x Slave LBB (with a variety of options which are probably not used)
  • 2x SASI/Dual Serial Boards
  • 1x Mitsubishi M4854-342 High Density Floppy Disk Drive
  • 1x NEC LR 56913Hard disk drive with Adaptec ACB-4000 SASI adapter
  • 1x Sysquest removable disk drive with Adaptec ACB-4000 SCSI adapter (external to computer and mounted on it’s own baseplate)

There is a lot of variation amongst the slaves. Perhaps from card swaps over the years, or perhaps this machine was put together using whatever was in stock. Serial port connectors can be straight or right-angled, a bare header, or a shrouded header, sometimes with release levers.

Each of the slaves is connected via serial to the SASI/Serial cards. The master owns the bus and therefore the SASI/Serial cards. The slaves must not attempt to use the STD bus, so where the interface is loaded it has to be nobbled with track cuts.

There seems to be no reason why the slaves need to be in the unit – they could just as easily be located elsewhere but there is not a lot to be gained as either way a serial connection is required.

The serial ports on the master were used for printers.

I tested each of the boards with an MP7A Monitor ROM in a different chassis.

The master little big board does come up ok, so probably it was silent at switch on because that’s how the boot ROM rolls.

Two of the slaves were ok, but the other two were not working. One had a bad solder joint and the other had lost 12V connectivity because the track is very close to the board edge was severed.  The damage would have occurred when I levered the board out of the backplane (there was no other way).

I could not get the master to boot from the floppy disk, even after adjusting the phase-locked loop as per Pulsar instructions. I parked that board and used a spare, which did boot.

From there the configuration tool was used to setup the slaves.  There are a lot of questions about each slave.  I took the easy options with automatic login of the privileged user.

Pulsar 7500 Floppy Disk Drive

The 7500 system uses a 5.25” drive rather than an 8″. As it turns out, the floppy disk drive in this unit, Mitsubishi 4854-342, is intended as an 8″ replacement – it even claims to be a 77 track drive although i suspect it’s good for 80. 

https://retrocmp.de/fdd/mitsubi/m4854_i.htm

The 50 pin host interface is connected to the 34 pin drive interface via a simple adapter. All up, this means that the 8” images can be written to HD 5.25” disks.

Looking at the simple 50/34 adapter board, I suspect that the drive has a couple of signals that may not be present on a 5.25” interface – Ready and 2Sides. I imagine that 2Sides is always asserted because there is no way for a 5.25″ drive to know if a disk is single sided. 8″ drives can.

The drive was cleaned and lubricated and tested ok with Imagedisk.

8” Pin8” SIgnal5.25” Pin5.25” AdapterComments for Emulation with Gotek
2TG43_LNot used
4
6
8
102SIDES_L2REDWC_LNot driven by controller or gotek.  Pull down
12
14SIDESEL32SIDESEL
16
18HEADLOAD_L4Not Used
20INDEX_L8INDEX_L
22READY_L34DISKCHG_L
24
26DS010DS0
28DS112DS1
30DS214DS2
32DS36DS3
34DIRC_L18DIRC_L
36STEP_L20STEP_L
38WDATA_L22WDATA_L
40WGATE_L24WGATE_L
42TRACK0_L26TRACK0_L
44WRTPRT_L28WRTPRT_L
46RDATA_L30RDATA_L
48
50
16MOTORON

I wrote an HD floppy disk from 8″ disk image 8_257_02 (Pulsar Turbo V1.3 Master Configuration Sys 14 Config V24 Single User) using greaseweazle.

Pulsar 7500 SASI/SCSI

The system has two SASI cards that I thought might accept a SCSI2SD card.

The drive configuration comes up in two places – firstly in configuration of the master or single user system configuration program, and then again when the drive is formatted.

In both cases, the following information is required:

  • SASI card number: 0 worked for one card but I tried multiple numbers with the other card without success
  • Drive Number: It allows 1 or 2.  1 seemed to be SCSI ID 0. 
  • Drive Manufacturer: Somewhat randomly chose Tandon 700
  • Drive Model Number: 31.2MB drive
  • Block size and directory entries: Default

The configuration also deals with partitioning.  The default partition size is 4MB which is the optimal size. With large drives, that’s a bit of a nuisance because you need a lot of partitions.  Having some optimal 4MB partitions and a larger sub-optimal partition seemed like a reasonable compromise.

The drive selection gave some geometry, but the specifics probably don’t matter with a SCSI2SD.  The SCSI2SD was set up with a simple 32MB disk at ID 0 with 512B sectors.  Termination needs to be on.

The process went like this:

  1. Create a fresh single user floppy disk
  2. Run the Configuration program and select modify
  3. Set up the hard disk as above
  4. Format the hard disk using HFORM30 with the same disk parameters

At this point the new drives were available starting at E: but when the directory was listed it appeared the disk was read only and the directory looked corrupted.  It didn’t seem to matter if the format was done first and then the configuration.

The “Creating Boot Tracks” section of the System Initialisation Procedure mentioned a program called ERASEDIR but really just in the context of making faster hashed entries.  Running this program on each of the drives resolved the issue.  It says to run this after BOOTDISC (which writes the boot tracks).

So:

  • Run BOOTDISK and write to E: – only the first partition can be a boot partition.  It can also be written to A:.
  • Run ERASEDIR on each of the new drives from e: to the last one.
  • Copy all the files from the A: to E: using DO DCOPY A: E:

When the system is powered up, it looks for a bootable drive.  If a boot floppy is in A: it will use it; otherwise it will boot using E:.

Programs were then copied on to the solid state disk from a gotek. TurboDOS supports multiple user areas so the these can be used as directories. User 0 files marked a global can be accessed by all users.

All users are assumed to be using Televideo 950 terminals. A lot of the software on the 8″ disks was configured to use this popular terminal.

To copy from 0A to 1H:

Copy a:*.* h: ;D01

The user must be privileged.

DiskE:F:G:H:I:
Capacity4MB4MB4MB4MB16MB
User     
0TurboDOS Files   TurboDOS Files Backup
1Multiplan (118/101)  Multiplan (432/310) 
2   Supercalc (332/248) 
3   Wordstar (214/160) 
4   DBase (238/169) 
5     
6 MBasic Games (066/63)  MBasic & Basic Compiler (240/171)CP/MUG Vol 53 (Adventure & Mbasic Games) (088/77) 
7  JRT Pascal V3.0 (261/189)  
8  Diagnostics II (262/190)  
9  Microsoft Fortran (434/312)Fortran Stuff (434/312) 
10  Cross Assemblers (008/007)  
11Pascal MT/Plus V5.5 & Programs (047/044)Pascal MT/Plus Sources DevelopmentPascal MT/Plus V5.5 Support Files Development  Pascal MT/Plus V5.5 G. Purpose Development   
12  Turbo Pascal (055/052)  
13 Zork (440/318)   
14     
15 Other Games