Setting G9 focus to infinity and locking it there during a timelapse - page 2 - General Help and Assistance on using CHDK stable releases - CHDK Forum

Setting G9 focus to infinity and locking it there during a timelapse

  • 31 Replies
  • 8617 Views
Re: Setting G9 focus to infinity and locking it there during a timelapse
« Reply #10 on: 05 / February / 2011, 20:27:18 »
Advertisements
Awesome!!  Thanks for posting so quick!  I've loaded it on my G9 and have tested during dinner (my wife must love me) and here's what I've seen so far.

1. it does have a 13 or so second delay from a shutter press to the first pic taken on the *second* time and after that I start the script.  The first time I ran it, the shot was within 4 seconds of the shutter press.  I wasn't paying that close attention the first time, but I was noting all it was doing.  This would have been the first time I loaded it on the SD card and ran the program. 

2. 10 second intervals ran for 10 minutes just fine, taking pictures right on the money.

3.  4 min 30sec intervals ran just fine for 15 mins

4.  I set up the end time for the pics at 7:10PM.  It took a pic at 7:13PM.  I have stopped it cause I have to get the kids ready for bed, but I'm going to test it further this evening and start a 7am to 7pm test for the next 7 days to see that it runs properly at all times on all days. 

5.  I set the MF Safety to "OFF" and it seems to stay focused where I put it.  Every time it shoots, the red square pops up in teh middle of the screen instead of a green autofocus lock.  Is this because of the MF Safety or because of something in your script?  Looks like you use "Shoot" just like the other scripts, so I'm guessing it's the MF setting.

I have a wall adapter, so I'll be happy to report the long term tests so you don't have to swap batteries, etc. 

Thanks again, you take payment in beer??!!

Re: Setting G9 focus to infinity and locking it there during a timelapse
« Reply #11 on: 06 / February / 2011, 02:03:13 »
a little more testing of the script has yielded two things.  I think that a couple of lines in code need to change but i'm not sure how.  The program will not terminate at the end time like it should, but will start when expected.  I changed these lines to this to make it start without the delay.

:check_time
  F=get_time 2
  Q=get_time 1
  F=F*100+Q
  if F<p then return
  if F>r then return
  gosub "take_shots"
  goto "check_time"

but I can't get it to terminate when expected.

I tried to break up the "or" statement in the "check time" as shown above, but it doesn't seem to matter.  I'm not sure I did the "if" statements correctly, but I wasn't sure if the second condition was being checked in the "if F<p or F>r then return" statement of the original code. 

*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
Re: Setting G9 focus to infinity and locking it there during a timelapse
« Reply #12 on: 06 / February / 2011, 02:11:42 »
...The program will not terminate at the end time like it should, but will start when expected.
I found the source of the timing delay and the termination problem earlier. Then I found a couple of other things that needed changing - during testing I decided to change the initial info displayed. I didn't get a chance to test over multiple days yet, so that will need checking. Here is the revised script.

Code: [Select]
rem Author SkyWalker9
@title Selective Intervalometer
@param a Number of Shots
@default a 180
@param e Interval (mins)
@default e 5
@param f Interval (secs)
@default f 0
@param p Starting Hour (24 Hr time)
@default p 7
@param q Starting Minute
@default q 0
@param r Ending Hour (24 Hr time)
@default r 18
@param s Ending Minute
@default s 0
@param u Start DOW (0=Sun..6=Sat)
@default u 1
@param v End DOW (0=Sun..6=Sat)
@default v 6

rem Check input variables for proper values
  if a<2 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
  if u<0 then u=0
  if u>6 then u=6
  if v<0 then v=0
  if v>6 then v=6

rem Calculate user specified cycle/interval time in ms
  d=(e*600+f*10)*100
  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
  P=p*100+q
  R=r*100+s

rem Print Error message if Start Time is after End Time and exit script
  if r>=p then goto "ok1"
    print "START Time after END"
    end
:ok1

rem Print message if Start Day of Week is after End Day of Week and exit script
  if v>=u then goto "ok2"
    print "START DOW after END"
    end
:ok2

rem Calculate length of time period (1 min=60K "ticks")
  N=((r*60+s)-(p*60+q))*60000

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

  select u
    case 0; print "Start on Sun"
    case 1; print "Start on Mon"
    case 2; print "Start on Tue"
    case 3; print "Start on Wed"
    case 4; print "Start on Thur"
    case 5; print "Start on Fri"
    case 6; print "Start on Sat"
  end_select
  select v
    case 0; print "End on Sun"
    case 1; print "End on Mon"
    case 2; print "End on Tue"
    case 3; print "End on Wed"
    case 4; print "End on Thur"
    case 5; print "End on Fri"
    case 6; print "End on Sat"
  end_select
 
  print a" Shots/Hrs "p":"q"-"r":"s
  print "Every "e" min "f" sec"

rem Allows camera vibrations to stop
  sleep 1000

rem Initializes shot counter; script terminate
rem when n=a in the "take_shots" subroutine
  n=1

rem -- Do not add comments after this point ---

:check_day
  gosub "dayofweek"
  if w>=u and w<=v then goto "check_time"
  goto "check_day"

:check_time
  F=get_time 0
  Q=get_time 1
  F=F*100+Q
  if F>=P and F<R then goto "take_shots"
  goto "check_day"

:take_shots
    i=get_tick_count
    i=i+N
:more
    b=get_tick_count
    shoot
    sleep 100
    print "Shot", n, "of", a
    if n=a then shut_down
    n=n+1
    s=b+d
:wait_loop
    b=get_tick_count
    if b<s then goto "wait_loop"
    if b<i then goto "more"
    goto "check_day"

:dayofweek
  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
  return
end

I'm going to be putting the script through more rigorus testing later and see what might need "tweaking", but I need to do some recharging (camera batteries and my mind). Good Luck with the revised script!
« Last Edit: 06 / February / 2011, 02:16:22 by SkyWalker9 »

Re: Setting G9 focus to infinity and locking it there during a timelapse
« Reply #13 on: 06 / February / 2011, 16:34:54 »
very cool, I started all day/all week testing about 3 hours ago and i'll let you know how it's going on a daily basis! 


Re: Setting G9 focus to infinity and locking it there during a timelapse
« Reply #14 on: 06 / February / 2011, 22:55:18 »
I set it to turn off at 7pm and just got around to checking on it...it's now 9:54pm and it's still taking pictures.  I'll dig into it here in a while and tell you what further testing yields.
« Last Edit: 07 / February / 2011, 00:18:09 by spe672 »

Re: Setting G9 focus to infinity and locking it there during a timelapse
« Reply #15 on: 07 / February / 2011, 01:11:58 »
I've been doing 1 minute testing where, say, I'll have it start at 11:30 and end at 11:31.  The code as you posted above starts taking shots at 23 seconds after the minute start and will end 23 seconds after the minute end, taking 6 shots as expected in one minute at a 10 sec interval.  I'm confused why it didn't stop taking shots earlier this evening when it was set to end at 1900 hours.  I was running a 4 minute interval in that test.   

I feel that one line needs to change, but could be wrong. 

:check_time
  F=get_time 0
  Q=get_time 1

I think should be,

:check_time
  F=get_time 2
  Q=get_time 1

because 0 is seconds, 1 is minutes and 2 is hours.  The If statement directly following this, is comparing hours and minutes to minutes and seconds as it stands.  Right?  Please straighten me out if i'm all wrong.  :)

  F=F*100+Q
  if F>=P and F<R then goto "take_shots"

when I change this, the camera starts taking shots at 1 second after the minute start time and ends nine seconds before the minute end time.  Therefore, it takes 6 shots in one minute with a 10 second interval and does terminate as expected when the minute rolls over.

I'm going to set the camera back up for tomorrow and see if it shoots between the expected times from 7am to 7pm with a 4 minute interval.




*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
Re: Setting G9 focus to infinity and locking it there during a timelapse
« Reply #16 on: 07 / February / 2011, 02:04:04 »
...I'm going to set the camera back up for tomorrow and see if it shoots between the expected times from 7am to 7pm with a 4 minute interval.
I started testing the script in more depth and discovered several problems. If you started the script during the period you wanted to capture (the right day of the week and started in the middle of the hour ranges), then it would continue to shoot photos after the end hour & minute you had setup. That required some checks & balances in code to keep the intervals very accurate and to terminate within seconds of the end hour & minute. I also was able to determine what was causing the abnormally long delay before the first photo is taken.

Due to the amount of testing I've been doing, I decided to make a few cosmetic changes in what gets displayed. Excluding any error or caution messages, the script will display the following info as a reminder:
.
.    (x) shots / DOW (x)-(y)
.    Hours (h:m-h:m)
.    Every (x) min (y) sec
.    Waiting for shot: (x)
.
- After shooting x number of shots on the DOW & time indicated, if all of the shots haven't been shot, then the screen is cleared and the startup parms are re-displayed with the next shot indicated.
- The shortest interval of time between shots is dependent upon several factors: shutter speed, size of photos, model of camera, if RAW is chosen, using bracketing for exposures (HDR).
- The accurracy of the intervals were all "dead on" in my testing (as per the EXIF data).

Please give this updated script a spin and let me know what you think.
Code: [Select]
rem Author SkyWalker9
@title Selective Intervalometer
@param a Number of Shots
@default a 180
@param e Interval (mins)
@default e 5
@param f Interval (secs)
@default f 0
@param p Starting Hour (24 Hr time)
@default p 7
@param q Starting Minute
@default q 0
@param r Ending Hour (24 Hr time)
@default r 18
@param s Ending Minute
@default s 0
@param u Start DOW (0=Sun..6=Sat)
@default u 1
@param v End DOW (0=Sun..6=Sat)
@default v 6

rem Check input variables for proper values
  if a<2 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
  if u<0 then u=0
  if u>6 then u=6
  if v<0 then v=0
  if v>6 then v=6

rem Calculate user specified cycle/interval time in ms
  d=(e*600+f*10)*100
  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
  P=p*100+q
  R=r*100+s

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"
    end
:ok1

rem Print message if Start Day of Week is after End Day of Week print msg & exit
  if v>=u then goto "ok2"
    print "START DOW after END"
    end
