Make your own free website on Tripod.com

[Uploaded Sep08] USB -'Plug & Play' or a new 'Plug & Problem'?

By: Stuart Cording

In the beginning .....

You'd be forgiven for thinking that adding new part to your PC was easy. It should be But many of our members who wield screwdriver withh the deftness of a Jed Knight and put up MFI cabinets with ease find the installation of PC peripherals whether a mouse or an expansion card, harrowing experience. Take away all the experience from those years of tinkering with things electronic and you begin tc understand how the man on the street copes with peripheral installation. The truth is he doesn't.

And the peripheral manufacturers aren't in a much better position. Profit margins are so slim on some products that a 15 minute call to their Help Desk will wipe out all the profit in the product you bought. It would be cheaper for them if you just took it back to the shop you bought it from. The Universal Serial Bus, or USB, has quietly slipped into the scene to save us all. Available on the newer PC's, probably Pentium II's and above, and Apple's iMac, it is supported by the latest edition of Win '95, Win '98, the latest version of Mac-OS and possibly current versions of other major operating systems. Essentially the USB system will make adding most new peripherals as simple as plugging in a telephone.

How? Well that is what I hope to share with you. And rather than just impart the overall architecture as you'll probably get from any electronics or computer magazine, I hope to share some of the actual methods of data transfer and electronic workings of the system to show you that, electronically, there is really nothing new about this system. It is based on technology that has been around for years and is well proven in other systems. You may find some of these systems in something you are repairing or you may include these techniques in your own designs.

So why could it be a new `Plug & Problem' I hear you say. The electronics of USB is pretty well defined and works very well, but USB is also heavily software based, both at the BIOS level and at the operating system level. So unfortunately we have to rely on the likes of Bill Gates and the other software manufacturers to provide us with `no faults' software to support this system. And as we already know, the software side of the PC is probably the most volatile part. To be fair though, I am led to believe that generally everything is going pretty well with the integration of USB into both the hardware and software side of the PC. USB is a big topic, and can't be done justice in just a few pages of our newsletter. I would like, therefore, to cover the architectural aspect of the system in this issue, in order that you can understand the basic workings of the system, and then add the details of the data encoding and transfer protocols in our next issue so you will be able to see them as part of a bigger picture. And so we move swiftly on.

So why is adding a new peripheral so complex?

Essentially, the reason we have so many problems is due to legacy issues. We could place every model of PC from the humble 286 to a sleek new Pentium machine on a desk and in each case you could point out the ISA, EISA and PCI bus, the serial port, the printer port, where to plug in the monitor and so on. In almost twenty years the PC has not really changed. And for good reasons too. To keep everything 'compatible' standards had to be set. But as time has gone by every function of the PC as been stretched, augmented and sped up for today's ever faster peripherals. The serial port, originally designed for your mouse and perhaps a serial plotter or printer, is now expected to handle high speed data transfer of Internet material. The printer port has been 'enhanced' to allow scanners and zip drives to be added. And although the expansion card slots have changed to provide for the ever expanding data bus, the interrupt support and memory locations available are essentially unchanged. Each port has its own connector type with or without twisted pair wiring, and partial or fully wired connectors. Most of the ports available support only one device and more often than not the device must be attached before your machine is switched on. Four gang mains leads soon become filled with power supplies and add to this messages about 'DMA and IRQ conflicts', if you understand what they mean, it is amazing we ever get anything to work. Even the introduction of 'Plug & Play' under Windows 95 didn't solve all the problems.

So how does USB solve all these problems?

Perhaps the most important thing here is that it doesn't. After looking at all the peripherals a user may wish to attach to their PC, the data transfer speeds that they require and the problems associated with adding those peripherals to a PC, a set of goals that the new system must achieve was drawn up. The result is a system which supports the majority of all peripherals available today, and has the capacity to handle the peripherals of tomorrow too.

The main goals of the USB system are listed below. Table 1 opposite is given as a reference to list typical data transfer rates required by today's peripherals in order that the following reasons for choosing the goals can be seen.

Speed Devices
10 - 100 kb/sKeyboard, Mouse, Stylus/Pen, Game Peripherals, Joystick, Virtual Reality, Monitor Configuration
500 - 10,000 kb/sISDN, Modem, Digital Audio, Scanner, Printer
25 - 500 Mb/sHard Disk, Real time Video, LAN, VDU

Table 1 - Typical PC peripheral transfer rates

The capabilities of the USB system mainly supports the products in the first two rows of table 1, leaving the high bandwidth devices to dedicated hardware.

Other systems are available but fail to give USB performance in some areas. Examples are:

Figure 1

The three lower lines reads at "logical" connection between driver and device; Physical connection between blocks; and Cable connection.

So how does USB fit into my PC?

