I'll describe here how to build a phototrigger device.
Recent changes:
Features:
Device uses ATMEL's atmega168 micro controller (at the time of writing this article code uses more than 12 kB of flash memory) + few passive and active peripherals. Schematics:
Device should be powered by 3 V, i.e. two 1,5 V batteries, it is possible that it could run with two 1,2 V batteries but that haven't been tested. Big power capacitor allows battery exchange before processor runs out of power. When active, device uses, highest backlight level, about 70 mA; when backlight is off: 1-2 mA; when off (RTC keeps running) about 50 µA (if my multimeter is correct). MCU is driven by internal calibrated RC set to 1 MHz. RTC is done entirely in software, only external „watch” crystal is used (32.768 kHz). There's voltage battery measurement circuit, the potentiometer should be set so that on ADC5 measures 1/4 of power supply (3 V ⇒ 0,75 V). LCD contrast is directly connected to OC0A PWM output, LCD backlight is also driven by PWM output (OCA1) through N-MOSFET transistor (BS170). LCD itself is connected entirely to PORTB. Shutter release circuit can be either a BS170 MOSFET (some may say it's more „dangerous” option) or an optotransistor for perfect isolation from the camera (disadvantage: uses more power due to LED in optoelement). User input is done through an ALPS (or compatible) encoder with switch, encoder and switch noise filtering is done by software. I've found than BS170 works perfectly. Mini jack connector is used as output. Board is using 6 pin ISP connector.
Fuse configuration for CPU is factory's default: 8 MHz internal RC clock + CKDIV8 ⇒ gives 1 MHz system clock. Remember to program EEPROM memory (.eep file), this file contains start/default values. Here's screenshot for fuses for reference (don't mind that the title says it's for atmega88):
Board is 100 mm x 41 mm. PCB has one copper layer with couple of connections on top layer. There are very little components to mount. Remember to use either optotransistor or MOSFET (see below for more details). Mounting of ISP connector is optional if you can program MCU in external programmer. Remember to use 3 V compatible LCD Display 2 × 16 characters), preferred is the model which is readable even when the backlight is turned off. When programming MCU remember to program also EEPROM memory (it contains default values). Before start set 1/4 of supply voltage on ADC5 using R2 (0.75 V for 3 V supply /2 batteries/).
For optotransistor option: mount IC2 (optotransistor) and R3, do not mount T1, J1 should not be short cut. R3 value depends on IC2 used (on schematics CNY17, but any other optotransistor can be used), normally it should be around 220 Ohm.
For N-MOSFET option: mount T1 and short cut J1 (bottom side), do not mount IC2 and R3.
To connect to camera use 1:1 cable:
Photo of a PCB board (please note that this is „b” version of PCB which slightly differs from the current version „c”):
Software was written entirely in c and compiled using avr-gcc. It uses modified example code from avr-libc site as well as tinymenu library. Binary size is more than 12 kB.
Code is well documented, I will describe briefly what's where. There are many files which control different parts of the device, here's a list with brief description:
Source files contain function bodies, header files contain constant (#define-s) which may influence how phototrigger works, ex. encoder rotation sensitivity, inactivity time out, etc.
After power on hardware is initialised (hwSetupAll()) CPU enters power save mode (hwEnterPwrSave()) - it is as the device was off. To turn on user must press encoder button for longer than RTCPWRONTIME (rth.h). After that some basic checks are done and startPT() function is called. Menu is handled by tinymenu library which calls handler functions for each menu entry. Timer2 takes care of RTC update, static timers, inactivity timer, power on timer (rtc.c), Timer1 controls LCD backlight (PWM) + dimming (lcd.c), Timer0 - LCD contrast + encoder handling.
Here's video demonstrating how it works (please note this is done on a prototype version with old software):
Here are some pictures of fully assembled phototrigger:
Here are some notes about this design:
What you can do using phototrigger:
Files for download:
Please note that I may remove some comments, after time, if they are not valuable.
Dyskusja