Control your old film camera with a Raspberry Pi

Lead Image © Elena Kozlova, 123RF.com

Vintage Pi Recipe

Using the techniques provided here, you can control a film SLR camera and a USB GPS receiver with a Raspberry Pi.

Using Raspberry Pi to control motors, LEDs, digital cameras, and other sorts of modern peripherals is nothing new. However, you can also make the tiny computer work with the technology of yesteryear. My recent Raspberry Pi-related project is a case in point.

Although I have a decent DSLR camera, I shoot film most of the time. One of my favorite film SLR cameras is an almost 30-year-old Nikon F-501 that I bought cheaply on the web. In addition to the kit lens, the camera included an MC-12B remote trigger. Out of curiosity, I disassembled the trigger and found it to be a rather simple device that simply closes the circuit between two pins in the camera's remote trigger connector. Rummaging through a box of old computery stuff, I also discovered an old USB GPS receiver, so I thought it would be fun to spend a weekend on a project that makes Raspberry Pi trigger the Nikon F-501 SLR camera and record geographic coordinates to a file.

Although this project might seem somewhat limited in scope (after all, probably not very many Raspberry Pi users shoot with film SLR cameras), it demonstrates a number of useful techniques. Among other things, it shows how to create a simple transistor switch and use Python scripts to control it. You'll also learn how to make a USB GPS receiver work with Raspberry Pi, as well as acquire geographic coordinates and save them in a text file.

Required Components

For this project, I used a Nikon F-501, but any SLR camera with a remote trigger connector would do. The only requirement is that the trigger must work by closing the circuit between two pins of the trigger connector. The MD-12 motor drive uses the same MC-12B, so in theory the solution described here should work with any Nikon SLR camera compatible with this motor drive. Obviously, you will also need a Raspberry Pi as well as a 2N2222 transistor and 1kohm resistor. The final piece of the puzzle is a USB GPS receiver, and you can find one cheaply on Amazon or eBay. I used a BU-353 model, but any GPS receiver known to work with gpsd should do the trick (refer to the GPSd compatibility table [1] for a list of supported GPS receivers).

Building a Transistor Switch

The first step is to build an electronic version of the mechanical trigger. Because the trigger merely closes the circuit between two pins, its task can be performed by a simple transistor switch controlled via a Raspberry Pi GPIO pin. A transistor is a semiconductor device that can act as both amplifier and switch. A transistor has three terminals: collector, emitter, and base. With no current at the base, no current flows between the collector and emitter. Applying current to the base switches the transistor on, which allows current to flow between the collector and emitter.

There are two types of transistors: NPN and PNP. In NPN transistors, current flows from the collector to the emitter, whereas in a PNP transistor, the current flows from emitter to collector. In this particular case, polarity is not important, so any transistor would do. I used a 2N2222 transistor [2] readily available in practically any electronics store. The circuit diagram of the transistor switch is very simple (Figure 1).

Figure 1: Simple transistor switch diagram.

Besides the transistor, the circuit also includes a 1kohm resistor that reduces current to the base. Figure 2 shows a breadboard layout of the transistor switch created in Fritzing. The circuit is controlled using GPIO pin 25 of the Raspberry Pi. When the pin is turned on, it applies current to the transistor's base. This closes the circuit, which in turn triggers the camera's shutter. Because the latest version of the Raspbian Linux distribution running on my Raspberry Pi comes with the RPi.GPIO module for controlling GPIO pins using Python, I wrote a simple trigger.py Python script (Listing 1) to turn on GPIO pin 25 and trigger the shutter.

Figure 2: Wiring diagram of a transistor switch.

Listing 1

trigger.py Script

01 #!/usr/bin/env python
02 from time import sleep
03 import RPi.GPIO as GPIO
04 GPIO.setmode(GPIO.BCM)
05 GPIO.setwarnings(False)
06 GPIO.setup(25, GPIO.OUT)
07 GPIO.output(25, True)
08 sleep(0.5)
09 GPIO.output(25, False)

The script is a rather standard affair: It initializes GPIO pin 25 for output and then turns it briefly on and off. Note that I added the 0.5-second interval between turning the pin on and off, required for the camera to register the signal and trigger the shutter.

With a bit of creative thinking, you can put this simple script to a variety of practical uses. Recently, I used it in combination with a cron job to shoot the sunrise from my window. I rarely have time to shoot in the morning, so I delegated this task to Raspberry Pi. Using the Sunrise and Sunset Photo Calculator [3], I found the best time for shooting a sunrise. I then created a cron job to run the trigger.py script at an exact time. Because the script must be run with root privileges I used the

sudo crontab -e -u root

command to edit the crontab file. The sunrise started at 7:53am, so I added the following cron job:

53 7 * * * /home/pi/trigger.py

Usually, taking a decent photo of a sunrise requires several attempts, so I tweaked the script to trigger the shutter five times at 15-minute intervals (Listing 2).

Listing 2

trigger.py with a Loop

01 #!/usr/bin/env python
02 from time import sleep
03 import RPi.GPIO as GPIO
04 i = 0
05 GPIO.setmode(GPIO.BCM)
06 GPIO.setwarnings(False)
07 GPIO.setup(25, GPIO.OUT)
08 while i<5:
09   GPIO.output(25, True)
10   sleep(0.5)
11   GPIO.output(25, False)
12   sleep(900)
13   i = i+1

Buy this article as PDF

Express-Checkout as PDF

Pages: 4

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content