Shutter Speed w/Av, Fully Adjustable (LUA) *UPDATED!* - Completed and Working Scripts - CHDK Forum supplierdeeply

Shutter Speed w/Av, Fully Adjustable (LUA) *UPDATED!*

  • 19 Replies
  • 14471 Views
Shutter Speed w/Av, Fully Adjustable (LUA) *UPDATED!*
« on: 24 / August / 2009, 21:36:57 »
Advertisements
I have completed a bit of an upgrade to this script.  I have now added Av (aperture) adjustability support, plus other additions.

Features:
- Tv (Shutter speed) stacking, all settings adjustable on-the-fly (#shots, step size, start)
- Selected shutter speeds estimated and displayed (1/xs for 1/4s or less, x.xxs for >1/4s to ~120s, x.xxm for >120s (2min))
- Av adjustable on-the-fly (in +/-1/3EV steps)
- Selected Av estimated and displayed
- Initial Tv and Av values don't need to be preset from the menu, script grabs current user-set ones (i.e. from M, Av or Tv modes)
- Pre-focus ON/OFF (focus once and lock for remaining pictures)
- Start delay and shot delay
- Pre-focus, start delay and shot delay adjustable on-the-fly (under "setup" from main menu)
- Shutter speed estimation works displays values from ~1/2,000,000s up to ~160,000m (values are estimates fairly close to the theoretical values), however, camera limitations will actually limit what shutter speeds will actually be achieved

Usage should be fairly easy, just start the script and follow the screen prompts

As it is written in LUA, response is pretty fast, and the script should be fairly useable for many requirements.
Please give it a try and provide feedback for errors (with description and/or how to reproduce) and any other features tha may be useful
Save as a .lua file and most of all Enjoy!

*Script in following message in 2 parts as total message length exceeds allowable*
« Last Edit: 26 / August / 2009, 11:48:18 by barberofcivil »

Re: Shutter Speed w/Av, Fully Adjustable (LUA) *UPDATED!*
« Reply #1 on: 26 / August / 2009, 11:46:51 »
To be posted in 2 parts

PART 1:
Code: [Select]
--[[
rem Author: barberofcivil

@title Shutter Stack w/Av - Adjustable
@param a EV fraction (1/x EV)
@default a 3
@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
@param h Pre-focus: 0=off, 1=on
@default h 1
--]]

if f<0 then f=0 end
if g<0 then g=0 end
if d<1 then d=1 end
if a<1 then a=1 end
if h<0 then h=0 end
if h>1 then h=1 end

function ShutterCalc (i)
  local k=(1-i)*e+u
  local p=(k*96)/a
  local l=(k/a/4)*4*a
  if k<0 then l=l-4*a end
  local n=(k-l)
  local j=(((((((((30*n^3)/(4*a))*n)/(4*a))*n)/(4*a))*243)/(4*a))*7)
  local j=j-(((((((30*n^3)/(4*a))*n)/(4*a))*254)/(4*a))*4)
  local j=j+(((((30*n^3)/(4*a))*227)/(4*a))*9)
  local j=j+(((30*n^2*307)/(4*a))*3)
  local j=j+(30*n*850)
  local m=16^(l/a/4+2)
  local o=(((((((j/(18000)+1)/2)+a)*m)/(128*a)+1))/2)
  local q=(((51200*a)/(((((j/18000)+1)/2)+a)*m)+1)/2)
  if m<1 then
    mm=16^(-l/a/4-2)
    q=(((((51200*a*100)/(((((j/18000)+1)/2)+a))/100)*mm)+1)/2)
  end
  if p<=-660 then q=q/60 end
  local r=q/100
  local s=(q-r*100)/10
  local t=q-r*100-s*10
  return o,p,r,s,t
end

function AVCalc ()
  local l=(x/192)*192
  local m=2^(l/192)
  local n=(x-l)
  local j=(n^3)+650*(n^2)+360000*n
  local q=((j/100000+1005)/10)*m
  local r=q/100
  local s=(q-r*100)/10
  local t=q-r*100-s*10
  return r,s,t
end

function ADJUST()
  o1,p1,r1,s1,t1 = ShutterCalc(1)
  o2,p2,r2,s2,t2 = ShutterCalc(d)
  r3,s3,t3 = AVCalc()
  if o1>=4 then xx1="1/"..o1 else xx1=r1.."."..s1..t1 end
  if o2>=4 then xx2="1/"..o2 else xx2=r2.."."..s2..t2 end
  if v==1 then xx0=">Tv:" else xx0=" Tv:" end
  if p1>-660 then xe1="s" else xe1="m" end
  if p2>-660 then xe2="s" else xe2="m" end
  cls()
  if d==1 then
    print (xx0..xx1..xe1)
  else
    print (xx0..xx1..xe1.." to "..xx2..xe2)
  end
  if v==5 then
    print (">Av:"..r3.."."..s3..t3)
  else
    print (" Av:"..r3.."."..s3..t3)
  end
  if v==2 then
    print (">Shots:"..d.."  Step:"..e.."/"..a.."EV")
  elseif v>2 and v<5 then
    print (" Shots:"..d.." >Step:"..e.."/"..a.."EV")
  else
    print (" Shots:"..d.."  Step:"..e.."/"..a.."EV")
  end
  if v==0 then BaseMenu()
  elseif v==1 then AdjustStart()
  elseif v==2 then AdjustShots()
  elseif v==3 then AdjustStep()
  elseif v==4 then AdjustEV()
  elseif v==5 then AdjustAV()
  end
end

function BaseMenu()
  print ("L:Start  R:Shots  U:Step")
  print ("D:/EV MENU:Av SET:Return")
  wait_click()
  if is_key("left")  then v=1 end
  if is_key("right") then v=2 end
  if is_key("up")    then v=3 end
  if is_key("down")  then v=4 end
  if is_key("menu")  then v=5 end
  if is_key("set")   then v=-1 end
end

function AdjustStart()
  print ("L:-1/"..a.."EV R:+1/"..a.."EV")
  print ("D:-1EV U:+1EV SET:Return")
  wait_click()
  if is_key("left")  then u=u+1 end
  if is_key("right") then u=u-1 end
  if is_key("up")    then u=u-a end
  if is_key("down")  then u=u+a end
  if is_key("set")   then v=0   end
end

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

function AdjustStep()
  print ("L:-1/"..a.."EV R:+1/"..a.."EV")
  print ("D:=0 SET:Return")
  wait_click()
  if is_key("left")  then e=e-1 end
  if is_key("right") then e=e+1 end
  if is_key("down")  then e=0   end
  if is_key("set")   then v=0   end
end

function AdjustEV()
  print ("L:-x/1EV R:+x/1EV")
  print ("SET:Return")
  wait_click()
  if is_key("left")  then a=a-1 end
  if is_key("right") then a=a+1 end
  if is_key("set")   then v=0   end
  if a<1 then a=1 end
  if a>96 then a=96 end
end

function AdjustAV()
  print ("L:-1/3EV R:+1/3EV")
  print ("D:-1EV U:+1EV SET:Return")
  wait_click()
  if is_key("left")  then x=x+32 end
  if is_key("right") then x=x-32 end
  if is_key("up")    then x=x-96 end
  if is_key("down")  then x=x+96 end
  if is_key("set")   then v=0    end
  if x<0 then x=0 end
end

function DELAY()
  if h==0 then xx0="OFF" else xx0="ON" end
  if v==1 then xx1=">" else xx1=" " end
  if v==2 then xx2=">" else xx2=" " end

  cls()
  print (    " Pre-focus  : "..xx0)
  print (xx1.."Start delay: "..f.."s")
  print (xx2.."Shot delay : "..g.."s")

  if v==0 then BaseMenu2()
  elseif v==1 then AdjustStartD()
  elseif v==2 then AdjustShotD()
  end
end

function BaseMenu2()
  print ("L:Start      R:Shot")
  print ("D:Pre-focus  SET:Return")
  wait_click()
  if is_key("left")  then v=1   end
  if is_key("right") then v=2   end
  if is_key("down")  then h=1-h end
  if is_key("set")   then v=-1  end
end

function AdjustStartD()
  print ("L:-1s        R:+1s")
  print ("D:Reset(0)   SET:Return")
  wait_click()
  if is_key("left")  then f=f-1 end
  if is_key("right") then f=f+1 end
  if is_key("down")  then f=0   end
  if is_key("set")   then v=0   end
  if f<0 then f=0 end
end

function AdjustShotD()
  print ("L:-1s        R:+1s")
  print ("D:Reset(0)   SET:Return")
  wait_click()
  if is_key("left")  then g=g-1 end
  if is_key("right") then g=g+1 end
  if is_key("down")  then g=0   end
  if is_key("set")   then v=0   end
  if g<0 then g=0 end
end


Re: Shutter Speed w/Av, Fully Adjustable (LUA) *UPDATED!*
« Reply #2 on: 26 / August / 2009, 11:47:25 »
PART 2:
Code: [Select]

u=(get_user_tv96()*32*a)/96
x=get_user_av96()

done=0
while done==0 do
  v=0
  o1,p1,r1,s1,t1 = ShutterCalc(1)
  o2,p2,r2,s2,t2 = ShutterCalc(d)
  r3,s3,t3 = AVCalc()
  if o1>=4 then xx1="1/"..o1 else xx1=r1.."."..s1..t1 end
  if o2>=4 then xx2="1/"..o2 else xx2=r2.."."..s2..t2 end
  if p1>-660 then xe1="s" else xe1="m" end
  if p2>-660 then xe2="s" else xe2="m" end
  cls()
  if d==1 then
    print ("One shot to be taken")
    print ("Tv:"..xx1..xe1)
  else
    print (d.." shots to be taken")
    print ("Tv:"..xx1..xe1.." to "..xx2..xe2)
  end
  print ("Av:"..r3.."."..s3..t3)
  print ("SET:proceed  MENU:adjust")
  print ("DISP:setup  other:cancel")
  wait_click()

  if is_key("menu") then
    while v>=0 do
      ADJUST()
    end
  elseif is_key("display") then
    while v>=0 do
      DELAY()
    end
  elseif is_key("set") then
    print ("Proceeding...")
    while f>0 do
      print ("Starting in "..f.."s...")
      sleep (1000)
      f=f-1
    end
    cls()
    if h==0 then
      print("Prefocus OFF")
    elseif h==1 then
      print("Prefocus ON")
      local focused = false
      local try = 1
      while not focused and try <= 5 do
        print("Pre-focus attempt " .. try)
        press("shoot_half")
        sleep(2000)
        if get_prop(18) > 0 then
          focused = true
          set_aflock(1)
        end
        release("shoot_half")
        sleep(500)
        try = try + 1
      end
      if not focused then print "Unable to pre-focus" else  print "Pre-focus complete" end
    end
    print ("Starting shots now...")
    for i=1,d,1 do
      cls()
      print ("Shot "..i.." of "..d)
      o1,p1,r1,s1,t1 = ShutterCalc(i)
      r3,s3,t3 = AVCalc()
      if o1>=4 then xx1="1/"..o1 else xx1=r1.."."..s1..t1 end
      if p1>-660 then xe1="s" else xe1="m" end
      print ("Tv:"..xx1..xe1)
      print ("Av:"..r3.."."..s3..t3)
      if p1==0 then p1=1 end
      set_av96_direct(x)
      set_tv96_direct(p1)
      shoot()
      sleep (1000*g)
    end
    done=1
  else
    print ("Script cancelled")
    done=1
  end
end

Re: Shutter Speed w/Av, Fully Adjustable (LUA) *UPDATED!*
« Reply #3 on: 16 / May / 2013, 23:37:26 »
Is there any way that I could interact with this script with a remote? I have a rig of 24x chdk cameras (yes, 24!) that I fire with a radio remote. At this stage to change the shutter speed I have to do it manually on all 24x cameras. Any thoughts?


Re: Shutter Speed w/Av, Fully Adjustable (LUA) *UPDATED!*
« Reply #4 on: 16 / May / 2013, 23:46:44 »
Is there any way that I could interact with this script with a remote? I have a rig of 24x chdk cameras (yes, 24!) that I fire with a radio remote. At this stage to change the shutter speed I have to do it manually on all 24x cameras. Any thoughts?
I'd suggest you stay away from five year old scripts and put together something you actually need.

So tell us more about what you are trying to do?   I assume you have all the cameras wired in parrallel at the USB port and are using a CHDK USB remote to fire all shutters at the same time?  It would be not too hard to write a script that loads & runs when each camera powers on that sets them all to a common shutter speed ( e.g. 1/60 sec).   

You could then use the script to have a manual pulse width (or pulse count) scheme with the remote to change shutter speeds - fast pulse = increase speed by 1 stop,  medium pulse = decrease speeds by 1 stop, long pulse = shoot.

Obviously this would be easier with a microcontroller putting out the pulses but you can do it manually.  The "zoom" device in the current USB remote is an example of how that can work.

Tell us more?
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Shutter Speed w/Av, Fully Adjustable (LUA) *UPDATED!*
« Reply #5 on: 17 / May / 2013, 00:46:41 »
Yes, I have all the cameras controlled in parallel, initially I fired them manually with a converted torch but now have adapted / hacked a car alarm which gives me a radio remote control with a 150m range. Not that I have ever needed that! So, typically I am shooting at around 1/160th and might be in a great location with the sun setting, ideally I would be able to adjust / drop the shutter speed in full stops remotely with a pulse combo. I think my car alarm set up is adjustable to be able to do that. But initially I would be interested in doing it manually. I currently have it set up to do a held pulse for set cameras and then when I cut the voltage they fire. here's one of the results.

Re: Shutter Speed w/Av, Fully Adjustable (LUA) *UPDATED!*
« Reply #6 on: 17 / May / 2013, 01:02:32 »
I currently have it set up to do a held pulse for set cameras and then when I cut the voltage they fire. here's one of the results.
Are you using a script or the built-in "one press" mode?
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Shutter Speed w/Av, Fully Adjustable (LUA) *UPDATED!*
« Reply #7 on: 17 / May / 2013, 01:07:17 »
i'm using the one press mode


Re: Shutter Speed w/Av, Fully Adjustable (LUA) *UPDATED!*
« Reply #8 on: 17 / May / 2013, 05:25:10 »
What 35mm-equivalent focal length are the cameras set to and which programme are you using to stitch them ?


David

Re: Shutter Speed w/Av, Fully Adjustable (LUA) *UPDATED!*
« Reply #9 on: 17 / May / 2013, 05:48:43 »
the cameras are roughly 28mm (horizontal FOV 75degrees) with a few degrees overlap. i go through a few different processes to get the stitching, panorama tools is one of them.

 

Related Topics