Field Programmable Intervalometer
■ FIGURE 5. The Completed Project.
the camera from the intervalometer.
I proved the interface operation
on a breadboard by placing the
resistors on a DIP header. On the
breadboard, the camera operated
correctly. I inserted the DIP header on
the Protoboard and connected the
optocouplers. Disappointingly, the
camera did not react.
I reviewed the interface circuit and
the placement of the DIP header on the
Protoboard. In that exact spot, the
Protoboard had holes shorted by
design. This was causing a short in my
resistor array. I changed the resistors on
the DIP to take advantage of the
Protoboard design. With corrections in
place, the camera operated as expected.
My final programming task was to
place time intervals between frames. The
SX- 48 on-board timers seemed an obvious choice. My first approach was to
monitor the number of timeouts on a
timer, and trigger the camera when the
timeouts equaled a pre-calculated count.
I was starting to run low on code space,
so I designed a more efficient solution.
I set up Timer1 in pulse width
mode (50% duty) and the other,
Timer2, in External Trigger mode. The
pulse from Timer1 triggers Timer2.
Next, I set the Timer2’s compare register to the number of pulses I needed
before I wanted a frame triggered.
When the number of counts was the
same as the compare register, the SX- 48
generated an interrupt. The code in my
interrupt routine became very simple:
reset Timer2 and trigger the camera.
ple, I needed to set the date and time of
the Real Time Chip and for the Delay
mode. I wrote the subroutine that sets
the date and time generically so that the
settings could be used for either. I also
reused camera control subroutines for
both manual and automatic operation.
that stores this value, I could change it
from 00100000 (space) to 00100101 by
changing two bits. On the display, the
status toggles between ‘space’ and ‘$.’
The SX/B PAUSE command compiles to a few lines of assembly everywhere it’s used. I copied the assembly
code of the PAUSE command to a
single SX/B subroutine — named
SystemPause — and passed in a single
argument. The argument set the number of milliseconds to pause. The overhead of calling into and returning from
my subroutine was not critical in my
application, and I saved code space.
I needed to indicate the operational
status on the display. Custom characters
required code space, so it was more
economical to use existing characters.
Also, I found that I could manipulate
the displayed character with masking to
indicate different status. For example,
the $ character has a binary value of
00100101. By manipulating the byte
I wrote a subroutine to turn off the
display when the intervalometer was
waiting to start in Delay mode. When I
made current measurements, I found
there was very little difference
between the display on and off — the
LCD still required power. I removed the
code and reclaimed the code space for
features that made more sense. For
example, when setting a date, I didn’t
check for a valid end of month date.
With the extra code space, I checked
for things like February 31st and prevented them. Also, I provided for an
automatic power-down after two minutes of navigation inactivity.
I made changes to subroutines
which freed up code space and helped
me add extra, unexpected functionality.
These changes included code reuse,
my own PAUSE command, display optimizations, and removing functionality.
I saved code space when I wrote
code that could be reused. For exam-
Figure 4 describes all of the menu
functionality in the intervalometer. I
verified most of it on the bench. With
the intervalometer complete (see
Figure 5), I needed a beta test. Since
my “project manager” wanted me to
Set up the timer in astable mode. A combination of decade counters
The NE555 Timer (4017) and ripple counters (4020 or 4040) would provide a range of intervals. Make sure the timer pulse width is wide enough for the
camera or interface circuit to detect.
■ FIGURE 6. Project Alternatives. Here
are a few alternatives to the project
The Nikon Coolpix S50C This model has the intervalometer function built in.
Use your Personal Most Canon PowerShot models include software which controls the cam-Computer era through its USB port. The software includes an intervalometer function.
December 2007 37