Interfacing with a USB keyboard

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
Don_Kirby
Posts: 341
Joined: 15 October 2006, 3:48 AM
Location: Long Island, New York

Interfacing with a USB keyboard

Post by Don_Kirby »

When I need to provide a user interface for a microcontroller project, I typically gravitate toward rotary encoders. Specifically, I prefer the types with an integrated pushbutton switch. It's a simple, elegant solution for many projects.

Not this project though.

There is a need to keep the front panel of the interface enclosure sealed to IP64 or better. Under normal operation, no user interaction is necessary, but there are numeric limits that need to be entered by the user during installation.

I am considering forgoing any built in controls, opting instead to use a standard USB keyboard. It would be an easy task to seal the USB port with a rubber plug when not in use.

To keep costs down, I'd like to use a ZX328n since it meets the needs of the application just fine. I am curious if anyone has been down this road before, maybe even without using an interfacing USB device such as one of the FTDI offerings. I have also looked at the MAX3421E. While they both seem to be overkill for just a keyboard, either one would most certainly provide the functionality I need with a minimum of experimentation.

On the topic of experimentation, somewhere around here, I must have at least a dozen USB to PS/2 adapters, which seems to indicate that I could simply treat the USB keyboard as a serial device, forgoing the USB issue altogether.

My cursory internet search turned up several home-brew projects related to the subject, none of which are quite what I am looking for. If anyone would like to point a finger in the right direction, I'd be very grateful.

-Don
Don_Kirby
Posts: 341
Joined: 15 October 2006, 3:48 AM
Location: Long Island, New York

Post by Don_Kirby »

A little Googling has turned up a few resources, but I still haven't quite grasped the USB/PS2 interoperability.

The Wikipedia entry for PS/2 contains the following passage:
Wikipedia wrote:Many keyboards and mice can connect via either USB or PS/2, selecting the appropriate protocol at power-on. Such devices are generally equipped with a USB connector, and ship with a simple wiring adapter to allow connection to a PS/2 port. Older PS/2-only peripherals can be connected to a USB port via an active adapter, which generally provides a pair of PS/2 ports at the cost of one USB port.
I read this as 'the keyboard can output either PS/2 or USB compatible data'. If this is true, then I can implement the USB keyboard in PS/2 mode without much hassle, without the need for any additional components, and certainly without the need to have a full fledged USB host.

Wandering a little off topic, but relevant to the project is the issue of non-standard use of the USB connector in this manner. Is it acceptable if the interface gracefully fails to respond when a non-keyboard USB device is plugged into this 'PS2 in a USB costume' port?


Proper pinout in hand, breadboard standing by. It shouldn't take to long to determine if this is a road worth traveling.

-Don
Post Reply