Selective Intervalometer

565pages on
this wiki

Selective IntervalometerEdit

Author : SkyWalker9

link >  CHDK forum discussion thread for Selective Intervalometer

Update: This version of the script has added a Day of the Week (DOW) parameter that allows the user to easily choose: everyday of the week, just Monday through Friday, or allows the user to manually choose the days of the week at run time. This script was designed for high accuracy and flexibility in mind. The script provides the ability to select shooting sequences by 1) number of days to run 2) specific days of the week 3) hours/minutes of the day, and 4) specific interval/cycles in minutes/seconds.

Having the ability to individually select only the days of the week can save substantial amounts of SD card space and the need for deleting unwanted photos later. For example, lets say you only wanted to shoot photos on Monday, Wednesday & Friday. Using this script versus a "range" script you would not have a series of photos from Tuesday & Thursday that wasted space on your SD card and you would realize a 40% savings in space requirements. You are still be able to select a "range of days" similar to a "range" intervalometer script simply by selecting all of the days of the week in the "range".

This script also provides the user with the capability to set the number of days the script is to run. If you do not want to set a specific range of days, you can set the "Number of Shots" to 0 and the camera will shoot as many shots as can fit on the SD card. For example, if the "Number of Shots" is set to 0, the script will shoot the maximum number of shots using the interval, days of week, and the hours/minutes selected during the dates indicated. This avoids having to calculate the number of shots in the days time periods using the selected interval. It is left to the user to insure there will be enough free space available on the SD card (note: after entering the number of days the amount of disk free space is displayed in MB and percent available).


No camera specific statements are used so this script should work on most CHDK equiped cameras - Requires ability to use Left, Right, and Set buttons on camera - Ensure Date & Times are set properly on your camera; script uses 24 hour times - Due to the normally long time sequences, an AC adapter and tripod are recommended

Script termination.Edit

There are basically four ways to exit this script: - Set the number of days to run - Set the number of shots to greater than 1 - Too many shots for the remining free space on SD card; error message, camera remains on - Pressing the shutter button; usually used when user needs to change something, camera remains on

Script Parameters:Edit

Number of Shots, Interval (mins), Interval (secs), Start Hour (24 Hr), Start Minute, End Hour (24 Hr), End Minute, and DOW all=1 M-F=2 sel=3

Accuracy of interval times.Edit

Basically there are two different methods that intervalometer scripts usually employ for interval times, 1) reading/using the camera's built-in time clock and 2) using the CHDK "tick_count" statements. Using the camera's built-in time clock isn't as accurate as using the CHDK "tick_count" statements, therefore this script uses "tick_count" statements in order to keep the interval times very accurate.

Error checking.Edit

As with most scripts, it is wise to do error checking on critical inputs provided by the user since intervalometer scripts usually run over longer time periods and involve shooting large numbers of photos. Therefore, this script tests critical inputs and where possible, corrects obvious errors so that the script can attempt to run. There is one error check that will terminate the script early - if the Start Time is set to occur after the End Time.

Caution message.Edit

Since this script normally requires a tripod or hard surface, a Caution message will be displayed if the Image Stabilization (IS) is enabled. The IS mechanism operates by correcting shake. When there is no shake, or when the level of shake is below the threshold of the system's detection capability, use of the IS feature may actually add unwanted blur to the photograph, therefore you should shut it off in this situation.

Entering "real-time" user input.Edit

One limitation of UBasic is that the size of the script appears to determine the maximum number of input parameters the script can display - small scripts can have more than larger scripts. Due to the size of this script, only 7 parameters could be used. However, this limitation was overcome by inputing data in "real time" during the running of the script. This method is used to enter the Number of days to shoot and Day Of the Week (DOW) user inputs.

The Day of the Week (DOW) parameter allows the user to select the following options: all=1, M-F=2, or sel=3. Obviously the 'all' would indicate the script is to shoot everyday of the week, the 'M-F' option directs the script to shoot only on the week days, and the 'sel' option allows the user to select the days of the week manually at run time.

Once the DOWs have been input (and number of days if using this method), the script runs unattended until completion or if terminated early by the user by pressing the shutter button. After the last DOW or number of days entry, the script waits 2 seconds to display a reminder of the amount of free disk space remaining on the SD Card AND allow camera vibrations to subside.

