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.
The second controller has been designed for field operations. It uses HD44780-compatible character LCD display, rotary encoder with push switch, and one extra button. Here is controller’s schematic. Title picture shows the implementation and picture on the right shows main components. The controller uses 3.3V Arduino Pro from Sparkfun, “Minimal” variant of USB Host Shield and 3.3V LCD display. LCD, encoder and switch are mounted on a small prototype PCB which plugs directly into USB Host Shield’s GPIO pins.
In addition to setting/displaying shooting parameters and taking shots this controller works as intervalometer with extended bracketing. If desired, a self-timer can be set up before the first shot in series. Also, each shot can be bracketed as wide and granular as camera exposure compensation range and step allows. For example, on 7D it is possible to set bracketing from -5 to +5 with 1/3 step between shots – more than enough for good HDR.
Let’s talk about the code. To compile the sketches, current versions of Arduino_Camera_Control and USB Host Shield libraries are necessary. Additionally, Time library from Arduino Playground has to be installed. Also, the code uses Quantum Leaps QP framework – a compact and robust open source implementation of UML state machines. Miro Samek is currently working on Arduino port of QP framework; in the mean time, I’ll show how to make Arduino-compatible setup from source code. Only QEP component of the framework is used and installation is simple.
First, create a directory under
arduino-00xx/libraries/, call it. let’s say, ‘qep’. Then download the QP/C++ from SourceForge. Unzip the archive somewhere else, navigate the directory tree to
qcpp_x.xx/qep/source and copy all files to Arduino library directory. After that, go to
qcpp_x.xx/include directory and copy
qs_dummy.h header files to the same Arduino library directory. Now, download AVR port, unzip it, navigate to
ports/avr/qk/gnu and copy
qep_port.h to Arduino library directory. Finally, in Arduino library directory, open
qassert.h in text editor and insert line
#define Q_NASSERT before the line containing
#ifdef Q_NASSERT (line 47 as of ver.4.1.01 of QDKCPP-AVR-GNU). Save the file. The sketches should now compile – try it with your camera and let me know if you have any problems.
Finally, I want to talk about hardware variants. Camera controllers described here can be built using “standard” Arduino (Duemilanove or Uno) plus “Simple” USB Host shield. This setup is easy to work with and troubleshoot. However, it is not as easy to power such setup – usually you would need 4xAA batteries, which is somewhat bulky. On the other hand, 3.3V setup can be powered from a single LiPo so 3.3V Arduino Pro/”Minimal” USB Host Shield setup is preferable for a portable controller. It is also possible to build a controller with 3.3V Arduino Pro Mini/USB Host Mini – the tiny form factor makes building more difficult but the resulting controller is going to be much smaller and also quite a bit cheaper. The code is compatible with any of hardware variants described above.
I’m planning to continue camera control code development – next milestone is Canon Powershot command set support, and it is very close to release. I’m also planning on making a small controller for Canon DSLR video mode. Stay tuned!
No related posts.