cheap avr intervalometer

this project is obsolete if you own a Canon supported by http://wiki.magiclantern.fm
open source tool that runs from the SD/CF card at camera startup.

now that i have a digital camera (but my heart will always belong to film-based photography) i can do time lapse photography. sadly the firmware of my camera isn’t supporting this feature, so i had to build an intervalometer. i didn’t want to use an arduino (overkill & pricy), so i went with an attiny45, a generic optocoupler, a voltage regulator and a potentiometer for adjusting the timer from 1 second to 1 minute.

i just found out that it’s possible to power the avr from the camera (focus ring). have a look at this complete and small solution: http://www.doc-diy.net/photo/hdr-jack/

//Intervalometer from 1 second to 1 minute
 
//Author: Patrick Sebastien Coulombe
//Website: www.workinprogress.ca
//Date: 2010-07-24
 
#define F_CPU 8000000
#include <avr/io.h>
#include <util/delay.h>
 
// use PB2 for led, pin 7
#define LED_BIT 2
// select ADC2, PB4, pin 3
#define CHANNEL 2
// shutter on (in ms)
#define HOLD 300 
 
// Return the 10bit value of the selected adc channel.
uint16_t get_adc(uint8_t channel) {
 
	// ADC setup
	ADCSRA = (1 << ADEN) | (1 << ADPS1) | (1 << ADPS0);
 
	// select channel
	ADMUX = channel;
 
	// warm up the ADC, discard the first conversion
	ADCSRA |= (1 << ADSC);
	while (ADCSRA & (1 << ADSC)); 
 
	ADCSRA |= (1 << ADSC); // start single conversion
	while (ADCSRA & (1 << ADSC)); // wait until conversion is done
 
	return ADCW;
}
 
// Scale
long map(long x, long in_min, long in_max, long out_min, long out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
 
// Main program
int main(void) {
 
	// vars
	uint16_t adcvalue = 0;
	uint16_t i;
 
	// define LED as outputs
	DDRB |= (1 << LED_BIT);	
 
	while (1) {	
 
		//release the shutter
		PORTB |= (1 << LED_BIT);
 
		//exposure length
		for (i=0; i<HOLD; i++) { 
			_delay_ms(1); 
		}
		PORTB &= ~(1 << LED_BIT);
 
		//interval time (using a potentiometer to adjust)
		adcvalue = map(get_adc(CHANNEL), 0, 1023, 1, 60);
		adcvalue = adcvalue * 1000;
 
		//one way to achieve long delay
		for (i=0; i<adcvalue; i++) { 
			_delay_ms(1); 
		}
 
	}
	return 0;
 
}

Time lapse test (3 hours) from my balcony.

I used Blender for making the tilt / shift effect. Here’s the source of the Blender file.

24

07 2010

0 Comments Add Yours ↓

  1. psc #
    1

    a phone cable might not be the best option here, but it’s so cheap (100 yen shop).
    yes, i use hot glue everywhere and lots of it!

    but if i had to redo the circuit, i would use this one: http://www.doc-diy.net/photo/hdr-jack/

  2. 2

    Hey, the intervalometer is excellent. I regret saying it was funny-looking now….



Your Comment