Intervalometer for recording road trips written in LUA - Completed and Working Scripts - CHDK Forum
supplierdeeply

Intervalometer for recording road trips written in LUA

  • 9 Replies
  • 13096 Views
Intervalometer for recording road trips written in LUA
« on: 17 / July / 2009, 10:40:57 »
Advertisements
Below is my first LUA script, an intervalometer designed for use for recording road trips.

Features:
* focus fixed at infinity
* power saving
* endless loop until power or memory fail
* occasional light reading.


Code: [Select]
--[[
Author: Andrew baisley
Heavily based on Fraser McCrossan's 'Accurate Intervalometer with power-saving and pre-focus'
Many, many thanks

Tested on A460, should work on most cameras.

An accurate intervalometer script designed for shooting road trips.

Features:
* focus fixed at infinity
* power saving
* endless loop until power or memory fail
* occasional light reading.
--]]

--[[
@title Cycle Lapse
@param s Secs per frame
@default s 10
@param m Mins per light reading
@default m 10
@param b Min battery voltage in mV
@default b 2150
@param d Min space on card in Kb
@default d 200
--]]

-- convert parameters into readable variable names
secs_frame, mins_per_reading, min_vbatt, min_space = s, m, b, d * 1024

props = require "propcase"

-- if the display mode is not the passed mode, click display and return true
-- otherwise return false
function seek_display_mode(mode)
   if get_prop(props.DISPLAY_MODE) == mode then
      return false
   else
      click "display"
      return true
   end
end

-- switch to autofocus mode, focus on infinity, then go to manual focus mode
function light_reading()
   set_aflock(0)
   press("shoot_half")
   sleep(2000)
   set_focus(65535)
   set_aflock(1)
   release("shoot_half")
   sleep(500)
end

-- switch off display, setting 2
while seek_display_mode(2) do
   sleep(1000)
end

light_reading()
start_ticks = get_tick_count()
ticks_per_frame = 1000 * secs_frame
frames_per_meter = mins_per_reading * 60 / secs_frame
frame = 1

-- shoot until battery or card fails
while get_vbatt() >= min_vbatt and get_free_disk_space() >= min_space  do
   shoot()
   set_backlight(0)
   if frame % frames_per_meter == 0 then light_reading() end
   sleep( start_ticks + frame * ticks_per_frame - get_tick_count() )
   frame = frame + 1
end

-- backlight on
set_backlight(1)

-- display on, setting = 0
while seek_display_mode(0) do
   sleep(1000)
end

-- print warning messages
if get_vbatt < min_vbatt then print("** CHANGE BATTERY **") end
if get_free_disk_space < min_space then print("++ CHANGE MEMORY CARD ++") end

-- restore focus mode
set_aflock(0)

-- sound alarm
play_sound(7)


Amendments and suggestions gratefully received.

Re: Intervalometer for recording road trips written in LUA
« Reply #1 on: 29 / August / 2009, 09:39:45 »
Took it cycling round Mt Ventoux and it worked great.

Taking 5500 pics on 2 AA batteries.

Re: Intervalometer for recording road trips written in LUA
« Reply #2 on: 31 / August / 2009, 12:40:25 »
Did a quick test and it feels nice.
But I get one error after ~35 min of shooting @ 5 sec interval:
:85: attempt to compare function with number
PRESS SHUTTER TO CLOSE

What can this mean.
I could repeat the procedure and get the error again.

I have 198MB of memory left and 30% battery.
I'm using a Ixus60 camera.

Re: Intervalometer for recording road trips written in LUA
« Reply #3 on: 31 / August / 2009, 12:46:35 »
Did a quick test and it feels nice.
But I get one error after ~35 min of shooting @ 5 sec interval:
:85: attempt to compare function with number
PRESS SHUTTER TO CLOSE

What can this mean.
I could repeat the procedure and get the error again.

I have 198MB of memory left and 30% battery.
I'm using a Ixus60 camera.


:85: means it's on line 85:
"if get_vbatt < min_vbatt then print("** CHANGE BATTERY **") end"

Haven't tried it, but I think "get_vbatt" should be "get_vbatt()"

I would assume also that
in the next line:
"if get_free_disk_space < min_space then print("++ CHANGE MEMORY CARD ++") end"
"get_free_disk_space" should be "get_free_disk_space()"


Re: Intervalometer for recording road trips written in LUA
« Reply #4 on: 31 / August / 2009, 20:34:07 »
Hi !

I tested it on my sx100is.. the script start but nothing happens! ???

