In recent years USB has taken the place of traditional serial standardsas the main communications protocol between devices. Lately, there hasbeen an increase in the market demand for products to support USBdevices like keyboards, printers, and memories; or for products tocommunicate with a PC through the USB interface.
Since its introduction more than a decade ago, the UniversalSerial Bus (USB)protocol has become a technology “rockstar”. Walk into any electronic store and most likely one out of threedevices has a USB port.
It started as a substitute to old communications ports on the PCsuch as RS232 and the parallel port to meet the new demands of the PCmarket. And since then it has been used in everything from coffee mugwarmers to 10GByte hard drives.
The USB specification defines everything from mechanical connectorsand cables, all the way through operation of the system, networklayers, and power management. We will review some of these issues inthis article and look at some example im[lementations.
The USB standard was officially introduced in 1995 by a consortium formby seven computer and telecommunication industry leaders: Compaq, DEC,IBM, Intel, Microsoft, NEC and Northern Telecom. Since then it hasgrown to more than 1000 members in the USB implementers forum (USB-IF).
In 1996 the USB 1.0 standard was released specifying the mainaspects of the USB standard as we know it: support for 12Mbps highspeed bus and a low speed bus at 1.5Mbps, the definition of themechanical connectors, and the specification of the software stack.
By 1999 due to the popularity of the USB protocol and some problemsthat had been identified, revision 1.1 was released. This versionclarified some ambiguities regarding timing and corrected some problemsthat existed in the previous revision.
But not until 1999, when Microsoft and Apple incorporated the use ofUSB into their operating systems did USB find “stardom”. In the year2000, the USB revision 2.0 was released specifying the implementationof a 480 Mbps bus and backward compatibility with revision 1.1.
Later in 2001 the USB On-The-Go (OTG) supplementwas added. This was done to accommodate the increasing demand of USBhandheld devices and the need to have devices talk to each other. Someof the features include smaller connectors and more efficient powermanagement.
Last year in May, the Wireless USB standard wasreleased which is a point to point wireless communications link basedon the USB network protocol. Presently, there are a few IC companiesmaking parts for the standard but these are in their final testingstages.
The USB standard specifies a star network configuration where eachhub is the center of the star. The network has only one host persystem, typically this is the PC but with the introduction of the USBOn-The-Go (OTG) standard any device can be the Host.
The USB Bus can provide power to devices that connect to it. Itinitially provides 100mA. This power can be used by devices duringconfiguration. Once the device is configured, the bus can increase thecurrent capabilities to 500mA.
Power distribution is one of the nice features that the USBinterface provides. As mentioned before; there are many products in themarket that use the USB port for power alone, like lamps, fans, andcoffee mug warmers. This kind of appliance usually use less than 100mAsince they do not initiate any handshake with the host, neverthelessstill it is 0.5W.
Some groups are working on creating a new standard for Powered USBor USB PlusPower. The USB PlusPowerdesign would provide power voltages up to 24VDC and current capacity of6A. This is achieved by two additional wire pairs inside the cable andmodified connectors that are backward compatible with the standard USBconnector.
The growth of applications for the USB bus has motivated the USBorganization to specify certain standard for products that have similarcharacteristics, these groups are called classes. The creation of thesespecifications allows developers to create generic device drivers thatcould be used with different devices within the same class. A singledevice can belong to multiple classes.
Doing USB designs – some designguidelines
When starting a USB design, just as with any other project, one shouldask multiple questions that will help the designer to select the rightparts and architecture for the design:
* Isthis design considered a host, a device, or both?
* Is the instrument going to interactwith other devices or a PC?
* Are we communicating at low, full,or high speed?
* Is it considered a high power orlow power device?
* Is the architecture going to bebased on stand alone design ormultipleprocessors?
* If multiple processors are to beused, how do they interface?
* To which devices is the designgoing to interface? HID class?Mass-storage? Etc?
*Should there be a USB hub?
* Do we need the USB compliance orcould we live without it?
As you proceed in your hardware design and look for solutions, youwill encounter an unlimited set of possibilities either for a hostdesign or peripheral. The most simple of these options is to purchasean external USB conversion adapter that interface the communicationsinterface present in your design.
To do this, there are products from companies like B&B or Belkinthat convert USB to RS-232, or USB to Ethernet. Also there arecompanies that already provide solutions with USB interfaces to DAQsand motion controllers.
If the requirement is more stringent in cost and size, theseadapters can be implemented with a set of ICs, and the circuits can beintegrated with your present design. Some manufactures such as TI,FTDI, and Kawasaki provide solutions to convert USB signals to Ethernetor RS-232.
Other companies such as Philips, Micronas, Cypress, Atmel, andGenesis provide solutions for specific designs including Flash DriveInterfaces, Audio Codecs, and Smart Media.
If your solution requires a specific low-cost controller, companiessuch as Microchips, Atmel, and Cypress provide 8-bit ARM controllerswith built-in device interfaces, host controllers, or on-the-gocontrollers. These solutions usually integrate the physical layer andsome level of the error detection.
For more sophisticated designs, Freescale, Intel, TI, and NECprovide higher end controllers with 32-bit cores or DSPs that allow youto interface devices that are more complex and require more intensivecomputing power. The implementation of a USB interface does not onlyhave implications on the hardware but also has implications on thesoftware.
If the design for a USB peripheral, then you need to be sure thatthe software complies with the USB protocol handshakes and classdescription. Usually the main USB software effort involves providing adescriptor to the USB host and respond to the host instructions.
If the software being developed is for a host, the implications arelarger since the host is a more complex entity. The software in thehost must interface to the host controller (if it is another IC), theUSB protocol, and then the drivers for the device which may have tocomply with one of the pre-defined classes given by the USBorganization.
To assist the software development effort and minimize the risk ofmeeting deadlines, one can look at commercial software that is alreadyavailable, especially when developing a USB host.
One option is to buy software stacks from companies such asSoftConnex (owned by Transdimension) and Jungo. Depending on thecompany, they usually provide a stack that has been rigorously testedand can interface to either custom OSes or commercial ones. Alsodepending on their license agreements and business strategies, theyprovide different packages that include USB protocol only, USB classstacks, source code, or onetime expense.
Another option is to use a commercial OS such as WindowsCE, Mentor'sNucleus, Linux (commercial or not), etc. This option provides an OS andin most instances includes drivers that are available and tested. Mostof these OSes are already ported to selected microcontrollers. In someinstances, the only task left is to create the host controllerinterface since the host in embedded system designs is implemented witha circuit that it is not common for PCs.
Example 1: A USB Peripheral/Host
A biomedical instrument had the following requirements with regard tothe communications interface:
*Interface to USB printer
* Interface to USB keyboard
* Interface to USB Flash drive
* Interface to PC USB port
One special note is that the peripherals and the PC interface aremutually exclusive. All of these features could have been implementedwith cheaper and simpler technologies such as serial and parallelinterfaces, but a primary attractive feature was the standardizationand availability of products with USB.
The design had included a 32-bit microcontroller to do the mainfunctions of the instrument and the user interface. So at the beginningof the design, we looked at options of microcontrollers that had USBfeatures built in. Most of them only had USB device interfaces, and thefew that had host and device controllers were not available or weremore expensive than our final solution. So we selected a standard32-bit controller and looked for a peripheral IC that would meet ourspecifications.
To meet the above specification, we looked at multiple options andICs, mainly from Cypress and Phillips. We decided on the CypressEZ-Host solution (CY7C67300) because it had four channels which allowedus to interface all the peripherals at the same time. It also had a fewoptions to interface the main 32-bit microcontroller and our experiencewith their technical support has been great.
The diagram in Figure 1 below shows a high level design, it onlyincludes the flash drive interface, the other two interfaces are alsoattached to the EZ-Host.
We connected the Cypress part and memory mapped it into themicrocontroller memory space. Since we were connecting to off-the-shelfperipherals, we had to be cautious with the design of the power supplyand power management of the USB bus. We had to mitigate in-rushcurrents and limited the power consumption such that it did not drainour power resources.
The next task was to choose a software development path. If thisinstrument were a peripheral only, the software path would have beenmuch simpler since a peripheral only has to support a limited number offunctions to be USB compatible, mainly provide a descriptor and do somehandshaking.
But since this instrument also had host functionalities, thesoftware implications were large and became critical in the shorttimeline we had for its implementation. We evaluated off-the-shelf USBstacks, commercial OSes, and custom OSes.
The solution we came up with was to use a commercial version ofembedded Linux. This reduced the development effort of building the USBdrivers, it also gave us the flexibility to have drivers for a varietyof USB devices (printer, keyboard, and flash drive) that already exist,and it had a lower cost than some of the other software stacksavailable.
The only missing piece was the software interface required by thehost controller, but fortunately this was also provided by Cypress withtheir development kit for the EZ-Host controller IC. Then it justbecame a system integration effort.
Since this design other products are available in the market thatmight ease the design process. Among these, there is a controllerdesigned by GHI Electronics called USBWiz that can interface USBdevices and interface a secondary processor through a serial port.
Example 2: Software Power Switch
A biomedical instrument had several USB devices (a camera and a motioncontroller) all connected through a USB hub, built in.
As shown in Figure 2, below ,the design of the instrument required asoftware-controlled power switch and limited the number of cablesbetween the PC and the instrument to one. Also, the power switch meantthat it had to be powered from a second source since the main powersupplies were not supposed to be ON.
Our solution was to integrate the power switch to the USB bus. Thedesign was based on a Microchip PIC18F2455 which has a USB interface.The PIC was the interface to the USB port and it controlled a solidstate relay. This relay then switched the main AC power lines that werethe source for the main power supplies. We presented the device as aHID interface such that the software development effort on the PC wasnot a huge task.
Example 3: USB/RS232 Adapter
In another instance, a design came about that required a productupdate. The present product was instrumentation equipment that had aRS-232 interface to the PC (Figure 3,below ). The RS- 232 interface waspart of a proprietary circuit that was not well-documented, and theowner did not want to make much of the schematic available.
For this application we used a similar Microchip part to the oneabove. The reason this option was selected was were previous knowledgeof the vendor USB hardware, low cost, and flexibility to add newfeatures, such as more digital I/O lines and analog input. Othersolutions we could have used were RS-232 adapters from Belkin orB&B, but these were too big for the space constraints the designhad, ICs from FTDI and TI were also available that required no softwaredevelopment but the limitation was the digital I/O.
Example 4: USB Hub Design
In this application (Figure 4, below )lwe had a need to connect fourRS-232 devices into a highly integrated device that had a built in PC.Unfortunately the PC did not have any RS-232 ports. The only option wasto convert all the RS-232 lines to USB and put all off them through aUSB hub, such that we could connect it to the USB port of the PC.
For the RS-232/USB adapter we used a similar solution to the onementioned above. For the USB hub, we used a simple TI part numberTUSB2046, the reason we used this part was its simple integration, lowcost, and that it was USB 1.1 compatible. Other options were availablefrom Cypress and Philips, especially components that were USB 2.0compatible.
The USB protocol has features that appeal to both product developersand users, including bus powered devices, auto-detection, selfconfiguration, expandability, and speed. Of course, all of thissimplicity is at the cost of a more complex and expensive hardware andsoftware design than the older serial and parallel interfaces itreplaces.
The interface is flexible enough to use for common peripheral typeslike drives and keyboards, as well as custom, application-specificdesigns like medical instruments, instrumentation equipment, or coffeemug warmers with PID controls.
Allan Neville is a Sr. ElectricalEngineer with DesignContinuum, Inc. He has over ten years of experience developingembedded systems for medical and consumer products. He has worked on avariety of projects designing and developing analog and digitalcircuits, RF circuits, motion control systems, and PC interfaces. Healso has vast knowledge of firmware and software development.
References and resources
1) Universal Serial Bus Specification, Revision 2.0
2) USB Design by Example: APractical Guide to Building I/O Devices, SecondEdition by John Hyde
3) USBComplete by Jan Axelsonhttp://www.penram.com/PC-Communication/USB-Complete.asp
4) www.beyondlogic.org/index.html#USB ” Has a great USB reference and links to a bunch of vendors.
5) www.usb.org” Has all the standards and a few presentations that have usefulinformation
6) www.everythingusb.com” Has a lot of products and new applications for USB
7) www.usbman.com” Has a lot of developer tips and other useful stuff
This article is excerpted from apaper of the same name presented atthe Embedded SystemsConferenceBoston 2006 .