Go Down

Topic: How does usb work (Read 1 time) previous topic - next topic

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.

Grumpy_Mike

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 :D

westfw

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.

fungus


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(!!)
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

1ChicagoDave



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?

;-)

Nick Gammon

Magic. :)




@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).
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

ryan27968

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.

KeithRB

"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.

Nick Gammon

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

Anyway, haven't Apple moved onto Thunderbird, Thunderbluff, or something like that?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

James C4S

http://en.wikipedia.org/wiki/Universal_Serial_Bus
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

fungus


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


So cunning you could brush your teeth with it.

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

tocpcs



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


....how does that work?

;-)


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

Go Up