Posts

PTP 2.0 library function turns on Bulb mode on Nikon DSLR camera via USB

Bulb mode activation code screenshot

Bulb mode activation code screenshot


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

Building YaNis Android Wireless EOS Controller

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.

Cut pin 9

Cut pin 9

Tx to level shifter

Tx to level shifter


Continue reading Building YaNis Android Wireless EOS Controller

PTP support for USB Host Shield Library 2.0 released

PTP ver.2

PTP ver.2

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!

Oleg.

Arduino USB Camera Controller – Status Report 1

Cam.controller rev0

Cam.controller rev0

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

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!

Oleg.

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.