Close

Lua script description

A project log for Pano-Bot

multi megapixel Spherical HDR Panorama Robot

rune-kyndalRune Kyndal 06/12/2020 at 14:260 Comments

Lua Script

when the Lua script is started on the camera,  
it activates the cameras "half press"  to focus and AF lock the camera.   
this half press is "held" throughout the whole sequence 
to keep the focus from changing between exposures. 

the script then waits for the Arduino to pulse the USB "HIGH",
which is received as a trigger event from CHDK.

the script initiates the exposure by having the camera go  "full press" and back to "half press"   
half press is not released until the end the exposure sequence.

the camera must be set to fixed exposure(s), to avoid the picture changing,
with varying light conditions as it pans around.

blinking the LED is done by poking directly to the Cameras hardware registers, 
specific to the camera type.  for the 110HS  its 0xC0220164 and 0xC022C028

I forget the details now. but I believe I based my Lua script on the  HDR Fast Shooter script
adding a few things, menus,  detection of finished exposure, and of-course the LED blink function.

--[[
--s 96
  @title HDR Panorama Robot
  @param m Number of HDR steps +/-
  @default m 0
  @values m S -S+ --S++ ---S+++
  @param t tV step size
  @default t 2 
  @values  t 0 0.5 1 1.5 2 2.5 3
  @param d shot delay 5
  @default d 0 
  @param b blink delay 3
  @default b 0

  --]]
 
  -- release AF lock on exit
  function restore()
     set_aflock(0)
  end

  
function blink_led()
status = poke(0xC0220164, 0x46, 1)  --Turn LED ON
status = poke(0xC022C028, 0x46, 1)  --Turn LED ON
sleep(( b*100))
status = poke(0xC0220164, 0x44, 1)  --Turn LED OFF
status = poke(0xC022C028, 0x44, 1)  --Turn LED OFF
end 
  
 
  -- setup 
    
  --n=m
  n=((m*2)+1)
  s=(t*(96/2))
  set_console_layout(10, 0, 40, 14)
  props=require("propcase")
  propset=get_propset()
  pTV=props.TV
  if( propset > 3) then pTV2=props.TV2 end
 print("** PANO BOT SCRIPT ***")
 print("**** MAKE SURE *******")
 print("**********************")
 print("* NOT CONTIOUS SHOOT *")
 print("**********************")
 
 
  -- focus and get exposure
  press("shoot_half")
  repeat
      sleep(50)
  until get_shooting() == true 
  set_aflock(1)     
 -- tv96val=get_tv96()-(n*(s/2))
  tv96val=(get_tv96()-((n-1)*(s/2)))    --
  origtvval=tv96val -- reset original TV start Value
 
 
 
 repeat
  if ((is_pressed("remote")) or (is_pressed("video")))  then 
    tv96val=origtvval
    ecnt=get_exp_count()
  -- take the shots as fast as possible
  for i=1, n, 1 do
     print("step=", i, "tv96=", tv96val)
     ecnt=get_exp_count()

     set_prop(pTV,tv96val)
     if( propset > 3) then set_prop(pTV2,tv96val) end
     press("shoot_full_only")
     repeat
      sleep(20)
     until(get_exp_count()~=ecnt)
     release("shoot_full_only")
     tv96val = tv96val+s
  end

repeat
      sleep(20)
until(get_exp_count()~=ecnt)
sleep((d*100))
blink_led()
end

until ( false )
restore()

Discussions