Interface to PC keyboard

May 18, 2020 9 Replies

Got a new project under consideration. Will want to use a standard USB PC-type keyboard. I will need to know how to interface this to a custom board we will make. Not sure which processor we will use yet. TBD.



Where can I find info on how to "talk" to a PC keyboard. In the old days, this was an 8048 and some "scan codes". I suspect that's not the case anymore with USB.



Frankly, I'd rather ditch the USB entirely, but I suspect that won't be viable if I want to use an "Under $10" keyboard off-the-shelf, and not try to roll something ourselves (either as keyboard, keypad, or something else.).



Since USB PC keyboards are commonplace now, I assume there is some standard way to communicate with them.


This might help get you started:

You should Google asbout Keyboard, it will tell a lot. In the old times the keyboard bus was two open collector lines, clock and data. Things were a bit complicated because sometimes it was the PC who send data to a keyboard. Arduino and many others have keyboard projects in the NET or at least available.

mandag den 18. maj 2020 kl. 16.11.59 UTC+2 skrev mpm:

as far as I remember PS/2 is similar to I2C and I believe many keyboards still support it using the USB data lines, auto detecting which interface to use at power up

We did some custom keyboards with Atmega chips before, but i don't have the code anymore. It's just emulating USB HID interfaces. There might be some examples in Microchip/Atmel site.

formatting link

They have firmware for HID -> SPI. I have not checked prices or availability. We have used a FDDI uart/usb before.

Chisolm Texas-American

I don't think that is what he is looking for. Those chips connect a PC to control and SPI port. He probably wants a slave SPI port that connected to a USB master so his MCU has a simple interface to control the USB keyboard.

There are MCUs with USB host interfaces and I expect they will be the path of lease resistance. Either that or raid a PC graveyard. I hear Jeff may be obsoleting some of his inventory. The old PCs had very simple interfaces.

Rick C. - Get 1,000 miles of free Supercharging - Tesla referral code - https://ts.la/richard11209

HID (human uinterface device) is the subset of USB that covers keyboards, blinkenlights, pointers, and other physical controls. the standards seem to be availabe at no cost from USB-IF - they make their money from licensing.

Building a USB host is more complicated than building a USB device.

Jasen.

Use same interface and scan codes; only thing different worth mentioning is the connector.

That FTDI chip could do the interfacing he needs. It has an internal microcontroller that can play USB host, allow a slave USB device to be connected, read data from it and talk to some other non-USB micro via UART or an other interface. There are pre-compiled ROM files for some common functions, including reading from a USB human interface device and sending the data over UART (over SPI is also available).

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required