CHDK/uBASIC/Scripts: OMNI Intervalometer

OMNI Intervalometer

 * Written for/on: Powershot S3 IS - CHDK Build 87 (or higher) Required
 * Also works on: S2(?) other models need the ":vid" subroutine modified.
 * Version 1.6 - Updated 2007-06-10 c.e.(CHDK Build 119 remapped shutter-values.)

This script includes a command that only works on S-series cameras, it will not work as-is on A-series cameras. See notes below the script on how to modify this for A-series or other cameras. This version includes a few features that should fit most any need that arises. First you can select if you want to shoot single Still-Frame photos, Videos, Both, or shoot a timed Burst event. You can set a delay in minutes and seconds to the first shot of your intervalometer sequence, the number of shots for the intervalometer sequence, as well as allowing you to flag a Yes or No "Endless" option to repeat the sequence endlessly until you interrupt it manually by pressing the shutter button. Documentation/Help (save as a small "omnintrvl.txt" file to your /SCRIPTS/ folder)

This interval shooting script allows you to choose between photos, videos, both, or a high-speed burst interval. You can also set a delay until the first shot in your intervalometer sequence. You may also choose to repeat the sequence endlessly. Use the "Endless" repeat with caution! If that flag is set it repeats non-stop until you interrupt it by pressing the shutter-button. Word of Warning: If you are running off of an AC power-supply and going to set the endless-repeat flag do so at your own risk. You should not allow your camera to run for many hours or days as it can harm your camera! (Though I'm not sure why, other than that warning is in all the Canon manuals.)


 * Photo=0 : Records single-frames only.
 * Vid=1 :  Records video for the time set in Video/Burst time settings.
 * P&V=2 :  Records a full-size single-frame at the begining of each video event.
 * Burst=3 : Puts camera into Continuous shooting mode and holds the shutter button for the time set in Video/Burst time settings.

Hint: if needing an endless intervalometer sequence of one shot per interval, it is easier to set number of shots to 1, turn on the "Endless" option, and then use the "Delay 1st Shot" as your time between shots -- instead of cranking up the number of shots to a very high number and using the "Interval" time settings.

These intervalometer scripts that use the "shoot" command (as opposed to the 'click "shoot_full"' command) also set focus and exposure before each shot (if the camera is not in Manual mode). Unlike the camera's own built-in intervalometer where exposure and focus is set for just the first shot. This allows it to compensate for all the varying conditions that can take place over the course of many minutes and hours, far surpassing Canon's concept of a useful intervalometer.

Note 1: The count-down timer for the "Delay to 1st Shot" phase won't display beyond the time you have set for your Power Saving / Display Off settings. On the S3 IS this is a maximum count-down display of 3 minutes. The script will continue running however. You just won't have a running tally of how long until the next intervalometer sequence or shot.

Note 2: If using shutter speeds longer than 1 second, then the dark-frame subtraction time is now figured into the total interval cycle-time. Use the total cycle-time as just a good approximation, as camera overhead for many frames could add up to make the total a bit different than what this script calculates.

Note 3: Due to needing a long delay in the :burst subroutine to make it work, there will be an extra 2.5 seconds of time added into your pause between events when using the Burst option. If needing more exact interval timings for burst shooting events, subtract at least that much time from your required interval spacings. OR if you wanted to manually engage your camera's high-speed "continuous" (burst) mode, you could edit that subtroutine so it's not doing it for you. Remove the 3 "click 'timer'" and the "sleep 2000" commands.

Script Code (save as "omnintrvl.bas" to your /SCRIPTS/ folder)

rem Author ~Keoeeit~ rem S-Series cameras ONLY rem Use Endless mode with caution rem See documentation for important info @title OMNI Intervalometer @param a Photo=0 Vid=1 P&V=2 Burst=3 @default a 0 @param b Delay 1st Shot (Mins) @default b 0 @param c Delay 1st Shot (Secs) @default c 0 @param d Number of Shots/Vids/Burst @default d 5 @param e Interval (Minutes) @default e 0 @param f Interval (Seconds) @default f 0 @param g Interval (10th Seconds) @default g 5 @param h Video/Burst Minutes @default h 0 @param i Video/Burst Seconds @default i 0 @param j Endless? No=0 Yes=1 @default j 0 p=b*600+c*10 t=e*600+f*10+g v=h*600+i*10 if a<0 then a=0 if a>3 then a=3 if d<1 then d=5 if t<1 then t=1 if j<0 then j=0 if j>1 then j=1 if p<0 then p=0 if v<10 then v=10 if a=0 then v=0 u=t get_tv k if a=1 then k=-14 if a=2 then t=t+10*d if a=3 then t=t+25*d if k=-12 then t=t+330 if k=-11 then t=t+270 if k=-10 then t=t+210 if k=-9 then t=t+170 if k=-8 then t=t+130 if k=-7 then t=t+110 if k=-6 then t=t+90 if k=-5 then t=t+70 if k=-4 then t=t+60 if k=-3 then t=t+50 if k=-2 then t=t+40 if k=-1 then t=t+35 if k=0 then t=t+18 if k=1 then t=t+15 if k=2 then t=t+13 if k=3 then t=t+11 if k=4 then t=t+10 if k=5 then t=t+8 if k=6 then t=t+6 x=p+(v*d)+(t*(d-1)) print "1 Cycle Time:", x/600; "min", x%600/10; "sec" goto "interval"
 * interval

if p>0 then gosub "pause" for n=1 to d print "Shot", n, "of", d  if n>1 then sleep u*100 if a=0 then shoot if a=1 then gosub "vid" if a=2 then gosub "vid" if a=3 then gosub "burst" next n if j=1 then goto "interval" else end
 * pause

r=(b*60)+c for m=1 to r q=r-m print "Intvl Begins:", q/60; "min", q%60; "sec" sleep 930 next m return
 * vid

if a=2 then shoot if a=2 then sleep 1000 click "video" sleep v*100 click "video" return
 * burst

click "timer" press "shoot_half" sleep 500 press "shoot_full" sleep v*100 release "shoot_full" release "shoot_half" sleep 2000 click "timer" click "timer" return

I timed the :pause subroutine and tweaked the sleep to 930 milliseconds to be about as accurate as possible for that loop to span 1 second for the for/print/next execution time. This was calculated on an S3 IS, your camera's uBASIC speed may vary, tweak "sleep 930" accordingly if you need more precision. (Accuracy testing hint: put your camera's display-on time to 3 minutes, set the script's Delay 1st Shot for 4 minutes, see what count-down timer line it ends on just before the screen goes blank (don't jiggle the camera or it resets the display-on time). On my S3 IS the screen went blank just as it was to start counting the 4th minute.)

