Showing posts with label Raspberry Pi. Show all posts
Showing posts with label Raspberry Pi. Show all posts

Sunday, January 6, 2013

Script to control Canon 1100D on Raspberry Pi

I've finished the first part of my plan to use Raspberry Pi to remote control a camera. I put together the efforts from http://mikkolaine.blogspot.fi/2012/08/controlling-canon-eos-1100d-with-linux.html and http://mikkolaine.blogspot.fi/2012/12/raspberry-pi-canon-eos-1100d-and-gphoto.html and wrote a Python script to do it all.

Why? With the camera itself I can take max 10 photos sequentially after having to go to the camera and press the trigger again, I can use exposure times only to max 30 seconds and as a result I get hundreds of photos named IMG_6013.CR2 and such.

The script I wrote:
  1. Asks for 
    • ISO
    • exposure time
    • number of photos
    • name for the object in photos.
    Name is required for naming the pictures and directory for them.
  2. Sets all the necessary settings for camera. You need of course to aim the camera, focus it manually and set the control wheel to manual mode (M).
  3. Takes number of photos, resetting the USB connection after each photo (because on RasPi this is required)
  4. Downloads each photo instantly from the camera and uploads it to my NAS (mounted by NFS on RasPi). The photos are put to a directory by name asked before and named with a timestamp. For example M42_2012-12-16_16.22.28.099570.cr2.
I just ran a test of 200 photos with exposure time of 31 seconds and it seems to have worked perfectly.

The script and instructions for it can be seen here. It's easier to share files on Google Sites than Blogger and I also want a permanent page of that. I'll update the page to always include the newest version of my script.

Tuesday, December 11, 2012

Raspberry Pi, Canon EOS 1100D and Gphoto

I finally have it! RS Components delivered it last week. Now all my free time has gone tweaking RasPi. :)

Because I plan to use RasPi as a media center, I chose Raspbmc as the operating system. It's based on Raspbian, which is basically Debian on ARM with some Raspberry specific packages. I'm sure I can get anything on this.

Then came the problems. Gphoto can control DSLRs and after initial problems, I got it working with my EOS 1100D. On RasPi, however, there are some more problems. First run works properly, but after the first I get only:

*** Error ***
PTP I/O error

*** Error ***
An error occurred in the io-library ('Unspecified error'): No error description available

After googling a bit and asking on #gphoto at Freenode, I found out the problem is not with Gphoto, but with Raspberry Pi. Hardware or software, no one seems to know.

There is a workaround!

After taking a photo with 

gphoto2 --wait-event=2s --set-config eosremoterelease=Immediate --wait-event=180s --set-config eosremoterelease=Off --wait-event-and-download=5s

the usb connection has to be reset. I found a piece of code to do just that: http://marc.info/?l=linux-usb&m=121459435621262&w=2. I copypasted that into usbreset.c, compiled it with gcc usbreset.c -o usbreset, and now taking photos seems to work. I'm running a loop of taking a photo, resetting usb and deleting the photos. While I'm writing this, it has successfully taken over 50 photos in a row.

Next I'm going to write a script to take photos, renaming them and sending them directly to my NAS.

Sunday, August 19, 2012

Controlling Canon EOS 1100D with Linux

I bought a DSLR camera mainly for astrophotography. Of course I use it for other photography as well (like 20GiB of photos of our 2 months old son) but reason for buying it was astrophotography. I decided to go as cheap as possible and found a Canon EOS 1100D for 300€. Not bad.

I can set the exposure time for 1100D to max 30s. While this is a long time, it's not enough for photographing nebulae or other dim objects. I got a tracking mount EQ3-2 which is supposed to make possible exposure times of couple of minutes. Still I have to take several exposures of the same object to get total exposures of maybe 20 minutes. I still haven't had a chance to test my equipment because of the summer here in Finland. Too much light even on midnight.

To take exposures longer than 30s I have to use camera's bulb setting. I use mainly Linux at home so I can't use Canon's EOS utility. Luckily there is Gphoto. It doesn't support all the cameras and for a while looked like 1100D wasn't on the supported list. I could take photos and change settings but couldn't get bulb to work. Developers on #gphoto in Freenode were kind to help me out and the correct commands for changing settings and using bulb are:


# gphoto2 --set-config iso=400
# gphoto2 --set-config shutterspeed=bulb
gphoto2 --wait-event=2s --set-config eosremoterelease=Immediate --wait-event=180s --set-config eosremoterelease=Off --wait-event-and-download=5s

The red --wait-event tells camera the exposure time in seconds.

I'll probably get the adapters required to mount camera on EQ3-2 next week and be able to test everything. Later I'm supposed to get a Raspberry Pi (might take two more months) and my plan is to use that to remote control the camera. I'll install Debian on the RasPi and use ssh to control it. If everything works as planned I'll get to sit inside while taking the photos of night sky.

If I blog here about instructions for something I usually write about it to a website as well. Blog doesn't work too well with information that might change and the reason for me to blog is to help others that might be doing the same thing. So you might want to check this page for Gphoto instructions.