how does a usb work?

ok ive wondered this for ever what pins do what on a usb port?

frollard7 years ago
Burf's answer probably includes a LOT of what I'm about to type...but oh well :D

There is power  +5v and Ground... and 2 data wires.  They only send digital data, ones and zeroes. 
This is the PHYSICAL layer of  usb communication.  The data signals are+ and -.   To put it bluntly, to get the data rates that usb does, they use differential signal processing - the signal goes in one wire, to the other end, and back to the sender on the other wire.  The receiver just notes which way the power was transmitting, forward or backward, to determine if it was a one or a zero.  This way, 'noise' would influence both data lines at the same time and be ignored by the signal processor.

An analogy for this is that you have each end of a rope in each of your hands, wrapped around a pulley some distance away.  You pull on one, and the pulley rotates.  The receiver notes that it went clockwise or counter-clockwise.  Someone in the middle (signal noise) grabs both ropes and shakes them vigorously.  The pulley shakes about, but does not rotate - thus the data is not influenced by the 'noise'.  Older systems (other serial communication) just sends the data in one direction, so noise on the line can influence what the receiver 'sees' as data, and can either corrupt or slow down communication.

USB above the physical layer is a protocol - a language that involves what the sender and receiver do to handshake, and communicate.  This is far above my understanding but it basically involves a packet data stream, with acknowledgements going both directions to ensure the data was sent intact.

The reason usb can handle many peripherals is because they all operate on some level with digital information, storage, keyboards, webcams, even sound and video cards are all just digital data that can be sent serially.  Multiple units can share the bus at the same time because each peripheral has a unique address and each gets its own turn to talk, one at a time.
caarntedd7 years ago
I knew it! Now someone has confirmed what I've been saying all along.
Re-design7 years ago
It's magic.
Burf7 years ago
Here is as good an explanation as you will find.