The initial display (after the remaining free space message) will look like this:

   180 shots at 1m 15s      2/14/11 +11 1m 15s
   S M T W T F S            S M T W T F S
   1 2 3 4 5 6 7:  145      1 2 3 4 5 6 7:  145
   Hours (11:30-11:40)      Hours (11:30-11:40)
   Waiting...               Waiting...
   Using #Shots            Using Number of days (#Shots set to 0)

For each shot afterwards, the screen will redisplay the setup info with the last shot number and the DOW & time the camera shoots the photo. The time indicated in the JPG EXIF data will indicate a time that is one or more seconds later. This is due to the length of the exposure + processing + the time required to save to the SD Card.

   180 shots at 1m 15s      2/14/11 +11 1m 15s
   S M T W T F S            S M T W T F S
   1 2 3 4 5 6 7:  145      1 2 3 4 5 6 7:  145
   Hours (11:30-11:40)      Hours (11:30-11:40)
   Last: 8 Sun at 11:40:0   Last: 8 Sun at 11:40:0
   Using #Shots            Using Number of days (#Shots set to 0)

The DOWs are indicated to the right of the numbers below the days of the week (In the example above, the days of the week to shoot photos is indicated as "145" which means that on Sunday, Wednesday & Thursday the script will shoot photos during the hours chosen using the Start and End time parameters.

The Number of days display above "2/14/11 +11 1m 15s" indicates that 12 days were chosen for the script to run starting on that days date of "2/14/11" and running "+11" more days and at midnight the script will shutdown (if there are no photos scheduled for that DOW). If there are shots scheduled on the last day of the run, then the camera will shut down after the last shot. Therefore, if you have additional days after the last scheduled DOW, the camera will stay on during those days until midnight of the last day.

Since UBasic doesn't have a capability to format the numbers when printing, numbers cannot be displayed with using a specific format, so we have to accept what is available. In the example above the time in "Last: 8 Sun at 11:40:0" looks "nice", however it will look odd 3 minutes after midnight (Last: 8 Sun at 0:0:3). Similar formatting will be apparent in the "Hours (11:30-11:45)" such as "Hours (0:3-23:58)".

Miscellaneous Comments.Edit

The "shoot" command waits for the camera to perform some normally automatic actions, such as auto-focusing, charging the flash, etc. The "shoot" command in an intervalometer script allows it to compensate for all the things that can change over the course of many minutes/hours/days. In dim light it can sometimes take 2 or more seconds for a camera to hunt for focus. If you are planning on using this script to set auto-focus in low-light conditions, it would be good to change the 600 of the "sleep 600" command to a value from 1500 to 2500.

The shortest interval of time between shots is dependent upon many factors: shutter speed, size/resolution of photos, model of camera, if RAW is chosen, using bracketing for exposures (HDR), the camera processing time for each JPG, class of SD card, etc.

The mimimal interval time using my SX20 with a class 10 SD card in low light conditions were about 9 seconds. I expect this to vary by camera model, class of SD card, etc.


Save the script as a *.BAS file and place in the CHDK/SCRIPTS folder to use.

rem Author SkyWalker9
@title Selective Intervalometer
@param a Number of Shots
@default a 10
@param e Interval (mins)
@default e 5
@param f Interval (secs)
@default f 0
@param p Starting Hour (24 Hr)
@default p 7
@param q Starting Minute 
@default q 0
@param r Ending Hour (24 Hr)
@default r 18
@param s Ending Minute
@default s 0
@param l DOW all=1 M-F=2 sel=3
@default l 1

rem Check input variables for proper values
  if a<0 then a=2
  if e<0 then e=0
  if f<0 then f=0
  if p<0 then p=0
  if p>23 then p=23
  if q<0 then q=0
  if q>59 then q=59
  if r<0 then r=0
  if r>23 then r=23
  if s<0 then s=0
  if s>59 then s=59

rem Calculate user specified cycle/interval time in ms
  if d<1 then d=1

rem Next two statements combine "hour" and "minutes" (hour:11 minute:30 = 1130)
rem This reduces the number of "if" statements required in "check_time" subroutine

rem Print Error message if Start Time is after End Time print msg & exit
  if r>=p then goto "ok1"
    print "START Time after END"

rem this section selects each day of week (DOW) & packs the DOWs into the single variable L

rem This sets DOW to every day of the week
  if l=1 then L=1234*1000+567

rem This sets DOW to M-F 
  if l=2 then L=23456

  if L<>0 then goto "sel_fini"

  for i = 1 to 7
    print "Left=No  Right=Yes"
    select i
      case 1; print "Sunday?"
      case 2; print "Monday?"
      case 3; print "Tueday?"
      case 4; print "Wednesday?"
      case 5; print "Thusday?"
      case 6; print "Friday?"
      case 7; print "Saturday?"
    print " "
  is_key k "left"
  if k=1 then let K=0
  is_key k "right"
  if k=1 then let K=1
  if K=9 then goto "sel_choose"
  if K=0 then goto "sel_off"
  next i


if a<>0 then goto "bypass1"
  print "Left(-)  Right(+)"
  print "Set when done"
  print "Number of days: "J
  print " "
  is_key k "left"
  if k=1 then let J=J-1
  is_key k "right"
  if k=1 then let J=J+1
  is_key k "set"
  if k=1 then goto "bypass1"
  if J<0 then let J=0
  goto "v2_exit"

rem Print a Caution message if Image Stabilization (IS) is enabled
  if x<>3 then print "Caution: IS enabled"

rem Displays the disk space/free disk space in MB & percent
  print "Free Space "y"MB ("z"%)"
  print " "
rem Built in delay of 1000 ms to allow camera vibrations to stop plus 1000 ms
rem to temporaily display the Caution msg if needed.
  sleep 2000

rem Calculate length of total time period (1 min=60K "ticks"). This is done to
rem allow use of "tick_count" instead of "sleep" statements. This results in more
rem consistent/dependable/accurate interval cycles.

rem This calculation corrects the length of time period above if the user starts
rem the script during the DOWs & Start/End range they have selected
  gosub "dayofweek"
   if w=K then goto "change"
   if x<1 then goto "ok3"
   goto "test_DOW1"
  F=get_time 2
  Q=get_time 1
  if x>=P and x<R then O=((r*60+s)-(F*60+Q))*60000

rem Initializes shot counter; script shutdown camera when n=a in the "take_shots" section 

rem if Number of Days J<>0 then use Number of Days method; V counts up to J
  if J=0 then goto "bypass"
   gosub "dayofweek"  
   Y=get_time 5

rem -- Do not add comments after this point ---
  if J=0 then print a" Shots at "e"m "f"s" else print G"/"H"/"I" +"J-1" days "e"m "f"s"
  print "S M T W T F S"
  print "1 2 3 4 5 6 7: "L
  print "Hours "p":"q"-"r":"s
  print "Waiting..."
  gosub "dayofweek"
  if J=0 then goto "test_DOW2"
  if w=v then goto "test_DOW2"
   if V>J then shut_down
  if w=K then goto "check_time"
  if x<1 then goto "check_day"
  goto "test_DOW2"

  F=get_time 2
  Q=get_time 1
  if F>=P and F<R then goto "take_shots"
  goto "check_day"

    x=get_time 2
    y=get_time 1
    z=get_time 0
    sleep 600
    gosub "info"
    if n=a and J=0 then shut_down
    if b<S then goto "wait_loop"
    if b<i then goto "more" 
    if V=J then v=W+1
    goto "check_day"

  D=get_time 3
  M=get_time 4
  Y=get_time 5
  A = (14-M)/12
  Y = Y-A
  M = M+12*A-2
  w = (D+Y+(Y/4)-(Y/100)+(Y/400)+(31*M/12))%7

  if J=0 then print a" Shots at "e"m "f"s" else print G"/"H"/"I" +"J-1" days "e"m "f"s"
  print "S M T W T F S"
  print "1 2 3 4 5 6 7: "L
  print "Hours "p":"q"-"r":"s
  select W
      case 0; print "Last:"n" Sun "x":"y":"z
      case 1; print "Last:"n" Mon "x":"y":"z
      case 2; print "Last:"n" Tue "x":"y":"z
      case 3; print "Last:"n" Wed "x":"y":"z
      case 4; print "Last:"n" Thu "x":"y":"z
      case 5; print "Last:"n" Fri "x":"y":"z
      case 6; print "Last:"n" Sat "x":"y":"z
Advertisement | Your ad here

Around Wikia's network

Random Wiki