Accurate Intervalometer[]

Written for/on: S3
Also works on: Probably any Digic II camera as is (Digic III will have to edit)
Required CHDK build: Fingalo's v 106 or later. (maybe recent SDM versions, if they have Fingalo's uBasic extentions.)
CHDK build must have the get_tick_count function

This script uses the get_tick_count function to accurately time the interval between intervalometer shots. If the interval is set too short, then the images will be acquired as rapidly as the camera can fire them.

Note: this script, as it is written, also uses 3 additional Fingalo uBasic commands: get/set_prop, set_raw, and set_raw_nr. These three commands are not necessary, and may even be undesirable for your application. I explicitly turn raw off using the set_raw command. (I never use raw, but sometimes inadvertantly turn it on, so this way I don't fill up a card with raw images by mistake). And I explicitly turn off the dark frame subtraction function using the set_raw_nr command.

The get/set_prop commands, as used here, probably won't work for digic III cameras (e.g., G7s) because they have different property # assignments from the digic II cameras. I use the get and set_prop commands to set the JPG compression to the lowest level (highest quality) and to set the image resolution to whatever the user desires (I typically use the 640x480 for intervalometer sequences where I intend to produce an AVI movie). Digic III camera users should either delete these commands and just preset those settings prior to running the script, or spend some time and find the Digic III property case numbers for these parameters.

The script uses the shoot command, which returns control to the script after it is done. It reads the time using the get_tick_count (which returns the time since the camera was turned on, in millisecond (msec) units). It then does a shoot, adds the interval to the last time (to get the next "go-time"), then waits for the next go-time to arrive.

As always, you can hit the shutter button to stop a script. (I've found with intervalometer scripts, you always want to err by telling it to take many more images than you think you need, as invariably something interesting will start to happen just as you near the end. So I usually am ending the script this way before the # of shots I specify have been taken).

Finally, this script does a 'sleep 100' command after the shoot command, so you can probably set the global script variable "Script shoot delay" to 0.

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

rem  author Divalent, based on my "simple intervalometer" script previously posted
rem     (which in turn was based on the ONMI intervalometer of Keoeeit)
rem  Camera: S3, and other Digic II camera's
rem  CHDK version: Fingalo's versions v106 or later
rem    (must have get_tick_count and get/set prop)
rem  Note: this intervalometer only shoots in photo mode (not video or burst)
@title Accurate Intervalometer
@param a Number of Shots
@default a 180
@param e Interval (Mins)
@default e 0
@param f Interval (Secs)
@default f 2
@param g Interval (0.1 Secs)
@default g 0
@param h image size (0,1,2,4,5)
@default h 4

  if e<0 then e=0
  if f<0 then f=0
  if g<0 then g=0

rem  TURN RAW OFF!  (this is my preference. You can delete)
  set_raw 0

rem  Turn NR off.  (I usually have this off, but just in case)
  set_raw_nr 1

rem ensure # of shots more than 1
  if a<2 then a=2

rem d = user specified cycle time (in 0.1 sec units)
rem now convert d to msecs (same units as get_tick_count uses)
  if d<1 then d=1

rem  ========  Digic III cameras, remove this section =========
rem, get jpg Image quality (= 0,1,2 from best to worst)
  get_prop 23 i
rem explicitly set quality to best
  set_prop 23 0

rem, get image size 24 = 0, 1, 2, 4, 8 for L, M1, M2, S, W
  get_prop 24 j
rem, check image size variable, force to a valid number
  if h<0 then h=0
  if h>4 then h=8
  if h=3 then h=4
  set_prop 24 h
rem  ========  end of Digic II camera-specific section =========

rem start with initial pause of 1 sec
  sleep 1000
  sleep 100
  print "Shot", n, "of", a

rem now we've done the first shot.  do the rest

  for n=2 to a
  if t<s then goto "wait_loop"
  sleep 100
  print "Shot", n, "of", a
  next n

rem, restore 23 & 24 Image quality and size
  set_prop 23 i
  set_prop 24 j