PS/2 -> PCjr keyboard conversion

Hardware questions and modifications

PS/2 -> PCjr keyboard conversion

Postby jharre » Tue May 06, 2014 10:42 am

Hargle suggested a new thread for this but I had a tough time deciding whether it should be in software or hardware. Hardware won out. ;)

This is a terrific idea. Last week I was keying in a fairly deep file path and wondering what fool at IBM decided to make the backslash an 'alt-ed' key. Bah!

Some time back, I bookmarked this page, http://www.computer-engineering.org/ps2keyboard/ that might have some useful information for this project if you want to go with PIC.

Other chips to consider would be Arduino and Picaxe. I'm not really a hardware guy either, but dabble a bit. The arduino has a free programming environment and lots of inexpensive clones out there. Code to decode the PS/2 keyboard is readily available. The Picaxe also has a free programming environment (in BASIC?), and if I recall correctly, has PS/2 keyboard decoding built in. It's been a while since I used the Picaxe, but it might be the easiest to use if the intent is something anyone can build.
jharre
 
Posts: 61
Joined: Tue Jun 18, 2013 9:48 pm
Location: Placitas, New Mexico

Re: PS/2 -> PCjr keyboard conversion

Postby jmetal88 » Tue May 06, 2014 3:55 pm

I would definitely be going with a PIC if I go through with this. I've never programmed a PIC before (for some reason my recent classes in college have focused on programming Motorola microcontrollers in assembly), but they're cheap, they're available in DIP packages, and quite a few of 'em can run on 5V without any problems.

But I wouldn't be able to start immediately because I need to buy some parts and buy/build a programming interface of some sort. If anyone wants to jump on it before I do, feel free, but I'll still likely try to write my own version as an exercise, haha.
jmetal88
 
Posts: 793
Joined: Sun Jul 25, 2010 10:22 am

Re: PS/2 -> PCjr keyboard conversion

Postby Hargle » Wed May 07, 2014 7:06 am

For the AT2XT converter, we used the 12F629 PIC:
http://www.digikey.com/product-detail/e ... -ND/459169

It seems to work quite well for the job, and is cheap.

I have a programmer for them, and have programmed up about 100 for the AT converter project, however, this &*#^$ programmer cannot erase the PICs. If it could, I'd be all set, ready to try to hack apart the PIC code that we already have and do some trial and error coding, but I'm not going to one time burn a bunch of PICs til I get it right.
The latest PIC source code is here:
http://www.vintage-computer.com/vcforum ... 1282177454



For everything else, all we'd need to do is slightly modify the PCB that andrew lynch created.
http://n8vem-sbc.pbworks.com/w/browse/# ... 20AT2XTKBD


and here's a listing of the parts we used. We'll use less of them on this project!
http://www.vintage-computer.com/vcforum ... post112490

The total cost, including PCB and components was around $10 for the AT converter.
Hargle
 
Posts: 115
Joined: Wed Apr 27, 2011 3:53 pm

Re: PS/2 -> PCjr keyboard conversion

Postby jmetal88 » Wed May 07, 2014 9:52 am

I'd consider the 12F629 except it's not low-voltage programmable. I'd kinda like to build a board to test on where I can re-program the PIC without removing it, and that'd require a low-voltage programmable chip.

I'm actually looking at the 16F1503, right now. Although my goal, of course, is to write everything from scratch. Certainly not the most efficient way to do this, but like I said before, I'm mainly interested in doing this as an exercise.
jmetal88
 
Posts: 793
Joined: Sun Jul 25, 2010 10:22 am

Re: PS/2 -> PCjr keyboard conversion

Postby Brutman » Thu May 08, 2014 10:48 am

I'm with Jeff - let's reuse the existing work from the Vintage Computer Forum project. Re-inventing the wheel is a great learning exercise, but also a great time sink.

Mapping keyboard scan codes from one form to another is trivial. I'd love to work on this too, but without any of the hardware setup I am at a disadvantage. (I really need to purchase a house and get my things out of storage. Some time to work would be nice too.)


Mike
Brutman
Site Admin
 
Posts: 911
Joined: Sat Jun 21, 2008 5:03 pm

Re: PS/2 -> PCjr keyboard conversion

Postby jmetal88 » Thu May 08, 2014 4:45 pm

Yeah, if we're re-using existing code (and I'm writing mine from scratch regardless of what anyone else is doing, haha), the main difference will be doing the bi-phase serial encoding. According to the tech ref, data is sent in 440 microsecond blocks for each bit. 220 microseconds low followed by 220 microseconds high for each 1, and 220 microseconds high followed by 220 microseconds low for each 0. I don't think it would be too difficult to implement.
jmetal88
 
