Utilities #1 (a collection of mini-scripts) - page 2 - Completed and Working Scripts - CHDK Forum
supplierdeeply

Utilities #1 (a collection of mini-scripts)

  • 20 Replies
  • 20495 Views
*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
Re: Utilities #2 update (a collection of mini-scripts)
« Reply #10 on: 08 / March / 2011, 19:16:53 »
Advertisements
Code: [Select]
:option2
  if c<=0 then c=1
  if b=0 then b=999999
  e=get_vbatt
  g=get_zoom_steps
  g=g-2
  n=1
  cls
  print "Resetting zoom"
  print " "
:repeat
  set_zoom 1
  gosub "save_shotnum"
  set_zoom g
  gosub "save_shotnum"
  goto "repeat"
:save_shotnum
  sleep 1000
  z=get_time 0
  y=get_time 1
  x=get_time 2
  m=get_time 3
  o=get_time 4
  p=get_time 5
  shoot
  sleep 600
  f=get_vbatt
  cls
  print_screen c
    print "Date: "m"/"o"/"p
    print "Time: "x":"y":"z
    print " "
    print "Shot number:", n
    print "Batt start: "e" mv"
    print "Batt   now: "f" mv"
  print_screen 0
  if c<1000 then c=c+1000 else c=c-1000
  n=n+1
  if n>b then goto "done"
  return

:option3
rem ** Caution ** Caution ** Caution ** Caution ** Caution ** Caution ** Caution **
rem This option has the ability to shoot non-stop; once started will run until the
rem camera runs out of space for photos or until the battery power is no longer
rem sufficient to continue.
rem ** Caution ** Caution ** Caution ** Caution ** Caution ** Caution ** Caution **
  if b<=0 then b=999999
  if c<0 then c=0
  if c>59 then c=59
  if d<0 then d=0
  if d>59 then d=59
  if e<0 then e=0
  if e>23 then e=23
  if f<0 then f=0
  if f>59 then f=59
  P=e*100+f
  D=(c*600+d*10)*100
  if D<1 then D=1
  sleep 1000
  n=1
  cls
  if b<>999999 then print "Number of shots: "b
  print "Start Time: "e":"f
  print "Intervals: "c"min "d"sec"
  print " "
  print "Waiting for Start Time..."
:check_time
  F=get_time 2
  Q=get_time 1
  F=F*100+Q
  if F>=P then goto "shot_loop"
  goto "check_time"
:shot_loop
    B=get_tick_count
    shoot
    sleep 600
    n=n+1
    if n>a then goto "done"
    cls
    if b<>999999 then print "Next shot: "n" of "b else print "Next shot: "n
    print "Intervals: "c"min "d"sec"
    print " "
    S=B+D
:wait_loop
    B=get_tick_count
    if B<S then goto "wait_loop"
    goto "shot_loop"
  
:done
end
<Part 3 of 3 - append to last section of code>
« Last Edit: 08 / March / 2011, 19:30:00 by SkyWalker9 »

*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
Re: Utilities #3 Updated (a collection of mini-scripts)
« Reply #11 on: 15 / March / 2011, 21:00:14 »
Utilities #3 Updated - added 2APEX

This is the third in the series of mini-scripts.
1CntDwn:2APEX:       :    (     1)
Seconds:Save :       :    (     0)
#Shots :     :       :    (     0)
IntMin :     :       :    (     0)
IntSec :     :       :    (     0)
Reverse:     :       :    (     0)
.      :     :       :    (     0)


Like the last time , each mini-script is identified by the first parameter line and the mini-script is chosen by the number in the name of the min-script. If there are parameters for that mini-script, they are shown in the column just below the mini-script name.

Utility mini-scripts

1CntDwn. This mini-script has a large pseudo-font countdown display timer for taking a series of pictures and was first included in Utility #2. Since then the script has been upgraded to overcome the reverse display problems when using an articulating display in the facing forward position. Because it was necessary to add more lines/characters to the original mini-script, I needed to put it in a different Utility, so this one was created - I'll add more mini-scripts as they are created.

There are now five parameters: Seconds, #Shots, IntMin, IntSec and Reverse. "Seconds" is the amount countdown seconds to display (1-10). The "#Shots" is the number of photos to shoot in the series.  The "IntMin" and "IntSec" is the amount between each countdown sequence (between shots) and allows the photographer time to setup the next shot.

I originally wrote this script so that I could use it on an SX20 which has an articulating display. Since CHDK doesn't display properly on the LCD when facing forward I had to design a way to display the countdown pseudo-font numbers in reverse and to the far right side of the normal CHDK script window. The "Reverse" parameter is set to 1 to use the articulating display facing forward - anything other than 1 will assume the display is not being used in the facing forward position.

In normal use (non-Reverse) the display is handy when taking group photos and experimenting with creating "cloning" photos. In addition to the pseudo-font countdown numbers, there is a special symbol to indicate when the script is waiting for the interval period to expire and the countdown sequence to begin. Here are  samples of the large display countdown pseudo-font and the special symbol:

    *   **
   **  *  *
    *  *  *
    *  *  *
   ***  **

   *       *
     * * *
     * * *
     * * *
   *       *

2APEX. This mini-script was written to measure the bv and sv values for an intervalometer script I'm testing. I've incorporated APEX statements into the intervalometer script to test if I'll be able to have the sunrise start the intervalometer script and have the sunset stop the intervalometer script each day. In order to determine the appropriate bv "triggers" I decided to write a mini-script to measure the light source over a week to determine an average trigger level for the start and stop triggers. This script simply reports the values when asked. There is only one parameter and that is to allow saving a LOG file in the CHDK/LOGS folder using hour & minutes as part of the name and to allow multiple LOG files. The data saved is:

Code: [Select]
Date: 15/3/2011
Time: 18:47:46
 
Mode:Av
Av:F2.8
Tv:1/30
ISO:AutoISO
av96=294 tv96=480
bv96=138 sv96=603

If you are not logging the data, then the script will wait for the "Set" button at the end before finishing so that the data is held on the OSD until you are ready to exit. Using an SX20, here are some of the readings I've recorded:
    a very dark room with no lights & dark overcast night bv was -908
    room using daylight bv was 207
    same room at night using Tunsten lighting bv was 250
    for standard landscape shot bv was 785
    pointed at a white stairway railing bv was 799
    bright, clear sky while pointed 90 degrees from the sun the bv was 1057; at noon, bv was 1114
