Posts

Generic PTP control of digital cameras

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

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.


Continue reading Generic PTP control of digital cameras

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

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

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.

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.

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.