Posts

USB Host Shield in store.

Four configurations in Arduino blue

Four configurations in Arduino blue

[EDIT] This post is about legacy product which is no longer supported. Visit USB Host Shield project page for up-to-date information[/EDIT]

Arduino USB Host Shields are in the store. If you are not yet familiar with the project, please browse “USB Shield” category of the site and read the articles. In short, the purpose of this shield is to add USB Host interface capability to Arduino. The software libraries for this shield currently support control and bulk-in transfers, while bulk-out transfer is in the works. Access to GPIO pins of MAX3421E is also supported. Sketch examples, demonstrating USB device control queries and polling USB keyboard, are published. More code will be developed in the future.

At present, four configurations of the shield are available. The first one, called “Minimal”, contains USB core components only. It is compatible with 3.3V Arduinos, such as Arduino Pro from Sparkfun. Also, since no 5V is available, only communication with self-powered devices is possible. Moreover, not every self-powered device would work in this configuration. For unknown reasons, some external hard drives refused to answer until VBUS voltage was raised to 5V. On the other hand, all printers and digital cameras that I and several beta-testers tried worked fine as well as other people’s external hard drives. “Minimal” configuration is the best one for battery-powered projects since 3.3V Arduinos consume less electricity.


Continue reading USB Host Shield in store.

Arduino USB Host – Peripherals.

USB constructor

USB constructor


The time has come to start using the code to communicate to peripheral devices. There are many devices which work well with microcontrollers. HID devices, such as keyboards, joysticks, and Radio Controller look-a-likes are useful and not too difficult to implement. Another good application of embedded USB host is digital camera control. Communication using Bluetooth and WiFi peripherals are also a possibility.

Today I’m going to show how to communicate with USB keyboard. Standard USB keyboard belongs to a class of devices, called HID (Human Interface Device). The format of data generated by HID device is quite flexible and each device stores it’s data definitions in structures called Report descriptor and Physical descriptor. Generally, to work with the device, report descriptor has to be retrieved and parsed. Because of HID flexibility, a universal HID driver will take many many lines of code. Luckily for us, if all we need is to talk to the keyboard, there is an easier way.


Continue reading Arduino USB Host – Peripherals.

Arduino USB Host Shield build log. Part 4.

Layout closeup

Layout closeup


Release candidate 1 boards has been received, built, tested, and came out green wire free – at last! I placed an order for a small batch with board house and expect PCBs to be available in a couple of weeks. I am making second call for beta testers – if you write code and/or blog, drop me a line with a link to your blog and your voltage preference for the shield – 3.3V or 5V. I have more 3.3V boards left from prototyping so naturally people requesting 3.3V boards will have more chances to get one.

Updated Eagle and Gerbers are available in Downloads section. If you don’t have Eagle, here is the PDF of the schematic. Please make sure you are not using scematic posted in one of the previous articles – there are quite a few changes.

In this article I want to give an overview of the board and it’s features. I’d like to start with most complicated part, which is power configuration. First of all, the USB core part of the shield (MAX3421E) requires 3.3V to function. Second, bus-powered USB peripheral requires 5V on Vbus. However, to use self-powered USB peripheral we only need to connect 3.3V to Vbus to be able to see speed-setting pullup resistors. Consequently, for digital camera control applications, shield can be mated with 3.3V Arduino (like Sparkfun‘s Arduino Pro) with no additional power supplies.


Continue reading Arduino USB Host Shield build log. Part 4.

Arduino USB Host Shield build log. Part 3.

USB Host Shield prototypes

USB Host Shield prototypes

Making functional 5V version of a shield proved to be difficult. I was hoping to publish a release after building previous protos. However, it turned out that together with fixing old errors I managed to make several new ones and also missed a couple from previous prototyping cycle. So, in order to produce a proto containing less errors than a previous one, I spent a great amount of time checking everything I could think about, writing test code, running those tests against prototypes, and then repeating them on all possible mixes of available Arduinos and voltages.

