Posts

RC car controlled by Wii Remote on Arduino

This is a quick post about another great project. Tomoyuki Tanaka AKA Tomo on this site, active in PS3 and Wiimote game controllers thread, AKA moyuchin on Youtube posted this little video of RC car controller made of Wiimote, Arduino Pro Mini and USB Host Shield Mini interfacing with Bluetooth dongle. Check out the video to see how speed, direction and steering controls have been implemented.

Tomoyuki also made the code available on github. The code is based on Richard Ibbotson’s popular Wiimote Bluetooth code, as well as my MAX3421E and USB Host libraries. The code is well organized and even has a brief documentation in README file. Further development is on the way – Tomo is planning to add ultrasonic sensor support, so keep an eye on this repo. Good job, Tomoyuki and thank you very much for sharing your outstanding work!

Oleg.

Controlling Canon Powershot cameras with Arduino

Canon A640 shooting Arduino board

Canon A640 shooting Arduino board

The Canon Powershot support for Arduino PTP Library has been released. The library code, as well as several examples, is posted to GitHub. The code allows remote controlling shooting parameters of certain Canon Powershot cameras ( see gphoto and Canon SDK pages for the list of cameras) via USB using Arduino board equipped with USB Host Shield.

Every function of the camera available via buttons/menus can be initiated through PTP. This includes shutter button, shooting mode (Av, Tv, etc.), aperture and shutter speed values, zoom, focus, white balance, just to name a few. Code examples demonstrate control technique. In addition to examples, I added a static page with detailed description of Powershot library.

Most PowerShot cameras have two modes of operation – ‘shooting’ and ‘PC connect’, selected by a switch on camera body. Typically, USB is deactivated in shooting mode and communication with camera is not possible; for remote shooting, camera has to be switched to PC connect mode. Newer PowerShots switch to PC connect mode automatically when USB connection is detected.

Continue reading Controlling Canon Powershot cameras with Arduino

5V boost converter for battery operated projects

5V buck converter

5V buck converter

Today, I finished testing new lightweight boost converter. It is intended as a replacement for my ever-popular 3.3V to 5V converter. The new one is built around Texas Instruments’ TPS61240. It has slightly less output current (rated at 400ma) but is much simpler ( uses just 3 external components ), has several protections built-in, as well as undervoltage lockout (UVLO), which makes this power supply suitable for portable DIY devices.

Take a look at the title picture as well as the datasheet. Here is why I like this controller. First, it has been designed for battery-operated applications – thanks to built-in 2.1V undervoltage lockout it is safe to run this converter from 3 NiMH cells or one LiPo; when battery voltage drops down to UVLO threshold, the converter automatically shuts down. Second, the working frequency of the converter is 3.5MHz, which means that small and inexpensive MLCC inductor can be used. The converter also works well with ceramic capacitors. The total part count is 4 including the IC, and all components are cheap. Lastly, over-temperature and over-voltage protections make this simple supply quite robust.

Continue reading 5V boost converter for battery operated projects

Arduino-based controller for Canon EOS cameras

Arduino Camera Controller

Arduino Camera Controller

Today, I’m writing about two more pieces of digital camera control firmware that have being posted to PTP gihHub repository. Alex Gluschenko, the author of PTP library for Arduino, developed two sketches, one called EOSRemote and the other EOSCamController to demonstrate PTP library capabilities. The code allows requesting camera settings, such as shutter speed, aperture, ISO, etc., change them, as well as take shots. It supports Canon EOS cameras and was tested on EOS 400D, 450D, and 7D; other cameras with similar command set ( see my collection of PTP device info dumps ) may work as well.

This is how the code works: when connection is established, camera sends back an initial packet with all its current settings along with a list of all possible values for each setting. Possible values depend on a camera model as well as lens that are mounted. For example, some cameras may have exposure compensation range from -2 to +2, others from -5 to +5; some lens have max.aperture 1.4, others – 3.5, an so on. The list of values received from the camera is placed in built-in EEPROM of Arduino microcontroller. After that, values are used in setting (called “property” in PTP lingo) change commands sent to the camera. When camera mode, such as Av, Tv, or lens is changed, camera sends initial packet again. The Arduino code tracks changes and updates the list stored in EEPROM.

Hardware requirements for both controllers are pretty standard. The EOSRemote sketch uses Arduino serial port facility for I/O, and the only hardware necessary is Arduino Duemilanove, Uno, or compatible clone, as well as USB Host Shield. User interface is designed with simple terminal emulator program in mind. It can be used with a PC connected to Arduino directly or over some distance utilizing a pair of serial to RF converters, such as ever-popular Xbee. The following screenshot shows top-level menu with camera connected and recognized.

Continue reading Arduino-based controller for Canon EOS cameras

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.

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.

Canon Powershot camera control project

Sandro Benigno from DIY Drones released camera control code for Arducam project. The goal of the project is to control Powershot camera mounted on UAV while feeding camera’s video output back to operator. Telemetry from UAV will also be sent back mixed in video using MAX7456 OSD ( on-screen display ) generator IC. Needless to say, I’m very interested in camera control side of this project.

The capabilities of the code can be seen in a video above. From my experience, Powershot cameras use identical control commands for different models so this code would work with other cameras with no or very minimal changes. For example, I tested it on my A640 and it works just fine. On the other hand, not every Powershot camera can be controlled over USB; suitable model numbers can be deduced from this gphoto list.

The project-related discussion is hosted on DIY Drones.

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 Host Mini in store

USB Host mini in test fixture

USB Host mini in test fixture

The first batch of USB Host Minis is built, tested, and boards are available in store. It is designed to be employed in lightweight, battery-operated circuits, for example, used for digital camera control. It can also be used as general MAX3421E breakout board. Title picture shows the board proudly sitting in its’ own ghetto-style Sparkfun-inspired pogo bed.

The design follows Arduino Mini minimalistic approach. It is 3.3V only and mates quite nicely with Sparkfun 3.3V Arduino Pro Mini. Only essential control and GPIO signals are available – no power supplies, level converters, or even jumpers are provided due to lack of space. However, since rearranging control signals is often necessary, extra pads have been placed for this purpose. They can be seen on product picture at the top and to the left of MAX3421E IC.

The board has VBUS routed to 3.3V. Even though the voltage is lower than specified 5V, the shield has been tested to work flawlessly with numerous self-powered devices, such as digital cameras, as well as some bus-powered devices, such as Sandisk Cruzer flash drive. However, if 5V VBUS is necessary, board can be easily modified – the trace from 3.3V to VBUS can be cut and 5V applied using a pad placed on the board for this purpose. It can be arranged using single 5V supply; since Arduino Pro Mini has on-board LDO, 5V can be applied to VRAW and VBUS while shield will be getting its’ 3.3V power from Arduino board, as usual.

Bottom picture shows my favourite arrangement – Arduino Pro Mini sits on top of the shield with its’ programming connector easily accessible from either side. Also, Arduino reset switch is easily accessible this way.

Project files and schematic are available in Downloads section. If you have any questions about this design, e-mail me or leave a comment here.

Oleg.

USB Host Mini and Arduino Pro Mini

USB Host Mini and Arduino Pro Mini

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.