Shutter Speed script - adjustable - Script Writing - CHDK Forum

Shutter Speed script - adjustable

  • 3 Replies
Shutter Speed script - adjustable
« on: 13 / December / 2007, 00:20:03 »
*edit #2*
Made a slight debugging change (multiple shot with zero step was calling single shot)
Also rearranged the shutter speed calculation and cls/printout order.  Doesn't speed it up, but removes the slight pause in the middle of the printout while shutter speed is calculated and does it before clearing the screen and reprinting.  Looks a little smoother.
I made a few minor adjustments to decrease the filesize slightly.
For those with cameras without an AllBest build, the script should be modifiable to Fingalo's build by:

  print "Shutter value:",p
  set_tv96_direct p


  if p>=0 and p<=19 then p=-1
  print "Shutter value:",p
  set_tv_override p

The line "if p>=0 and p<=19 then p=-1" is to bypass the override indexing that has been included in Fingalo's build for these values

I got an idea based on Divalent's property case tester script ( and wanted to get some feedback on it before sending it to the wiki.

This is similar to my previous Shutter Speed script in it's basic usage and settings, however it has added functionality to adjust the scripts parameter on the fly.

When using this, remember that the settings changed within the script are only temporary, they will reset to your defaults when you restart the script.

The onscreen prompts are as descriptive as I could make them with limited text space.  Further information is below:

After starting the script you are shown the main screen.  The menu tree from here is as follows and is accessed using the directional pad:
MENU enters adjustment menu
     (the parameters of the script are shown here and are updated with each adjustment so the effect can be seen)
     -> LEFT enters starting shutter speed menu
          -> LEFT decrease starting shutter by 1 partial stop (-1/xEV)
          -> RIGHT increase starting shutter by 1 partial stop (+1/xEV)
          -> UP decrease starting shutter by 1 full stop (-1EV)
          -> DOWN increase starting shutter by 1 full stop (+1EV)
          -> SET returns to adjustment menu
     -> RIGHT enters number of shots menu
          -> LEFT  decrease number of shots by 1 (bounded by minimum 1)
          -> RIGHT increase number of shots by 1
          -> UP (not used)
          -> DOWN reset number of shots to 1
          -> SET returns to adjustment menu
     -> UP enters step size menu
          -> LEFT decrease step size by 1 partial stop (-1/xEV)
          -> RIGHT increase step size by 1 partial stop (+1/xEV)
          -> UP (not used)
          -> DOWN reset step size to 0EV
          -> SET returns to adjustment menu
     -> DOWN enters EV fraction adjustment mode (warning: this affects all parameters based on the EV fraction)
          -> LEFT decrease fraction base by 1 (-x/1EV)
          -> RIGHT increase fraction base by 1 (+x/1EV)
          -> UP (not used)
          -> DOWN (not used)
          -> SET returns to adjustment menu
     -> SET returns to main screen
SET begins shooting sequence
Any other key cancels script

copy and paste this into a text file called "ShutterSpeedAdjust.bas" in \CHDK\SCRIPTS
Code: [Select]
rem Author: barberofcivil
rem Tested on S2 IS
rem Requires AllBest build

@title Shutter Speed - adjustable
@param a EV fraction (1/x EV)
@default a 3
@param b Start Tv (1EV)
@default b -11
@param c Start Tv (1/xEV)
@default c 0
@param d No.Shots
@default d 1
@param e Step Size (y/x EV)
@default e 1
@param f Start Delay (s)
@default f 0
@param g Delay between shots (s)
@default g 0

if f<0 then f=0
if g<0 then g=0
if d<1 then d=1
if a<1 then a=1
if c>=a then c=a-1
if c<0 then c=0
if b<0 then c=-c


if d=1 then gosub "Single" else gosub "Multiple"

print "SET:proceed  MENU:adjust"
print "Any other key to cancel"

is_key x "set"
  if x=1 then print "Proceeding..."
is_key y "menu"
  if y=1 then gosub "Adjust"
if (x+y)=0 then gosub "Cancel"

for w=1 to f
  if f>0 then print "Starting in",(f-w+1),"s..."
  if f>0 then sleep 1000
next w

print "Starting shots now..."

