Table of Contents

lamaPLC Communication: USB

USB logo Universal Serial Bus (USB) is an industry standard that allows data exchange and delivery of power between many types of electronics. It specifies its architecture, in particular its physical interface, and communication protocols for data transfer and power delivery to and from hosts, such as personal computers, to and from peripheral devices, e.g. displays, keyboards, and mass storage devices, and to and from intermediate hubs, which multiply the number of a host's ports.

Introduced in 1996, USB was originally designed to standardize the connection of peripherals to computers, replacing various interfaces such as serial ports, parallel ports, game ports, and ADB ports. Early versions of USB became commonplace on a wide range of devices, such as keyboards, mice, cameras, printers, scanners, flash drives, smartphones, game consoles, and power banks. USB has since evolved into a standard to replace virtually all common ports on computers, mobile devices, peripherals, power supplies, and manifold other small electronics.

In the current standard, the USB-C connector replaces the many various connectors for power (up to 240 W), displays (e.g. DisplayPort, HDMI), and many other uses, as well as all previous USB connectors.

As of 2024, USB consists of four generations of specifications: USB 1.x, USB 2.0, USB 3.x, and USB4.

USB stecker

transfer rates of the USB interfaces

USB standardUSB speed
USB 1.012 Mbit/s (1,5 MByte/s)
USB 2.0480 Mbit/s (60 MByte/s)
USB 3.05 Gbit/s (625 MByte/s)
USB 3.110 Gbit/s (1,25 GByte/s)
USB 3.220 Gbit/s (2,5 GByte/s)
USB 440 Gbit/s (5 GByte/s)
USB 4 type 280 Gbit/s (10 GByte/s)

System design

USB device communication is based on pipes (logical channels). A pipe is a connection from the host controller to a logical entity within a device, called an endpoint. Because pipes correspond to endpoints, the terms are sometimes used interchangeably. Each USB device can have up to 32 endpoints (16 in and 16 out), though it is rare to have so many. Endpoints are defined and numbered by the device during initialization (the period after physical connection called “enumeration”) and so are relatively permanent, whereas pipes may be opened and closed.

There are two types of pipe: stream and message.

A message pipe is bi-directional and is used for control transfers. Message pipes are typically used for short, simple commands to the device, and for status responses from the device, used, for example, by the bus control pipe number 0.

A stream pipe is a uni-directional pipe connected to a uni-directional endpoint that transfers data using an isochronous, interrupt, or bulk transfer:

Isochronous transfers

At some guaranteed data rate (for fixed-bandwidth streaming data) but with possible data loss (e.g., realtime audio or video)

Interrupt transfers

Devices that need guaranteed quick responses (bounded latency) such as pointing devices, mice, and keyboards

Bulk transfers

Large sporadic transfers using all remaining available bandwidth, but with no guarantees on bandwidth or latency (e.g., file transfers)

When a host starts a data transfer, it sends a TOKEN packet containing an endpoint specified with a tuple of (device_address, endpoint_number). If the transfer is from the host to the endpoint, the host sends an OUT packet (a specialization of a TOKEN packet) with the desired device address and endpoint number.

If the data transfer is from the device to the host, the host sends an IN packet instead. If the destination endpoint is a uni-directional endpoint whose manufacturer's designated direction does not match the TOKEN packet (e.g. the manufacturer's designated direction is IN while the TOKEN packet is an OUT packet), the TOKEN packet is ignored. Otherwise, it is accepted and the data transaction can start. A bi-directional endpoint, on the other hand, accepts both IN and OUT packets.

Device classes

The functionality of a USB device is defined by a class code sent to a USB host. This allows the host to load software modules for the device and to support new devices from different manufacturers.

Device classes include:

