[EDIT] r2.0-compatible PTP code has been released, see here [/EDIT]
A significant progress has recently been made in Arduino USB Host 2.0 library development. The estimated release date is still several months away; however, I just can’t wait that long to share my excitement. A hub support is now fully incorporated into the library, as well as all necessary multi-device support – connect/disconnect, initialization and event handling. The very first device class implemented for the new library is ever-popular PTP digital camera control. A short Youtube video shows Arduino controlling two different camera systems simultaneously.
Some interesting numbers: a sketch used to drive cameras in the video takes 19K and contains one instance of USB, one instance of hub, one instance of EOS and one instance of Powershot class. The same sketch with only one camera instance takes 17K, which means one camera instance occupies roughly 2K. Since ~30K of program memory is available on Atmega328P-based Arduino board, it should be possible to drive seven cameras with a single Arduino! Also, I’m using development version of code with lots of debug strings and other less-than-necessary stuff – release version will definitely be smaller.
Watch the video, stay tuned to the code development and please let me know what you think about all that! Multi-camera control opens new exciting possibilities – anyone interested in (relatively) cheap 3D video rig?
This is first iteration of camera controller layout inspired by Fernando Radi’s project. I designed a PCB containing Arduino Pro Mini, USB Host Mini, as well as other small parts necessary to complete the circuit. The whole thing is about the size of 16×2 LCD display and 1 inch high.
Next picture shows the controller with LCD removed. LCD connector is at the top left. Two resistors below the connector set the screen contrast. Slide switch next to LCD connector turns backlight on/off while power switch sits at the top right. USB Host Mini and Arduino Pro Mini are mounted underneath the LCD; encoder and “Back” button are placed to the right of LCD.
Project files include Eagle schematic and board layout, as well as a pdf of bottom side of PCB ready to be used in toner transfer process. EOSCamController code can be run on this board with no modifications. Some encoders have their A,B outputs swapped so if you see screen navigation moving backwards, swap encoder outputs. If you want to build this controller, refer to Eagle board layout file for part and jumper placement.
Cam.controller with LCD off
In the next iteration of the layout, I’m planning to move power switch to the left closer to backlight switch and use right-angle encoder and “Back” button. I will also try to find space for a LiPo charger. Stay tuned and please leave a comment if you have better layout in mind!
Fernando Radi sent me pictures of the project he’s recently finished. It is Arduino Digital Camera Controller ( which has been posted back in January as a proof-of-concept circuit ) with some clever modifications – Fernando used Mini variant of the shield, Arduino Pro Mini and ultra-tiny LCD. As a result, the controller is very small. Make sure to read Fernando’s comment to the article linked above for construction details. Also, I suggest visiting Fernando’s blog – I don’t know Spanish well enough to read his posts but his photographs are very good!
..Electronics is not my field of expertise and I do not have any tool other than a Dremel, so the enclosure is not fancy but small enough and fit my needs. BTW, the one in the picture was the third attempt, dremel is very slippery 😉
This quote from Fernando’s e-mail triggered another idea that I want to share with my readers. I understand that many people who want to make a camera controller are not familiar with building electronic circuits from small parts. To help them, I’d like to put together a kit containing necessary parts (i.e., USB Host, Arduino, LCD, switches, buttons, etc.) plus PCB to solder parts to and a small enclosure. A PCB will be laid out using large traces so that builders who possess home made PCB fabrication skills can save some money. I’m thinking about using standard size LCD instead of super tiny one to keep the circuit simple. Estimated end-user price for this kit is going to be $75-80. Let me know what you think about the kit and especially price. I’m currently playing with overall layout and hoping to post something in about a week or two.
Thanks again, Fernando for sharing your project with us!
Development of Arduino_Camera_Control library (which runs on top of USB_Host_Shield library written to support USB Host Shield ) continues at steady pace. Nikon point-and-shooters has been on a test bench for the last couple of weeks and they are already talking. Even more exiting is the fact that they are talking the language we already know – the plain old PIMA 15740-2000.
Arduino-controlled Nikon P100
It also looks like that PTP protocol implementation in all Nikons is very close to the standard with very few vendor extensions and it will be possible to use the same code base for both point-and-shoot cameras and DSLRs. In this article, I’m showing a lightweight implementation of Capture command for Nikon cameras. Unlike its’ sister sketches, EOSCapture and PSCapture, this one can’t really be called NikonCapture – keep reading to find out why.
The InitiateCapture command, which is part of standard PTP command set can be seen in PTPDevInfo output of several Canon PowerShot and all Nikon cameras – see, for example, Canon A640 section, line 82 or Nikon Coolpix S4000, line 47. Regrettably, PowerShots seem to require setting D045 vendor-defined property before this command will be accepted by the camera; therefore, PowerShot-specific class would have to be instantiated, adding significantly to program size. On the other hand, Nikons are happily executing InitiateCapture as-is.
The following sketch does what other “…Capture” sketches do – it takes a shot once a second second in an endless loop. What makes it different is that it doesn’t use any vendor-specific code, compiles in ~9K and can be loaded into Atmega168-based boards leaving plenty of room for another functions.
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
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.
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.
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.
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.