Special notes:

1. Since the CHDK UBasic is an interpreted script reader, any mini-script that is time sensitive should be located near the top of the "Utility" script in order to insure the fastest run times.

2. If PropCas statements are used in a mini-script, they are specifically identified in the script positioned between "rem" statements so that they can be easily found and updated to the user's model of camera. Since the list of PropCas for the SX20 is not complete, I have been keeping track and updating the list of PropCas values that I find in the SX20 forum in this post: http://chdk.setepontos.com/index.php?topic=4348.msg60704#msg60704

Just save this script to your CHDK/SCRIPT folder as BAS.

<Part 1 of 3>
« Last Edit: 17 / March / 2011, 10:07:02 by SkyWalker9 »

*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
Re: Utilities #3 Update (a collection of mini-scripts)
« Reply #12 on: 15 / March / 2011, 21:02:43 »
Code: [Select]
rem Author SkyWalker9
@title Utilities #3
@param a 1CntDwn:2APEX:       :
@default a 1
@param b Seconds:Save :       :
@default b 0
@param c #Shots :     :       :
@default c 0
@param d IntMin :     :       :
@default d 0
@param e IntSec :     :       :
@default e 0
@param f Reverse:     :       :
@default f 0
@param g .      :     :       :
@default g 0

if a=1 then goto "option1"
if a=2 then goto "option2"
goto "done"

:option1
 cls
 gosub "num_hold"
 D=(d*600+e*10)*100
 if D<1 then D=1
 if c<1 then c=1
 if d<=0 and e<=0 then e=30
 for h=1 to c
  B=get_tick_count
  S=B+D
:opt1_wait_loop
  B=get_tick_count
  if B<S then goto "opt1_wait_loop"
  if b>10 then b=10
  if b<0 then b=0
  for i=0 to b-1
   cls
   x=b-i
   if x=0 then gosub "num_0"
   if x=1 then gosub "num_1"
   if x=2 then gosub "num_2"
   if x=3 then gosub "num_3"
   if x=4 then gosub "num_4"
   if x=5 then gosub "num_5"
   if x=6 then gosub "num_6"
   if x=7 then gosub "num_7"
   if x=8 then gosub "num_8"
   if x=9 then gosub "num_9"
   if x=10 then gosub "num_10"
   sleep 1000
  next i
  cls
  shoot
  sleep 600
  gosub "num_hold"
 next h
 cls
 goto "done"
:num_0
 if f=1 then goto "num_0_R"
 print "      **"
 print "     *  *"
 print "     *  *"
 print "     *  *"
 print "      **"
 return
:num_0_R
 print "                 **"
 print "                *  *"
 print "                *  *"
 print "                *  *"
 print "                 **"
 return
:num_1
 if f=1 then goto "num_1_R"
 print "       *"
 print "      **"
 print "       *"
 print "       *"
 print "      ***"
 return
:num_1_R
 print "                 *"
 print "                 **"
 print "                 *"
 print "                 *"
 print "                ***"
 return
:num_2
 if f=1 then goto "num_2_R"
 print "      **"
 print "     *  *"
 print "       *"
 print "      *"
 print "     ****"
 return
:num_2_R
 print "                 **"
 print "                *  *"
 print "                 *"
 print "                  *"
 print "                ****"
 return
:num_3
 if f=1 then goto "num_3_R"
 print "     ****"
 print "         *"
 print "      ***"
 print "         *"
 print "     ****"
 return
:num_3_R
 print "                ****"
 print "               *"
 print "                ***"
 print "               *"
 print "                ****"
 return
:num_4
 if f=1 then goto "num_4_R"
 print "     *"
 print "     *  *"
 print "     *****"
 print "        *"
 print "        *"
 return
:num_4_R
 print "                   *"
 print "                *  *"
 print "               *****"
 print "                *"
 print "                *"
 return
:num_5
 if f=1 then goto "num_5_R"
 print "     ****"
 print "     *"
 print "     ****"
 print "         *"
 print "     ****"
 return
:num_5_R
 print "                ****"
 print "                   *"
 print "                ****"
 print "               *"
 print "                ****"
 return
:num_6
 if f=1 then goto "num_6_R"
 print "      ***"
 print "     *"
 print "     ****"
 print "     *   *"
 print "      ***"
 return
:num_6_R
 print "                 ***"
 print "                    *"
 print "                 ****"
 print "                *   *"
 print "                 ***"
 return
:num_7
 if f=1 then goto "num_7_R"
 print "     ****"
 print "        *"
 print "       *"
 print "      *"
 print "      *"
 return
:num_7_R
 print "                ****"
 print "                *"
 print "                 *"
 print "                  *"
 print "                  *"
 return
:num_8
 if f=1 then goto "num_8_R"
 print "      ***"
 print "     *   *"
 print "      ***"
 print "     *   *"
 print "      ***"
 return
:num_8_R
 print "                 ***"
 print "                *   *"
 print "                 ***"
 print "                *   *"
 print "                 ***"
 return
:num_9
 if f=1 then goto "num_9_R"
 print "      ***"
 print "     *   *"
 print "      ****"
 print "         *"
 print "      ***"
 return
:num_9_R
 print "                 ***"
 print "                *   *"
 print "                ****"
 print "                *"
 print "                 ***"
 return
:num_10
 if f=1 then goto "num_10_R"
 print "    *   **"
 print "   **  *  *"
 print "    *  *  *"
 print "    *  *  *"
 print "   ***  **"
 return
:num_10_R
 print "               **   *"
 print "              *  *  **"
 print "              *  *  *"
 print "              *  *  *"
 print "               **  ***"
 return
:num_hold
 if f=1 then goto "num_hold_R"
 print "   *       *"
 print "     * * *"
 print "     * * *"
 print "     * * *"
 print "   *       *"
 return
:num_hold_R
 print "              *       *"
 print "                * * *"
 print "                * * *"
 print "                * * *"
 print "              *       *"
 return


<Part 2 of 3>

