View previous topic :: View next topic |
Author |
Message |
robpar
Joined: 18 Feb 2005 Posts: 32 Location: Vancouver BC
|
Posted: Fri Mar 11, 2005 5:58 pm Post subject: PC Keyboard Scan Codes |
|
|
I would like to connect a PC Numeric Keypad to my AVR. I have read the part in the manual and in Klaus's BASCOM book. I know about the make and brake codes and understand that, at least enough to get started. However when I look at the Data Table I am not sure what I am looking at.
There are a lot of Zeros, "0", which I do not understand. I thought that those would be the code that was sent from the Keyboard. Since I will not have a full PC keyboard I will have to make my Data Table and would like to understand what is happening.
Thank You
Bob Parry |
|
Back to top |
|
 |
Luciano
Joined: 29 Nov 2004 Posts: 3149 Location: Italy

|
Posted: Fri Mar 11, 2005 6:17 pm Post subject: |
|
|
See this link:
http://mcselec.com/an05.htm
Maybe a starting point.
(Target microcontroller probably not the same).
Luciano |
|
Back to top |
|
 |
dswinscoe
Joined: 09 Feb 2005 Posts: 17 Location: London, UK

|
Posted: Mon Mar 14, 2005 9:37 pm Post subject: |
|
|
I have never used the Getatkbd command but a couple of my students over the years have used BASCOM-AVR to read from a pc keyboard. They found the information at http://www.computer-engineering.org/ps2protocol/ very useful. They both found it was much easier to write the code if they disabled the break codes by sending the command 0xF9 (Set All Keys Make) to the keyboard, this also disables the repeat function. |
|
Back to top |
|
 |
robpar
Joined: 18 Feb 2005 Posts: 32 Location: Vancouver BC
|
Posted: Tue Mar 15, 2005 7:37 pm Post subject: |
|
|
I think I am getting to know what is required. So for a Lookup Table
the value that is returned by the GETATKEY command (Not correct spelling) is the Data location in the Data Statement?
For Example: if the value returned was 05 Hex than in the table below the
value would be "Q" ?
Data, 0,0,0,0,0,"Q",0,0,0
I think this means that I have to make a table that includes all the scan codes for the AT keyboard even though I am using a separate numeric keypad with only 21 keys.
Bob Parry
 |
|
Back to top |
|
 |
Lupe
Joined: 14 Nov 2004 Posts: 26 Location: San Antonio,Tx.

|
Posted: Thu Mar 31, 2005 1:03 am Post subject: data table layout |
|
|
Not sure if this is correct but it helps me and I thought I would share it with you guys. Someone please correct me if I am wrong. The data table in the bascom manual appears to be a hex data table. For example using robpar's example above (05 hex) is the scan value. The data returned would be the value in location (05 hex). In bascom's example's the data returned appears to be ASCII values and not the actual letter. So if the scan code is (2A hex) in the sample below there is ASCII code 118 which represents the letter (v). I think the ASCII value can be any value that will get you the character you want when you hit the key in the location for the hex value. I am however trying to figure out the layout of the hex table in relation to the actual pc keyboard. Also some keys dont work and others don't return the character you want, I quess that has something to do with the scan codes. In my table below i used zero's to better understand the table. As far as i can tell the zero's don't affect any values at all. Any comments welcomed. Thanks Lupe,
| 0| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
0 |0 |000|000|000|000|0Q0|000|000|000|000|000|000|000|000|000|000|
1 |0 |000|000|000|000|000|000|000|000|000|000|000|000|000|000|000|
2 |0 |099|120|100|101|052|051|000|000|032|118|102|116|114|053|000|
3 |0 |000|000|000|000|000|000|000|000|000|000|000|000|000|000|000|
4 |
5 |
6 |
7 | |
|
Back to top |
|
 |
robpar
Joined: 18 Feb 2005 Posts: 32 Location: Vancouver BC
|
Posted: Thu Mar 31, 2005 2:08 am Post subject: |
|
|
Lupe:
I have tried the Bascom code with my keyboard and it works quite well. I noticed like you did that some keys did not return a code. I did notice that the , (comma) and . (decimal) keys were reversed on my keyboard. Since Bascom is from Europe and they often use commas where we use decimals that is understandable.
I ws also trying to use 1 to 255 for the data table to try and sort out what the scan codes were but have not been able to find the time.
I have not been able to find out as of yet how to iniiate the numeric keypad. When I do I will post what I find. The keypad can be a excellent entry system for my needs. High quality and cheap, just what I need.
Bob Parry |
|
Back to top |
|
 |
|