The USB Host Controller and Root Hub are the central point of the USB system. The overall architecture is shown in figure 1. The USB system is a 'single master' controlled system. This means that only the Root Hub can initiate any data transfers on the bus. The Host Controller is responsible for turning the parallel data received from ' the USB System Driver Software into serial data to be sent over the USB Bus from the Root Hub, and turning bus data received from peripherals back into parallel data for the USB System Driver Software.

The USB System Driver Software is the 'brain' of the whole system. It is responsible for giving each new USB peripheral added a unique address, and finding out the type of device and specific needs of each device so that bandwidth and power can be made available for that device. It is also the link between the individual device driver software and the peripheral itself. It schedules all the data transfers that are required into 1ms time slots called "frames". It may be that a device drivers wish to send or receive data from it's peripheral will be completed in a single lms frame or will be split over several time frames. This is decided upon by the USB System Software through its knowledge of the requirements of each device on the bus, how many other data transfers need to be made and what priority those transfers have. The USB System Driver Software is closely tied in with, or is part of, the BIOS. This is necessary because peripherals such as the keyboard still need to function if the Windows operating system does not boot up and you have to start from a DOS prompt. The device driver software is nothing new to us. It is the software that links the operator or the operating system to the peripheral. The driver software is completely unaware ' of the USB system. As far as it is concerned it is actually talking to the peripheral it is written for. This is shown as a 'Logical Link' in figure 1. Increasingly we will see device drivers included in the operating systems (e.g. Win '98/2000), however some device manufacturers will still provide their own driver software.

Next we move on to the peripheral end of the system, in this case a printer. The peripheral is made up of several parts. The first is an analogue section to receive and transmit the data on the cable link, or USB Bus, to the PC. This is connected to a digital logic hardware section to decode the information sent and extract the data from all the packing. The packing is all the error checking and USB specific system information. Once the data has been successfully recovered it will commonly be passed to a combination of hardware and software, most likely in the form of a microprocessor or micro controller, which will deal with the functionality of the device, and possibly some USB specific protocols too.

Figure 2

USB chips for peripherals vary from simple 'USB to 8-bit data converters' to micro controllers with an integrated USB node. The design of a USB peripheral is left to those highly experienced in electronic design, micro controller programming and PC software programming since the driver software for the peripheral may or may not already exist.

The Hub is a special device in the system. The hubs are intelligent. They keep track of all the devices which are connected to them, help to ensure that current limits are adhered to, disconnect devices which fatally fail on the bus and act as repeaters of the data which is being sent upstream or downstream on the bus. The hubs can use power from upstream, be self powered, or be integrated into a peripheral such as a monitor, printer or keyboard.

The topology of the system is called a "tiered star". The interconnections between tomorrow's peripherals may look a little like that shown in figure 2. The monitor is included here, which may take you by surprise as you'll remember the monitor or VDU was in the last row of table 1. You'll notice, however, that the video signal is still supplied by a standard PCI video card. The USB connection is used for controlling the monitors' functionality, for example the screen resolution. Also the network connection is still provided by a PCI ' expansion card.

One other important point which is shown in figure 2 is the way the two connector types, A and B, are used in the system. A peripheral such as a mouse may have a fixed lead terminated in a type A plug, where as a peripheral such as a modem without a fixed lead will have a type B socket and will be supplied with a type 'A to B' cable. The purpose behind this is to stop two type A sockets being connected together, and more importantly, two PC's. Also, the maximum length of cable that can be used to connect two devices together is 5m. The length cannot be increased beyond this due to the problems caused by transmission line effects. To attach a peripheral further away than 5m a hub should be placed in between to repeat the signal. Also, due to the time delay along the transmission lines and delays in the hubs themselves, no more than five hubs can be supported along any single path through the system.

Until next time..

Well that's all for now I'm afraid. I hope this has given you a taste for the USB system and how it works. Next time I will be covering the details of the signalling, data encoding and other internal architecture details. If you have any further questions about USB try the USB website at www.usb.org. If you have any queries about the system, my explanation of it here or any other questions about USB which you cannot get answers to then please email me at Stuart.Cording@nsc.com so that I can either include further details in the next article, or I will return an answer personally.

Glossary:
DMA - Direct Memory Access - System where a peripheral can store information directly into the processors memory without processor intervention.
(E)ISA - (Extended) Industry Standard Architecture.
IRQ - Interrupt ReQuest - Signal `a peripheral provides to the processor to request that it should be serviced. This will interrupt the processors current activity temporarily.
kb/s - kilobits per second (1024 bits every second).
kB/s - kilobytes per second (8192 bits every second).
Mb/s - megabits per second.
PCI - Peripheral Component Interconnect.

Stuart Cording is studying Electronics Engineering at De Montfort University, Leicester.

References:
USB Specification Vr 1.0 1996
USB System Architecture - D. Anderson, Minshare Inc. 1997