*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
Re: Utilities #3 Update (a collection of mini-scripts)
« Reply #13 on: 15 / March / 2011, 21:03:37 »
Code: [Select]
:option2
 if b<>1 then goto "skip_save"
 z=get_time 0
 y=get_time 1
 x=get_time 2
 m=get_time 3
 n=get_time 4
 p=get_time 5
 g=x*100+y
 if g<1 then g=1
 if g>9999 then g=9999
 print_screen g
 print "Date: "m"/"n"/"p
 print "Time: "x":"y":"z
 print " "
:skip_save
 rem *** SX20 ***
 get_prop 50 B
 if B=8228 then print "Mode:Custom"
 if B=-32767 then print "Mode:Manual"
 if B=-32766 then print "Mode:Av"
 if B=-32765 then print "Mode:Tv"
 if B=-32764 then print "Mode:Program"
 if B=-32768 then print "Mode:Auto"
 if B=-32755 then print "Mode:Portrait"
 if B=-32756 then print "Mode:Landscape"
 if B=-32757 then print "Mode:Night Snapshot"
 if B=-32249 then print "Mode:Sports"    
 if B=16402 then print "Mode:Sunset"  
 if B=-32246 then print "Mode:Stitch Assist"    
 if B=2600 then print "Mode:Movie"
 rem *** SX20 ***
 press "shoot_half"
 sleep 600
 x=get_user_av_id
 gosub "prnt_av"
 x=get_user_tv_id
 gosub "prnt_time"
 x=get_iso
 gosub "prnt_iso"
 get_user_av96 A
 get_user_tv96 T
 print "av96="A" tv96="T
 get_bv96 B
 get_sv96 S
 print "bv96="B" sv96="S
 if b=1 then goto "done"
 gosub "opt2_wait_loop"
 goto "done"

:prnt_time
 if x=-12 then print "Tv:15s"
 if x=-11 then print "Tv:13s"
 if x=-10 then print "Tv:10s"
 if x=-9 then print "Tv:8s"
 if x=-8 then print "Tv:6s"
 if x=-7 then print "Tv:5s"
 if x=-6 then print "Tv:4s"
 if x=-5 then print "Tv:3.2s"
 if x=-4 then print "Tv:2.5s"
 if x=-3 then print "Tv:2s"
 if x=-2 then print "Tv:1.6s"
 if x=-1 then print "Tv:1.3s"
 if x=0 then print "Tv:1s"
 if x=1 then print "Tv:0.8s "
 if x=2 then print "Tv:0.6s"
 if x=3 then print "Tv:0.5s"
 if x=4 then print "Tv:0.4s"
 if x=5 then print "Tv:0.3s"
 if x=6 then print "Tv:1/4"
 if x=7 then print "Tv:1/5"
 if x=8 then print "Tv:1/6"
 if x=9 then print "Tv:1/8"
 if x=10 then print "Tv:1/10"
 if x=11 then print "Tv:1/13"
 if x=12 then print "Tv:1/15"
 if x=13 then print "Tv:1/20"
 if x=14 then print "Tv:1/25"
 if x=15 then print "Tv:1/30"
 if x=16 then print "Tv:1/40"
 if x=17 then print "Tv:1/50"
 if x=18 then print "Tv:1/60"
 if x=19 then print "Tv:1/80"
 if x=20 then print "Tv:1/100"
 if x=21 then print "Tv:1/125"
 if x=22 then print "Tv:1/160"
 if x=23 then print "Tv:1/200"
 if x=24 then print "Tv:1/250"
 if x=25 then print "Tv:1/320"
 if x=26 then print "Tv:1/400"
 if x=27 then print "Tv:1/500"
 if x=28 then print "Tv:1/640"
 if x=29 then print "Tv:1/800"
 if x=30 then print "Tv:1/1000"
 if x=31 then print "Tv:1/1250"
 if x=32 then print "Tv:1/1600"
 if x=33 then print "Tv:1/2000"
 if x=34 then print "Tv:1/2500"
 if x=35 then print "Tv:1/3200"
 return
:prnt_iso
 if x=0 then print "ISO:AutoISO"
 if x=1 then print "ISO:50(80)"
 if x=2 then print "ISO:100"
 if x=3 then print "ISO:200"
 if x=4 then print "ISO:400"
 if x=5 then print "ISO:800"
 if x=6 then print "ISO:1600"
 if x=7 then print "ISO:3200"
 if x=-1 then print "ISO:HiISO"
 return
:prnt_av
 if x=9 then print "Av:F2.8"
 if x=10 then print "Av:F3.2"
 if x=11 then print "Av:F3.5"
 if x=12 then print "Av:F4.0"
 if x=13 then print "Av:F4.5"
 if x=14 then print "Av:F5.0"
 if x=15 then print "Av:F5.6"
 if x=16 then print "Av:F6.3"
 if x=17 then print "Av:F7.1"
 if x=18 then print "Av:F8.0"
 return
:opt2_wait_loop
 wait_click 10000
 is_key k "set"
 if k=1 then goto "exit_wait"
 goto "opt2_wait_loop"
:exit_wait
 return

:done
 release "shoot_half"
 print_screen 0
end

Update 4-19-11: When using the wait_click statements, some cameras require the timeout be specified; recommend starting with "wait_click 10000" (10secs). The script has been updated to reflect the change.

<Part 3 of 3 - final part>
« Last Edit: 19 / April / 2011, 18:22:50 by SkyWalker9 »


*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
Re: Utilities #3 - added 3SunInt (a collection of mini-scripts)
« Reply #14 on: 19 / March / 2011, 18:58:47 »
Utilities #3 Updated - added 3SunInt (reduced coding requirements of 2APEX mini-script and added 3SunInt mini-script)

This is the third in the series of mini-scripts.
1CntDwn:2APEX:3SunInt:    (     1)
#Shots :Save :#Shots :    (     0)
IntMin :     :IntMin :    (     0)
IntSec :     :IntSec :    (     0)
Seconds:     :Bv(x50):    (     0)
Reverse:     :       :    (     0)
.      :     :       :    (     0)
Like the last time, each mini-script is identified by the first parameter line and the mini-script is chosen by the number in the name of the min-script. If there are parameters for that mini-script, they are shown in the column just below the mini-script name.

Utility mini-scripts

