cheap avr intervalometer

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.

//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 &#038; (1 << ADSC)); 
 
	ADCSRA |= (1 << ADSC); // start single conversion
	while (ADCSRA &#038; (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 &#038;= ~(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;
}

A short time lapse test (4 hours) from my balcony. I used Blender for making the tilt / shift effect. Here's the source of the Blender file + the png mask.

24

07 2010

singing birds

10 watts amplifier with built-in 16-bit / 48kHz RIFF-WAVE player (music on a SD-CARD). 2 servos for controlling the beaks. I did this project mostly to learn stuff. The result is a bit stupid, i do agree.

VIDEO:

Get the Flash Player to see this content.

 

PHOTOS:

13

04 2010

biscuit box computer

i am sure there’s plenty of projects like this one. the idea is to get a “cheap” and “small” full featured linux box. a good keyword to start with: itx motherboard cpu combo. this one have hdmi 1080p, wifi, dual-core 1.6 ghz. i paid 147$ used. got also 1 gig of used ram for 20$. total of 167$ CAD. weight is 0.8 kg for the box and 0.3 kg for the supply. Just 18W at idle, and 23W full load (someone measured it with a Kill-a-watt device). the power supply is 90W. for the storage, i went with a laptop hard-drive (it’s smaller). i paid 100$ for a 500 gig, 7200 rpm, sata.

all this information will be outdated, now.

running a realtime kernel with enlightenment and blender:

01

04 2010

kicad – video tutorial

Kicad is an open source (GPL) software for the creation of electronic schematic diagrams and printed circuit board artwork.

schematic editor & cvpcb (transcript):

pcbnew (transcript):

V-USB kicad project (clean):
http://www.workinprogress.ca/wp-content/uploads/kicad_vusb.zip

Kicad:
http://kicad.sourceforge.net/wiki/index.php/Main_Page

Update:
http://kicad.1301.cz/

Libraries:
http://kicadlib.org/
http://per.launay.free.fr/kicad/kicad_php/composant.php

24

01 2010

filtering pwm for music

i would like to start by saying that this solution might not be the best… if any analog guru read this, please leave a comment.

for 2.75$ you can have a chip that is able to run at 64 mhz (phase-locked loop) and output a pulse width modulation at 250 khz. attiny85 is your friend here. i didn’t found any atmega with this option (pll)… the good news is that it’s fast enough to output a stereo WAV at 16 bits / 48 khz. if you are interested in this project, take a look here: http://elm-chan.org/works/sd8p/report.html

since i want to connect the pwm output in a power amplifier, i need to filter the signal. here’s the waveform of the pulse width modulation @ 440 hz:

pwm_signal

now let’s see if we use a simple RC low pass:

pwm_filtered_rc_osc

looks good to me, but then testing with a triangle instead of an oscillator revealed this:

pwm_filtered_rc_tri

that’s not beautiful… here’s a close-up:

pwm_filtered_closeup_rc

maybe using more passive filter could help, but since you need to use an op-amp as a buffer (so that your load doesn’t affect the RC filter), why not use a sallen-key topology. this will act as an active low pass filter and a buffer. let’s look at the results:

pwm_filtered_sk_tri

close-up:

pwm_filtered_closeup_sk

not perfect, but better!

SIMULATIONS
simple RC (250khz = -22db)

sallen-key second-order (250khz = -44db)

sallen-key third-order (250khz = -67db)

third-order is the best and using this method only 1 stage is needed.

when choosing the op-amp, consider this:
100 * highest Q * GBW = Gain Bandwidth Product (read about it here)
slew rate => 2V/µs
i am using a rail-to-rail input / output op-amp.

now simply add an electrolytic capacitor (100 uf) and you can feed an amplifier with the original pwm signal (hopefully).

29

11 2009