Showing posts with label Terminals. Show all posts
Showing posts with label Terminals. Show all posts

Wednesday, January 23, 2019

TeleVideo Systems Part II - Keyboards

TeleVideo 965 Keyboard Emulation

The Terminal

I purchased a set of TeleVideo 965 terminals for a relatively good deal on eBay, hoping that I could make them work with existing TeleVideo keyboards I have.  I had some reason to suspect this - older terminals both used a 12V power supply to the keyboard and a TTL-level RS-232 connection between the keyboard and terminal logic.

Unfortunately, they weren't quite compatible, as I noticed the 965 has a 4-pin (handset-style) modular jack, and the slightly earlier 970 terminal I have has a 6-pin (RJ14 type) modular cable.

Older Terminal keyboards

TeleVideo 970 keyboard, missing F1 and CHAR INSERT

TeleVideo's original detached-keyboard terminals, the 925 and 950, both use a 4-pin modular jack. Going through the 925 schematics available on Bitsavers, it's apparent what the pinout is, and the supply voltage. The maintenance manual also lists the baud rate of 1200 baud for this keyboard.

The later model 970 keyboard added pins for a shield (likely to appease the FCC) and -RESET line to the terminal (the same keyboard was used on the TS-803 computer, and possibly others). Looking through the 970 technical manual on Bitsavers, you can see that the supply is 12V, like the earlier keyboard.  However, the baud rate is increased to 9600 baud, as I was able to verify with an oscilloscope.

Keyboard protocol analysis

I figured the best place to start was to decode what data the 970 keyboard was sending to the terminal.


TeleVideo 970 keyboard data capture on a 'scope

Hooking an oscilloscope to the keyboard pins, using a couple of spare modular jacks to connect pins through, I was able to verify the voltage of the connection, and the data coming out of the keyboard was 2 bytes of TTL level serial, at 9600 baud, 8/N/1.  I then connected the output of the keyboard up to a Linux PC using a generic TTL serial adapter.  From there, I was able to write a small program to log key presses and let me input what I was pressing, and dump the output into a CSV file for filtering through.



Keyboard decoding hardware setup

I discovered that the basic protocol is a byte to indicate the status of shift/modifier keys, such as shift, caps lock ("alpha lock"), control, and function, along with a second byte to indicate the key pressed, which was mostly the ASCII version of the key pressed.  This made the keyboard fairly simple to understand.  All I had to do is see how the modifier keys modified this second byte, and what all of the special function keys on the keyboard did.

At this point, I hoped that the terminal didn't have to send any data to the keyboard to initialize it.

Keyboard interface analysis


I assumed that the 965 keyboard interface would be similar to the older 970 interface, and used a multimeter to test the pins coming out of the terminal.  I quickly discovered that the terminal ran off of 5V instead of 12V, and was hoping that the baud rate was still 9600 baud.   


Keyboard simulator using "echo"

My first test was to use my Linux box to simulate a keyboard and send two-byte sequences to the terminal.  This worked perfectly, and I was able to get things I typed to show up on the terminal screen after looping back the primary serial port Tx/Rx pins.

Testing with an adapter

Keyboard with modular jack adapter

I grabbed a couple of surplus modular jacks I had laying around, connected wires between them, and attempted to run this, with just by-passing the 7805 voltage regulator on the keyboard.  This didn't quite work, as the voltage regular drew too much power, so I instead found a spare 12V DC wall-wart power supply to connect to my modular jack setup to power the keyboard.

To my surprise, this worked pretty much perfectly! So my earlier effort reverse-engineering the 970 keyboard protocol gave me exactly what I needed to replace the 965 keyboards.  I used the TTL serial adapter to record the commands that the terminal sent to the keyboard, and slowly figured out what some of them were -- reset, set/disable key repeat, etc.

Arduino PS2Keyboard library

My first thought at an adapter was to finally one of the Arduino boards that I had picked up at a Pi-day sale at Sparkfun.  With minimal searching, I found the PS2Keyboard library that was available for Arduino and worked on getting it to work with a PS/2 keyboard (I was using an IBM Model M since I had several of them laying around). After some work, I was able to get the example code to work.

My initial tests didn't work out, because I had messed up the pin-out on the PS/2 jack, and swapped +5V and the clock signal around, which gave strange results from the keyboard and attached oscilloscope confirmed there was a problem.  Fortunately, PS/2 interfaces are pretty hardy, and I didn't manage to break things.  If I had reversed data pins and the 12V power line to the TeleVideo keyboard, I'm sure it wouldn't have worked out well.

Re-writing PS2Keyboard

After digging into what the library would do by itself, I quickly discovered what its limitations were.  There were a few things that I wanted to do with my adapter, such as support the non-alphanumeric keys on the keyboard and modifier keys, which were not really supported with the Arduino library.  So, I decided to scrap most of what the library included, and just focus on reusing the library parts that directly interacted with receiving data from the keyboard and turning the bit stream into PS2 scan codes.  From there, I could use some translation tables to convert that data into the TeleVideo keyboard protocol modifier bytes.

In researching this, I spent lots of time reading every reference I could find on the PS/2 keyboard protocol. The MCS electronics app note on interfacing to an AT keyboard was useful, along with this article on the PS/2 keyboard protocol, along with another article from the same author. I used a few different references on keyboard scan codes including this osdev wiki page and this other list. And a few more general references, including the IBM PS/2 Hardware Interface Technical Reference manual.

I decided on some translations to do for keys that differed between the two.  PS/2 keyboards don't have a "SET-UP" or "SEND" key, but both of those are important keys to support on the TeleVideo terminal. I was able to get this mostly working, which was fairly easy to debug by moving the RS-232 output on the Arduino between my Linux box and a terminal.

After getting this all mostly working, I was able to add in support to send commands back to the keyboard, mostly so that I could control the LED keyboard lights and make the interface a bit more user-friendly.


Schematics and Code


The connections to the Arduino were fairly simple, just wiring up to RS-232 from the terminal, and connecting power, ground, clock and data to the PS/2 connector.

Schematic of keyboard converter 

I have uploaded the code to Github here.

The future!

I have re-created the device using an Arduino Pro Mini, so that it can fit into a small enclosure and be a small adapter. I'd like to extend it to support other keyboard interfaces which are RS-232 compatible, like the earlier TeleVideo terminals, and DEC LK-201/401 keyboards.

TeleVideo Systems Part I

TeleVideo Systems, Inc.


Who was TeleVideo?


Televideo Systems, Inc, was a bay area company that started in the 1970s by producing CRTs and monitors.  Using this experience, they then produced dumb terminals, including terminals emulating the popular Lear Siegler line of ADM terminals, Digital VT-52 and VT-100, and many others.  They then produced single-user and then multi-user Z-80 and CP/M based systems in the early 1980s.  Once the IBM PC became popular, they produced 8088-based PC clone systems, including systems that interoperated with their Z-80 multi-user systems, and then multi-user based 80x86 PC-compatibles.

TeleVideo terminals

TeleVideo's first terminal was the 912, which looked much like the Lear Seigler ADM-3A which it emulated.


TeleVideo later produced the popular 925 and 950 terminals, which were similar looking with different features.  They used a 6502 CPU to control the CPU, with a pile of random logic (and later, gate chips) to create the display image from the screen buffer.  On earlier terminals, this meant that changes in display attributes (blink, underline, reverse video, half intensity, etc) took up a display position.  Doing this helped to reduce the memory required for the display buffer, and reduce the cost of the terminals.


The 970 had a sleek look with an adjustable tilt 14-inch green phosphor CRT, and ANSI, VT-100, and VT-52 emulation modes.  The ANSI mode included a form-based mode which worked much like the IBM 3270-style block mode.  The system sent a form down, laying out fields on the display, and what type of data could be entered in the fields, which the terminal would verify.  When the user was done entering data, they'd hit the SEND key on the keyboard, which would transmit some or all of the screen back to the host.  This helped to minimize the interaction with the host system (which with a single Z-80 serving multiple users wasn't particularly fast) and made the system more responsive and user-friendly.


Later terminals such as the 965 would emulate dozens of other terminals.  TeleVideo moved away from making straight clones (like the 912 that looked like the ADM 3A that it emulated) towards making their own unique, nicely styled, sleek products.

The 965 is a fairly versatile terminal, which used a 65816 CPU (the 16-bit version of the 6502, just like what the Apple IIgs used) to emulate many different terminals.


One of the more unique terminals that I have found is the TeleVideo pt100 "Personal Terminal", which was a small easily portable all-in-one terminal, with a small amber CRT, mini keyboard, optional modem, and emulated a VT-52 and VT-100.

One of the features that I've noticed while digging into TeleVideo systems is that TeleVideo liked to standardize on parts. Large chunks of TeleVideo terminals and computers used the same or fairly similar keyboards, for example.  Since the keyboards are hard to find, that helped me make use of the systems and terminals that I received without a keyboard.  I was able to use that info to build a keyboard converter for the 965 terminals that I didn't have a compatible keyboard for based on information gathered from keyboards for the earlier 970 and 925 terminals that I do have.

