Posts

HID support for USB Host Shield Library 2.0 released

HID r.2.0 released

HID r.2.0 released

I pleased to announce that after a long and difficult development period Human Input Device AKA HID class support has been added to USB Host Shield Library r.2.0 and is available on gitHub – I suggest downloading the whole directory, since some modifications has been also made to core files to accommodate a new class. HID devices include popular devices like keyboards, mice, joysticks, game controllers, bar code scanners, RFID and magnetic card readers, digital scales and UPSes, to name a few.

I previously wrote about interfacing to HID devices here, here, and here. The code examples in these articles were written for legacy USB Host Shield library and can’t be compiled with current revision, however, the basic principles are the same – the device is periodically polled by the host and sends back data block called report containing changes in device controls (buttons, switches, jog dials etc.) since the last poll. Even though different devices have different report formats, for a certain device, report format is stored in the device in data structure called report descriptor. Therefore, it is possible to learn about device controls from the device itself by parsing its report descriptor.

There is one special case where report format is known in advance. Almost all HID keyboards and mice support so-called boot protocol intended for communication to very simple systems like PC configuration screen when computer runs from BIOS. Keyboard boot protocol report consists of 8 bytes containing state of modifier keys (CTRL, SHIFT,etc.) in the first byte, second byte being reserved, and up to 6 key scan codes in the rest of the report. Mouse boot protocol report consists of 3 bytes, first of which contains state of left, right and middle buttons and other 2 store X and Y travel since last poll.

In many cases boot protocol capabilities are more than enough for an Arduino project; for this reason, boot protocol class is the first to be released. To demonstrate operations of this class, 2 simple sketches has been developed, one for mouse, another for keyboard.

Continue reading HID support for USB Host Shield Library 2.0 released

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.

Arduino USB Host Mini – first prototype.

First prototype of USB Host Mini

First prototype of USB Host Mini

This is the status update on Arduino USB Host Mini development, announced 3 weeks ago. I received rev.0 PCBs last Saturday – BatchPCB is faster than ever! I made a test build (see title picture) and after fixing one major and several minor mistakes placed an order for what I’m hoping will be the final pre-production sample.

The prototype was built to sit on top of Arduino Pro Mini to make access to the parts easier during troubleshooting. On the final board USB connector is placed slightly further away from the pins; it will be possible to place Arduino on top of the shield so that the height of the “sandwich” will be less or equal to the height of USB connector.

In 2-3 weeks I’m hoping to finalize the design and start producing the USB Host Mini. Stay tuned!

Oleg.

Controlling robotic arm with Arduino and USB mouse

Many people asked me to post a video showing an arm from inverse kinematics article in action. While making a video, I realized that shots of the arm following a pattern of computer-generated coordinates is going to be less than exciting and decided to add manual control. The video below shows the result. In addition to the video, a HID introductory page has been written describing HID communication basics as well as some simple Arduino code. Enjoy! ( Youtube link, where HD quality video can be selected ).

Arduino sketch written for this video is on gitHub.

Arduino USB Host Mini – initial revision

USB Host mini rev.0

USB Host mini rev.0

This post announces starting of development of new Arduino USB Host Shield variant. There are several projects in the works (thanks, guys for letting me know!), where standard size Arduino board is too big. Since electronics of USB Host Shield is pretty simple, it was decided to shrink the board as much as possible. Here is the first iteration.

The initial revision of USB Host Shield in Mini form factor is shown on title picture, It is intended to be used with Sparkfun’s 3.3V Arduino Pro Mini. Intended applications include digital camera control devices, robots, as well as any other projects where size and weight has to be minimized. The Gerbers was sent to BatchPCB; I’m expecting boards back in couple of weeks. The main goals of this first prototype are manufacturability check as well as checking claims made below.

The Mini Host is simplified version of full-sized shield; only USB and GPIO are available. By default, VBUS is routed to VCC, therefore only self-powered USB devices are expected to function (even though I have at least one USB flash drive which works fine powered from 3.3V VBUS). I also provided extra pads to simplify signal re-routing, however, since there was no place left for jumpers a trace has to be cut instead. The same has been arranged for VBUS – if 5V power is necessary, Arduino Pro Mini/Shield combination can be powered with 5V on RAW pin, the VCC trace cut off VBUS and RAW and VBUS connected.

As soon as first prototype is tested, I will post CAD files and also make boards available at BatchPCB. Stay tuned!

Oleg.

Towards an FT232 Driver for the USB Host Shield- Part 0

FTDI232RL IC on a breakout board

FTDI232RL IC on a breakout board

Based on some discussion on the Arduino Forum, Richard has added this blog entry as work in progress on developing a library to support FTDI Serial port devices on the USB Host Shield. While cautious to publish at this early testing stage, the content here should help parallel developers.

My thoughts last year were that an FT232 driver for the Host Shield was not really useful. It seemed rather reverse to add a USB host plus a USB device to achieve something that can be done with a piece of wire. However USB is coming to be the baseline interface and is now the only interface offered on many serial devices.

USB Shield Hardware
Since my last blog update, Sparkfun have released their own version of the USB Host Shield. Great to have another source of the shield, with good stock at many International Sparkfun distributors. However they did add a couple of problems too:
Sparkfun swapped the RESET and the GPX pins from the original from Oleg. This means the shield will not work with the libraries from Oleg without a modification.
The current Max3421e_constants.h from Oleg has:

