Posts

Interfacing MIDI devices with Arduino using USB Host Shield

Another popular USB peripheral code for USB Host Shield has been implemented! Collin Cunningham from Collin’s Lab @ MAKE found a neat way of interfacing USB MIDI devices with Arduino. The video above demonstrates using Akai LPK25 keyboard and USB video game guitar to play music on Arduino. Quoting Collin, his setup is “USB MIDI to old-school MIDI converter”.

Make sure to check out Collin’s code – it’s one-piece sketch, short, clean and easy to understand. It is Richard Ibbotson’s PS3 code, re-purposed to parse MIDI data. While not a textbook implementation of USB MIDI, Collin’s code can be used to talk to MIDI keyboards, guitars, and consoles, to name a few. Good job, Collin!

Oleg.

Linear power supply on USB isolator board.

Linear power supply

Linear power supply

Several days ago I received an e-mail from Larry Owens, my fellow Coloradoan. Larry is Hi-Fi enthusiast; he built USB isolator kit and made very elegant and clever modification to it – a linear power supply. Larry’s design fits on existing board footprint.

Here is a quote from Larry’s e-mail:

Thought you might like to see what a little creativity can yield — did not fancy a SMPS’s noise, but wanted to be able to handle various battery sources. Since the off-board supply would be rather quiet, just selected a plain old 7805C (found in drawer, able to dissipate plenty of heat w/ 12v+ supplies and full 500mA USB loads). Thought a power-up LED would be nice too… …the challenge was to find existing pads for all components without having to use any cut/jumps… do consider that outcome lucky at the least…

Take a look at the title picture (click on it to make it bigger). TO-220 next to the barrel connector is old trusty 7805 linear regulator. Small bypass capacitor is soldered between output and ground pins of it. Input and output pads are occupied with electrolytic caps, 100 ohm ( @100 MHz ) ferrite bead sits on inductor pads. Finally, a small LED is mounted in place of 3300pF cap with current-limiting resistor across LT1376 pins 7 and 8.

This is it – simple, elegant and very useful. Thanks again, Larry for sharing the design and very nice and clear picture!

Oleg.

Bluetooth code for Arduino USB Host

Arduino to Bluetooth connection

Arduino to Bluetooth connection

[EDIT]The standard RFCOMM/SPP implementation is available in rev.2.0 of the library.[/EDIT]

I am pleased to announce addition of Bluetooth dongles to the family of USB devices supported by USB Host Shield. Bluetooth dongles are affordable, interface is well documented, and USB transport layer is very simple. Even though full Bluetooth protocol is heavy and takes a lot of program space, it can be stripped down quite a bit for a particular application. One good example of such approach is Richard Ibbotson’s HID over Bluetooth implementation – see Wiimote Game Controller Interfacing article for details. I wanted to have simple communication transport over Bluetooth which would fit into Arduino and the code I’m presenting in this article is doing just that – it’s lightweight terminal program allowing two Arduinos talk to each other over Bluetooth. The code has been developed by George Lgotkin.

The source is hosted in GitHub repository. Standard Arduino library format of the code has not been tested yet, for now it’s easier to just copy all the files in a directory and open btclass_h.pde in Arduino IDE. To use the program, you need two Arduinos, two USB Host Shields, and two Bluetooth dongles. You need to compile and load the sketch into both Arduinos and then open two terminal windows, one to a serial port of each Arduino – this can be done from a single computer. Don’t use Arduino IDE built-in terminal. Also, SPI library shipped with recent versions of Arduino IDE is not compatible with USB Host library, if you have compiler errors related to SPI, replace your library with one from Arduino-0018 or the Playground. Serial port speed is set to 115200 in the sketch, it can be changed in setup(), if necessary.

Sketch starts by printing short help (see screenshot below) and then waits for the command. In order for two Bluetooth devices to talk to each other, one has to be the server and another one client. In one terminal, type ‘S’ and press Enter. This starts the server. If you are curious, type ‘M’, Enter – the address of the module will be printed. Note that if you send address request before starting the server, address containing all zeroes will be returned.

To establish connection, type ‘C’, Enter in other terminal. The sketch will print “Connecting…”. After some time ( 30 seconds or less ) both terminals will print “Connected”. Now type something in one terminal and press Enter – the string you just typed will appear in other terminal window. Easy.

