Keyboard hookup with minimal means (dream)

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice.
User avatar
marcelk
Posts: 81
Joined: 13 May 2018, 08:26

Keyboard hookup with minimal means (dream)

Post by marcelk » 13 May 2018, 22:28

This is a thread to collect ideas on this ultimate goal of "direct keyboard hookup" while preserving the minimalistic style of the rest of the system: only simple hardware, preferably 1 or even 0 extra ICs, and nothing more complex than a shift register. Bonus points when it is possible to mod it into existing builds.

PS/2 has first attention, because such keyboards are still easy to find and are relatively simple compared to USB. But in reality the PS/2 protocol is a bulky protocol already. The PC/XT protocol is perfect, even simpler than matrix keyboards, but good luck finding those. PS/2 doesn't play nice with software-defined signal processing, and it doesn't play nice with the type of input/output lines the Gigatron has now. From the top of my head, here are the pain points:
  • Fast clock required, same order of magnitude as VGA scanlines. If the CPU has to sample this once per scanline, it might need to drop audio support, drop vCPU speed a lot, and with that possibly lose support for at67's nice sprite function. I'm not ready to accept any such a sacrifice yet...
  • Clock signal is not under control of the host, so you don't know when you get data
  • Bi-directional protocol (hopefully that can be ignored)
  • Two open collector transmission lines (hmm..: the data line into the Gigatron's shift-register already has a pull-up resistor...)
  • 11 bits sent per byte, so you can't just let one shift-register catch bytes and sample it at low frequency.
  • Data on falling edge (7400-series is happiest with rising edges)
If this turns out to be unsolvable, we might consider matrix keyboards. But in my perception they are really hard to find, unless you want to destroy an old C64 for that purpose. [Edit: Or can they be made by modding a modern board?] Stealing from microcomputers can't be the way forward as a general solution.

malcolm851
Posts: 1
Joined: 22 May 2018, 16:01

Re: PS/2 keyboard hookup with minimal means (dream)

Post by malcolm851 » 22 May 2018, 16:08

Alternative sources of keyboard matrices that don't wreck existing machines:
(1) design and build your own
(2) repurpose existing ones eg https://www.sellmyretro.com/offer/detai ... tches-3974


Malcolm.

WattSekunde
Posts: 24
Joined: 22 May 2018, 10:25

Re: PS/2 keyboard hookup with minimal means (dream)

Post by WattSekunde » 23 May 2018, 14:25

I would also prefer a DIY TTL driven keyboard maybe in a Gigatron wooden case ;-).

At first I would use the H/VSYNC poll mechanism like the Famicom controller.
That leads us direct to shift registers in our custom keyboard.

=> n x 8 key matrix (Like the ZX Spectrum one Malcolm has linked in.)

The 8 lines go into the 8-bit parallel in serial out shift register.

To drive n we can use the 4 lines from the blinkenlight outputs wired to the DB9 connector. But this requires modification on the Gigatron.
I don't have any problems with some bodge wires ;-).

OR

Use H/VSync at DB9 to
- count and reset a decimal counter for n
- clock the 8-bit-parallel-in shift register.

The counter selects the next keyboard line n after 8 bits are shifted out. That could be the a bit tricky to use as few ttl parts and diodes as possible... that is the fun part I would say ;).

Michael

matrix_sm.jpg
ZX Spectrum keyboard matrix
matrix_sm.jpg (53.46 KiB) Viewed 450 times

PS: Thinking a bit further...
With an 8 to 3 line decoder (74148) we can "compress" the 8 columns into 3 bit and get a key pressed signal to load the shift register (74166). Now we have 5 bits left for the row number.

WattSekunde
Posts: 24
Joined: 22 May 2018, 10:25

Re: PS/2 keyboard hookup with minimal means (dream)

Post by WattSekunde » 25 May 2018, 15:05

I couldn't resist ;) .

Here is my first try for a Gigatron keyboard matrix adapter. It uses only the available Signals on the DB9 (Famiclone) connector.

The idea:
- With each falling edge of V-SYNC the actual row, the key pressed col number, a shift-key and a key-pressed-flag (low active) are sampled into the 8-bit shift register (4014 CMOS series).
- The next 8 /H-SYNC (SER_PULSE) pulses will shift the bits to SER_DATA. V-SYNC has to stay high for 8 /H-SYNC pulses, as seen on my Gigatron with the oscilloscope.
- The falling edge of V-SYNC puts the shift register (4014) back into parallel load mode and increments the row counter (74393) if no key is pressed.

[ Schematics V1.3 deleted - Happy little mistakes... ;) ]

Here comes the new one.
Gigatron Keyboard 1.4.3.png
Gigatron Keyboard 1.4.3.png (983.67 KiB) Viewed 309 times

7-Bit ASCII compatible data format:
D7 = /key
D6 = row_3
D5 = shift
D4 = row_2
D3 = row_1
D2 = col_3
D1 = col_1
D0 = col_0

Beware of, it's not fully tested yet!
Now I have to search thru my parts shelf for the Chips and breadboard... maybe there is some obvious show stopper?

Michael
Last edited by WattSekunde on 02 Jun 2018, 21:22, edited 8 times in total.

at67
Posts: 48
Joined: 14 May 2018, 08:29

Re: PS/2 keyboard hookup with minimal means (dream)

Post by at67 » 26 May 2018, 13:17