/* Arduino pin definitions for USB Host Shield signals. They can be changed here or while calling constructor */
#define MAX_SS 10
#define MAX_INT 9
//#define MAX_GPX 8
#define MAX_RESET 7

These work for the shield from Oleg, and existing published code and libraries without change.

However for the Sparkfun Shield they must be changed in Max3421e_constants.h, or optionally changed when the constructor is called to:


#define MAX_SS 10
#define MAX_INT 9
//#define MAX_GPX 7
#define MAX_RESET 8


Continue reading Towards an FT232 Driver for the USB Host Shield- Part 0

PTPDevinfo in 16K

Blue Arduino USB Host Shield tied to telephoto lens mount

Blue Arduino USB Host Shield tied to telephoto lens mount

Developer Si Li shared his version of PTPDevinfo.pde, which fits into older Aduinos. Si wanted to get PTP device information from Canon EOS 500D, but he only has 16K Seeduino at hand. So he stripped devinfoparser off all unnecessary strings leaving only ones essential for parsing Canon EOS camera device info.

The modified devinfoparser files are available from “Downloads” section.

Troubleshooting Arduino USB Host Shield

USB Host Shield in a test fixture

USB Host Shield in a test fixture

[EDIT]This article covers revision 1 of the shield. Current revision (2.0.x) is slightly different and works under different software. The following test routine shall be used to test the board and generate test signals.[/EDIT]

Making electronic devices requires close interaction with parts – reversing supply polarity, overloading inputs, and inadvertently shorting pins with test leads. Consequently, occasional destroying of parts is natural and shall be anticipated. I have been in correspondence with several electronics enthusiasts helping them getting their shields fixed and since their problems look similar to what I see when doing post-manufacturing quality control I decided to share my testing procedure along with some pictures.

In the past, it was customary to include schematic with every electronic device documentation. Complex devices, such as oscilloscopes, spectrum analyzers and other test instruments used to have service manuals containing detailed calibration and repair procedures. At some point, service manuals and schematics disappeared from the documentation for various reasons – equipment users were left to deal with manufacturer’s support or rely on their own reverse engineering skills. With open source movement and general understanding that sharing information is beneficial, manufacturers resumed publishing schematic diagrams of their creations. This article presents next logical step – a service manual for Arduino USB Host Shield, sort of.

Much of the testing is performed using board test sketch, available from examples section on github. Two files are necessary – board_test.pde and board_test.h containing diagnostic messages. The sketch tests 4 major parts of the circuit – SPI interface, general purpose input/output pins (GPIO), quartz crystal oscillator, and finally USB SIE. The main loop is written so that any test can be turned off if necessary by commenting out a single line. GPIO lines are checked using a loopback adapter – a thing that connects GPIN0 to GPOUT0, GPIN1 to GPOUT1, and so on. This test is made optional – if you don’t connect GPIO lines as described, the test will print an error message and continue with the next test. Also, GPIO test is placed between short and long SPI tests. The reason for this is that due to MAX3421E internal organization both short SPI test (reading REVISION register) and GPIO read/write doesn’t require working crystal oscillator, whereas long SPI test (reading/writing any other register) will fail and stop if crystal is defective. Therefore, when I see short SPI and GPIO tests passed and long SPI test fail I know that it’s actually a crystal which is dead, not SPI.

In addition to board test program, you will need a multimeter with thin sharp test leads to measure voltage and resistance between board elements. Some of them are quite small so a magnifier is also handy. Certain steps of the test procedure call for time-base instrument. Modern digital mixed-signal oscilloscope is the best choice, however, since very few people can afford one, a method of visualizing SPI traffic with plain analog oscilloscope will also be demonstrated. Logic analyzer is handy, but optional. For testing USB transactions you will also need some sort of device connected to shield’s USB connector. I usually use USB flash drive as a test device.

The article as well as board test program is written for worst-case scenario, i.e., shield which was built from scratch or came from major rework like MAX3421E replacement due to applying 5 volts to 3.3V pin. The test program works the same way with all four configurations, however, manual tests are shown only for “Simple” configuration, i.e. one with level translators and receiving both 3.3V and 5V from Arduino Duemilanove or similar (no DC-DC converters). Testing other configurations is slightly different and will be noted in the text. Also, “Minimal” configuration calls for specific type of test device – I use digital camera.


Continue reading Troubleshooting Arduino USB Host Shield

Next revision of USB Host Shield goes to production

A panel of rev.1.21 shields

A panel of rev.1.21 shields

I’ve been working lately on improving manufacturability of my products. As a first result, I’m changing board revision of USB Host Shield to 1.21. The main difference between revisions 1.0 and 1.21 is level converters and jumpers in SMT packages. Picture on the right shows the very first panel of rev.1.21 board fresh from the oven.

Functionally, the board is the same. However, schematic has changed a little in part where control signals go through level converters. Therefore, it is important to use the right schematic when troubleshooting or hacking the shield. Downloads section has been rearranged and documentation for both variants added and labeled. I also posted closeup pictures of new board in store listings for the shield and bare PCB. I still have several rev1.0 boards available, they should be all gone by the end of the week so when you buy a board this week, you may get an old version. If you have a preference, let me know.

Lastly, from now on USB Host Shields comes bundled with stackable headers, the famous 4uconn part numbers 18688 and 18689. “Bundled” here means that by default they come in a bag, un-soldered. However, if you prefer, I can solder them for you – send me an e-mail after the purchase stating that you’d like your headers soldered and indicate the direction, female or male side up.

Oleg.

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.