Query : USB Keyboard

51 views
Skip to first unread message

chetan patil

unread,
Apr 4, 2012, 1:51:47 AM4/4/12
to opena...@googlegroups.com
Hi,

Anyone here knows proper working of a Keyboard. What I know is that
there are make and break code for every key. However where does the scan
code is : D+ or D- PIN of USB ? 

I want to understand this in terms of interfacing it to some MCU not MPU.

Please share your prowess.

Thanks.

--
Thank You and Warm Regards,
 
Chetan Arvind Patil,
www.chetanpatil.info



Surendra Kumar

unread,
Apr 4, 2012, 3:54:26 AM4/4/12
to opena...@googlegroups.com
Chetan,

Best Gude : http://retired.beyondlogic.org/keyboard/keybrd.htm

helped me in interfacing a At Keyboard to the 8051 a decade ago

Regards,
Surendrakumar
--
regards
Surendra Kumar

J T Dsouza

unread,
Apr 4, 2012, 5:36:55 AM4/4/12
to opena...@googlegroups.com
You are mixing up two things (or rather several things).

The original keyboard i/f was a simple 2 wire i2c like interface. It later aquired bidirectional capabilities.

The usb device is a phy layer with a software stack (USB HID, storage, bulk etc). Keboard scan codes have to be picked up by he software stack (USB HID) and sent over the phy layer.  D+ and D- act as balanced differential lines and carry data.

chetan patil

unread,
Apr 4, 2012, 5:41:00 AM4/4/12
to opena...@googlegroups.com
Hi,

On Wed, Apr 4, 2012 at 3:06 PM, J T Dsouza <jtd...@gmail.com> wrote:
You are mixing up two things (or rather several things).
The original keyboard i/f was a simple 2 wire i2c like interface. It later aquired bidirectional capabilities.
The usb device is a phy layer with a software stack (USB HID, storage, bulk etc). Keboard scan codes have to be picked up by he software stack (USB HID) and sent over the phy layer.  D+ and D- act as balanced differential lines and carry data.

So you mean to say standalone MCU can't capture USB Keyboard scan codes and store or display it ?
 
On Wed, Apr 4, 2012 at 1:24 PM, Surendra Kumar <p.suren...@gmail.com> wrote:
Best Gude : http://retired.beyondlogic.org/keyboard/keybrd.htm

helped me in interfacing a At Keyboard to the 8051 a decade ago

My query is for USB type Keyboards. Not AT Keyboard.

Anant Gokhale

unread,
Apr 4, 2012, 7:10:40 AM4/4/12
to opena...@googlegroups.com
Chetan,

The web link referred by Surendra Kumar is excellent link to understand how PC AT keyboards used to work with PS/2 interface. PS/2 keyboards have normally 80C51 compatible CPU inside which communicates with PC CPU. This CPU generates scan codes and sends them to BIOS of PC which interprets the keys correctly. With USB keyboard, same legacy scan codes are used, but physical layer is USB. Keyboard gets enumerated as HID class device to PC. So to interface PC USB keyboard to your MCU, your MCU needs to do whatever PC does with its USB host stack for HID class. You will need to select a MCU already having a USB host with HID class device driver.  Microchip has one demo board with similar application and quite a few devices to select from. Visit www.microchip.com/usb for further info.

Thanks,
Anant.

J T Dsouza

unread,
Apr 4, 2012, 7:39:30 AM4/4/12
to opena...@googlegroups.com
On Wed, Apr 4, 2012 at 3:11 PM, chetan patil <chtp...@gmail.com> wrote:
Hi,

On Wed, Apr 4, 2012 at 3:06 PM, J T Dsouza <jtd...@gmail.com> wrote:
You are mixing up two things (or rather several things).
The original keyboard i/f was a simple 2 wire i2c like interface. It later aquired bidirectional capabilities.
The usb device is a phy layer with a software stack (USB HID, storage, bulk etc). Keboard scan codes have to be picked up by he software stack (USB HID) and sent over the phy layer.  D+ and D- act as balanced differential lines and carry data.

So you mean to say standalone MCU can't capture USB Keyboard scan codes and store or display it ?

Not without usb hid software and usb hardware OR bitbanged io pretending to be usb hardware. search for avr usb bit banging.
 
 
On Wed, Apr 4, 2012 at 1:24 PM, Surendra Kumar <p.suren...@gmail.com> wrote:
Best Gude : http://retired.beyondlogic.org/keyboard/keybrd.htm

helped me in interfacing a At Keyboard to the 8051 a decade ago

My query is for USB type Keyboards. Not AT Keyboard.

USB type keyboards are almost always AT keyborads - AT scan codes.

There are  some exceptions like newton  keyboards and HMI keyboards. But we will let that pass as insignificant.
 

chetan patil

unread,
Apr 4, 2012, 8:57:17 AM4/4/12
to opena...@googlegroups.com
Hi,

Considering the scenario :

1) USB female port is connected to MCU via Rx & Tx at D+ & D-
2) Keyboards USB Male port gets attached to above USB Female connector.

Now if I press a key on Keyboard then a make and brake code will be formed and can't the 
MCU just use a loop to scan the code and gather the make brake code and with a look up table
send that to lets say a LCD display ?

After all its a serial communication. 

Anant Gokhale

unread,
Apr 4, 2012, 9:04:47 AM4/4/12
to opena...@googlegroups.com
Well Chetan,

USB world is not so easy as you think. Because USB offers plug and play features, companies have agreed on protocol stack and device drivers long time back and all manufacturers are adhering to that. So unless you implement a USB host driver, you will not get from third party keypad, which faithfully adheres to HID class implementation which works seamlessly with any make PC motherboard.
 
Thanks,
Anant.

J T Dsouza

unread,
Apr 4, 2012, 3:35:45 PM4/4/12
to opena...@googlegroups.com
On Wed, Apr 4, 2012 at 6:27 PM, chetan patil <chtp...@gmail.com> wrote:
Hi,

Considering the scenario :

1) USB female port is connected to MCU via Rx & Tx at D+ & D-
2) Keyboards USB Male port gets attached to above USB Female connector.


Now if I press a key on Keyboard then a make and brake code will be formed and can't the 
MCU just use a loop to scan the code and gather the make brake code and with a look up table
send that to lets say a LCD display ?

After all its a serial communication. 

Why dont you try out and tell us the results. As I said in my previous mail, all you need is a little bit banging on the D+D- to simulate a USB HID endpoint.

Also trim the irrelevant portions of your mail and do not top or bottom post.


Reply all
Reply to author
Forward
0 new messages