tunozemichanの日記 / tunozemichan's diary

SORD社のコンピューターM68やM68MXの解析についての備忘録です。This blog is a memorandum about the analysis of SORD's computers M68 and M68MX.

Create an alternative keyboard for NEC PC-8801FH

The PC-8801FH that I got before does not have a keyboard; the main unit of the PC-8801 series is sold in auctions, but the keyboard is rarely sold. Fortunately, there is a god-like person who has analyzed and published the keyboard protocol of the PC-8801FH, so I decided to make one based on that.

First of all, I tried to use the popular raspberry pi pico MicroPyhon, but I failed to make 2080pbps. So I decided to try it with an Arduino Mega2560 that I found in a junk box.

 

Assume the following configuration.

 

PC-8801FH <----- arduino mega2560 <----- ps/2 keyboard

 

First, connect the PC-8801FH to the Arduino and send waveforms according to the protocol, and check if there are no problems.

 

Keyboard connector pinout of PC-8801FH

 

f:id:tunozemichan:20210401192851p:plain

 

Keyboard protocol of PC-8801FH

 

The PC-8801FH, like a PS/2 keyboard, sends a make signal when you press a key, and a break signal when you release the key. The code for the make signal is as follows (other people's pages are much more detailed than this page).

 

For example, pressing the Q key will send 001010111111 (with a 0 at the end as the parity bit), and releasing the Q key will send 001011111111 (with a 1 at the end as the parity bit).

 

 

1. Asynchronous, no control signal

2. Start bit 1, 12-bit data, even parity, stop bit 1

3. 20800bps

4. Data is transmitted when the key is pressed (make signal), and data is transmitted when the key is released (break signal).

5. Wait for 100ms between data.

 

f:id:tunozemichan:20210401192926p:plain

 

Even parity is a code that adds up all the "1 "s in R0 to D7 and sets the parity bit to "1" if it is an odd number or "0" if it is an even number.

 

I spent the most time trying to find the correct data and data latency. This is because other people's pages about the protocol say to wait 2.3ms at minimum, but in my environment, I had to wait 100ms to get either no response or inexplicable results.

 

The next time I wasted time was in determining the transmission rate of 20800 bps. This was because I was doing a lot of things under the assumption that the transmission speed was the problem, without realizing that there was an error in determining the latency between data. It all didn't work.

Finally, I tried using a function generator to create a square wave, but it still didn't work.

In the end, it turned out to be a problem with the latency of the data interval, and the transmission speed turned out to be correct as expected.

 

Since it is 20800 bps, the retention time of one bit is 1/20800 ≈ 4.808㎲.

 

f:id:tunozemichan:20210401200617p:plain

A slight error in the holding time does not affect the operation.

 

This time, I used a function generator to create a 10.4kHz signal and applied an external interrupt to the Arduino at the rising edge of this signal.

However, in reality, the Arduino running at 16MHz can create relatively good timing by adding a delay function and a nop instruction, so external components are not necessary.