Also, I found that USB-B connector on Duemilanove shorts GPIN contacts on a shield. Cover top of the connector with piece of Scotch tape, if you haven’t already.

Today I placed an order with BatchPCB to what I call “Release candidate 1”. I am hoping this is a design which will be released when I get it back in 3 weeks or earlier( BatchPCB is getting faster ). Also, I forked previous repo containing Arduino libraries, the current development is now contained in USB_Host_Shield. I removed Vbus power control support since it’s not implemented on a shield and added functions for GPIO pins read/write. I’m freezing previous repository to support old sketches.

While waiting for PCBs I will continue working on HID code for the shield and also write a library to control LCD/buttons via GPIO pins. Stay tuned.

Oleg.

Arduino USB Host Shield build log. Part 2.

USB Host Shield prototypes

USB Host Shield prototypes

I finished building Arduino USB Host Shield prototypes. Functionality has been tested, errors found, fixed, and 1.0rc boards ordered. Title picture shows two prototypes, 3.3V sitting on top of Arduino Pro from Sparkfun and 5V on top of Duemilanove (bought at Sparkfun also).

As you can see, the biggest amount of errors has been made in 5V part of the circuit. To be honest, I’m not quite sure all of them are fixed. At some point I decided to stop messing with temporary fixes and order a board – if anything is still not right, I will find out later.

One of the goals of this build was to test 3.3V to 5V DC-DC converter (schematic). You can see it populated on 3.3V shield. It can be used on 3.3V-only systems to provide power to Vbus. This converter is designed around LTC3426, delivers ~700mA (slightly more than needed for powering Vbus) and runs cold with 90-94% efficiency. Output ripple was measured at 25mV. Note of caution: you should expect stability issues when powering such setup from USB (for example, during development) – in one of my tests Arduino was regularly rebooting during USB drive connect.


Continue reading Arduino USB Host Shield build log. Part 2.

Arduino USB Host Shield build log. Part 1.

5V to 3.3V converter

5V to 3.3V converter


Parts has arrived yesterday and I started test-building my USB Host Shield prototype PCB to check functionality and buildability. Since design is not final, I’m not publishing Eagle files yet – they will be online as soon as I get all errors fixed. In the meantime, the PDF of the schematic diagram is available.

One of the goals of this design is to make it compatible with both 5V and 3.3V Arduinos. Since MAX3421E is 3.3V part, I added some extra circuitry to provide 5V compatibility.

I started my testing by building 5V to 3.3V converter piece to check parts values and circuit layout. The circuit is located in the upper-left corner of the schematic and in the lower-right corner of the board. Please also take a look at the title picture if you haven’t already to see the layout. This converter comes in handy if, for example, you are using 5V Arduino and/or need to provide Vbus power for bus-powered peripheral and want to use this supply to power the shield/Arduino also. Converter is rated for 600ma, enough to power both MAX3421E and Arduino, if necessary.


Continue reading Arduino USB Host Shield build log. Part 1.

USB Host Shield for Arduino – first prototype.

Arduino USB Host Shield PCB

Arduino USB Host Shield PCB


While developing Arduino code for MAX3421E USB Host controller I was thinking about making a shield for it. Sure, breakout board riding on top of protoshield works just fine, however, some people don’t like the wire clutter. Additionally, since many Arduinos are 5V devices, level translation may be necessary. I was playing with different configurations, and routed a draft prototype to build and see how it would look like. I received PCBs today from BatchPCB – just in time before the weekend.

In addition to MAX3421E with accompanying parts, the shield contains level translating logic for all signals and GPIN/GPOUT ports, and 3.3V to 5V step-up and 5V to 3.3V step-down converters. I decided to use DIP packages for level translators – this way if translation is not necessary, the PCB can be simply modified with jumper wires.

I’m going to start building/debugging this board today and produce final version in 2-3 weeks. After that, the plan is to order a batch of boards, build them and send to beta testers. If you want to participate in testing, leave a comment and I’ll put you on a list.

