How to connect USB keyboard to embedded device?

Jul 15, 2005 41 Replies

We have a need in a new product design to be able to connect a standard USB keyboard. That's the only USB device we will ever want to plug in (no, really!). I know next to nothing about USB, having just downloaded the spec yesterday. I gather we want a USB Host, and that most "USB micros" cannot function as hosts. I also gather that Hosts are much more difficult than hubs and functions. What I'd like is a chip that can take keyboard USB in one end and spit out serial or parallel characters on the other end, taking as many shortcuts from a universal USB design as possible given the keyboard-only requirement. What would be the easiest approach to doing this?



Oh yeah, while I'm not completely opposed to an existing stand-alone brick, what I'm really asking about is a chip that can be designed into a medium-volume product. Many thanks!



[...]

Why USB and not PS/2 keyboard ? They are already serial.

Vadim

The xscale ARM pxa270 (not pxa255) can act as USB client and host, but it would not be cheap for this only. If you also need other functions, it might be considered.

You can always do an FPGA for it.

On the other hand USB to PS/2 adaptor might siffice ,

That begs the question: how would producing such a brick in medium volumes be conceptually different from getting yourself a medium volume of keyboards with a proper, non-USB interface produced?

You're taking a huge detour via USB, which will cost an enormous amount of money, development time, space and power, for *no* useful gain other than the mass-production advantage of standard keyboards. Odds are high you'll overcompensate that gain in costs for the interface brick.

Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.

I never question customer's request, perhaps they are doing a USB to PS/2 converter. Anyway, high end ARM such as PXA270 and AT91RM9200 and others can do USB host and client.

Cypress sell embedded host controllers.

formatting link
and follow the USB links. Around $5.

That's a valid question. I am sure they will not want to deal with custom keyboards. My reference to a brick was to an already-available one, not to us designing our own. If we design our own it would be built in to our product, not an external brick.

If that's the case, that making a keyboard-only USB host is so demanding (in all the categories you state), then we will of course rethink our ideas. But is that the consensus? Is a simple USB host really so difficult? Another poster mentioned a $5 USB host device. Is that $5 plus a years development time, or $5 plus a weeks development time? Of course, I'll need to research that myself, but I'm hoping for some guidance from this group as well.

I would think that using USB keyboards in custom devices is not an unheard-of desire. Is bare-bones USB hosting really such a monster?

That's a possibility. What are the chances that such keyboards will be around for the next 5 years?

I did search for PS/2 keyboards but only found USB keyboards for PlayStation 2s.

Now that _is_ interesting. And only $5-$10. That also makes me wonder even more about how difficult it is to host USB keyboards. Thanks for expanding my horizons!

[Attribution lost]

AIUI, some modern "USB" keyboards are like the dual-interface (serial-PS/2) mice: the "adapter" connects different signals, the keyboard detects how it is connected, and uses the appropriate interface.

Regards,

-=Dave

Change is inevitable, progress is not.

A simple google turned up this:

formatting link

It provides complete board layout, schematics, BOM, etc. You asked about a "chip" and this uses just such a thing and it may help you think out the idea more, in the context of medium volume.

Jon

A quick glance through the BOM shows the use of the FT232, serial to USB converter, client only. The OP was looking for a host USB solution.

-CH

Ah. Noted!

Isn't it possible to significantly pare down what a host needs to do, if there is ONLY going to be one and exactly one keyboard attached? Being ignorant of the details, it sure seems to me that it should be possible to set aside almost all of the host functionality and strip the need down to a much simpler system.

Jon

Mike:

This takes some work, but not much. First you need a USB Host chip. We have used the Cypress 811HS and a microcontroller. The micro controller typically would have a UART. Since this is the only device that you would be bringing on line, you need only monitor the enumeration with an USB analyzer and emulate the same data exchanges with your uC/811HS. We have done this for USB printers. We have a little board that takes serial data and packages it into USB packets and delivers it to the printer. We service a 4 endpoints.

From a development viewpoint, there are some idiosyncracies with the 811HS, but it yields without too much hair pulling. Doing this development without an USB analyzer however would make it a lot tougher.

Blakely

Blakely LaCroix Wrenchman, Inc. Minneapolis, Minnesota, USA

"Design is Art in practice"

Yes, that is my hope. I just noticed another thread where the OP is using a USB host chip with a PIC, and it's mostly working. That lets me breathe a lot easier. :-)

The USB host side is not trivial to implement without a dedicated controller. Someone mentioned already the cypress chip, there is also the Philips one:

formatting link

which Digikey happens to have in stock.

-CH

Thanks a bunch for your comments. I've got the 811HS data open in another window right now, and I just saw another thread where somebody had it more-or-less working with a PIC.

I will also definitely take your USB analyser copy-what-works advice to heart.

Someone

Yes, but that wasn't my question. I wasn't wondering about how difficult it was to implement _if_ one does everything that a general purpose host USB must do. I don't think anyone is disagreeing that this is non-trivial and more.

The question I'm asking from my ignorance of USB is whether or not it is possible for someone very knowledgeable about USB hosts and the requirements for PC keyboards to pare everything down (hardware and software) so that the result would still work very well and not be nearly the burden that a general purpose USB host would present.

In other words, is it possible to strip it down to the essentials and significantly reduce the problem, in this particular case?

Jon

It won't be quite that simple. All you need to do is read the USB HID spec. Unless you want to allow only ONE mfg/productid keyboard to be your (perpetually available) keyboard, you will need to parse the HID descriptors and figure out which key code goes to which key.

Regards ~Steve

There is no "x" in my email address.

Yes, but then it wouldn't be USB.

Join the Discussion

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

Didn't find your answer?

Ask the community — no account required