News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Ynot.zer0

6128 Keyboard scan codes

Started by Ynot.zer0, 17:54, 01 August 09

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ynot.zer0

Hi,
Does anyone know if there is any information on using a CPC 6128 keyboard, capturing and converting the scan code signals and outputting to a PS/2 keyboard (basically so I can plug a genuine 6128 keyboard into my T-REX or a PC laptop running WinAPE).

I've found CPCKey but there is not enough information supplied and the project died a long time ago.

Basically I'm looking for any information anyone has on the scan codes that get output from the keyboard membrane to the CPC (are there any electrical engineers out there?)  I plan to capture the scan codes, use a simple PIC to then convert them to PC codes and then output to the PS/2.

any help greatly appreciated.

Ynot.zer0

 :o  maybe I should have searched the CPCWiki a little bit harder the first time around!

also found a helpful reference guide in the 'Anatomy of the CPCs' book, Page 80+81 (maybe having all the books scanned in and uploaded to the CPCWiki is a good idea, after all)

Still, if anyone else has done this sort of thing before (or even considered it and stopped), please let me know

Gryzor

Heh! I saw the email notification and I was sure there was something on the wiki, but you beat me to it :D

Ygdrazil

The CPCKey project is a very extensive project and would probably not be well suited for your "Laptop CPC project" - The complexity and physical size would make it hard to fit into the small casing of a laptop. A more modern approach would be to use a PIC controler and let it make the matrix calculations instead.

Having all the books scanned on the CPCWIKI would indeed be great.. But it would also be the mother of all scanning projects!! But who nows only time can tell.. One book at a time.

By the way i think your laptop CPC project is very very nice. I am anxious how it will turn out.

/Ydrazil



Quote from: ynot.zer0 on 18:57, 01 August 09
:o  maybe I should have searched the CPCWiki a little bit harder the first time around!

also found a helpful reference guide in the 'Anatomy of the CPCs' book, Page 80+81 (maybe having all the books scanned in and uploaded to the CPCWiki is a good idea, after all)

Still, if anyone else has done this sort of thing before (or even considered it and stopped), please let me know

Ygdrazil

Well to be more specific,

A similar approach with a PIC controller has already been used on a Apple II 70's computer!

check:

http://seb.riot.org/appleII/keyboard.sml

I would use a different PIC controller because the way the CPC addresses the keyboard is different than how the Apple II does.

The PIC18F1XK22 would do okay i think, and costs about 2€ at my local electronics store. 

The pins of the 20pin keyboard connector of the CPC would go into the respective I/O ports of the PIC otherwise the diagrams would be the same.

As stated on the page:

Even if it's obvious: don't solder everything directly to the CPC keyboard-socket, put another 20pin connector with pins on both sides inbetween, you risk damaging the CPC PCB
You would need a PIC flasher and some PIC programming nowledge(not to hard as there are som exelent tutrials/tools out there), and not be affraid to use a soldering iron  :)

Would be nice project though..

Regards,
Ygdrazil

PS. About PIC's http://en.wikipedia.org/wiki/PIC_microcontroller

Quote from: Ygdrazil on 11:54, 02 August 09
The CPCKey project is a very extensive project and would probably not be well suited for your "Laptop CPC project" - The complexity and physical size would make it hard to fit into the small casing of a laptop. A more modern approach would be to use a PIC controler and let it make the matrix calculations instead.

Having all the books scanned on the CPCWIKI would indeed be great.. But it would also be the mother of all scanning projects!! But who nows only time can tell.. One book at a time.

By the way i think your laptop CPC project is very very nice. I am anxious how it will turn out.

/Ydrazil

Ynot.zer0

...couldn't get PIC18F1XK22, but could get some PIC18F13K50 - I'll keep you informed on how the progress goes on interfacing the CPC 6128 keyboard matrix with the PS/2 output for the T-REX (encased within an original CPC 6128 casing)

Ygdrazil

#6
Hi ynot.zer0                         

Excellent, I am very excited about your "laptop" project. It's been done for the C64 and Atari 800. So why not the CPC?

Having a quick glance at the tech specs of the PIC18F13K50 I think it could be done pretty simple but I think you will need som external logic to map the 20pin CPC Keyboard connector to the 16pin I/O Of the PIC!

/Ygdrazil

Quote from: ynot.zer0 on 23:58, 02 August 09
...couldn't get PIC18F1XK22, but could get some PIC18F13K50 - I'll keep you informed on how the progress goes on interfacing the CPC 6128 keyboard matrix with the PS/2 output for the T-REX (encased within an original CPC 6128 casing)

Longshot