1CntDwn. This mini-script has a large pseudo-font countdown display timer for taking a series of pictures and was first included in Utility #2. I originally wrote this script so that I could use it on an SX20 which has an articulating display. Since CHDK doesn't display properly on the LCD when facing forward I had to design a way to display the countdown pseudo-font numbers in reverse and to the far right side of the normal CHDK script window.
 I added a Reverse parameter to indicate when the reverse display is used with an articulating display in the facing forward position. It was necessary to add more lines/characters to the original mini-script, so it was moved to this script.

There are five parameters: #Shots, IntMin, IntSec, Seconds and Reverse. The "#Shots" is the number of photos to shoot in the series.  The "IntMin" and "IntSec" is the amount between each countdown sequence (between shots) and allows the photographer time to setup the next shot. "Seconds" is the amount countdown seconds to display (1-10). The "Reverse" parameter is set to 1 to use the articulating display facing forward - anything other than 1 will assume the display is not being used in the facing forward position.

In normal use (non-Reverse) the display is handy when taking group photos and experimenting with creating "cloning" photos. In addition to the pseudo-font countdown numbers, there is a special symbol to indicate when the script is waiting for the interval period to expire and the countdown sequence to begin. Here are  samples of the large display countdown pseudo-font and the special symbol:
    *   **
   **  *  *
    *  *  *
    *  *  *
   ***  **

   *       *
     * * *
     * * *
     * * *
   *       *

2APEX. This mini-script was written to report the APEX values of bv96, sv96, av96 and tv96. An example of one of the uses is in the intervalometer mini-script (3SunInt) that follows. This mini-script simply reports the values when asked. There is only one parameter and that is to allow saving a LOG file in the CHDK/LOGS folder using hour & minutes as part of the name and to allow multiple LOG files. After the data is saved a photo is also taken as part of the logging process so that there is a record of what the photo process would look like at that Bv. The data logged is:

Code: [Select]
Date: 15/3/2011
Time: 18:47:46
 
bv96=138 sv96=603
av96=294 tv96=480

If you are not logging the data, then the script will wait for the "Set" button at the end before finishing so that the data is held on the OSD until you are ready to exit. Using an SX20, here are some of the readings I've recorded:
    a very dark room with no lights & dark overcast night bv was -908
    room using daylight bv was 207
    same room at night using Tunsten lighting bv was 250
    for standard landscape shot bv was 785
    pointed at a white stairway railing bv was 799
    bright, clear sky while pointed 90 degrees from the sun the bv was 1057; at noon, bv was 1114
There is one special case where bv96 may indicate zero in very dark conditions (instead of a negative number). Because it happens in very few cases, it is very difficult to determine the exact conditions under which this might happen, so it is advisable to take this special case into consideration when writing scripts.

3SunInt. This sunrise-sunset intervalometer mini-script was written to allow starting and stopping using available daylight. When the appropriate amount of daylight is sensed, this mini-script will start the shot sequence. The light is measured via bv96 and is used to start the shot sequence (sunrise). The script can be set end in two ways: 1) allow the bv96 value to stop the mini-script when it reaches the Bv setting - the light level decreases to the bv96 setting (i.e. sunset) or 2) set a maximum number of shots. As with other scripts, this script can also be prematurely stopped by pressing the shutter button to terminate the script.

There are four parameters: #Shots, IntMin, IntSec and Bv(x50)

#Shots. This parameter allows a user to set the maximum number of shots. This would be useful if the user only wanted photos of a sunrise. If you want photos throughout the entire day from sunrise to sunset then set the #Shots to zero and the mini-script will take photos from beginning to end using the intervals specified.

IntMin & IntSec. These interval parameters allow you to accurately set an interval time (minutes & seconds) between shots. This mini-script uses tick_count statements rather than sleep statements to control the time between shots.

Bv(x50). This parameter sets the start and stop "triggers" for the mini-script. The "x50" indicates that any value used for this parameter will be multipled times 50. For example, on my SX20 I have found that a bv96 level of -200 works good for several of my series, so I set the Bv parameter to -4 (-4x50=-200). The bv96 values may vary between cameras and shooting scenarios, therefore it is best that you determine the bv96 values that are best for your needs. If you are unsure what trigger value to use, I recommend you use the 2APEX mini-script above to check the light levels. While waiting for the start of the sunrise "trigger", the mini-script checks the Bv value approximately every 10 minutes (the interval between the first and second may be shorter). The 10 minute delay was determined by monitoring bv96 changes during sunrises over multiple days.

I noticed on my SX20 that occassionally bv96 indicates zero instead of a negative number in dark conditions (maybe due to camera settle time?). This script checks for this condition and forces the script to recheck the value of bv96 again. Since a zero reading for bv96 happens infrequently, the effect of this re-check should be negligible.

Special notes:
1. Since the CHDK UBasic is an interpreted script reader, any mini-script that is time sensitive should be located near the top of the "Utility" script in order to insure the fastest run times.

2. If PropCas statements are used in a mini-script, they are specifically identified in the script positioned between "rem" statements so that they can be easily found and updated to the user's model of camera. Since the list of PropCas for the SX20 is not complete, I have been keeping track and updating the list of PropCas values that I find in the SX20 forum in this post: http://chdk.setepontos.com/index.php?topic=4348.msg60704#msg60704

Just save this script to your CHDK/SCRIPT folder as BAS.

<Part 1 of 3>
« Last Edit: 20 / March / 2011, 14:52:12 by SkyWalker9 »

*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
Re: Utilities #3 - added 3SunInt (a collection of mini-scripts)
« Reply #15 on: 19 / March / 2011, 19:00:28 »
Code: [Select]
rem Author SkyWalker9
@title Utilities #3
@param a 1CntDwn:2APEX:3SunInt:
@default a 1
@param b #Shots :Save :#Shots :
@default b 0
@param c IntMin :     :IntMin :
@default c 0
@param d IntSec :     :IntSec :
@default d 0
@param e Seconds:     :Bv(x50):
@default e 0
@param f Reverse:     :       :
@default f 0

if a=1 then goto "option1"
if a=2 then goto "option2"
if a=3 then goto "option3"
goto "done"

