Last week my friend Hans and I spent some time in my lab exploring which features of his Nikon D300 are available via PTP protocol. Hans is working on extended range HDR-capable intervalometer and he needed to find out a way to switch his camera into bulb mode using Arduino board and USB Host shield. After we finished I realized that while bulb mode is not tricky to activate, it is not obvious either and no hints exist in the code and examples showing how to do this. This short article is intended to fill the void.
In PTP, shooting parameters, such as shutter speed, aperture, ISO, etc. are changed by setting certain device property. For each parameter there exists a list of allowed values of this property, each property value corresponding to a parameter value. For some parameters, property and parameter value lists are dynamic. For example, starting and ending aperture values are different for different lenses; additionally, the aperture step can be changed in camera settings. Stepping can also be changed for shutter speed and exposure compensation and this can also happen during PTP session if a photographer decides to switch modes – in this case a property may become unavailable, like shutter speed in aperture priority mode. Therefore, before changing a property value for one of these parameters it is necessary to somehow retrieve a list of available property values.
The property value list retrieval mechanism is slightly different for different cameras. On Canon DSLRs, a special event is generated by the camera and sent back to PTP host at the beginning of the session and also each time camera mode was changed, lens were swapped and so on. The application needs to track those events and constantly maintain current value list for each property. On Nikon DSLR, it is possible to simply get value list for a property any time it is needed. To save memory, the list is not stored but simply requested from the camera each time a property needs changing. It is combined with actual property change in two templates – StepUp and StepDown. If you need to increase, for example, shutter speed – call StepUp. If you need to decrease it, call StepDown.
If you “step up” shutter speed on Nikon DSLR manually, the last 2 values will be 30 seconds and bulb. If you step up shutter speed using StepUp method using Nkremote sketch it will stop at 30 seconds. This happens because bulb mode is not included in the list of available property values for shutter speed but simply defined as 0xffffffff. As a result, StepUp doesn’t know that another value is available. It is still possible, however, to set the property directly and I will show you how to do it. Continue reading PTP 2.0 library function turns on Bulb mode on Nikon DSLR camera via USB
After spending a week with focus stacking assistant I realized that I need more units. I’d like to have one unit dedicated for studio work, another to carry in camera bag and yet another one to control my Nikon (code for which I’m hoping to finish soon). Full-size Arduinos are big and expensive and I wanted this controller to be cheap and portable so I built my next controller using Arduino Pro Mini 3.3V, USB Host Mini, and a small home made PCB with buttons and LED. Finished mini-assistant can be seen on title picture and uses the same code as its big brother. What follows is a build log of mini-controller. It follows traditional layout, used, for example, here – a sandwich where Arduino Pro Mini sits on top of USB Host Mini. In addition to that, I needed to add another board on top of the sandwich to carry control and indication bits.
One of my favorite shooting techniques is focus stacking. Many pictures on Circuits@Home site are made using this technique. I use Helicon Focus for post processing and even though this program has camera control built-in, it obviously requires a computer close to the object of shooting. In order to be able to control my camera in the field, I wanted to replace a laptop with simple lightweight controller able to move focus of camera lens and take pictures between steps. In this article, I will show how to build one from Arduino, USB Host Shield and several small parts.
Finished circuit can be seen on the title picture. As you may already have guessed, the sequence of shots used to produce the picture has been made with the very unit depicted on it. Focus stacking assistant is controlled by 3 buttons: first moves focus towards the camera, second moves focus away from the camera, third button starts shooting sequence. Long press on focus move button sets “near” of “far” points, after both points are set shooting sequence can be run – it always starts from “near” point. The sequence can be stopped at any time by pressing on any of focus move buttons. It is important to understand that after a point is set, subsequent focus moves must be performed with focus move buttons only.
The controller can also be set to “free run” mode. Long press on third button starts shooting sequence from current lens position (which in this case can be set by hand using lens’ focusing ring) towards infinity and will run indefinitely. It can be stopped at any moment by pressing on a focus move button.
A single LED shows states of the controller. Short blink once a second indicates “idle” state – controller is connected to the camera, PTP session is open. Continuous frequent blinking means some kind of an error – most likely, controller not being able to initialize the camera or open PTP session. 3 short blinks act as a feedback to long press, focus move, etc. Additionally, more detailed diagnostic is output to Arduino serial console.
Even while connected to the camera, Focus Stacking Assistant allows camera buttons to function as usual. For example, camera LCD can be turned on and zoom area can be moved to the area of interest and then zoomed in to help focusing. Shooting mode, as well as aperture/shutter speed/ISO can be changed. It is also possible to access or erase images on the card and perform other manipulations as necessary. Continue reading Focus stacking assistant for EOS cameras
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!
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.
[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!