This time in the multipart blog on the home-made Telecine, I’ll discuss the Canon Hack Development Kit and its connections with the Arduino. The CHDK is a wonderful, open source project, in which dedicated programmers have reverse-engineered the Canon camera operating system. The hacked version of the firmware allows the user not only to access every feature of the camera via menus, but also to script the actions of the camera using either Basic or a language called LUA. (It also brings games to your IXUS, which is a quaint little feature).

CHDK front page

CHDK front page

I knew what to look for, because from day 1 it was evident that some sort of remote trigger would be needed for the camera, and because my son had built a remote trigger for his D1000 using an old mouse and a hack kit called Magic Lantern, I was sure there’d be a hack kit for the trusty IXUS. I searched for IXUS hack, and the first hit pointed me to this wonderful site. The people who run it have created a new firmware for each and every make of digital cameras ever put out by Canon, so all you have to do is to use the firmware identifier to locate the correct package, and then install it.

You can use CHDK to build time lapse cameras, motion detection video cameras, and a million other useful cameras out of your plain little IXUS. If you have a digital SLR, try Magic Lantern for the same services and more. If I decide at some point to use a real SLR on the Telecine, I’ll be sure to head out that way.

The absolute killer feature of CHDK is that you don’t make any permanent changes to your camera. The firmware is loaded onto the memory card, and when you now boot the camera in the gallery mode and press MENU, the last item in the menu has changed into Update Firmware. When you do this, the camera boots, and now the DISPLAY key has become the ALT key. Pressing the ALT key lets you access the scripting menus, and pressing MENU gets you to the settings of the camera – all of them. It is simply amazing what the gurus at the CHDK have put together.

You can still use the camera as normal, but the scripting gets you very many new options. For example, in my case, I needed a script that would first turn on autofocus lock, then let me focus to the film frame, and then let me shoot images, thousands of them, by commands from the Arduino. The kind gentlemen of CHDK provided me with a LUA script, which did just that. When I was ready to start shooting, I’d load the 8mmSync.LUA script, start it, zoom and focus the camera and then sit and wait for the Arduino. Perfect!

Schematic view of the Telecine

Schematic view of the Telecine

This might be a good place to explain the entire routine and its parts. The heart of the thing is the Arduino, which has two inputs (the switches at the film gate and the film takeup spool), and three outputs (the film gate servo and the film transport servo). The film gate servo rotates at a portly speed of one rotation every 2.2 seconds. It doesn’t stop for the image taking – the rotation is transformed into a camshaft movement by the gate.

The film gate moves the film with a spike. When the gate is at the down position, it presses the film gate switch closed, which tells Arduino to send a +5 volt signal to the camera via USB. The camera has been prepared with the CHDK, and it knows to be waiting for it, focused and zoomed and ready. It then grabs a picture, the switch opens when the gate rises, and the Arduino program knows to start waiting for the next film gate closing. Simple really, but getting the timing to work wasn’t really that easy. The film transport switch is a little device that maintains the tautness of the film going into the takeup spool: if the switch opens, the film is slack, and the servo that is attached to the takeup spool axle turns faster until it closes again.

In the Arduino there are two things that have to be managed, timewise. One is the speed at which the servos run, and another is the delays that are necessary for Arduino’s command voltages to rise and fall. The camera basically expects to get 500 milliseconds of +5V into the USB plug to shoot, but the script provided by the CHDK wizards cut that down to just 100 or so milliseconds.

The rotation speed of the servos depends on the control pulse length I send to them from Arduino. I tested the pulse lengths extensively until I came to the conclusion that the best rotation speed is 22 revolutions per minute, and to get that to the film gate servo,  I have to issue this command:

myGateServo.writeMicroseconds(1565)

For the other servo, here are two pulse lengths to use: a fast one to run the servo until the film goes taut, and a slow one to allow the film to go slack again. The function that governs it looks like this:

 if(filmTransportSwitchOpen()) {
 myTransportServo.writeMicroseconds(1600);
 delay(100);
 }
 else
 {
 myTransportServo.writeMicroseconds(1500);
 delay(100);
 }
}

Incidentally, the delay(100) is a very common command in Arduino. It halts the execution of the program for the specified length of time in milliseconds, because without little delays, it’d be changing output pin voltages and checking input pins all the time, in a haphazard fashion. The delay commands bring some orderly timekeeping to the execution of the program.

If I use the pulse length 1485 microseconds, the servo stops altogether. This seems to be slightly different for each servo, though. It also is worth mentioning here that my servos are full-rotation servos, which is a special class in servo motors. Usually servos are commanded to turn in degrees of rotation, but I needed mine to rotate through. If the movement of the film wasn’t so crucial to the accuracy of the shooting, I probably would have tried printing my own film gate, but as you can see from the image with the 5 cent coin and the film, it’s not really an option if one is not a watchmaker.

Some people have asked me why I don’t use motion detection in the triggering of the photo. I could have used that since CHDK has motion detection, and for some time I considered using the camera’s capabilities for shooting. I tried that to some degree, but the results were not good (I freely admit I should have asked the demigods at CHDK for advice and tested seriously, but pretty soon I decided to go with a mechanical shooting trigger anyhow. This decision was heavily influenced by my colleague and friend Tero Karvinen, one of the world’s foremost Arduino experts and authors. He suggested that since I have definite movement in the gate I could use as the switch press, I should use that. It was a good piece of advice.

Be sure to check the first part of this Telecine project blog, and stay tuned for Part 3, the printing of the parts.

Latest edit: I was made aware that the actual LUA script for running the camera is not available anywhere.

I am sorry for this oversight, but this is the code, which you can save on your camera in the CHDK scripts folder and run from there. I am indebted to the kind folks at CHDK for writing this script in the first place.

--[[
@title Remote AFL V3
@chdk_version 1.3
--]]
shots=0

text_size = 2
xpos2 = get_gui_screen_width()==480 and 140 or 80 -- shot count
ypos2 = 180
clr1 = 258
clr2 = 259
set_console_layout(0, 1, 48, 6)


sleep(1000)
set_config_value(121,1) -- make sure USB remote is enabled 
set_record(1) -- switch to shooting mode
sleep(2000)

print("press Func/Set to focus")
print("press Menu to enable shooting")
repeat
wait_click(10)
if is_key('set') then -- reset AFL 
set_aflock(1)
print("locking focus")
end
until is_key('menu')
sleep(1000)
print("shooting")
print("press menu to halt")
press('shoot_half')
repeat sleep(10) until get_shooting()
repeat
wait_click(10)
if is_key('remote') then 
press("shoot_full_only")
repeat sleep(50) until(get_exp_count()~=ecnt)
release("shoot_full_only") 
shots=shots+1
end
string2 = "shots:"..shots 
draw_string(xpos2, ypos2,string2, clr1, clr2, text_size) 
until is_key('menu')
release('shoot_half')
sleep(500)
set_aflock(0)
set_config_value(121,0) -- make sure USB remote is enabled

 

Categories: 8mm film

1 Comment

Home Made 8mm Digitizer | Hackaday · 18/03/2016 at 15:31

[…] how and why he made the decisions he did. This series goes over the overall view of the project, using CHDK to control the camera, 3D printing parts, wiring the Arduino and writing the code that controls the […]

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.