I put the routine to engage video on a separate subroutine named ":vid" so it would be easier to modify this for other cameras.

Other camera models (A-series), will have to modify this ":vid" subroutine completely, using the proper key-presses or modes and menus on their cameras. I looked at the code for another video intervalometer script, but it appears that on other cameras that you have to set your camera for video mode from a dial or something, as there are no commands in the script to engage video. If someone else would like to jump in and add a way to include video for them on this script to make it compatible to other cameras that would be great. Because you can test it, whereas I can't.

In order to get around the camera's time requirements for going into and out of different modes when choosing to shoot both still-frame and video, I had to put in a full 1 second delay between the "shoot" and click "video" commands. I compensated for this delay in the overall "print 1 Cycle Time".

p.s. I totally remapped all the variables from earlier versions, just to make this easier to follow for anyone that wants to tear it apart or make it better. Hey? Do I at least get an award for being the first to use up all 10 user-definable variables? :-)

v1.4 Update: Okay, I think I got most of the bugs worked out of it. The problem was in trying to use the old original intervalometer script as my base to work from. I had to rewrite the main :interval routine to get it to accept all these options properly, as well as keep track of total cycle-times properly for all 3 shooting modes (photo-only, video, or photo+video). It appears to be doing everything as planned, if anyone notices some main snafu, please throw a note in the "talk" section.

v1.5 Update: I added in a routine to engage high-speed burst mode. It is after-all titled "OMNI Intervalometer", I wouldn't want to get blamed for false advertising. :-) HEY!! I only gots 10 bytes of space left out of 2000 available! Is there REALLY a 2k script limit and is that 2000 or 2048 bytes? I had to pack together all kinds of stuff to get under 2000. :-)

v1.6 Update: CHDK Build 119 had its shutter times remapped better so there are no gaps in the table. The script was tweaked accordingly. This script can still be used as-is on earlier builds, but the 1-Cycle Time reported will be in error, being 6 seconds longer than that displayed if using shutter speeds from 10 and 13 seconds, and 18 seconds shorter if using a 15 second shutter speed, Everything else will work just fine, it's just the Cycle-Time display will be off in those 3 instances.

If you don't have access to CHDK Build 119 or later and want a more accurate display, then you can just edit these lines if k=-12 then t=t+330 if k=-11 then t=t+270 if k=-10 then t=t+210 back to: if k=-13 then t=t+330 if k=-12 then t=t+270 if k=-11 then t=t+210