:option3
rem This sunrise-sunset intervalometer mini-script has the ability to shoot non-stop.
rem Once started it will run until the camera runs out of space for photos
rem or until the battery power is no longer sufficient to continue.
  if b<=0 then b=999999
  if c<0 then c=0
  if c>59 then c=59
  if d<0 then d=0
  if d>59 then d=59
  e=e*50
  D=(c*600+d*10)*100
  if D>0 then goto "opt3_interval_ok"
  print "No interval specified..."
  goto "done"
:opt3_interval_ok
  press "shoot_half"
  sleep 2000
  release "shoot_half"
  n=1
:opt3_check_time
  gosub "opt3_check_bv_level"
  if B>=e then goto "opt3_shot_loop"
  cls
  if b<>999999 then print "Number of shots: "b
  print "Interval: "c"m "d"s"
  print "Bv:"B" (Min:"e")"
  print "Checked at "x":"y
  gosub "Bv_check_delay"
  goto "opt3_check_time"
:opt3_shot_loop
  X=get_tick_count
  gosub "opt3_check_bv_level"
  if B<=e then goto "done"
  shoot
  sleep 600
  n=n+1
  if n>b then goto "done"
  cls
  if b<>999999 then print "Next shot: "n" of "b else print "Next shot: "n
  print "Intervals: "c"m "d"s"
  print "Bv:"B" (Min:"e")"
  print " "
  S=X+D
:opt3_wait_loop
  X=get_tick_count
  if X<S then goto "opt3_wait_loop"
  goto "opt3_shot_loop"
:opt3_check_bv_level
  press "shoot_half"
  sleep 600
  get_bv96 B
  get_sv96 S
  release "shoot_half"
  sleep 600
  if B=0 then goto "opt3_check_bv_level"
  x=get_time 2
  y=get_time 1
  return
:opt3_Bv_check_delay
  y=get_time 1
  if (y%10)<>0 then goto "opt3_Bv_check_delay"
  return

<Part 2 of 3>
« Last Edit: 20 / March / 2011, 14:53:29 by SkyWalker9 »

*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
Re: Utilities #3 - added 3SunInt (a collection of mini-scripts)
« Reply #16 on: 19 / March / 2011, 19:01:43 »
Code: [Select]
:option1
 cls
 gosub "num_hold"
 D=(c*600+d*10)*100
 if D<1 then D=1
 if b<1 then b=1
 if c<=0 and d<=0 then d=30
 for h=1 to b
  B=get_tick_count
  S=B+D
:opt1_wait_loop
  B=get_tick_count
  if B<S then goto "opt1_wait_loop"
  if e>10 then e=10
  if e<0 then e=0
  for i=0 to e-1
   cls
   x=e-i
   if x=0 then gosub "num_0"
   if x=1 then gosub "num_1"
   if x=2 then gosub "num_2"
   if x=3 then gosub "num_3"
   if x=4 then gosub "num_4"
   if x=5 then gosub "num_5"
   if x=6 then gosub "num_6"
   if x=7 then gosub "num_7"
   if x=8 then gosub "num_8"
   if x=9 then gosub "num_9"
   if x=10 then gosub "num_10"
   sleep 1000
  next i
  cls
  shoot
  sleep 600
  gosub "num_hold"
 next h
 cls
 goto "done"
:num_0
 if f=1 then goto "num_0_R"
 print "      **"
 print "     *  *"
 print "     *  *"
 print "     *  *"
 print "      **"
 return
:num_0_R
 print "                 **"
 print "                *  *"
 print "                *  *"
 print "                *  *"
 print "                 **"
 return
:num_1
 if f=1 then goto "num_1_R"
 print "       *"
 print "      **"
 print "       *"
 print "       *"
 print "      ***"
 return
:num_1_R
 print "                 *"
 print "                 **"
 print "                 *"
 print "                 *"
 print "                ***"
 return
:num_2
 if f=1 then goto "num_2_R"
 print "      **"
 print "     *  *"
 print "       *"
 print "      *"
 print "     ****"
 return
:num_2_R
 print "                 **"
 print "                *  *"
 print "                 *"
 print "                  *"
 print "                ****"
 return
:num_3
 if f=1 then goto "num_3_R"
 print "     ****"
 print "         *"
 print "      ***"
 print "         *"
 print "     ****"
 return
:num_3_R
 print "                ****"
 print "               *"
 print "                ***"
 print "               *"
 print "                ****"
 return
:num_4
 if f=1 then goto "num_4_R"
 print "     *"
 print "     *  *"
 print "     *****"
 print "        *"
 print "        *"
 return
:num_4_R
 print "                   *"
 print "                *  *"
 print "               *****"
 print "                *"
 print "                *"
 return
:num_5
 if f=1 then goto "num_5_R"
 print "     ****"
 print "     *"
 print "     ****"
 print "         *"
 print "     ****"
 return
:num_5_R
 print "                ****"
 print "                   *"
 print "                ****"
 print "               *"
 print "                ****"
 return
:num_6
 if f=1 then goto "num_6_R"
 print "      ***"
 print "     *"
 print "     ****"
 print "     *   *"
 print "      ***"
 return
:num_6_R
 print "                 ***"
 print "                    *"
 print "                 ****"
 print "                *   *"
 print "                 ***"
 return
:num_7
 if f=1 then goto "num_7_R"
 print "     ****"
 print "        *"
 print "       *"
 print "      *"
 print "      *"
 return
:num_7_R
 print "                ****"
 print "                *"
 print "                 *"
 print "                  *"
 print "                  *"
 return
:num_8
 if f=1 then goto "num_8_R"
 print "      ***"
 print "     *   *"
 print "      ***"
 print "     *   *"
 print "      ***"
 return
:num_8_R
 print "                 ***"
 print "                *   *"
 print "                 ***"
 print "                *   *"
 print "                 ***"
 return
:num_9
 if f=1 then goto "num_9_R"
 print "      ***"
 print "     *   *"
 print "      ****"
 print "         *"
 print "      ***"
 return
:num_9_R
 print "                 ***"
 print "                *   *"
 print "                ****"
 print "                *"
 print "                 ***"
 return
:num_10
 if f=1 then goto "num_10_R"
 print "    *   **"
 print "   **  *  *"
 print "    *  *  *"
 print "    *  *  *"
 print "   ***  **"
 return