Posts: 793
Joined: Sun Jul 25, 2010 10:22 am

Re: PS/2 -> PCjr keyboard conversion

Postby jmetal88 » Thu May 08, 2014 7:03 pm

I just hooked up my PCjr keyboard to my sound card (via a resistor divider so I wouldn't overload it) so I could record the waveforms coming out of it during keypresses.

There are a couple of things I noticed:

1. My sound card seems to be inverting the waveforms compared to the way they are illustrated in the tech ref. At first I thought the keyboard was actually outputting an inverted waveform, but my voltmeter assures me the idle state is 5V and not 0V like the recording is showing. I'm pretty sure the tech ref is correct on this, especially since I also tested an AT keyboard and it shows the same issue for that compared to what I've read online about the subject.

2. The tech ref says the keyboard sends 11 stop bit 'cells' and I wasn't sure what that meant. Turns out the keyboard just pulls the data line HIGH after the parity bit is sent, and pauses for a bit before the next scan code is sent. If the tech ref is to be believed, it is held HIGH for a minimum of 4.84 milliseconds between each byte sent.
jmetal88
 
Posts: 793
Joined: Sun Jul 25, 2010 10:22 am

Re: PS/2 -> PCjr keyboard conversion

Postby jmetal88 » Sun May 11, 2014 9:56 am

I already probably have over 50% of the coding for my 'from scratch' version done now. I have no idea if any of it works because I still don't have the chip I'm writing for or any programming hardware (and thus the chunk of code I have now will probably be very difficult to debug when I actually do get ready to test it), but I'm having a lot of fun trying to think of things that could go wrong and then correct for them. I'm thinking when I get ready to test thing thing, I'll probably implement debugging messages to be sent out via SPI (which I'll try to interface to my computer's RS232 serial port -- I'm sure I have a couple of spare MAX232 chips around here somewhere) so I can see what processes it completes successfully if it does get hung up somewhere. And of course I'll probably have it try to output which scancodes it's reading via SPI as well so I can be sure my look-up table is functioning properly before I try to implement output to the PCjr. I'll probably try to make properly controlling the keyboard LEDs the last thing I deal with.

EDIT: Regarding the SPI-RS232 interface, I think I misunderstood the diagram I was looking at. It wasn't referring to a MAX232-type level shifter, it was actually referring to a chip with a built in synchronous serial to UART conversion, which would be something else I'd have to order if I went with that route.

EDIT 2: Actually I think it'd be easier on me if I wrote the code for one of the PIC chips I already have. At the moment, I have a couple of PIC16F505s, a few PIC16F688s, and a few PIC16F88s. I didn't think any of these were low-voltage programmable (hence why I was looking for another chip) but it turns out the 16F88s are low-voltage progammable. In addition, the 16F88s have a built-in UART, which would make my debugging idea a lot easier. So that's my new target (and hopefully I won't have to change too much).
jmetal88
 
Posts: 793
Joined: Sun Jul 25, 2010 10:22 am

Re: PS/2 -> PCjr keyboard conversion

Postby Hargle » Mon May 12, 2014 6:16 am

about all I can do here is stand back and wish you good luck on this.
I do have a saleae analyzer that I can donate to the cause if you need it.
Hargle
 
Posts: 115
Joined: Wed Apr 27, 2011 3:53 pm

Re: PS/2 -> PCjr keyboard conversion

Postby jmetal88 » Mon May 12, 2014 10:30 pm

I might have to restart my effort, haha. I got everything set up with the keyboard and the RS-232 finally, and it seems to be working its way through recording a full scancode each time I press a key, but it never kicks into the 'delay' mode I wrote in to make it wait for multiple bytes before transmitting. Then since the 'delay' mode invokes transmission once it completes without being interrupted, the translated scancodes never get sent.

In the interest of helping people out (since nobody else is in a position to start coding yet) I might look at porting the 12F629 code over to my 16F88 tomorrow, after which hopefully I'd just have to implement the PCjr bi-phase serial transmission to make the thing work.

EDIT: I finally figured out, while messing around with a simpler program, that part of my problem is that my PIC keeps resetting itself. Turns out it's the Watchdog Timer doing that, so I guess my next step will be to disable it and try the program again.
jmetal88
 
Posts: 793
Joined: Sun Jul 25, 2010 10:22 am

Next

Return to PCjr Hardware

Who is online

Users browsing this forum: No registered users and 1 guest

cron