for i=1 to d
  gosub "ShutterCalc"
  print "Shot",i,"of",d
  if k>=6 then print "Shutter ~1/"o,"s" else print "Shutter ~"r"."st,"s"
  print "Shutter value:",p
  set_tv96_direct p
  sleep 1000*g
next i


  if k<0 then l=l-4*a
  for j = 1 to (l/a/4+2)
  next j

  print "Shots cancelled"

  if e=0 and d>1 then print "Tv locked (step=0)"
    gosub "ShutterCalc"

  print "One shot to be taken"
  if k>=6 then print "Tv: ~1/"o,"s" else print "Tv: ~"r"."st,"s"

    gosub "ShutterCalc"
    gosub "ShutterCalc"

  print d,"shots to be taken"
  if k>=6 then print "Tv Start: ~1/"w,"s" else print "Tv Start: ~"x"."yz,"s"
  if k>=6 then print "Tv End:   ~1/"o,"s" else print "Tv End:   ~"r"."st,"s"

    gosub "ShutterCalc"

    gosub "ShutterCalc"

  if k>=6 and v<>1 then print " Tv Start: ~1/"w"s"
  if k<6  and v<>1 then print " Tv Start: ~"x"."yz"s"
  if k>=6 and v=1 then print ">Tv Start: ~1/"w"s"
  if k<6  and v=1 then print ">Tv Start: ~"x"."yz"s"
  if k>=6 then print " Tv End:   ~1/"o"s" else print " Tv End:   ~"r"."st"s"

  if v=2 then print ">Shots:"d"  Step:"e"/"a"EV"
  if v>2 then print " Shots:"d" >Step:"e"/"a"EV"
  if v<2 then print " Shots:"d"  Step:"e"/"a"EV"

  if v=0 then goto "BaseMenu"
  if v=1 then goto "AdjustStart"
  if v=2 then goto "AdjustShots"
  if v=3 then goto "AdjustStep"
  if v=4 then goto "AdjustEV"

  print "L:Start  R:Shots  U:Step"
  print "D:EVFraction  SET:Return"
  if is_key "left"  then v=1
  if is_key "right" then v=2
  if is_key "up"    then v=3
  if is_key "down"  then v=4
  if is_key "set"   then goto "loop"
  goto "Adjust"

  print "L:-1/"a"EV R:+1/"a"EV"
  print "D:-1EV U:+1EV SET:Return"
  if is_key "left"  then u=u-1
  if is_key "right" then u=u+1
  if is_key "up"    then u=u+a
  if is_key "down"  then u=u-a
  if is_key "set"   then v=0
  goto "Adjust"

  print "L:-1 Shot R:+1 Shot"
  print "D:Reset(1) SET:Return"
  if is_key "left"  then d=d-1
  if is_key "right" then d=d+1
  if is_key "down"  then d=1
  if is_key "set"   then v=0
  if d<1 then d=1
  goto "Adjust"

  print "L:-1/"a"EV R:+1/"a"EV"
  print "D:=0 SET:Return"
  if is_key "left"  then e=e-1
  if is_key "right" then e=e+1
  if is_key "down" then e=0
  if is_key "set"   then v=0
  goto "Adjust"

  print "L:-x/1EV R:+x/1EV"
  print "SET:Return"
  if is_key "left"  then a=a-1
  if is_key "right" then a=a+1
  if is_key "set"   then v=0
  if c>=a then c=a-1
  goto "Adjust"
« Last Edit: 13 / December / 2007, 21:09:57 by barberofcivil »

Re: Shutter Speed script - adjustable
« Reply #1 on: 13 / December / 2007, 11:03:27 »
Another nice one!

I played with it a little last night. It works, just as advertised. :D  I like the way it makes shutter-speed selections like a normal button-feature on a camera. But ... I have to admit, due to the 10ms per line speed limit of all scripts it runs a little slow. But for someone that needs to see more precise 1/3rds stop shutter speeds, this is fantastic. I had fun dialing in shutter speeds OVER 1/100,000 second. :)

btw: I've been prefixing my script filenames with things like ab_ (for allbest), fg_ (for fingalo), etc. to make them easier to find in file-list batches for the build they need to be run on. I've collected so many scripts this year it's getting out of hand! :)

Thanks!  I wanted to be able to see immediately what the shutter speed values were rather than having to exit the script, change parameters and restart it, and had just came across Divalent's script.  Unfortunately you are right about the slow response, I don't think I can do anything about that.

The settings are actually valid from +8EV (256s) down to at least -20EV (1/1,048,576s) before hitting the numerical limitations, which are well beyond the actual camera limitations (so far, has anyone actually got a 4 min or 1millionth exposure yet?  If not, keep working at it).

Re: Shutter Speed script - adjustable
« Reply #2 on: 13 / December / 2007, 12:39:54 »
No, I don't think you can speed up the scripts. As mentioned many places, each line of uBASIC has to be hit with a key-scan routine from the camera, and it does that once every 10ms. There's more about this on some of the Wikia pages, but you have to hunt around for it. (Unfortunately, I'm finding out that the search feature on the Wikia pages isn't very complete. It misses many words that I've tried to search for that I know exist, and then I find them on my own later.)

This is why creativity and ingenius ways where many lines of code can be done with just one line will greatly speed them up. Even REM lines each take 10ms to process, so it's good to remove those too if you need "faster".

I tend to like my scripts to be informative with lots of text so there isn't much more I can remove that I can see yet.  Feel free to suggest any optimizations...  The shutter speed calculation also takes a little bit of time to do which adds to the lag, especially when doing it twice for start and end, I could come up with a simpler function, but it would have less accuracy.

Not 1/1,000,000 yet, but I think I've documented getting 1/64,000. I don't have the right equipment to test it properly though. However, now that I have my new way-cool CHDK-EXIF to Standard EXIF patcher utility, I've been going through and using it to process huge batches of my ultra-highspeed Tv files. I've finding some where the exposure time was recorded as high as 1/81,553,170.  :lol :haha That should be fast enough to even photograph an atom splitting.

When I'd just let a +1EV exposure bracketing run for a long time just to see where things might end up.

I'm strongly suspecting that the true limit lies somewhere around 1/64,000 or 1/80,000 with f-stops of 8.0 - 11.0. It's so hard to test due to the light levels needed at such fast speeds. I'm hoping the sun might come out today so I can see about (*carefully*) photographing some sunspots without a filter. :D

From what I've done so far, it seems to be around this range for limits, but it is hard to check without really bright lighting.  I've been using HDR Shop to compare images by subtraction to try see if there is a difference.  At such low shutter speeds (low light) it's difficult to tell because the noise can tend to be around the same magnitude.  I've only been trying it with jpeg though, perhaps I should try some RAWs.

Re: Shutter Speed script - adjustable
« Reply #3 on: 13 / December / 2007, 14:27:24 »
Well, I just came back in from some sub-zero windchills (damn that wind is howling!) and found out that even at 1/100,000 TV setting with +5 Av override that it's still not dim enough to image the solar disk without filters. CLOSE but not close enough. I bet with just 2 crossed polarizers it might be enough filtering though.

What IS surprising though, is that the +5 Av override that the image of the sun was remarkably dimmer. F/11 may not be the smallest f/stop available after all. I'll have to compare histograms to see how much the light shifted from f/8 to +5 Av.

(now downloading sun images to hard-drive to take a closer inspection of what I managed to image)

Well, according to this: Wikipedia: Apparent Magnitude, the sun is 449,000 times brigher than the full moon (the full moon is the same brightness as subjects on earth lit in daylight). So ... someone do the math. How small of an f-stop and how high of a shutter speed would we actually need to image sunspots without a filter??

My resulting photos are just blurred disks from too much light. :D

Just some rudimentary math.
If you want to see the sun at the same exposure as the moon, and the moon is 449,000 times brighter, this represents about 18.78 stops (2^18.78 = 450136). Assuming the moon can be imaged with a shutter of about 1/1000s (-10EV), the sun would need an exposure of -28.78EV (-10-18.78) which is 1/460,938,809s shutter speed which I believe is well beyond the capabilities of the camera (even with the developers working day and night on it).  Try my script to see if you can get it :D (the shutter setting will get calculated correctly (2763), but the speed will likely not be)


Related Topics

SimplePortal 2.3.6 © 2008-2014, SimplePortal