One important thing you've to think about your project is the problem with keyboard serigraphies...
For example, an azerty cpc keyboard is not exactly similar to an azerty pc keyboard.

So your pic code will have to convert:
one pc key  ==> one cpc key
two pc keys ==> two cpc keys
two pc keys ==> one cpc key
one pc key  ==> two cpc keys

But i think there's no way to have a perfect keyboard emulation.

Example :
On PC Azerty kbd, you have one key for "<" and ">" symbols
On CPC Azerty kbd, you have one key for "* and <" and one key for "# and >"

So if you press "<>" key on pc, you have to simulate the "Shift" and "*<" keys to get a "<" symbol with a french rom.
(e.g. to have bit 1 and 5 of kbd line 2 zeroed)

If you press "shift" + "<>" key on pc, you have to simulate the "Shift" and "#>" keys to get a ">" with a french rom.
(e.g. to have bit 3 and 5 of kbd line 2 zeroed)

A "#" symbol on Cpc is simulated by : "AltGR" + "3"#" pc keys
A "*" symbol on Cpc is simulated by : "**" pc key

With this method you can reach a good configuration, but not perfect.
Imagine that you press simultaneously the following keys on pc : "<>" and "ù*" keys
"<>" give line2.1=0 and line 2.5=0 (shift pressed)
"µ*" give line2.1=0 and line 2.5=1 (not shifted)

So you've to determinate a rule.
For example, a zeroed bit has the highest priority.
Some case are impossible to match when you have two cpc distinct keys for one pc key and the cpc is testing the two keys simultanously.

:P :P :P :P
Rhaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!!

Ynot.zer0

@Ygdrazil
Good point about the PICs, I have some 16F688's in a drawer also (somewhere), they also might not be enough, but might be useful for initial prototyping / proof of concept.

@Longshot
Internationalization - yes...something I was pondering for version 2.0  ::)   All good points for me to keep in mind.  The initial version was going to be purely QWERTY (as that's what I'll be using), but you've definitely raised some good things to me to consider even just using QWERTY.

One thing to remember also, I'm converting from the CPC keyboard to a PC keyboard input connector (the one attached to the T-REX motherboard which is running the Amstrad at the moment using a PS/2 keyboard) - I only mention this as most things I've found online refer to connecting a PC keyboard to an old computer and I'm aiming doing it the other way around.

So, I just want to switch from:
PS2 Kb ---> T-REX [running AMSDOS]

To:
CPC Kb --> [PS2 Kb convertor] --> T-REX [running AMSDOS]


I'll be happy if I can get version 0.1 to just gives me 'Z','X','O','P','Enter','SpaceBar' (and arrow keys).  Due to my current work workload, I expect to have a prototype of some sort within the next 4-5 weeks.

Any further thoughts totally appreciated though!

Longshot

The problem is exactly the same with qwerty keyboard because the UK and German Cpc keyboard layout is not exactly as the british standard.
See http://en.wikipedia.org/wiki/Keyboard_layout

So just have a look to get the "@" symbol on the cpc qwerty keyboard and an actual qwerty pc keyboard. On the cpc, the "@" is combined with "|" symbol. And these symbols are located on two differents keys you have to "shift".
You have to press (on pc)  "shift" + "2@" to simulate on cpc "no shift" + "@|'
You have to press (on pc) "shift" + "\|" to simulate on cpc "shift" + "@|'

The problem described above is similar if you press on pc "shift" + "2@" + "\|"
Two pc key link to one cpc key...

And like spoken on a previous post about keyboard simulation improvement in winape, i'd suggested to separate the two pc "shift" to treat the single shift as a single dynamic key

PC LEFT SHIFT + "2@" give the CPC "@|" key
PC RIGHT SHIFT + "2@" give the CPC a SHIFT and a "@|" key. Not really cool here but useful for some simultaneous scanning.

Another solution ...
PC LEFT & RIGHT Shift keys give the CPC SHIFT key until a second PC key is pressed . At this moment the CPC SHIFT key is "unzeroed (non pressed)" according to the the serigraphy settings of the keyboard connected.
When the TWO PC SHIFT KEYS are pressed simultaneously on PC, the CPC SHIFT stays pressed (zeroed), even if the corresponding CPC KEY is not shifted.

Example:
PC KBD KEYS ==> CPC KBD KEYS
SHIFT R or L ==> SHIFT
SHIFT R and L ==> SHIFT
SHIFT R or L + "2@" ==> "@|"
SHIFT R and L + "2@" ==> SHIFT + "@|"

Rhaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!!

Powered by SMFPacks Menu Editor Mod