Benchmarking camera shutters

Happy Saturday, here’s my nearly incoherent video about timing camera shutters with electronics. I never script these. Consequently, when editing, I often wonder precisely what the hell I’m talking about.

I naively thought this project was going to be a one-nighter. The setup seemed pretty straightforward, but I was surprised at the inaccuracy of arduino’s built-in micros() function. After I got the photo diode and laser working correctly, I noticed that the value returned by micros() was sometimes much higher than it should have been. Maybe it was just my code?

In this case, a better way of getting moderately high-frequency timing from an Arduino is to use an interrupt to count the pulses of an external oscillator. In this video, I’m doing it pretty old-school, with a beloved 555 timer. With some trimmer resistors I think I was able to get the frequency fairly close to 10,000 hz, as confirmed by the oscilloscope. I guess the accuracy of this setup will wander with ambient temperature, but that’s fairly easy to control.

Of course, the laser is totally unnecessary. You could do this with any bright light, so long as you can keep the photodiode in shadow when the camera shutter is closed.

The resistors I used for the (reverse biased) photo diode were about 500k and 50k. In my house, with these resistors and with my light source, the arduino’s analog input reads the PD output at ~20 in the dark and at a hard 1023 when illuminated.

The 555 timer components were ~4400 ohms for R1, ~5000 ohms for R2, and .01 microfarads for the cap.

EDIT: Source code now available after the jump.

#define PDINPUT 0
#define DIAGLED 13
//The timer is to be put on pin #3 (interrupt 1).

const int thresh = 512;
volatile unsigned int pulseCt;

void setup(void)

void loop(void)
  int last;
  int cur;
    cur = inputBlock(PDINPUT);
    if( cur >= thresh && last < thresh )
      pulseCt = 0;
      attachInterrupt(1, clock, RISING);
      while( inputBlock(PDINPUT) > thresh );

    last = cur;

void clock(void)

//The idea behind inputBlock is that you would modify as necessary to minimize sampling noise,
//i.e. by making multiple calls to analogRead with or without delay.
inline int inputBlock(const int pin)
  int a;
  a = analogRead(pin);
  a += analogRead(pin);
  return a / 2;

  1. Wow, this is brilliant. I have tons of old cameras I’d love to test, and I’d seen the sound card hack you mention and didn’t like that it wasn’t very portable (I also like to go shopping old cameras when I find the time). I had seen someone recommend trying to make a BASIC Stamp based tester a while back, but it didn’t occur to me until today to see if anyone had done it with the Arduino. Lo, your YouTube video made its presence known. I have a few questions about it, if you don’t mind. My original idea was to use an oscilloscope app on my old, jailbroken 2nd gen iPod Touch and the sensor setup, or a slightly modified one, for the sound card hack. The only app that looked like it could actually perform the necessary tasks of accepting the input pulse and letting me measure it on screen was $15, which I found too steep for something that I wasn’t 100% sure would work and was probably more trouble than it was worth. Now, I understand your setup is still connected to a computer for the output. How difficult would it be to make it a standalone project with a simple LCD or LED readout of the computed shutter speed? I dug around the SparkFun website and saw modules for these sorts of things. From a layman’s perspective it looks like my ideal device would cost less than $100 in parts, plus the joys and pains of learning, right? More than the $15 oscilloscope app, but more useful and mind expanding in the long run, so it has much greater value.

    I should preface everything with this: my knowledge of electronics peaked in 7th grade with my last 200-in-1 electronics projects kit from Radio Shack. Soldering I’m good at, from having to hack flash syncs and other camera bits. Programming I can learn. But I lack a lot of base knowledge to do things like you’ve done, like what’s the difference between using a photo diode and a photo transistor?

    Anyways, this would have probably been better as an email rather than a blog comment. Your Flickr stream and YouTube videos are fantastic! Cheers.


  2. Hey yo,

    First of all, regarding the soundcard version: sure, you could use a $15 oscilloscope program, or you could use any free audio recorder that will let you zoom in and measure a recorded waveform. Really, all the oscilloscope program seems to offer in this scenario is convenience. A word of caution, however: depending on how the device is designed, it may be bad mojo to feed any ‘ol signal into a line input jack. Whatever goes in there should look a lot like audio: +/- 2.5 volts, 22-47k ohms of source impedance, minimal DC offset, etc. A real oscilloscope can withstand dangerous signals but the input circuitry on a phone is almost certainly less robust.

    At any rate, that’s not the direction you sound like you’re going in anyway. For a beginner, I would recommend a 4-digit 7-segment display ( over an LCD, since LCDs are marginally more complicated to talk to and significantly trickier to debug. Still, there are a couple of gotchas with the 4-digit 7-segment displays Sparkfun sells: they require a minimum of 11 i/o pins, and you have to ‘roll’ across the digits, rapidly turning them on and off.

    You can get away with spending 11 pins on the arduino and still have enough pins for the timer input and photo diode. But you should be very liberal with your resistors (you always couple LEDs with resistors), choosing high values to ensure the arduino doesn’t cook itself trying to dump current into 7 power-hungry LEDs.

    The programming isn’t too hard. You have to use interrupts, which are only a slightly advanced programming technique. In the end, I’d wager this would be a fairly solid first project if you’re interested in getting into electronics. You will probably need to do some mini “spikes” along the way, like proving to yourself that the 555 timer works and teaching yourself the code.

    And yes, you should be able to do this for under $100, including tools.

    I’ll see if I can find the arduino source to post here. Good luck with your project!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s