I can't see any issues here, it looks sound, you shouldn't have any issues with fan in/outs, race conditions or meta-stability; but if you want to be 100% sure then you should be able to simulate it in any number of logic simulators without having to breadboard or solder anything; setting up VSync/HSync signals to clock your circuit would be trivial: or you could just dive right in and make sure that magic blue smoke doesn't escape. :)

User avatar
marcelk
Posts: 81
Joined: 13 May 2018, 08:26

Keyboard hookup with minimal means (dream)

Post by marcelk » 29 May 2018, 17:21

Nice and clear. As an inverter we can repurpose one from the clock: U1E is not really needed. In the next series its output is not even connected any longer to get a somewhat cleaner CLK1 signal. Furthermore, the DB9 allows feedthrough of more signals than are currently connected. We can also consider a CD4017 decade counter for the driving side of the matrix. Just random ideas...

For PS/2, I'm toying with the idea of adding two more shift registers, so the hardware can buffer the 22 bits of a key-up events without software support. No idea yet how to readout and reset however. (First I'll build an ATTiny85 solution for myself anyway, so this can brew a bit longer.)

WattSekunde
Posts: 24
Joined: 22 May 2018, 10:25

Re: PS/2 keyboard hookup with minimal means (dream)

Post by WattSekunde » 29 May 2018, 23:12

Thanks at67 & marcelk,
my next step is definitely the breadboard. I ordered some of the chips that are not in my drawer. My scope has a built in programmable pattern generator that should be able to create the VGA sync signals. I'm a bit busy this week but on the next weekend I'll try to escape the magic smoke :lol:

Yes, more programmable output signals on DB9 would be very helpful. I think the 4 bit from Blinkenlights could be an easy and useful first patch? And - yes I socketed a lot ;-) Just random ideas...
Blinkenlights.jpg
Blinkenlights sockets LEDs
Blinkenlights.jpg (40.85 KiB) Viewed 364 times

The good old 4017. As a kid in the 80s I builded a lot of LED projects with it. Back then I was more of a CMOS 40/45 series guy 8-).
Here I won't use a decimal counter, because I need the binary representation of the rows and wouldn't rely on parallel counting in software or burden the CPU with it. I also used a key pressed flag (bit d7) to reduce the software polling load as much as possible.

Hmmm, more shift registers to implement PS/2… I'm not sure If I like it. Two more ICs only for a „specialized interface“?
First: I would prefer a more versatile solution for DB9. Ok, my external keyboard matrix needs 4 ICs but I think it's designed to be an external add on solution between DB9 and some given or DIY keyboard matrix.
Second: Every prehistoric computer has it's own quirky, usefull keyboard layout and special keys we never forget! :ugeek: Just random thinking - „Good thing wants to have a while“...

PS: It was an informative view of the Gigatron development on your nice presentation at Belgrade Hackady 2018. > Thumbs up! And beautiful music from my favorite band Carbon Based Lifeforms 10:51 near the end - Wow!

User avatar
marcelk
Posts: 81
Joined: 13 May 2018, 08:26

Re: Keyboard hookup with minimal means (dream)

Post by marcelk » 02 Jun 2018, 16:17

I agree that two more shift registers is not nice. The one on the board is already a little cheater. After all, software could easily sample the game controller bits during vertical pulse. The 74HC595 is rather complex because it has 16 flip-flops and a tri-state buffer. We're effectively not using its latching capability, but still, it could have been a 74LS244 as was on the prototype breadboard. [Our excuses for replacing it: more pins, no space, and no motivation at the time to shovel even more into software. We conveniently blamed the complexity on the "modern" game controller :?.]

The 4 chip design is fine, they are on the other end of the cable of course. If this will work we can also make the ATtiny-solution compatible: don't let it send ASCII codes but send codes matching your matrix layout.

There is some chip count reduction possible by hooking directly into the Gigatron circuit. I'm looking at the Y register outputs... On the breadboard I had one LED on its unused pin. They are also close to J4, unlike the LEDs. On the receiving end it is not as clear unless by removing the 74HC595 anyway and putting a 74HCT244 back there.

WattSekunde
Posts: 24
Joined: 22 May 2018, 10:25

Re: Keyboard hookup with minimal means (dream)

Post by WattSekunde » 02 Jun 2018, 16:18

It works... so far. No magic smoke!

GigaKey_Proto_1.jpg
GigaKey_Proto_1.jpg (496.21 KiB) Viewed 321 times

- I swaped the 74165 for the 4014 shift register. Now I don't need the inverter that causes to much delay.
- The wired AND stops row counting as long as a key is pressed.

YES - Now I can say the hardware part is working because I can measure all received bits correct at the Gigatron data bus behind 74HC595!

( More than one attachment per message doesn't work? Maybe it's Safari. )

Now I have to learn a bit GCL and setup an Arduino. To be continued...

Michael
Last edited by WattSekunde on 02 Jun 2018, 23:30, edited 1 time in total.

WattSekunde
Posts: 24
Joined: 22 May 2018, 10:25

Re: Keyboard hookup with minimal means (dream)

Post by WattSekunde » 02 Jun 2018, 16:19

Attachment 2:
(Shift Bit is still in non ASCII compatible position D6 here.)

GIGAT-10.PNG
GIGAT-10.PNG (34.95 KiB) Viewed 308 times
Last edited by WattSekunde on 02 Jun 2018, 21:27, edited 2 times in total.

Post Reply