Pages: [1]   Go Down
Author Topic: How does usb work  (Read 696 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31382
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ohhhh, I see now. Thanks for clearing that up smiley-grin
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 106
Posts: 6371
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4545
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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(!!)
Logged

No, I don't answer questions sent in private messages...

Chicago
Offline Offline
Sr. Member
****
Karma: 5
Posts: 456
With every answer comes more questions.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

;-)
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Magic. smiley



@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).
Logged

South Africa
Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Edison Member
*
Karma: 18
Posts: 1170
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Austin, TX
Offline Offline
Faraday Member
**
Karma: 63
Posts: 6049
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

http://en.wikipedia.org/wiki/Universal_Serial_Bus
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 118
Posts: 4545
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

So cunning you could brush your teeth with it.

Logged

No, I don't answer questions sent in private messages...

0
Offline Offline
Full Member
***
Karma: 0
Posts: 151
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: