Flexible Intervelometer Script - Script Writing - CHDK Forum

Flexible Intervelometer Script

  • 12 Replies
  • 12394 Views
Flexible Intervelometer Script
« on: 21 / May / 2008, 20:15:03 »
Advertisements
OK, I finished yet another Intervaometer script. This one offers quite a few options. Due to use of "get_prop 206" and "get_tick_count", timing should be relatively accurate. See timing test info below. It is written to run on DigicIII cameras. If you search and replace all occurences of "206" with "205," it should work fine on DigicII.

Mode: The script offers 3 ways to determine your number of shots. # lets you enter the total number of shots you want and the interval between them. Infinite continues to shoot until memory or battery runs out at the specified interval. Time calculates the number of shots and interval based on your desired frame rate, desired video legth and the original timespan. See notes on time mode below.

Number of Pics: In # mode, this is the total number of pictures you want taken.

Interval: This is the time, in minutes and seconds, you want between each shot in # mode and infinite mode.

Initial Delay: The time in seconds you want the camera to wait before starting the sequence.

Lock Focus: When on, all shots will use focus and exposure that will be locked in on first shot. When off, the camera will set focus and exposure before each shot.

Original: Timespan, in hours and minutes, that you would like to capture images of. Only used in time mode.

Target: Time, in minutes and seconds, that you would like the end video to be.  Only used in time mode.

FPS: Framerate (frames per second) you would like end video to be.  Only used in time mode.

Log: If on, info about the sequence will be written to PR_SCREEN.txt in your scripts directory. Info includes time of day at which sequence starts, the total number of pictures to be taken, the total time the script is expected to run, and the interval between shots. Log is especially useful in time mode, as you may not know the interal and number of shots ahead of time.

About time mode: This script deals only with whole seconds. Intervals will be rounded down to the nearest whole number. For example, if you enter time parameters that would call for a 1.33 second interval, the actual interval used will be 1 second. The script has been designed to compensate for this - if you ask for it to shoot for an hour, it will shoot for 1 1/12 hours, producing 3600 shots at 1 second intervals instead of 2700 shots at 1.33 second intervals. If this isn't satisfactory, check out Time Bandit. Time bandit is an intervalometer that works similar to time mode, but will shoot at intervals with fractions of seconds if needed.

Code: [Select]
rem based on 'Interval' by Johan Van Barel
rem Massively Modified by A_Str8

@title FlexInterval