Z80 systems


TeleVideo made several single-user systems, some of which could be used with a central host to make a multi-user system. They communicated over an 800K-baud RS-422 serial link, which used the SDLC protocol to serialize packets of data to communicate.

The TS-801, picture above, had two 5.25" floppy drives.  All of their systems came with 64K (sometimes 128K) of ram standard, as at that point it was clear that maxing out the memory was a good idea.  It has a Z80A running at 4MHz for a central processor, included the Z80 DMA chip, a Z80 SIO/2 to run the serial ports and an optional RS-422 port, and a WD 179x / NEC D765 floppy controller.  The TS-801 was a "cheap" model, which lacked an integral terminal that their other early models had (like the TS-800 / TS-802).



The systems were based around Digital Research's CP/M.  Since they were fairly late in the CP/M timeframe, they used a fairly standard and easy to inter-operate with 5.25" double-density, double-sided, soft-sectored floppy format.  The disks are 18 sectors, at 256 bytes per sector, 40 tracks per side (48tpi), using MFM encoding, and can be easily read and written on a PC floppy controller.

The TS-803 above added an integrated "terminal", which supported character mode, using the logic array chip from a TeleVideo 925 terminal, and a graphics mode, which used the Synertek 6545 CRT controller and 32K of dedicated video RAM.  It allowed 64K or 128K of bank-switched RAM. on the main CPU, and had a slot for an add-on card with a Z80-SIO/2 and line drivers for a host RS-422 interface.

Some of the systems included a 5-40MB hard drive, using a controller based on the Western Digital WD1000 controller.

The single user systems would have zero - two floppies and up to two hard drives.  Systems without any drives, such as the TS-800A/TS-800R are designed to only be used as terminals or user stations on a central host that would provide storage.



Two host systems were available.  The TS-806 was a smaller host system, which provided ports for 6 terminals, a Centronics parallel port for a printer, a couple of RS-232 ports for a printer or modem and a console terminal, along with a single 5.25" floppy drive and a 10 / 10MB 5.25" full height hard drive.  It could be expanded with another hard drive of the same size, and an optional QIC tape drive to do back-ups to.  It used a 4MHz Z80A CPU, 64KB of RAM, Z80A-SIO/2 chips for the user station links, a Z80A DMA interface chip to manage data transfer to/from devices and user stations, and Western Digital floppy and hard drive controllers.
The TS-816 was an expanded version of the TS-806. It allowed up to 16 user stations over RS-422 links, an optional Centronics parallel printer port, three RS-232 connections for printers/etc and a maintenance terminal, and a QIC tape drive and 8" hard drive that stored 25 or 40MB. It used the same Z80A CPU, but had 128K of bank-switched RAM, plus the same Z80A-SIO/2 chips for user station links, DMA and WD hard drive controller.

Both host systems had fairly ugly beige and black cases that were designed before TeleVideo switched to more modern looking cases (apparently after they hired someone to do product design for them).




One of the more interesting systems was the "TPC-I" TeleVideo Portable Computer. There was a TPC-II version which was introduced a little later as a PC compatible computer.  The TPC-I had a Z80, 64K of ram upgradable to 128K, the same graphics mode as on the TS-803 and included the same mouse port.  The TPC-II is notable as it was the first computer I had growing up (but sadly was thrown out when my parents moved out of their house).

The TPC-I I acquired had two 5.25" double-sided, double-density (TEAC FD55-B) floppy drives. There was an available option of an RS-422 port (using the same adapter as the TS-803), but that was not installed in the system I received.  It was also, unfortunately, missing the keyboard.  However, it is compatible with the PC keyboard from the TS-1605 and TPC-II models, so I was able to use the system with that keyboard.  The keyboard and lack of a hard drive interface seem to be the two main (software-affecting) differences between it and the TS-803 -- the TS-803 boot image loads on the TPC-I, although the keyboard doesn't work.

PC compatibles


TeleVideo produced a few 8088-based PC compatibles. After the first model (TS-1603), they started producing systems with an ISA card slot, and optional expansion chassis, which allowed system expansion using the now standardized IBM PC expansion bus.

From the first systems, they moved into 286 and 386-based systems, before mostly giving up the clone market, which had been greatly diluted with competitors by the time, and focused back on terminals.  They produced a few Windows Terminal Server compatible terminals, before eventually selling off parts of the company, filing for bankruptcy, and ending terminal sales completely in 2011.