Oleg.

Arduino USB Host – USB Descriptors.

Get device descriptor trace

Get device descriptor trace

I finished porting USB transfers from PIC C to Arduino C++. There is now a USB class in the repository. Two main types of USB transfers – control and bulk, are implemented. If you want to know more about USB transfer mechanics, take a look at this article. The code was written to work on Microchip PIC, however, the Arduino code is almost identical.

Since we now have tools to talk to USB device, let’s start using them by looking at USB descriptors. In order for sketches from this article to work you need to copy current repository contents ( *.cpp and *.h files ) to a sub directory in your Arduino hardware libraries directory. In addition, don’t forget to supply 5V to Vbus and connect a USB device, such as flash drive or mouse to USB connector of a breakout board.

First sketch demonstrates access to device descriptor. Device descriptor is the first descriptor that the host retrieves from the device during enumeration. The information which host needs is device endpoint zero maximum packet size. In this example, maximum packet size is already set by a function in USB class, called “Task”. In addition to maximum packet size device descriptor contains other information, used during device configuration.


Continue reading Arduino USB Host – USB Descriptors.

Arduino USB host – First programs.

MAX3421E on a protoshield

MAX3421E on a protoshield

I started porting my PIC USB host code to Arduino platform. There is now a repository on GitHub. Right now it contains a single class of functions talking to MAX3421E. This is not enough to support full USB host functionality, but enough to get started. To follow examples given in this article, create a sub-directory in your Arduino hardware libraries directory and copy MAX3421E*.* files from the repository into it.

MAX3421E talks to Arduino via SPI, so you will need Arduino SPI library. SPI uses pin13 – a pin also used to blink LEDs. Some Arduinos even have this LED hard-wired to pin13. My Arduino has it, and it co-exists peacefully with MAX3421E, however, there is no guarantee it will work on others. It would depend on current drawn by the LED. If you have problems communicating with MAX3421E and/or you can’t see SPI clock on this pin with your oscilloscope or protocol analyzer, try to disconnect the LED and see if it changes anything.

Picture on the right shows the final arrangement. The breakout board sitting on top of protoshield is a 3.3V part. Since I’m using 3.3V Arduino Pro from Sparkfun, no level converters are necessary. Look at the previous article for the closeout picture and schematic. The breakout receives power from Arduino.


Continue reading Arduino USB host – First programs.

Arduino USB host – Pre-prototyping.

Arduino USB Host Shield prototype

Arduino USB Host Shield prototype


I have been thinking about expanding ways to use my recently conceived USB Host controller based on MAX3421E. Nice and very popular AVR development platform called Arduino looked like logical target. After quick Internet search, I went to SparkFun to pick up an 3.3V 8 MHz Atmega168 Arduino Pro, a protoshield, and USB to serial cable. After checking that everything works fine together, I populated a MAX3421E breakout and soldered it on the top of protoshield ( see schematic ).

I wanted to make a quick prototype and not worry about level translation for now. Arduino Pro is 3.3V and is able to talk to MAX3421E directly. The circuitry to adapt this shield for 5V Arduinos will be added later. This is going to be interesting since MAX3421E is not only a USB controller but also a port expander. It provides 8 general purpose outputs and 8 inputs, which can be configured as interrupt sources, all accessible via SPI. I’m using 1 input and 1 output for Vbus tracking, the rest is available for general use.

In order to use Atmega’s SPI peripheral I imported SPI library from Arduino playground. The default initialization will work. Below is the quick sketch that I wrote to make sure that MAX3421E is talking. Here I’m defining pins, setting initial state, and configuring MAX3421E SPI to full-duplex mode. This is not the right way to initialize MAX3421E, however, the beauty of this controller is that its SPI subsystem is separate from the rest of the chip and will work in any state as long as power is applied. No fancy resets are necessary.


Continue reading Arduino USB host – Pre-prototyping.