@param a Number of Pics
@default a 10
@param b Interval (Min)
@default b 0
@param c -       (Sec)
@default c 20
@param d Initial Delay (Sec)
@default d 1
@param e Mode(0=#,1=infinite,2=time)
@default e 0
@param f Lock Focus (0=no, 1=yes)
@default f 0
@param g Original (Hours)
@default g 4
@param h -       (Min)
@default h 0
@param i Target (Min)
@default i 0
@param j -      (Sec)
@default j 30
@param k FPS
@default k 24
@param l Log (0=no, 1=yes)
@default l 0

if e=2 then gosub "math"

if a<2 then let a=2
if b<0 then let b=0
if c<0 then let c=0
if d<0 then let d=0
if f<>1 then f=0
t=b*60000+c*1000
d=d*1000
s=2

if l=1 then print_screen 10
T=get_day_seconds
T=T/60
H=T/60
print T/60":"T%60, " - New interval set"
if e<>1 then print "   Pics:"; a
if e<>1 then print "   Tot. Time:", t*(a-1)/60000; " Min", t*(a-1)%60000/1000; " Sec"
if e=1 then print "   Unlimited pics . . ."
print "  Interval: "b " Min "c " Sec"
print "------------"
if l=1 then print_screen 0

if f=1 then gosub "lock_focus"

if d>Z then M=d-Z else M=0
sleep M

if e<>1 then print "Pic 1 of", a
if e=1 then print "Pic 1"
if f=1 then gosub "quick_shoot" else gosub "focus_shoot"

if e=1 then goto "endless" else gosub "norm_loop"

print "Exiting . . ."
sleep 1000

end


rem Focus. Record elapsed time in 'Z'
:focus
   X=get_tick_count
   press "shoot_half"
   do
      get_prop 206 P
   until P=1
   Y=get_tick_count
   Z=Y-X
return


rem Lock focus. Record elapsed time in 'Z'
:lock_focus
   gosub "focus"
   click "down"
   sleep 250
   click "erase"
   sleep 250
   release "shoot_half"
   Y=get_tick_count
   Z=Y-X
return
   

rem Focus, then shoot. Record time elapsed in "Z"
:focus_shoot
   gosub "focus"
   W=Z
   gosub "quick_shoot"
   Z=W+Z
return


rem Shoot without focusing. Record time elapsed in "Z"
:quick_shoot
   X=get_tick_count
   click "shoot_full"
   do
    get_prop 206 P
   until P<>1
   Y=get_tick_count
   Z=Y-X
return


rem Take preset number of shots
:norm_loop
   for s=2 to a
      print "Wait",b;"Min",c;"Sec"
      if t>Z then M=t-Z else M=0
      sleep M
      print "Pic", s, "of", a
      if f=1 then gosub "quick_shoot" else gosub "focus_shoot"
   next s
return


rem Take unlimited number of shots
:endless
   print "Wait",b;"Min",c;"Sec"
   if t>Z then M=t-Z else M=0
   sleep M
   print "Pic", s
   if f=1 then gosub "quick_shoot" else gosub "focus_shoot"
   s=s+1
goto "endless"


rem Calculate correct interval and number of shots based on desired framerate, original time, and

target time.
rem Please note this calculation is not accurate because intervals are always rounded down to the

nearest second.
:math
   A=g*3600+h*60
   D=i*60+j
   B=D*k
   C=A/B
   if C<1 then C=1
   b=C/60
   c=C%60

   a=k*D
   if a*C>=A then return
   a=A/C
return


To test of the timing of my interval script, I aimed my camera at a clock that shows seconds and ran the script. At 10 second intervals, the script seems to lose around one second every third shot.

Script settings
Focus Lock: On
Interval: 10 seconds

Camera Settings
Camera: Canon A720
Shutter Speed: 1/2 second

*

Offline ab

  • *
  • 17
Re: Flexible Intervelometer Script
« Reply #1 on: 21 / May / 2008, 20:33:45 »
I was able to get around the time drift by recalculating the sleep times between frames and cutting out an extra 3000 ms or so in my Time Bandit script.  In your case, maybe you  can have it subtract 333 ms from your calculated sleep time?

sleep M-333

Re: Flexible Intervelometer Script
« Reply #2 on: 21 / May / 2008, 21:37:43 »
Which time drift do you mean?

If you mean the rounding issue - the only way to fix that would be to go back and handle all time calculations in milliseconds rather than seconds. I was contemplating doing this, but then I figured if someone needs a script that doesn't round, they can use yours.

If you mean the 1 second/3 shot loss (I think this is probably what you're talking about) - I only did the one test, so I don't know if that drift time is constant at various shutter speeds and settings. It might also vary by camera. If people are interested in doing some more timing tests to determine the rules to the drift, we should be able to figure out a way to compensate

*

Offline ab

  • *
  • 17
Re: Flexible Intervelometer Script
« Reply #3 on: 22 / May / 2008, 15:55:59 »
I was talking about the 1 second/3 shot loss.

I think the drift happens because we need to account for the processing time of the script itself.  Writing to the card is another fudge factor because all these cards are different.

... oh and not to mention really long exposures ...


Re: Flexible Intervelometer Script
« Reply #4 on: 22 / May / 2008, 16:48:52 »
I was thinking it must be the timing of the script. I also didn't consider that "shoot delay" setting - doesn't that add time between the execution of lines?

*

Offline albo

  • *
  • 21
Re: Flexible Intervelometer Script
« Reply #5 on: 12 / June / 2008, 18:50:33 »
@A_Str8:

I'm trying to use this script on my sd870 with allbest #51 (build 411).  It works just fine when setting the number of shots and in infinite modes (modes 0 & 1), but it bombs out in time mode (mode 2).  It bombs out in a similar manner to how the ultra_intervalometer does.  That is, it seems to be running, but after about 5 seconds, the screen flashes quickly and then the camera dies (the lens doesn't retract, and you have to press the power button to get it going again, but it starts up in record mode, not play mode like CHDK usually starts up the sd870).

When I turn logging on, pr_screen.txt gets written in modes 0 & 1, but doesn't get written in mode 2.  I'm not sure where the log gets written in the script, but perhaps that can help narrow down where the problem is coming from.

I'm not sure what's going on here.  Any idea what might be causing this?

thanks,
allie
« Last Edit: 12 / June / 2008, 19:01:57 by albo »

Re: Flexible Intervelometer Script
« Reply #6 on: 13 / June / 2008, 09:55:21 »
Replace the math subroutine at the end with the following. Post the texty that ends up in the print file and the settings you used
Code: [Select]
:math
   print_screen 11

   print "A=g*3600+h*60"
   A=g*3600+h*60
   print "A=", A
   
   print "D=i*60+j"
   D=i*60+j
   print "D=", D

   print "B=D*k"
   B=D*k
   print "B=", B

   print "C=A/B"
   C=A/B
   if C<1 then C=1
   print "C=", C

   print "b=C/60"
   b=C/60
   print "b=", b

   print "c=C%60"
   c=C%60
   print "c=", c

   print "a=k*D"
   a=k*D
   print "a=", a

   if a*C>=A then return
   a=A/C
   print "a=", a
return

Re: Flexible Intervelometer Script
« Reply #7 on: 27 / June / 2008, 16:36:17 »
None of the modes work for me.  Camera starts script, displays "Pic 1 of x", waits about 13 seconds (regardless of interval), then crashes (powers down without retracting lens).   Camera is in Auto mode. 

I just started with this, but could it have anything to do with some scripting syntax not supported in allbest?  like Do...Until?
« Last Edit: 27 / June / 2008, 16:39:14 by eforman »
A650 IS, SD1000


*

Offline Cola

  • *
  • 4
  • SD630 with CHDK 0.9.7-719
Re: Flexible Intervelometer Script
« Reply #8 on: 05 / July / 2008, 13:06:52 »
Because I have an SD630, I changed all 206 entries to 205 in the script.

# mode seems to work ok.  It was able to take 6 shots before I interrupted it.

Infinity mode works too.  It was able to take 12 shots before I interrupted it.

Time mode doesn't work for me.  It says the script started (***STARTED***) but just hangs there for about 5 seconds and shuts down the camera without retracting the lens.

*

Offline albo

  • *
  • 21
Re: Flexible Intervelometer Script
« Reply #9 on: 06 / July / 2008, 17:12:19 »
@A_Str8:  I replaced the math subroutine with what you suggested, but it still bombs out just as before.  The only think in the print_screen file seems to be from a previous run:

17:57 - New interval set
Pics:10
Tot. Time: 3 Min 0 Sec
Interval: 0 Min 20 Sec

I'm not sure what's happening here.  I'd love to use your script, so any help would be much appreciated.  I've updated to #51 build 426, but it didn't change the behavior.  Thanks.

allie

 

Related Topics