:num_10_R
 print "               **   *"
 print "              *  *  **"
 print "              *  *  *"
 print "              *  *  *"
 print "               **  ***"
 return
:num_hold
 if f=1 then goto "num_hold_R"
 print "   *       *"
 print "     * * *"
 print "     * * *"
 print "     * * *"
 print "   *       *"
 return
:num_hold_R
 print "              *       *"
 print "                * * *"
 print "                * * *"
 print "                * * *"
 print "              *       *"
 return

:option2
 if b<>1 then goto "opt2_skip_save"
 z=get_time 0
 y=get_time 1
 x=get_time 2
 m=get_time 3
 n=get_time 4
 p=get_time 5
 g=x*100+y
 if g<1 then g=1
 if g>9999 then g=9999
 print_screen g
 print "Date: "n"/"m"/"p
 print "Time: "x":"y":"z
 print " "
:opt2_skip_save
 press "shoot_half"
 sleep 600
 get_bv96 B
 get_sv96 S
 print "bv96="B" sv96="S
 get_user_av96 A
 get_user_tv96 T
 print "av96="A" tv96="T
 if b=1 then goto "almost_done"
 gosub "opt2_wait_loop"
 goto "done"
:opt2_wait_loop
 wait_click 10000
 is_key k "set"
 if k=1 then goto "opt2_exit_wait"
 goto "opt2_wait_loop"
:opt2_exit_wait
 return

:almost_done
 shoot
 sleep 600
:done
 release "shoot_half"
 print_screen 0
end

Update 4-19-11: When using the wait_click statements, some cameras require the timeout be specified; recommend starting with "wait_click 10000" (10secs). The script has been updated to reflect the change.

<Part 3 of 3 - final part>
« Last Edit: 19 / April / 2011, 18:24:00 by SkyWalker9 »

*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
This is the fourth in the series of mini-scripts.

As in previous Utility mini-scripts, each mini-script is identified by the first parameter line and the mini-script is chosen by the number in the name of the mini-script. If there are parameters for that mini-script, they are shown in the column just below the mini-script name.

1ZmStep:2LensEqv:3TstDOF       (     1)
.      :Step#   :Step#         (    64)
.      :All (1=REG 2=CSV)      (     0)
.      :        :JPGs (1=YES)  (     1)
.      :        :JPG#          (  2375)
Utility mini-scripts

Special note: While the "2LensEqv" & "3TstDOF" mini-scripts use some camera specific code for the SX20 camera, the mini-scripts can be easily modified for other cameras. Some statements are normally camera specific such as PropCas; in this case there are also three variable statements that use coefficients for a quadratic equation specifically for the SX20. This data came from the "1ZmStep" mini-script and was recorded from a SX20; the coefficients processing was done using an off-camera curve fitting program.

1ZmStep. This mini-script is used to accurately determine the zoom steps for the 35mm equivalent markings on the camera lens. These values can then be used to interpolate the 35mm equivalent setting for each zoom step using a quadratic formula. Using a quadratic formula to interpolate these settings is much more accurate than linear plotting between the same points.

Since there are only two zoom steps that are considered truely accurate on a zoom lens, the 0 step and the last step (128 for a SX20), I used them as a reference when measuring the other 35mm equivalent markings on the lens. In order to accurately determine the other zoom steps for the 35mm equivalent markings on the lens, I needed to be able to accurately re-position the lens to the same relative offset from each mark as the 0 and 128 steps (28mm & 560mm respectively). This mini-script allows you to very accurately re-position the zoom step and then read the zoom step for that marking.

The process to read the zoom steps is as follows
1. BEFORE starting the script, zoom relatively close to the respective 35mm equivalent marking
2. Run this mini-script to "fine-tune" (re-position to) the zoom step using either the "left" & "Right" or "zoom-in" & "zoom-out" buttons.
3. manually record the zoom step
4. press the "set" button to exit the script

After each reading you need to press the "set" button to exit the script (step 4). If you do not exit the script, the next time you start the script it will re-position to the last zoom step recorded (even though you may have already zoomed to a new location.)

The process after the recording of these zoom steps is to use the data to determine coefficients for the "best fit" curve using a quadratic equation. There are several apps available that can to do this, but i chose to use "CurveExpert v1.3" (curve fitting program) to solve for the coefficients:

Data from SX20
step   35mm      Quadratic Fit:  y=a+bx+cx^2
0       28       Coefficient Data:
47      85       a = 27.93578
62     135       b = -0.49513
76     200       c = 0.03626
93     300
109    400
128    560
If you don't have access to a curve fitting program that solves for the coefficients of a quadratic equation/data plot and you would like help with this step, please post a reply to this thread. Just include the camera info and I'll be glad to provide the respective coefficients for the quadratic equation for the camera. In addition to providing the camera model, please include the zoom step for each 35mm equivalent mark on your camera lens. For example, my SX20 has 35mm equivalent markings from 28mm-560mm so I recorded the following data points

  35mm equiv marks: 28mm, 85mm, 135mm, 200mm, 300mm, 400mm, 560mm
              zoom steps:  0, 47, 62, 76, 93, 109, 128

Here is a PDF file that shows the process & results of using the a quadratic equation to interpolate the 35mm equivalents by zoom steps: http://hotfile.com/dl/115664336/af6f5bd/Results.pdf.html

2LensEq. This mini-script was created to display 35mm equivalent focal lengths using zoom steps on the SX20. It allows the user to display the value of a zoom step individually or create a log with all of the zoom step/35mm equivalent values.

While doing a comparison with several DSLR lenses, I needed to zoom the lens to relatively the same 35mm equivalent positions as the DSLR lens. My SX20 has markings for several of the 35mm equivalent positions so it is fairly easy to go to the marked 35mm equivalent positions using the zoom-in and zoom-out buttons, however it is difficult to accurately position the lens using the zoom-in and zoom buttons. Using a script it is much easier to position the camera lens to the desired 35mm equivalent position if you know which zoom step to use for the 35mm equivalent. This mini-script allowed me to quickly create a chart of the zoom steps/35mm equivalent for marked & unmarked positions.

