Propeller ---> 5v Keyboard Interface
cbmeeks
Posts: 634
I just recently received my very first Commodore 128D (DCR, actually) computer. I have other C128's but this is my first 128D. This model has a detachable keyboard.
Unfortunately, the eBay seller didn't have a keyboard for it. But the good news is that the keyboard interface looks pretty simple. It has 25 pins with 2 of the pins being +5v and GND. The other 23 pins are for the ROW select (8 pins), COLUMN select (8 pins), etc.
My thought was to take a PS/2 keyboard and convert the signals to the Commodore. I'm reasonably sure it's a one-way interface and no signals are sent to the Propeller. But I don't know if the 3.3v would be enough to trigger a valid signal on the Commodore.
So, assuming worse case and the Commodore needs 4-5v to register a HIGH, how would you recommend I handle this? With the 32 inputs for the Propeller, I wouldn't even need a shift register. :-) Do you recommend diodes between each pin? Of course, this would protect the Propeller and not really the Commodore.
Any suggestions on how to protect the Commodore from me doing something stupid? I'd rather damage my Propeller than my C128D!
I will see if I can find some schematics for the keyboard connector but it's pretty sparse for the C128D.
Thanks!
Unfortunately, the eBay seller didn't have a keyboard for it. But the good news is that the keyboard interface looks pretty simple. It has 25 pins with 2 of the pins being +5v and GND. The other 23 pins are for the ROW select (8 pins), COLUMN select (8 pins), etc.
My thought was to take a PS/2 keyboard and convert the signals to the Commodore. I'm reasonably sure it's a one-way interface and no signals are sent to the Propeller. But I don't know if the 3.3v would be enough to trigger a valid signal on the Commodore.
So, assuming worse case and the Commodore needs 4-5v to register a HIGH, how would you recommend I handle this? With the 32 inputs for the Propeller, I wouldn't even need a shift register. :-) Do you recommend diodes between each pin? Of course, this would protect the Propeller and not really the Commodore.
Any suggestions on how to protect the Commodore from me doing something stupid? I'd rather damage my Propeller than my C128D!
I will see if I can find some schematics for the keyboard connector but it's pretty sparse for the C128D.
Thanks!
Comments
Are you sure all the other signals are inputs to the commodore? Usually one set (row or column) is an output and the other an input so the keyboard can be scanned to determine what key is pressed.
You're probably right. I was thinking the keyboard "pushed" the values.
I have the Commodore 128 Programmers Guide (not specifically for the 128D) and it has a page showing a table where the rows/cols intersect for a given key.
But it doesn't mention anything about scanning the keyboard or interrupts.
The propeller can read the character from the keyboard and output a high on the appropriate column when the corresponding row goes high. Another approach would be to use 2 analog mux/demux chips and have the propeller output the row and column numbers based on the keyboard character.
http://computers.mcbx.netne.net/8bit/c128/index.htm#keyb
A keyboard could be built like that as long as the pc keyboard you start with is one of the older mechanical contact types and not the capacitive ones. Simpler imo to use a ps2 keyboard with a prop as the interface to the commodore. That way replacing a bad keyboard is simple, and the extra keys could be used for programmable macros.
Note also that there is a link in that section that shows the keyboard schematic.
I will look into this more. Thanks for the help.
Yes, thanks for posting that. I looked at that and downloaded two of the manuals. That schematic does make it easy enough to convert a suitable PC keyboard to one that can be used on the commodore 128.
I soldered up a simple circuit to allow me to tie the keyboard expansion to a protoboard.
Next, using this diagram:
http://computers.mcbx.netne.net/8bit/c128/51.gif
I can connect PIN17 (C3) to PIN10 (R2) and I see the letter "G" on screen. Which is what I want.
But, here is where I'm stupid...how do I take the Propeller and "tie" those two pins together? I can touch the wires together on the board and it works great.
I want to build the circuit without a PS/2 keyboard at first. Basically send it a stream of keystrokes. Because I might just use a serial monitor to send over keystrokes.
I hope this makes sense.
Thanks!
Then you need to determine if the output pins are normally high and go low when selected, or are normally low and go high when selected. This is simple to do with a scope, and if you do not have a scope you can use a propeller with 3.9K or higher series resistors on the pins.
sometimes one does not see the forest because of the trees.
So the commodore is scanning the keyboard by setting the output lines one after the other and reading the input lines to find out the key pressed (connecting output and input).
To simulate this with the propeller, you have to read the outputs from the commodore and set the according input lines of the commodore for the key press you want to transmit.
If @rosco_pc has it right you basically have to wait for a change on pin 10 while reading from the propeller and then set pin 17 to transmit a 'G'.
Enjoy!
Mike
So here is what I have tried so far:
Declared PIN17 as OUTPUT and PIN10 as INPUT. When PIN17 is HIGH then make PIN10 HIGH. Nothing. Reversed it. When PIN17 is HIGH then make PIN10 LOW. Nothing. Then checked for when PIN17 is LOW, make the other high, etc.
Basically, I tried all possible combinations of checking for one pin being high and setting the other to low or high. The screen appears to be holding the down-arrow key (or possible enter) because the screen scrolls up.
I've put a scope on both pins. Both pins show HIGH. Either separately or even together. Which I don't understand.
Only by touching the two pins together (PIN10 physically touching PIN17) do I get a "G" on screen.
BTW, I still don't have a physical keyboard on the C128. I just want to stream characters via serial at the moment.
**EDIT**
I actually found a guy who makes the exact circuit I'm trying to build. However, I'd like to build my own version instead. :-)
Anyway, it looks like he is using one of these:
http://www.microsemi.com/products/switches/analog-cross-point-switches/mt8812
That you can see in his schematics:
http://www.go4retro.com/products/ckey/
Scroll down to the Image Gallery and look at the first pic.
That's why the other quy most likely used external HW: set the correct switch in the matrix with the micro controller, keep it active for some time and release again. You'll only need to find out the time needed to keep it active, too long and you'll get repeated 'key presses', too short and the key press is not seen.
You might try if the following works:
receive key press from ps/2
select correct c128 input pin to set high based on key pressed (e.g. 17)
waitpeq (state, mask, 0) with state and mask pointing to the c128 pin to monitor for the key pressed (e.g. 10)
and set selected c128 pin high when triggered
edit: on the scope trace you can measure the time between scan pulses (so you get some idea how much time you have to set the pin high and can see if it can be done in PASM)
More progress!
OK, in my parts bin I have some of these
http://www.nxp.com/documents/data_sheet/74HC_HCT4066.pdf
I was able to connect PIN10 and PIN17 to the 1Y and 1Z and the mcu to 1E.
Now I can grab "G" from serial and then pulse 1E and I get a "G".
So it seems adding some of these IC switches works pretty well. Perhaps I could find one that had more inputs. But with a 11x8 matrix...that's going to be a lot!
Maybe there's a better way?
There is a better way. All you need is a propeller chip, maybe an octal driver, and a ps2 keyboard. There is an object in the obex that will receive data from the keyboard and decode the character. Based on the character the propeller waits for the proper output from the c128 and outputs the specific signal to the c128 inputs.