Wednesday, July 10, 2013

BL-328 Computer: The keyboard

I was going to integrate this into the megapost for BL328, but there was enough here that I wanted to give it its own post.

For a while, I was thinking that I wanted to use a PS2 keyboard for my BL-328 computer.  This would have worked well; being just software serial to receive PS2 messages from the keyboard, and sending down RS232 keys, or just integrating it right into the main board of the device, using the above.  Space was getting tight on the main board, but I could have made it work.

One fateful trip up to Active Surplus up on Queen Street in Toronto, Canada changed that idea.  (NOTE: this is one of the reasons I love browsing there.  I wish they were closer!)


I found this.  It's a Commodore 16 keyboard.  I remember looking up Commodore 64 keyboards at one point, and they were a simple matrix.

Keyboard matrices work pretty simply. You have a grid of wires in the horizontal and vertical.  At each intersection, there's a switch (one key on the keyboard).  To "read" it, you send out a signal on each of the horizontal lines, then read in through each of the vertical lines. If you see the signal on the vertical line, you know that the intersection of that vertical with the horizontal that you sent out the signal on is where there's a key that's pressed down.



I made an interface for this using an old serial Arduino board, a Seeed Studio shield kit, and a bunch of wire. Above you can see the early version of this before I had everything figured out.  The above worked somewhat, but had to be directly plugged in to an Arduino.  I've since added a FTDI header for communications, as well as switching around one line to he header.  On the Arduino boards (and on this board) Digital 13 was broken out to an LED for display.  This interfered with the keyboard scanning, so I had to rewire it a bit.  The topmost red line was swapped down to be just below the bottommost line.  It made the code a little confusing, but it all worked out.

In a testing configuration, directly wired in to an Arduino Pro.  Notice that I'm using a Commodore 64 keyboard instead of the Commodore 16 keyboard purchased/shown earlier.

Detail showing that one rewired line on the controller board.  This is also after I mounted the Arduino, Shield and keyboard on a piece of lexan.  Rubber feet on the bottom, underneath the keyboard keep it nice and sturdy.  This also shows the three-wire serial at the top of the image, which connects it to the host computer.

Hooked up to a test display to get a feel for how it would work.
And as a part of the completed system.  CPU board is in the red project box, with a battery pack sticking out from it.  Keyboard and controller sit on the bottom of the image.  Between the two is the video display module, sitting on its plexiglass monitor stand. I also settled upon a color scheme for the keyboard as well.