Here is another exciting camera control project – an improvement of Yanis controller which I covered some time ago. The author – Ziggy from Crisp Concept used Yanis hardware as-is but developed his own control code for both Arduino and Android. Several additional commands has been implemented, most notably video recording and LiveView zoom control.
The project is hosted on Google Code. The source code of Arduino sketch is posted there and can be used for learning how to use commands not covered in PTP library examples. It should be noted that Ziggy uses modified versions of old PTP and USB Host libraries – you’d need to use them instead of standard ones in order for sketch to compile.
I’m hoping parallel development will be beneficial for Manishi’s and Ziggy’s projects. I’m following both with great interest and will be posting updates here. Stay tuned!
This is a little Android application providing basic terminal emulator functionality over ADK interface. Its primary purpose is to be able to use Android phone as laptop replacement while debugging Arduino projects in the field. It can also be used to provide simple alphanumeric display. Victor Serbo, my long time friend, helped develop this application. It can be downloaded from here and currently in beta – as soon as code stabilizes I will make source code available. [EDIT] The source code is now available. It is released under GPL2, if you modify it, please make your modifications available.[/EDIT]
When Arduino is connected to the phone via USB Host Shield, it can send characters to the application’s screen and receive characters typed on application’s keyboard. Standard CR and LF control codes are also recognized so it is possible to output, for example, single line with changing content. Additionally, the appearance and behaviour of the screen can be customized – font size and type, foreground and background colors, local echo, screen rotation and more. The app has been thoroughly tested on Nexus One and Nexus S phones and works well.
Two demo sketches has been posted to gitHub. The functionality of term_test can be seen on title picture – strings sent from Android are output back on the screen. The term_time sketch demonstrates single line output. Below is brief explanation of ways to provide input/output on Arduino. I’ll start with term_test; all necessary functionality is implemented in loop(). Continue reading Android ADK terminal emulator for Arduino
In this article I’ll show how to build Wireless EOS Controller designed by Manishi Barosee. I’m building it for my Canons and if I like it, I’ll see if it’s possible to modify it for other camera systems. My controller is built around full-size USB Host Shield instead of Mini which Manishi used – I’m going to do some debuggung and need space to connect probes. Also, full-size shield is much easier to work with.
The design of Yanis is simple yet elegant. It consists of Arduino board, USB Host Shield and serial Bluetooth module. An Arduino sketch reads the serial port, generates camera control commands and sends them to the camera over USB. The Android application acts as a UI for the controller and sends control data over Bluetooth. Here is very basic schematic drawing of Arduino part of the controller showing necessary connections. USB Host connections are described in hardware manual and Bluetooth module connections are shown in detail below.
I’d like to start with radio link. The Bluetooth module used in this build is RN-42 from Roving networks. It is 3.3V device and its pins are not specified as 5V tolerant which means that Tx pin of standard 5V Arduino can’t be connected directly to Rx pin of [my] RN-42. Fortunately, the 5V to 3.3V level shifter on USB Host shield has 2 extra gates and I will be using one of them to “condition” the Tx. To do this, I need to cut ground trace going to pin 9 of D6 (marked ‘HCT’ on the PCB), connect it to Arduino pin 1 and then connect pin 8 of D6 to Rx of RN-42.
Digital camera control code AKA PTP (Picture Transfer Protocol) compatible with USB Host Shield rev.2.0 Arduino library has been released and posted to GitHub. New code has all functionality of original camera control library and adds new elements, namely ability to control several cameras simultaneously and (finally!) support for Nikon DSLRs.
The code comes with numerous examples demonstrating various aspects of digital camera control. All examples were compiled using Arduino IDE rev.0022 with USB Host Shield 2.0 and PTP 2.0 libraries installed as usual (by copying the whole library directory in %arduino%/libraries) and tested on Arduino UNO equipped with USB Host Shield. There are also several examples which require Quantum Platform state machine framework, they can be recognized by qp_port.h header included in the text of the sketch. If you want to try one of those, install QP Development Kit for Arduino and then replace qp_port.cpp with this file.
More detailed explanation of library examples will follow soon. In the mean time, play with the library and try the examples. Stay tuned for the updates!
This is another excellent project which uses USB Host Shield and digital camera control library. Manishi Barosee created Bluetooth interface between Canon EOS camera and Android phone. Current revision of the code allows for manual control of aperture, shutter speed, ISO, white balance, focus, LiveView, and of course, capture. Planned features include video mode control, rack focusing, as well as intervalometer/timer/HDR services.
Watch the video and if you’d like to build the circuit, visit Manishi’s blog to see what’s involved. I am very impressed with design of this controller and plan to build one myself to control my DSLRs. Also, please take a look at Arduino code – an easy to understand sketch, which can be modified for other camera systems without touching the Android part of the controller.
Google Open Accessory Interface is now included in USB Host Shield Library 2.0 package. It follows standard structure of rev2.0 device driver (wherever possible) and because of this is slightly different from original Arduino code developed by Google. The interface itself is pretty simple and there are many articles on the net describing it in details; in this article I will give brief overview of new code and explain the differences.
To test the code I made a little “shield” resembling Google’s one. Since the only thing I cared about while testing was data transfer in both directions, I implemented just one LED and one button. The demokit_20.pde Arduino sketch works with DemoKit.apk Android application, however, only “B1” button and “LED 1 Red” are functional. To run the sketch, you will need an Arduino board, USB Host Shield, as well as USB Host Shield 2.0 library.
The ADK class contains all necessary functionality to communicate to Android phone via ADK interface. In order for USB subsystem to initialize the device when it is connected, the instantiation should look like the following code fragment. First, the USB class is instantiated, then ADK is instantiated taking address of USB instance as the first parameter. The rest of the parameters are ID strings for the phone – they are identical to the original code.
The initialization of Android device and switching it to accessory mode is performed automatically by USB subsystem. The ADK::Init() member function is called each time a new device is detected on a bus. It first tries to determine if a device is in accessory mode already by reading its VID, PID, and if yes, configures it and reports success to the system. If device fails accessory check, the standard probing and accessory switching method is performed. If successful, device resets and appears on USB bus as an “accessory mode-capable” unit. In certain cases, Init() may be executed two times. Continue reading Google Open Accessory Interface for USB Host Shield Library 2.0 released
Here is another quick demonstration of USB Host Shield 2.0 Library. This article describes how to communicate to Navibee GM720 GPS receiver based on SiRF Star III chipset and PL2303 USB to serial converter. This GPS device is available on eBay for around $25 new, used units can sometimes be found for $10 or even less. The receiver has waterproof case, magnet mount and comes with 6 foot cable. Another nice feature of this device is its 40mA current consumption. Here are some pictures of the unit – PCB, internal antenna, as well as front and back of the original packaging.
“Classic” GPS receiver sends and receives NMEA 0183 messages via serial port at 4800 bps. Modern GPS units often support faster speeds and vendor-specific messages. However, they mimic classic GPS unit behavior – at power-on they start sending basic navigation messages at 4800 bps. The following sketch outputs messages, received from Navibee GM720 GPS unit via its built-in PL2303 USB to serial converter connected to USB Host Shield. Full text of the sketch is available on gitHub, below is just a fragment where speed is set to 4800.
The OnInit() member function is called to change serial parameters after initialization. A lc structure of type LINE_CODING is declared on line 14. It is filled with baud rate (line 15) and number of data bits per byte (line 18) and then sent to Pl instance in line 20.
Despite being quite old, asynchronous serial interface is still popular these days. Xbees, Bluetooth and WiFi embedded adapters, standalone GPS modules are often equipped with asynchronous serial data port. At the same time, standard size Arduino comes with just one asynchronous port – and the same port is used to load compiled sketches and print debug messages. Using these functions while sharing serial port with peripherals is never trivial and often impossible. Recently announced revision 2.0 of USB Host Shield library allows communication with several USB devices simultaneously making it possible to talk to multiple peripherals via USB to serial converters. The converters are available from many places and cost around 15 dollars. However, any old cell phone data cable is essentially a USB to serial converter and can be used as such with not much difficulty. In this article, I will show how to modify data cable originally intended for Sony Ericsson T226 phone into general purpose USB-to-serial. Continue reading Building PL2303 USB to Serial converter from old data cable
One of the main motivations for adding asynchronous CDC support code to rev.2.0 of USB Host Library was to be able to use cell phones in Arduino projects – establish simple data exchange via SMS, take pictures or connect to the Internet. Second hand phones are inexpensive yet quite capable. Also, m2m (machine to machine) SIM cards start at $4-$6/mo, some even allow for free incoming SMS. All that makes a cell phone an attractive communication option for hobby projects. In this post, I will be talking about basics of cell phone control using data port and AT commands. I will also present simple terminal emulator sketch – to use the code you will need an Arduino board, USB Host Shield, as well as USB Host Shield 2.0 library.
Modern (<10 year old) phones have standard GSM chip interface implemented and accessible via so-called “data port”. The oldest phones implement TTL level asynchronous serial interface by means of “custom” USB data cable, which is just proprietary connector on one end, standard USB connector on the other end, and USB-to-serial converter chip (almost always Prolific PL2303) between them. Newer cell phones have USB-to-serial converter built-in. Motorola phones usually terminate data port on standard mini-USB connector, others, like Samsung and Sony Ericsson, use proprietary cable. The USB-to-serial converter in these phones is almost always standard CDC ACM type.
Many functions of the phone can be accessed by AT commands, similar to commands used to control Hayes phone modems. Standard GSM commands are defined in 3GPP TS 07.07 (look for the latest version, which is 7.8.0). Cell phone manufacturers also define their own AT commands. In documentation AT commands are usually presented in uppercase, however, most phones accept lowercase just as well. A command shall be followed by CR,LF (usually Enter key). If a command is accepted, OK is returned, along with response. If command is not recognized, ERROR is returned. Some commands will be accepted in certain phone states and rejected in others. Continue reading Interfacing Arduino to a Cellular Phone
What started as a quick re-factoring effort transformed to a major redevelopment, but finally all pieces fit together tightly and I am pleased to announce that initial release of USB Host Shield library ver.2.0 has been posted to github. This new version contains several major improvements:
Only 5 Arduino pins are now required for USB Host Shield to function – 3 standard SPI pins (SCK, MISO, MOSI) and 2 remappable pins (SS and INT).
The low-level interface to MAX3421E has been re-designed. Arduino pin manipulation routines has been replaced with mechanism inspired by Konstantin Chizhov’s C++ AVR pin templates. As a result, low-level transfers became approximately 3.5 times faster. Also, pin reassignment can be done much easier by passing pin numbers into MAX3421E template during instantiation.
The high-level interface to USB devices has been re-designed as well. It is now possible to connect USB hub to the shield and have many devices on USB bus, up to 7 daisy-chained 8-port hubs plus up to 44 devices connected to hub ports left after daisy-chaining, memory permitting. Also, a standard mechanism of device initialization/polling/releasing has been added to enumeration.
Several minor code improvements has also been made. NAK_LIMIT is now tied to an endpoint – it is now possible to have NAK_LIMIT set to 1 for interrupt endpoint and 32000 for bulk endpoint of the same device simultaneously. Control transfer function now accepts callback in order to split long chunks of data, if necessary. inTranser() function now is able to return actual number of bytes received.
Support for several popular device classes has been added. Device initialization and event handling is now moved to a library specific to device class, therefore user application does’n need to do this and only needs to process actual device data. The following devices are now supported by the library code: Continue reading USB Host Shield library Version 2.0 released.