ClassUsageDescriptionExamples, or exception
00DeviceUnspecifiedDevice class is unspecified, interface descriptors are used to determine needed drivers
01InterfaceAudioSpeaker, microphone, sound card, USB and FireWire
02BothCommunications and CDC controlUART and RS-232 serial adapter, modem, Wi-Fi adapter, Ethernet adapter. Used together with class 0Ah (CDC-Data) below
03InterfaceUSB human interface device (HID)Keyboard, mouse, joystick
05InterfacePhysical interface device (PID)Force feedback joystick
06InterfaceMedia (Picture Transfer Protocol(PTP) / Media Transfer Protocol (MTP)Scanner, Digital camera
07InterfacePrinterLaser printer, inkjet printer, CNC machine
08InterfaceUSB mass storage, USB Attached SCSIUSB flash drive, memory card reader, digital audio player, digital camera, external drive
09DeviceUSB hubHigh speed USB hub
0AInterfaceCDC-DataUsed together with class 02h (Communications and CDC Control) above
0BInterfaceSmart cardUSB smart card reader
0DInterfaceContent securityFingerprint reader
0EInterfaceVideoWebcam
0FInterfacePersonal healthcare device class (PHDC)Pulse monitor (watch)
10InterfaceAudio/Video (AV)Webcam, TV
11DeviceBillboardDescribes USB-C alternate modes supported by device
DCBothDiagnostic deviceUSB compliance testing device
E0InterfaceWireless ControllerBluetooth adapter
EFBothMiscellaneousActiveSync device
FEInterfaceApplication-specificIrDA Bridge, RNDIS, Test & Measurement Class (USBTMC), USB DFU (Device Firmware Upgrade)
FFhBothVendor-specificIndicates that a device needs vendor-specific drivers

USB mass storage / USB drive

USB mass storage / USB drive The USB mass storage device class (MSC or UMS) standardizes connections to storage devices. At first intended for magnetic and optical drives, it has been extended to support flash drives and SD card readers. The ability to boot a write-locked SD card with a USB adapter is particularly advantageous for maintaining the integrity and non-corruptible, pristine state of the booting medium.

Though most personal computers since early 2005 can boot from USB mass storage devices, USB is not intended as a primary bus for a computer's internal storage. However, USB has the advantage of allowing hot-swapping, making it useful for mobile peripherals, including drives of various kinds.

Several manufacturers offer external portable USB hard disk drives, or empty enclosures for disk drives. These offer performance comparable to internal drives, limited by the number and types of attached USB devices, and by the upper limit of the USB interface. Other competing standards for external drive connectivity include eSATA, ExpressCard, FireWire (IEEE 1394), and most recently Thunderbolt.

Media Transfer Protocol

Media Transfer Protocol (MTP) was designed by Microsoft to give higher-level access to a device's filesystem than USB mass storage, at the level of files rather than disk blocks. It also has optional DRM features. MTP was designed for use with portable media players, but it has since been adopted as the primary storage access protocol of the Android operating system from the version 4.1 Jelly Bean as well as Windows Phone 8 (Windows Phone 7 devices had used the Zune protocol—an evolution of MTP).

The primary reason for this is that MTP does not require exclusive access to the storage device the way UMS does, alleviating potential problems should an Android program request the storage while it is attached to a computer. The main drawback is that MTP is not as well supported outside of Windows operating systems.

Human interface devices

A USB mouse or keyboard can usually be used with older computers that have PS/2 ports with the aid of a small USB-to-PS/2 adapter. For mice and keyboards with dual-protocol support, a passive adapter that contains no logic circuitry may be used: the USB hardware in the keyboard or mouse is designed to detect whether it is connected to a USB or PS/2 port, and communicate using the appropriate protocol. Active converters that connect USB keyboards and mice (usually one of each) to PS/2 ports also exist.

Device Firmware Upgrade mechanism

Device Firmware Upgrade (DFU) is a generic mechanism for upgrading the firmware of USB devices with improved versions provided by their manufacturers, offering (for example) a way to deploy firmware bug fixes. During the firmware upgrade operation, USB devices change their operating mode effectively becoming a PROM programmer. Any class of USB device can implement this capability by following the official DFU specifications. Doing so allows use of DFU-compatible host tools to update the device.

Audio streaming

The USB Device Working Group has laid out specifications for audio streaming, and specific standards have been developed and implemented for audio class uses, such as microphones, speakers, headsets, telephones, musical instruments, etc. The working group has published three versions of audio device specifications: USB Audio 1.0, 2.0, and 3.0, referred to as “UAC” or “ADC”.

UAC 3.0 primarily introduces improvements for portable devices, such as reduced power usage by bursting the data and staying in low power mode more often, and power domains for different components of the device, allowing them to be shut down when not in use.

Sources

Wikipedia (https://en.wikipedia.org/wiki/USB)

USB topics on lamaPLC

PageDateUserTags
2024/11/15 17:16Sandor Vamos, , , , , , , , ,


This page has been accessed for: Today: 3, Until now: 36