Re: Intervalometer for recording road trips written in LUA
« Reply #5 on: 01 / July / 2010, 14:49:36 »
I used this on a recent trip from socal to norcal (7.5 hours) on my A590. I think the power saving features worked wonderfully. One set of batteries lasted 4 hours and the second (nicer) set powered the rest of the drive and more.

I had one big problem, which is the pictures were out of focus. I realized this at the rest stop when I changed batteries and I tried setting the focus manually and using landscape mode (I didn't know the details of this mode but I was desperate). Neither maintained the focus, so for most shots, the auto focus was used and the bug splatters on my windshield are nice and crisp but everything beyond that is blurry. I've spent many hours reading the forums again and I see a lot of people are aware of the issue of having the display off and manual focus set. Does this script implement a solution for that? Do I need to do something other than set focus in MF mode? I ask because I expect to have another drive, this time from California to Ohio and I want to attempt to get a better timelapse if I can. In any case, the camera will be mounted inches from the windshield this time so it won't focus there, but who knows what will happen if its not locked at infinity :-/

edit: A suggestion that I'm not sure has been explored. When using this script, I mute all sounds to avoid the beep at a half-shutter press. It would drive me nuts to constantly hear it. But it looks like there is an alarm at the end of your script that I did not hear, most likely because the sounds were muted. I'd bet volume and muting is controllable by CHDK, and perhaps an option to set mute during the script is possible. But more importantly, a way to turn the muting off to play an alarm sound would be great.
« Last Edit: 01 / July / 2010, 15:48:35 by munk_e »

Re: Intervalometer for recording road trips written in LUA
« Reply #6 on: 05 / July / 2011, 11:27:55 »
Sounds good but how to I turn the code into a script?

Re: Intervalometer for recording road trips written in LUA
« Reply #7 on: 06 / July / 2011, 14:16:20 »
Hi Britman,

just copy-paste the text in notepad, then save in your CHDK/scripts folder with a .lua (not .txt) extension.

Should work.

Good luck.

p.s. script doesnot work on my sx130 :-(

jeff
La parcimonie, c'est bien beau, mais faut pas trop en mettre.


Re: Intervalometer for recording road trips written in LUA
« Reply #8 on: 19 / August / 2011, 18:02:33 »
This is the very basic script for making trip video for S3.

Code: [Select]
--[[
@title Cycled Video intervalometer
@param b video length in seconds
@default b 300
@param v buffer wait time in 1/1000sec
@default v 4000
@param c number of videos, >2
@default c 4
@param p print log  (1==enabled)
@default p 0
@param k delete all files from SD
@default k 0

--]]

--[[
Req:
just free SD card,
Canon S3 camera,
Predfined shooting parameters in chosen mode
No photos or other files in DCIM - they will be killed
Only current CANONxxx folder in DCIM allowed (it can be deleted by "Erase all" or CHDK File Browser)
if script fails or jamm, try to increase buffer wait time
mailto: wild_creator@inbox.ru
--]]
a=1
if k==1 then
        dir = os.listdir("A/DCIM", false)
count = table.getn(dir)
for i=1,count do
         dirr = os.listdir("A/DCIM/"..dir[i], false)
[admin: avoid swearing please] = table.getn(dirr)
for j=1,[admin: avoid swearing please] do
s="A/DCIM/"..dir[i].."/"..dirr[j]
if p==1 then print ("Removing: "..s) end
os.remove(s)
end
end
end
while true do
       if p==1 then print("cycle start") end
       if p==1 then print(a) end
       press("video")
       sleep(1000)
       release("video")
       if p==1 then print("recording..") end
        sleep(b*1000)
        if p==1 then print("stopping rec...") end
click("video")
        sleep(200)
if p==1 then print("waiting for buffer...") end
        sleep(v)
a=a+1
if a==c+1 then
                if p==1 then print("video files limit") end
                a=c
dir = os.listdir("A/DCIM", false)
count = table.getn(dir)
s=dir[count]
s="A/DCIM/"..s
dir = os.listdir(s,false)
count = table.getn(dir)
s=s.."/"
        if p==1 then print("removing "..dir[1]) end
os.remove(s..dir[1])
        if p==1 then print("removing "..dir[2]) end
os.remove(s..dir[2])
      if p==1 then print("waiting for buffer...") end
        sleep(v)
end       
       if p==1 then print("cycle end") end
end       

This script keep defined No of video files on SD, and automatically delete old ones.

Re: Intervalometer for recording road trips written in LUA
« Reply #9 on: 22 / April / 2018, 22:28:58 »
Hi, I did a script to make movies from JPG images from time lapse shots.
The script is auto-installable and so simple to use:
https://github.com/danielbcjr/thunderlapse =D

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal