How does a USB keyboard work?
Ben Eater・2 minutes read
PS2 keyboards use four pins for power and communication, sending bursts of data with clock pulses and various bits. USB keyboards operate at different speeds, signal their speed through data signals, and require a computer for communication initiation.
Insights
- PS2 keyboards use a simple four-pin interface for power and communication, while USB keyboards have a more complex setup with additional pins for ground, power, and data signals.
- USB keyboards operate at different speeds, signaling their speed through specific pins, and involve intricate data decoding processes, including NRZI encoding, bit stuffing, and differential pair transmission for enhanced signal integrity.
Get key ideas from YouTube videos. It’s free
Recent questions
How does a USB keyboard differ from a PS2 keyboard?
USB keyboards use four pins for power and data, while PS2 keyboards use only four pins for communication. USB keyboards operate at different speeds, with low speed at 1.5 Mbps and full speed at 12 Mbps. USB keyboards signal their speed by pulling D- high for low speed and D+ high for full speed. USB keyboards require connection to a computer for communication initiation. USB keyboards send more data than PS2 keyboards, but USB's faster speed compensates for the increased data transfer.
What is the process of decoding USB data packets?
Analyzing USB data involves decoding J and K states, identifying packet boundaries, and interpreting sync patterns. USB data uses NRZI encoding, where a one is represented by no level change and a zero by a level change. NRZI encoding aids in reliable data detection by focusing on transitions between voltage levels. Using a differential pair in USB data transmission reduces interference susceptibility and emissions, enhancing signal integrity. Level changes indicate zeros, crucial for clock recovery and bit counting. USB protocol uses bit stuffing to ensure signal transitions, preventing miscounts.
How do USB keyboards handle key presses?
Keyboard responses vary based on key presses, with modifier keys represented by specific bits. Limitations exist in detecting simultaneous key presses beyond six due to internal connections in the keyboard matrix. Negotiating with a computer can allow for more than six simultaneous key presses, although six is the typical default outside of specialized gaming hardware. Initial setup is required when plugging in a keyboard, involving communication with the computer to establish parameters and configurations.
What are the key components of a USB data packet?
Decoded first four bits as 1001 represent an "in" packet. Following four bits are the complement of the first four, serving as a data integrity check. Address, endpoint, and CRC are decoded from subsequent bits, with CRC checking address and endpoint. Address 24, endpoint 1, and CRC F4BF indicate an "in" command for keyboard data retrieval. Data packet decoded with eight bytes of zeros and a CRC F4BF for data integrity. Acknowledgement packet decoded as a response to the data packet.
How does USB protocol ensure data integrity?
USB keyboards use NRZI encoding, bit stuffing, and CRC checks to ensure data integrity. NRZI encoding aids in reliable data detection by focusing on transitions between voltage levels. Level changes indicate zeros, crucial for clock recovery and bit counting. USB protocol uses bit stuffing to ensure signal transitions, preventing miscounts. Address, endpoint, and CRC are decoded from subsequent bits, with CRC checking address and endpoint. USB keyboards send more data than PS2 keyboards, but USB's faster speed compensates for the increased data transfer.