NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Sensors, Actuators, and Robotics » How to use a USB keyboard with my Nerdkit

June 24, 2014
by jmuthe
jmuthe's Avatar

I saw the tutorial on how to interface a microcontroller with a PS/2 Keyboard. Now I am interested in doing so with a usb keyboard. I want to know how to get it to work with the Atmega microcontroller. I understand how the PS/2 keyboard works. Everytime you press a key, a clock is activated on one pin and different serial data is transmitted on another pin. The data is different based on which key is pressed. Could someone explain how the USB keyboard transmits data. I know that there are four wires. One is the power, the other is ground, and the other two are Data+ and Data-. Could you explain to me what these data pins do when you press a key? Is one of them a clock? Does data have to be sent to the keyboard from the microprocessor before it sends information back?

June 25, 2014
by BobaMosfet
BobaMosfet's Avatar

USB isn't that simple for a number of reasons.

It's a differential signal
It clocks too fast for the ATMEGA
It is a protocol that is a bit more complex for differing speeds and voltage levels.
Client .v. host responsibilities exist.

BM

June 25, 2014
by BobaMosfet
BobaMosfet's Avatar

You might be able to put a USB Stack on it, for USB 1.0 only, if you want to go that far, but it would probably be more work for you than it's worth.

BM

June 25, 2014
by jmuthe
jmuthe's Avatar

I guess this is harder than I thought. I don't think will be able to use it with my Nerdkit. I am still curious as to how exactly a USB keyboard sends out a signal. Does anyone know where I can find more information on the subject? I searched the Internet without success.

June 26, 2014
by BobaMosfet
BobaMosfet's Avatar

USB.com

June 26, 2014
by JKITSON
JKITSON's Avatar

BM

This seems to be an invalid address.

Jim

June 26, 2014
by jmuthe
jmuthe's Avatar

Yeah, I didn't get anything either.

June 26, 2014
by esoderberg
esoderberg's Avatar

jmuthe,

You can get fairly cheap USB to serial breakouts that do most of the work for you. An IC similar to the one used on this breakout board is what is included on Arduino boards so they are able to connect via USB.

usb to serial at Sparkfun

June 26, 2014
by BobaMosfet
BobaMosfet's Avatar

My apologies--

http://www.usb.org/home

They invented USB.

esoderberg is correct-- and for the 8-bit micros, I recommend that route. Saves yourself a lot of time, unless you want to engineer the USB circuit yourself :)

BM

July 02, 2014
by jmuthe
jmuthe's Avatar

I might consider buying that adapter but I am still curious about how the USB sends signals to a device. I probably won't do much with that information but it would be nice to know it. I looked at the Website that BobaMosfet suggested and it gives a lot of information USBs but I can't find the exact information that I am looking for. I want to know how a USB device sends out signals and I can't find that information on the Website. Could you tell me where exactly on the Website, does it give this information?

July 02, 2014
by BobaMosfet
BobaMosfet's Avatar

jmuthe-

If you're asking what it looks like-- It's a DIFFERENTIAL signal. D+ has a square-wave pattern, and D- has the same pattern, but exactly opposite. This is a method to reduce EMI used in most higher-speed signaling today.

       __    __          __
D+:  _|  |__|  |________|  |_
     _    __    ________    _
D-:   |__|  |__|        |__|

Power and Ground are used for obviously power and ground, depending on client or host, powered or needing power.

BM

July 02, 2014
by BobaMosfet
BobaMosfet's Avatar

jmuthe-

At the USB site I listed, the entire document list (and specification) is here. Chapter 8 describes the protocol.

USB

BM

Post a Reply

Please log in to post a reply.

Did you know that you can build an analog amplifier with one transistor and a few resistors? Learn more...