How does usb work

Hello, this is probably a very newbish question, but I have always wondered how a USB plug is able to control so many inputs and outputs. For instance a keyboard... there's a lot of keys on a keyboard but there's only like 5 pins in the USB plug it uses. Could someone clear this up for me? thanks in advance.

You can write a whole book about USB. But basically it just transfers memory from one place to the other. In the case of a keyboard it only has to transfer a single byte to convey any one of 256 keys being held down.
In practice it uses a few bytes for things like keyboard modifiers and such.
USB needs intelligence ( a processor ) at each end to do all the protocol stuff involved with transfer.
The Host ( computer ) is the only thing that can initiate communications to it has to constantly ask the client ( the thing you plug in to the computer ) if it has any data it wants to send. This is called polling.

Ohhhh, I see now. Thanks for clearing that up :smiley:

You can think of USB as a sort of "network"; the host computer figures out all of the devices that are connected, and then sends or reads a small amount of data to/from each one, in succession. This happens very quickly, so it appears that everything can be talking at the same time.

Uberokeer:
Hello, this is probably a very newbish question, but I have always wondered how a USB plug is able to control so many inputs and outputs.

Your internet connection has only one plug but you can connect to millions of different computers(!!)

fungus:

Uberokeer:
Hello, this is probably a very newbish question, but I have always wondered how a USB plug is able to control so many inputs and outputs.

Your internet connection has only one plug but you can connect to millions of different computers(!!)

....how does that work?

:wink:

Magic. :slight_smile:


@OP - the USB system is probably one of the more cunning inventions for computers. Inside the (rather complex) protocol it uses are things like device identification, so that it can tell if it has a keyboard, mouse, disk drive, etc. plugged into it. Then devices will be assigned numbers so you could actually have multiple keyboards on a USB hub.

Finally, this data is sent out, one bit at a time, using a "balanced" electrical signal (A/B wires) where one wire is usually low while the other is high, to eliminate electrical interference. Plus, power and ground. So there you have your four connections. (The A and B type USB plugs only have four wires, not five).

think of it this way, there are millions of different things one human can say to another, but we dont have one mouth for each possible thing to say, we just have one mouth which has many different vocal patterns meaning different things. usb is the same. it has different patterns used for each key in the keyboard.

"the USB system is probably one of the more cunning inventions for computers"

Firewire was years earlier and used much more intelligent controllers that did not burden the host PC nearly as much.

Sure, but where are the Firewire mice, keyboards, MIDI controllers, etc.?

Anyway, haven't Apple moved onto Thunderbird, Thunderbluff, or something like that?

KeithRB:
"the USB system is probably one of the more cunning inventions for computers"

So cunning you could brush your teeth with it.

1ChicagoDave:

fungus:
Your internet connection has only one plug but you can connect to millions of different computers(!!)

....how does that work?

:wink:

Broadcast traffic, every packet is sent to every computer one bit at a time. It's surprisingly reliable.