This code is just a small example, error handling is minimal. It works better if no other Bluetooth radios are transmitting nearby. If client Arduino reports “Connected” but server doesn’t, it means that client has connected to some other server, most likely your laptop or phone. This can also be used to your advantage for testing – start Bluetooth on a PC and then see if both Arduinos are able to connect to it in client mode.


Continue reading Bluetooth code for Arduino USB Host

USB Isolator Assembly Guide

Soldering ADuM4160

Soldering ADuM4160


Long overdue USB Isolator Assembly Guide is finished. It describes building Analog Devices ADuM4160-based USB Isolator kits. The guide contains component identification, step-by-step building instructions and soldering hints. Those who has their isolators already built will find useful powering and tweaking information at the end of the guide.

If you see any errors or have any questions, please let me know!

Enjoy!
Oleg.

Digital camera control using Arduino USB Host Shield. Part 2 – Canon EOS Cameras.

ptptask2
New version of PTP Library for Arduino USB Host Shield has been posted on GitHub. In this version, PTP::Task() has been completely rewritten to provide for non-blocking state machine-type execution. Another major addition is comprehensive support for Canon EOS cameras – many camera functions including changes of shooting parameters, Live View, focus move, are now well understood and supported. The library is released under GNU General Public License version 2.

In addition to the code library, a manual page has been created outlining EOS-specific extensions to PTP protocol, a code example, and library reference. Similar page for basic PTP functions is planned also.

The code is stable (more or less) and no application interface changes are planned at this moment. It is, however, incompatible with an old version, which is preserved in “legacy” branch of GitHub repo. The camera interface has not changed much and migration of old projects should be easy. If you have issues with migration, comment below and I will try to help.

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.

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.

Digital camera control using Arduino USB Host Shield. Part 1 – basics.

Arduino taking picture of itself

Arduino taking picture of itself

I’m starting new series of articles describing exciting field of digital camera control. In modern cameras, USB port can be used not only for transferring images to a PC, but also for sending control commands to the camera. It is often possible to send commands which “press” the shutter button, modify shutter and aperture values, some cameras are even capable of doing focus control. At the same time, new shooting techniques, such as HDR and stacked focus, require that a photographer makes several shots, slightly modifying one or several shooting parameters from shot to shot. Even age-old time lapse technique could use some automation. Since camera manufacturers are, as always slow to implement there cool features, Arduino comes to the rescue.

I am announcing new code developed for Arduino USB Host shield which implements digital camera control functions via PTP. Alex Glushchenko, a developer from my native Russia, recently joined camera control project and code shown here and in the future articles is mainly his. He did most of reverse engineering and code development and my contributions to this project were mainly code testing, camera borrowing, and blogging. Code is hosted on github separately from USB Host library. Be warned – this source is preliminary and will be changed many times before it becomes stable! It is also expected to grow quite a bit – different cameras use different commands and developing universal code supporting all manufacturers (or even every camera from one manufacturer) is not possible due to the modest resources of Arduino platform. Therefore, several libraries have been developed, each covering specific set of cameras. The cameras supporting functions of a certain library are listed in library’s header file. The list of cameras is currently quite small but I’m hoping to get more cameras supported in the future.

Digital camera as USB peripheral is much more complex and less standard than a keyboard. The complexity starts at the very first level – device configuration. Very often , several different configurations are supported on a device and the default configuration is not the one we need. Therefore, the first step would naturally be learning how to recognize configuration which supports camera control commands.

There are 3 specifications describing USB digital camera works. Still Image Device specifies USB requests, descriptors and endpoints. The protocol structure is described in Media Transfer Protocol (MTP), which is better known by its previous name, “Picture Transfer Protocol” (PTP). The most interesting document, which actually lists commands supported by camera class, is known as “PIMA 15740-2000”. It is available for a fee from I3A, however, second-hand pdf copy can be obtained for free after some googling. Camera manufacturers implement their own functions, expanding PIMA definitions. In addition to that, some older cameras use their proprietary protocols instead of PTP; support for such cameras will be added eventually.


Continue reading Digital camera control using Arduino USB Host Shield. Part 1 – basics.