:ok2

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

rem Allows camera vibrations to settle
  sleep 1000

rem Calculate length of total time period (1 min=60K "ticks")
  N=((r*60+s)-(p*60+q))*60000

rem Calculate length of time period (1 min=60K "ticks") if
rem user starts during the active time period
  O=N
  gosub "dayofweek"
  if w<u or w>v then goto "ok3"
  F=get_time 2
  Q=get_time 1
  x=F*100+Q
  if x>=P and x<R then O=((r*60+s)-(F*60+Q))*60000
:ok3

rem Initializes shot counter; script terminate
rem when n=a in the "take_shots" subroutine
  n=1

rem -- Do not add comments after this point ---

:info
  if n>1 then cls
  print a" Shots / DOW "u"-"v
  print "Hours "p":"q"-"r":"s
  print "Every "e" min "f" sec"
  print "Waiting for shot: "n

:check_day
  gosub "dayofweek"
  if w>=u and w<=v then goto "check_time"
  goto "check_day"

:check_time
  F=get_time 2
  Q=get_time 1
  F=F*100+Q
  if F>=P and F<R then goto "take_shots"
  goto "check_day"

:take_shots
    i=get_tick_count
    i=i+O
:more
    b=get_tick_count
    shoot
    sleep 100
    print "Shot", n, "of", a
    if n=a then shut_down
    n=n+1
    S=b+d
:wait_loop
    b=get_tick_count
    if b<S then goto "wait_loop"
    if b<i then goto "more"
    O=N
    goto "info"

:dayofweek
  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
  return
end

*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
Re: Setting G9 focus to infinity and locking it there during a timelapse
« Reply #17 on: 07 / February / 2011, 20:47:07 »
I ran a large variety of tests using a "tweaked" version of the last script, so far no problems and I'm pleased with how accurate the results are thus far. The "tweak" was to add extra lines of code to display the disk free space upon startup of the script - nothing to do with the rest of the code - I ensured that it would have no effect on the other code. I also reworded a few of the comment lines for clarification. I'll post the "tweaked" update after this update note. For the one remaining test that I really want to check I have to wait until around midnight tonight. I want to check that the script handles things properly over multiple days (only two days in this case). Since I don't have a AC adapter to power the camera, this was the only way I could think of to run this test. Just waiting for midnight...
Code: [Select]
rem Author SkyWalker9
@title Selective Intervalometer
@param a Number of Shots
@default a 180
@param e Interval (mins)
@default e 5
@param f Interval (secs)
@default f 0
@param p Starting Hour (24 Hr time)
@default p 7
@param q Starting Minute
@default q 0
@param r Ending Hour (24 Hr time)
@default r 18
@param s Ending Minute
@default s 0
@param u Start DOW (0=Sun..6=Sat)
@default u 1
@param v End DOW (0=Sun..6=Sat)
@default v 6

rem Check input variables for proper values
  if a<2 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
  if u<0 then u=0
  if u>6 then u=6
  if v<0 then v=0
  if v>6 then v=6

rem Calculate user specified cycle/interval time in ms
  d=(e*600+f*10)*100
  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
  P=p*100+q
  R=r*100+s

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"
    end
:ok1

rem Print message if Start Day of Week is after End Day of Week print msg & exit
  if v>=u then goto "ok2"
    print "START DOW after END"
    end
:ok2

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

rem Displays the disk space/free disk space in MB & percent
  x=get_disk_size
  x=x/1000
  y=get_free_disk_space
  y=y/1000
  z=(y*100)/x
  print "Free Space "y"MB ("z"%)"

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.
  N=((r*60+s)-(p*60+q))*60000

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
  O=N
  gosub "dayofweek"
  if w<u or w>v then goto "ok3"
  F=get_time 2
  Q=get_time 1
  x=F*100+Q
  if x>=P and x<R then O=((r*60+s)-(F*60+Q))*60000
:ok3

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

rem -- Do not add comments after this point ---

:info
  if n>1 then cls
  print a" Shots / DOW "u"-"v
  print "Hours "p":"q"-"r":"s
  print "Every "e" min "f" sec"
  print "Waiting for shot: "n

:check_day
  gosub "dayofweek"
  if w>=u and w<=v then goto "check_time"
  goto "check_day"

:check_time
  F=get_time 2
  Q=get_time 1
  F=F*100+Q
  if F>=P and F<R then goto "take_shots"
  goto "check_day"

:take_shots
    i=get_tick_count
    i=i+O
:more
    b=get_tick_count
    shoot
    sleep 100
    print "Shot", n, "of", a
    if n=a then shut_down
    n=n+1
    S=b+d
:wait_loop
    b=get_tick_count
    if b<S then goto "wait_loop"
    if b<i then goto "more"
    O=N
    goto "info"

:dayofweek
  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
  return
end


Re: Setting G9 focus to infinity and locking it there during a timelapse
« Reply #18 on: 07 / February / 2011, 21:07:38 »

*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
Re: Setting G9 focus to infinity and locking it there during a timelapse
« Reply #19 on: 07 / February / 2011, 23:10:53 »

 

Related Topics