CHDK/uBASIC/Scripts: Ultra Intervalometer

Ultra Intervalometer

 * Written for/on: Powershot S3 IS
 * Also works on: Should work okay on all of them.

This intervalometer script includes a few features that should fit most any need that arises. 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 or your [print]/[shortcut] button. Having this one repeat endlessly sort of supersedes my previous "Unlimited Interval Shooting" script so it could probably be removed now.(?)

My BASIC programming is 30-years rusty, and while I tested this for each option and it seems to be working just fine, if anyone runs into a problem please post about it in the DISCUSSION section (tab above), and I'll try to sort out what I did wrong. Documentation/Help (save as a small "ult_intrvl.txt" file to your /SCRIPTS/ folder)

This interval shooting script allows you to set a delay until the first shot in your intervalometer sequence as well as allowing the sequence to repeat 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 (or exit the  mode with other button presses). 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.)

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: The total time shown for each cycle does not take into account the shutter-speed time (at this time, but may in a future version). So if you are using long exposure times of 1 to 15 seconds, be aware that the total time for 1 Cycle will be much greater than what is displayed when first running the script. Exposures of 1.3 seconds or greater also add in a dark-frame subtraction to reduce image noise. In effect, a 15 second shutter speed actually takes 30 seconds to elapse. Until this can be figured into the script you'll just have to do some mental arithmetic if knowing a more accurate cycle time is important to you for long shutter-speeds.

IMPORTANT: In CHDK versions BEFORE "test1-pre12-xxxx-100a-65" (changeset 149), it has been found that lengthy intervalometer sessions with shutter speeds below 1 second (1.3 to 15 seconds) will cause your camera to show an error code or just shut down after 2 to 12 exposures. This has been traced down the noise reduction routine in the camera (whenever you see the "busy" in the viewfinder after a long exposure). Solutions: use shutter-speeds 1-second or faster.

This problem seems to be fixed now in version test1-pre12-xxxx-100a-65 (changeset 149).

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

rem Author - Keoeeit rem Written for S-Series rem Should be okay on others rem Use Endless mode with caution rem See documentation for important info @title Ultra Intervalometer @param a Delay 1st Shot (Mins) @default a 0 @param b Delay 1st Shot (Secs) @default b 0 @param c Number of Shots @default c 5 @param d Interval (Minutes) @default d 0 @param e Interval (Seconds) @default e 0 @param f Interval (10th Seconds) @default f 5 @param g Endless? No=0 Yes=1 @default g 0 p=a*60000+b*1000 t=d*60000+e*1000+f*100 if c<1 then let c=5 if t<100 then let t=100 if g<0 then let g=0 if g>1 then let g=1 if p<0 then let p=0 z=t*c y=p+z print "1 Cycle Time:", y/60000; "min", y%60000/1000; "sec" goto "interval" :interval if p>0 then gosub "pause" print "Shot 1 of", c  shoot for n=2 to c  sleep t   print "Shot", n, "of", c   shoot next n  if g=1 then goto "interval" else end :pause n=(a*60)+b for m=1 to n  q=n-m print "Intvl Begins:", q/60; "min", q%60; "sec" sleep 930 next m  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.)


 * NOTE: Updated for remapped shutter-speed values in CHDK Build 119 or later. If using earlier CHDK Builds the only thing that will be off is the cycle-time displayed being 6 seconds longer per cycle than actual time if using shutter-speeds from 10 to 15 seconds . Otherwise it is still fully functional.

Well, here's "Take 2" on the subject. I included a table of values that will help compensate for the extended dark-frame subtraction times for exposures over 1 second, and a few of the longer shutter times from 1/4 second to 1 second. So that the total cycle time is more representative. I timed these dark-frame shutter times using a stopwatch so they are prone to human error and reaction-time on my part, but they are all within 1/4th second. I was surprised to find that a 15" exposure actually took 33" to cycle. (The dark-frame exposure times used here for value h are in 10ths of a second, 210 = 21 seconds, in case you are curious how each one panned-out in timing tests.) These delays of longer than "shutter speed X 2" shows there's more going on under the hood than first suspected. But in all cases, even when shutter speeds are much faster there still seems to be a bit of a 1 to 2 second lag when you figure-in for camera processing overhead for each exposure. Use the "Cycle Time" as a general guideline, nothing more. It'll be close to within a few seconds at least. (Because I wasn't sure how much space would be taken up by the dark-frame shutter table, I tightened up the code a bit to make extra room. You might want to compare equivalent strings between this and the older version in case you want to edit the original Ultra Intervalometer for more compact code.)

v1.1 (updated 2007-05-30 c.e.) I forgot to separate the interval delay variable from the calculated time variable with the new black-frame delay times figured in. The interval delay will be accurate again if you use a shutter speed slower than 1/4th second. And a bug with 1 shot, a startup delay, and "endless" is fixed.

rem Author - Keoeeit rem Written for S-Series rem Should be okay on others rem Use Endless mode with caution rem See documentation for important info @title Ultra Intervalometer @param a Delay 1st Shot (Mins) @default a 0 @param b Delay 1st Shot (Secs) @default b 0 @param c Number of Shots @default c 5 @param d Interval (Minutes) @default d 0 @param e Interval (Seconds) @default e 0 @param f Interval (10th Seconds) @default f 5 @param g Endless? No=0 Yes=1 @default g 0

p=a*600+b*10 t=d*600+e*10+f if c<1 then c=5 if t<1 then t=1 if g<0 then g=0 if g>1 then g=1 if p<0 then p=0 u=t get_tv h if h=-12 then t=t+330 if h=-11 then t=t+270 if h=-10 then t=t+210 if h=-9 then t=t+170 if h=-8 then t=t+130 if h=-7 then t=t+110 if h=-6 then t=t+90 if h=-5 then t=t+70 if h=-4 then t=t+60 if h=-3 then t=t+50 if h=-2 then t=t+40 if h=-1 then t=t+35 if h=0 then t=t+18 if h=1 then t=t+15 if h=2 then t=t+13 if h=3 then t=t+11 if h=4 then t=t+10 if h=5 then t=t+8 if h=6 then t=t+6 x=p+(t*(c-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 c print "Shot", n, "of", c  if n>1 then sleep u*100 shoot next n if g=1 then goto "interval" else end


 * pause

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