Posts

USB Host Shield 2.0 released

USB Host 2.0 connected to Arduino Mega 2560

USB Host 2.0 connected to Arduino Mega 2560

A major revision of USB Host Shield for Arduino has been released and is available in the store. The board’s improved layout makes this shield compatible with more Arduinos, makes it easier to use and opens new possibilities. The main differences from rev.1xx are outlined below:

  1. The SPI interface has been moved to ICSP header making shield compatible out of the box with “big” Arduinos – Mega and 2560. Standard size boards, such as Duemilanove, UNO, as well as clones with classic connector layout, are also compatible with this revision of the shield. This compatibility is maintained on a software level as well – all necessary code changes are performed using conditional compilation preprocessor directives.
  2. USB connector has been moved to the opposite side of the board. All external connectors are now in the same place making enclosure layout easier.
  3. MAX3421E RESET line is no longer handled by dedicated Arduino pin. While MAX_RESET pin is still used in current version of USB Host library, it will be dropped from the next major revision of the code.
USB Host Shield 2.0 with AVR Dragon

USB Host Shield 2.0 with AVR Dragon

Besides “Mega-formfactor” compatibility, connecting to Arduino SPI signals on ICSP connector has several advantages. First of all, in this layout traces are much shorter and as a result, the shield works more reliably at higher SPI speeds and/or larger signal and power noise. Second, since the 2X3 connector, which comes bundled with the shield, is of ‘stackable’ variety, it is possible to connect AVR Dragon or other ICSP programmer to Arduino while USB Host Shield is mounted – picture on the left shows the arrangement. Finally, pins 11-13, occupied by SPI signals on “classic” Arduinos, are vacant on Megas and also uncommitted on the shield. Therefore, they can be used for other purposes without USB library code modifications.

The shield comes in 2 configurations. One, called “Standard” is compatible with official full-size Arduino boards (Duemilanove, UNO, Mega, Mega 2560, and possibly others), as well as clones which supply both 3.3V and 5V to the shield. One example of such clone is BlackWidow; if you are aware about other compatible clones, please let me know.

Another configuration, called “3.3V” is designed for battery-operated projects. It is compatible with Sparkfun’s Arduino Pro 3.3V board (I’m not aware of any other 3.3V-only full-size clones). It also supplies 3.3V to VBUS instead of spec’d 5V, therefore some bus-powered devices may function erratically (but not necessarily; I actually use bus-powered USB flash drive during final testing of production 3.3V shields). Self-powered devices, such as digital cameras, usually don’t care about VBUS voltage at all. Additionally, board layout makes it possible to mount external power supplies to generate 5V from 3.3V and vice versa, if necessary.

The shield is compatible with current version of USB library. It is also very similar to rev.1.xx shield and information from previously posted articles is mostly valid for 2.0 board. Schematic and Eagle CAD files are also available for download. I am currently working on detailed description of the shield and hoping to get it ready in a week or two.

Along with this shield I will continue producing rev.1.21 board – there are still “not-so-compatible” Arduino clones around. However, next major revision of USB library will not be compatible with rev.1xx shields; it will be possible to make it work after minor hardware/software modifications.

As always, your questions and comments about the product are welcome and appreciated.

Oleg.

Updated USB Host library uploaded to gitHub

No SPI

No SPI

New version of USB Host library has been uploaded to gitHub. I managed to find a couple of bugs and solve some compatibility issues. The biggest change, however, has been made on the very lowest level of the library – SPI transfers between Arduino and MAX3421E registers.

From the beginning, USB Host firmware relied on Arduino Playground SPI library. Starting from version 0018 of Arduino IDE, this library became part of the distro. Two versions after that, Arduino team decided to re-write SPI library, among other things changing function names. As a result, USB Host code became incompatible with “stock” SPI library. To remedy the situation, I incorporated SPI routines directly into MAX3421E support code. The new code is independent of Arduino SPI library and builds correctly on “old” (i.e. 0017) and “new” (0021) versions of Arduino IDE. In addition to that, new code accounts for SPI pinout difference between Arduino variants and works on both Atmega 328 and Atmega 1280/2560 based boards. ( Note: the current rev1.x USB Host Shield still needs to be modified to work with Megas )

The new library can be downloaded from USB Host Shield gitHub repository. If you are upgrading existing installation of the library, please make a backup copy before downoading! I checked it against all code examples and USB devices in my possession and everything works without a hitch. However, code written with tight timing may stop working because of speed difference since new SPI routines are slightly faster.

As you can see in the title picture ( click on it to enlarge ), the line #include "Spi.h" is no longer needed. In next several days I’m going to update all USB examples on this site to match the new code. If you have any any problems with the library, please let me know!

Oleg.