When a single zoom step (Step#) is set, the lens is positioned to the zoom step so that the 35mm calculation can be compared to markings on the lens (if present); if there are no 35mm markings this option would allow someone to accurately mark the 35mm setting on the SX20 lens if desired.

There are two parameters: Step# and All. "Step#" allows the user to specify a particular zoom step, i.e. a number from 0-8, 0-14, or 0-128 depending on the model of camera. To create a log of all zoom steps, set the "All" parameter to 1 or 2, depending on the print format required. To print the info in the regular format, set this parameter to "1"; for a CSV format printout, set this parameter to "2". A log of all of the 35mm equivalent values for each of zoom step will be created in the CHDK Scripts/Logs folder named "LOG_0111.TXT" for the regular format or "LOG_0222.TXT" for the CSV format. The CSV format is preferable when using the file as an import source to analyze/plot the results.

<Part 1 of 3>
« Last Edit: 24 / April / 2011, 12:58:10 by SkyWalker9 »


*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
3TstDOF. This mini-script is used to test how the DOF works on the SX20 camera. There has been discussion in the forums about a bug in CHDK DOF and how it calculates the focus point, near-limit & far-limit. This mini-script allows testing of individual cameras and FW versions to see how each camera handles this situation. It may identify particular zoom steps where the related DOF calculations can be a problem, thus allowing the user to avoid them.

There are four parameters: Step#, All, JPGs and JPG#. "Step#" allows the user to set the zoom to a specific zoom step and display various DOF information. To create a log of all zoom steps with the information at each zoom step, set the "All" parameter to 1 or 2, depending on the print format required. To print the info in the regular format, set this parameter to "1"; for a CSV format printout, set this parameter to "2". A log will be created in the CHDK Scripts/Logs folder named "LOG_1111.TXT" for the regular format or "LOG_2222.TXT" for the CSV format.

Although this isn't a parameter I normally would use, I have included it because it proved useful when troubleshooting so I left it in the mini-script. When the "JPGs" parameter is set to 1 this parameter will capture a JPG at each zoom step and provide confirmation that the photo was actually in focus at the time of the readings. The "JPG#" parameter is only used if the previous "JPGs" parameter is set to 1. It needs to be set to the number of the last JPG shot before this script is started. As each new JPG is shot during this script, the script will record the number in the log with the DOF information for that photo.

The script may have difficulty reading the focus point & near-limit & far-limit information, so you may see something like the following preceding the normal printout: chk:1 focus:14942 rng:8714 to -1 (this will NOT be printed if "All" is set to "2")

In order for the DOF test to work properly over many different zoom steps, the following sequence must occur:
- MF must be disabled
- camera is then zoomed to a specific step
- MF is then enabled
- shoot-half is executed and the readings taken
- if specified, a photo is then taken

There are several camera specific checks in the script (Camera mode must be Av or M, Safety MF disabled, IS disabled) and there is a PropCas statement required to enable and disable MF.

During the reading of the focus point, near- & far-limits, there are times when the values are negative or zero; the script will attempt to re-read the values several times if needed. The number of re-checks are dependent upon the values obtained for the variables. Three attempts are made to re-read when the values are -1 or zero and ten attempts are allowed for negative numbers other than -1.

Results of "3TstDOF" mini-script test runs using SX20:
1. If Focus Point, Near-limit, Far-limit, Hyperfocal & DOF sharpness are desirable, the usable range is from zoom steps 20-79 (34mm-216mm) and unreliable for other zoom steps
2. Focus Point varies widely over the steps; appears best-fit-curve quadratic trend
3. Hyperfocal is "well behaved" over 0-88 step range, unrealiable at other steps; best-fit-curve is quadratic
4. DOF sharp - the results for this were very erractic when plotted so I don't really know what to make of this
5. Near-limit & Far-limit usable range is from zoom steps 20-79 but unreliable for the rest of the zoom steps; both appear best-fit-curve quadratic trend; Far-limit is much more erratic than Near-limit
6. 35mm Equivalent is well behaved and very smooth throughout range - best-fit-curve is quadratic

Here is a PDF file that shows graphs of the DOF vs zoom steps testing: http://hotfile.com/dl/115659066/230f47e/Results_of_DOF_Test_-_graphs.pdf.html

Save this Utility script to your CHDK/SCRIPT folder as BAS.

-- -----------------------
Special notes:
1. Since the CHDK UBasic is an interpreted script reader, any mini-script that is time sensitive should be located near the top of the "Utility" script in order to insure the fastest run times.
2. If PropCas statements are used in a mini-script, they are specifically identified in the script positioned between "rem" statements so that they can be easily found and updated to the user's model of camera. Since the list of PropCas for the SX20 is not complete, I have been keeping track and updating the list of PropCas values that I find in the SX20 forum in this post: http://chdk.setepontos.com/index.php?topic=4348.msg60704#msg60704

<Part 2 of 3>
« Last Edit: 24 / April / 2011, 13:05:46 by SkyWalker9 »

*

Offline SkyWalker9

  • ****
  • 301
  • SX20 IS (fw 1.02b)
Code: [Select]
@title Util4
@param q 1ZmStep:2LenEqv:3TstDOF
@default q 1
@param d .      :Step#  :Step#
@default d 64
@param e .       All(1=R 2=C)
@default e 0
@param f .      :        :JPGs(1=Y)
@default f 1
@param g .      :        :JPG#
@default g 2842

rem ------ SX20 camera specific coefficient info for 35mm equiv ------
rem 129 zoom steps (0-128); 35mm equivalent zoom 28mm-560mm
rem   zoom steps (x):  0  47  62  76  93 109 128
rem   35mm equiv (y): 28  85 135 200 300 400 560
rem
rem Quadratic Fit for SX20: y=a+bx+cx^2
rem   where  x=zoom_step & y=35mm_equivalent
rem     a=27.93578
rem     b=-0.49512685
rem     c=0.036260383
rem
rem Since the current UBasic build requires that variables be assigned integer values
rem with less than 7 digits, we need to assign the variable values another way such
rem as using "expressions":

    a=2793*1000+578
    b=495127*(-1)
    c=36260

rem After initial calculations are performed, they are corrected by dividing
rem the results by the appropriate powers of ten, adding 5 to "round up" if needed,
rem then dividing by ten the final time:
rem
rem      y=(a/10000+5)/10 + (((b*x)/100000)+5)/10 + ((((c*x*x)/100000)+5)/10)
rem
rem Notice that not all of the digits of the coefficients are used in the above expression.
rem Due to the maximum value of "x" that is possible, there could be a problem with integer
rem overflow (going negative), so limiting the number of digits was required to prevent this
rem from occurring. Although some accuracy was sacrificed it appeared to be inconsequential.
rem
rem ------ SX20 camera specific coefficient info for 35mm equiv ------

M=get_zoom_steps

if q=1 then goto "option1"
if q=2 then goto "option2"
if q=3 then goto "option3"
goto "done"

:option1
  h=get_zoom
  print "Adjust zoom step"
  print "Zoom Step:"h
:opt1_tweak_loop
   wait_click 5000
   is_key k "zoom_out"
   if k=1 then h=h-1
   is_key k "zoom_in"
   if k=1 then h=h+1
   is_key k "left"
   if k=1 then h=h-1
   is_key k "right"
   if k=1 then h=h+1
   is_key k "set"
   if k=1 then goto "done"
   if h<0 then h=0
   if h>M then h=M
   set_zoom h
   cls
   print "Adjust zoom step"
   print "Zoom Step:"h
  goto "opt1_tweak_loop"

:option2
 if d<0 then d=0
 if d>(M-1) then d=M-1
 if e=1 or e=2 then goto "opt2_create_all"
  x=d
  set_zoom d
  sleep 1000
  y=(a/10000+5)/10 + (((b*x)/100000)+5)/10 + ((((c*x*x)/100000)+5)/10)
  print "Zoom step="d
  print "35mm Equiv="y
 goto "done"
:opt2_create_all
  if e=2 then goto "opt2_CSV"
    print_screen 111
    print "Zoom 35mm"
    print "step Equiv"
  goto "opt2_CSV_log"
:opt2_CSV
    print_screen 222
    print "Zoom step, 35mm Equiv"
:opt2_CSV_log
  for x=0 to M-1
   y=(a/10000+5)/10 + (((b*x)/100000)+5)/10 + ((((c*x*x)/100000)+5)/10)
   if e=2 then print x", "y else print x"     "y
  next x
  print_screen 0
  goto "done"

:option3
rem ---- camera specific; can be omitted -----
  get_prop 133 z
  if z=0 then goto "opt3_okay1"
   set_prop 133 0
   sleep 1000
:opt3_okay1
  y=0
  get_prop 50 z
  if z=-32767 or z=-32766 then y=y+1 else print "Camera mode not Av or M"
  get_prop 281 z
  if z=0 then y=y+1 else print "Safety MF not disabled"
  x=get_IS_mode
  if z<3 then y=y+1 else print "IS not disabled"
  if y=3 then goto "opt3_okay2"
   end
rem ---- camera specific; can be omitted -----
:opt3_okay2
  cls
  if f<>1 then goto "opt3_okay3"
    print "Is JPG# set to"
    print "last JPG shot?"
    wait_click
:opt3_okay3
  if e=1 or e=2 then goto "opt3_save_all"
   set_zoom d
     sleep 1000
rem ------- camera specific; enables MF -------
   set_prop 133 1
     sleep 5500
rem ------- camera specific; enables MF -------
   press "shoot_half"
     sleep 1000
   get_focus w
   x=get_near_limit
   y=get_far_limit
   print "Zoom Step:"d
   print "Focus:"w
   print "Range:"x" to "y
   w=get_hyp_dist
   x=get_dof
   print "Hyperfocal:"w
   print "DOF Sharp:"x
  goto "done"
:opt3_save_all
  h=g
  if e=2 then goto "opt3_csv"
   print_screen 1111
   z=get_time 0
   y=get_time 1
   x=get_time 2
   m=get_time 3
   n=get_time 4
   p=get_time 5
   print "Date: "n"/"m"/"p
   print "Time: "x":"y":"z
   print " "
   goto "opt3_reg_csv"
:opt3_csv
  print_screen 2222

:opt3_reg_csv
  if e=2 then print "Step, Eq, Foc, N, F, ck, Hyp, DOF, JPG#"
  for x=0 to M-1
   set_zoom x
     sleep 1000
   p=0
   m=0
:opt3_re_check
rem ------- camera specific; enables MF -------
   set_prop 133 1
     sleep 5500
rem ------- camera specific; enables MF -------
   press "shoot_half"
     sleep 1500
   p=p+1
   get_focus w
   v=get_near_limit
   y=get_far_limit
rem count when w=0 or w-v-y are (-1)
   if w=0 or w=-1 or v=-1 or y=-1 then m=m+1 else m=0
rem if w=zero or w-v-y are (-1) three times then stop re-checking
   if m>2 then goto "opt3_re_check_done"
rem if w-v-y are all normal values <OR> we have reached max number of re-checks
   if m=0 or p>9 then goto "opt3_re_check_done"
    release "shoot_half"
      sleep 1000
rem ------- camera specific; disables MF -------
    set_prop 133 0
      sleep 600
rem ------- camera specific; disables MF -------
    if e=1 then print ".  chk:"p" focus:"w" rng:"v" to "y
    goto "opt3_re_check"
:opt3_re_check_done
   u=(a/10000+5)/10 + (((b*x)/100000)+5)/10 + ((((c*x*x)/100000)+5)/10)
   j=get_hyp_dist
   k=get_dof
   release "shoot_half"
     sleep 600
   if f<>1 then goto "opt3_skip_shot"
    h=h+1
    shoot
      sleep 1000
:opt3_skip_shot
   if e=2 then goto "opt3_CSV2"
    print "Zoom Step:"x" ("u"mm)"
    print "Focus:"w" Range:"v" to "y
    print "Hyperfocal:"j" DOF Sharp:"k
    if f=1 then print "JPG number:"h
    print " "
    goto "opt3_CSV2_skip"
:opt3_CSV2
   if f=1 then print x", "u", "w", "v", "y", "p", "j", "k", "h else print x", "u", "w", "v", "y", "p", "j", "k
:opt3_CSV2_skip
rem ------- camera specific; disables MF -------
   set_prop 133 0
   sleep 1000
rem ------- camera specific; disables MF -------
  next x
  print_screen 0
   set_zoom 0
   sleep 1000

:done
end
<Part 3 of 3>

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal