Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

PC Keyboard Scan Codes

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
robpar

Bascom Member



Joined: 18 Feb 2005
Posts: 32
Location: Vancouver BC

PostPosted: Fri Mar 11, 2005 5:58 pm    Post subject: PC Keyboard Scan Codes Reply with quote

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
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Fri Mar 11, 2005 6:17 pm    Post subject: Reply with quote

See this link:
http://mcselec.com/an05.htm

Maybe a starting point.
(Target microcontroller probably not the same).

Luciano
Back to top
View user's profile
dswinscoe

Bascom Member



Joined: 09 Feb 2005
Posts: 17
Location: London, UK

uk.gif
PostPosted: Mon Mar 14, 2005 9:37 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
robpar

Bascom Member



Joined: 18 Feb 2005
Posts: 32
Location: Vancouver BC

PostPosted: Tue Mar 15, 2005 7:37 pm    Post subject: Reply with quote

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


Cool
Back to top
View user's profile
Lupe

Bascom Member



Joined: 14 Nov 2004
Posts: 26
Location: San Antonio,Tx.

blank.gif
PostPosted: Thu Mar 31, 2005 1:03 am    Post subject: data table layout Reply with quote

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
View user's profile
robpar

Bascom Member



Joined: 18 Feb 2005
Posts: 32
Location: Vancouver BC

PostPosted: Thu Mar 31, 2005 2:08 am    Post subject: Reply with quote

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
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum