jump to navigation

Astrophotography Using Canon Camera’s Hack Development Kit August 16, 2009

Posted by GuySoft in Astronomy, Crictor, diy, Hamakor, ITU, linux, open source, programming.
Tags: , , , , , , , , , , ,

CHDK booting

Hi all,

I am going to explain here how I managed to use the Cannon open source hack development kit , known as CHDK, to photograph stars and even create neat movies of the stars motion.

It all started this Monday, I was lucky to see that there is going to be Perseids meteor shower, a day in advance. So I had time getting the code ready before it was too late. I thought I would go somewhere next to Jerusalem and photograph, but in the end, friends of mine (Shy and Anna) from the Israeli Astronomy Association, which I am part of, told me they are going down south to the dessert, far away from light pollution, to take count of the meteors for the IMO. So I joined him, and my data is also available.

Before all the technical stuff, here is a video I made that shows you what this all comes to:

Now back to CHDK, and how this was done.

What is CHDK? And how do I install it?

CHDK is a firmware addon for Cannon powershot digital cameras. It supports most of them, mine is a simple powershot A590, costs to date about 700 NIS. Moreover, since its an addon, it will not void warranty, and can’t damage your camera. It has a lot of features (including games and an e-book reader!).

Installing it is really easy and comes the complete version comes with everything you need. All you do is extract the version for your camera on your SD card. Then start the camera in the review mode, and select in the menu ‘Firm Update…’, Look at CHDK’s wiki for more info.Now that CHDK is running,  pressing the (used to be useless) printer button on your camera. It will bring an <alt> symbol at the bottom of the screen, meaning all buttons will control the options of CHDK. Pressing the printer button again will move you back to use the camera menus. Restarting the camera will wipe out CHDK from the memory (you need to do ‘Firm Update’ again, to use it again). So if you want to stop CHDK, just turn the camera off and on. Uninstalling is just removing CHDK’s files from the card.

Firm Update (not really a firm update)

Firm Update (not really a firm update)

My Basic Ubasic application

Once I got CHDK running, and after  looking around the menus and confusing people by playing Reversi on my camera, I started looking in to the scripting capability.

One can write scripts both in ubasic and lua. I wrote mine in ubasic, although I never wrote in ubasic/basic before, it was dead easy to pick up. I choose ubasic because some developer told me lua has some timing problems. Both languages don’t need compilation, just write a text file and put it in the /CHDK/SCIPTS folder in the SD and they will run. To run a script select the ‘load script’ option, when in <alt> mode. Now, when in standby mode, using the capture button will run the selected script, and not just photograph as normal.

The programming commands I got mostly from this tutorial. Note how easy it is to let the user to have configurable parameters, print stuff on the screen, and shoot images. You can also change parameters of the camera using PropertyCase commands (see my code to see how it is used).

My meteor script, avilable here, it basically (pun!)  starts the camera, disables flash and goes in to loop shooting images on a given ISO and exposure time until the shooting button is pressed again. You can see the selection interface on the right (sorry for the typo on the word Meteor, it was late). If you use my script then you better disable the screen display before shooting, and the review time, so at night, all you see is a blinking led telling you the camera us working (was ok for the astronomer standard too). The camera lasted about an hour of photographing before the batteries ran out. Luckily I had about 4 pairs of AA batteries. There is much to improve in the script, but it works.

Loading the Meteor program

Loading the Meteor program

Processing Animations with FFmpeg

Sadly, I did not catch any meteors in any of my 700 images. I think I did not set the aperture to be open all the way, I expected it will do it in a dark setting.

However, connecting all the images together gave me an animation of the moving sky Using FFmpeg. It seems that FFmpeg is a bit picky about its file formats. So here is how to take your jpg images and turn them to a movie:

  1. You will need to download all your images to a single folder.
  2. Run this bash script I wrote, it will make an ‘out’ folder in the folder, and copy all the files numbering them 000.jpg 001.jpg etc. Like FFmpeg likes, otherwise ffmpeg segfaults (thanks to #ffmpeg on freenode for the guidlines):
  3. #!/bin/bash
    # Not enough information to compute
    if [ $# -lt 1 ]; then
    echo "Syntax: `basename $0` "
    #if dir exists, then go over all files and copy them
    if [ $# -eq 1 -a -d "$1" ]; then
    mkdir -p $1/"out"
    for file in $1/*.[jJ][pP][gG]
    cp "$file" $1/out/$(printf "%0.3d.jpg" $i)
    i=$(( $i + 1 ))

  4. After the jpg images ready, you can run FFmpeg with this command in your folder: ffmpeg -r 24 -f image2 -i %3d.jpg -b 700000 -s 720x480 output.avi . Note you can change resolution there, bitrate, and do anything ffmpeg does. Since the images are in a camera quality you can even do HD video with a cheep camera!
  5. Thats is, you have a time lapse video

My Videos

List of videos using this script. I also made a page for them here.


CHDK seems to have many new ways to take a simple camera, one you might even already have, and do things you never thought possible on a normal camera. Maybe next I’ll try using RAW imaging, that will let me get even better views of the stars.

Thanks to #chdk and #ffmpeg on freenode, for helping me out with the code.

And thanks to Anna and Shai for a wonderful night 🙂

Update: There is a forum thread in CHDK’s website about the blog post with even more talks.

Meteor Counting

Meteor Counting

Waiting in the middle of nowhere, for my bus up north

Waiting in the middle of nowhere, for my bus up north

Orion, Venus and Sunrise



1. ram-on - August 16, 2009

פוסט לתפארת.

מגניב לאללה. רץ לנסות על הפאור שוט שלי.

2. Tom - August 20, 2009

Hey cool stuff man, thx

I was doing a search on Canon Powershot A590 IS and AStrophotography since I’m about to buy this Camera.

I like it because it’s threaded as well, you can add an Digi T Adapter and put it on the eyepiece of your telescope.

GuySoft - August 20, 2009

Glad you like it 🙂
Using a Digi T Adapter would be cool. I tried searching for them in e-bay, but can’t find anything. Do you have any link for a decent place that sells them?

If you are planning to buy a camera for serious astrophotography, of course, you should consider a good DSLR camera, or a CCD that connects to your telescope directly. But of course, this solution is really cheep.
I think I would have got a DSLR, but since my telescope has no goto mount. I can’t do much.

3. Tom - August 20, 2009

Yeah, I have an Orion XT10, no go to or tracking, besides I really cant spend or really dont want to on a DSLR and other stuff because I like the pictures I took with a cheap HP camera so far.

http://www.scopetronics.com/ for digi t ring for your Canon, click on the left: Digital Camera Adapters under Imaging-Telescope Accessories than click on the 5th link Digi-T ..for Digital Cameras and you will find NEW! Digi-T System for Canon A570 IS and A590 IS

That site seems less expensive and some people say they are not responding, others say they are, some say to go here: http://www.cncsupplyinc.com./ I really dont know, when my time comes, I will probably call them to be sure! Good luck!

Some pictures of The Moon I took ther other night: (With a HP Photosmart E337 75$ cam!)

4. GuySoft - August 20, 2009

Hmm, they seem to really limit your field of view.
About 5 years ago I got for the same price a SLR, you can see that the pictures are much better. Here is my moon photo for comparison. Sadly that camera died.

5. Tom - August 20, 2009

Hehe, actually these are just closeups!

I can take the whole moon easilly, I will make another video with the other pictures I have wth the Moon. They will be like yours exactly. I can make them closer or further.

6. Tom - August 24, 2009

Hey bud,

Forgot to ask, which Memory card do you think I should get, especially when using CHDK, I think around 2gb should be enough? Should I get Sandisk Ultra II SD 2GB?

GuySoft - September 4, 2009

I used 4 and 2GB. really does not matter, depends how many photos you plan to capture. You can also use a 32MB if you really want.

7. הבלוג של GuySoft » צילום אסטרונומי באמצעות ערכה לפריצת התוכנה של מצלמות קנון - October 21, 2009

[…] גם שירשור בפורום של CHDK אודות הפוסט הזה. והפוסט האנגלי שלי. סופרים מטאורים מחכה באמצע המדבר, לאוטובוס חזרה צפונה […]

8. Sameer - March 9, 2013

your article help me to do my first ever Time-lapse Astrophotography
here is result of your script from highly light polluted city Mumbai India. only concern that my camera back controls left button not functioning as desire. it’s 5 year old cam might need servicing or malfunctioning component.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

%d bloggers like this: