Intervalometer Script, uses Time of Day, and Day of Week - Completed and Working Scripts - CHDK Forum

Intervalometer Script, uses Time of Day, and Day of Week

  • 7 Replies
  • 11232 Views
Intervalometer Script, uses Time of Day, and Day of Week
« on: 16 / September / 2010, 10:24:51 »
Advertisements
Hello all,

This is my first script.  It is based heavily off of Keoeeit's Ultra Intervalometer script, but I've added code to tell the script to run only between defined times and between defined days of the week.  This seems to be working well on an A480.

The reason I made this is because I will be taking time-lapse photos of a construction project, and I only want the pictures being taken during hours that work is being done.

PROBLEMS:  I do not believe this script will work if the "ending" time is earlier than the "starting" time; i.e., if the script is told to start shooting at 9PM and stop at 7AM.  It also will not work if the "starting day" comes after the "ending day; i.e. start shooting Friday, end on Monday. 

I am not a programmer by profession, I've done some light scripting in other languages and that's it, so fixing these issues and streamlining the script isn't particularly easy for me... I would like to clean it up to work in all cases but I may not get around to it for a bit as the script does what I need it to do right now.

That being said, I would love to hear comments and suggestions for how to improve this!  I know there are some real programmers on this board for whom this would be a piece of cake...

Thanks - Joe

Code: [Select]
rem Author - JoeD, based on original script by Keoeeit
rem x-accuracy for delay, j-accuracy for interval
rem Day of week parameters determine what days the camera takes pictures
rem Proper values are from 0-6, with 0 being Sunday and 6 being Saturday
rem Script has not been optimized


x=-1
j=-1755

@title Ultra Intervalometer with Day of Week and Time
@param a Delay 1st Shot (Mins)
@default a 0
@param b Delay 1st Shot (Secs)
@default b 0
@param c Number of Shots (0 inf)
@default c 0
@param d Interval (Minutes)
@default d 0
@param e Interval (Seconds)
@default e 10
@param p Starting Hour (24 Hr time)
@default p 7
@param q Starting Minute
@default q 0
@param r Ending Hour (24 Hr time)
@default r 16
@param s Ending Minute
@default s 0
@param u Day of Week to Start (0 is Sunday, 6 is Saturday)
@default u 1
@param v Day of Week to End (0 is Sunday, 6 is Saturday)
@default v 6
@param

rem sets number of shots already taken to 0
n=0
rem calculates time in ms between each shot
t=(d*600+e*10)*100+j
if c<1 then let c=0
if t<100 then let t=100
rem calculates first shot delay in seconds
g=(a*60)+b+x
if g<=0 then goto "interval"
rem displays seconds left before shooting begins
for m=1 to g
 print "Intvl Begins:", (g-m)/60; "min", (g-m)%60; "sec"
 sleep 930
 next m
goto "interval"

:interval
  l=get_time 3
  o=get_time 4
  y=get_time 5
  rem following lines calculate current day of week in variable w, 0 is sunday
  if o<3 then gosub "change"
  k=(l+(2*o)+(6*(o+1)/10)+y+(y/4)-(y/100)+(y/400)+1)
  w=k%7
  if w<u or w>v then goto "weekend"
  rem calculate time of day, determine if it's in range
  i=get_day_seconds
  f=(p*3600)+(q*60)
  h=(r*3600)+(s*60)
  if i<f or i>h then gosub "rest"
     
  n=n+1
  if c=0 then print "Shot", n else print "Shot", n, "of", c
  shoot
  if n=c then shut_down
  sleep t
  goto "interval"
 
:change
  o=o+12
  y=y-1
  return
 
:rest
do
sleep 60000
i=get_day_seconds
until i>=f and i<=h
return

:weekend
i=get_day_seconds
z=(86400-i)
goto "interval"

Re: Intervalometer Script, uses Time of Day, and Day of Week
« Reply #1 on: 17 / December / 2010, 13:45:40 »
Thank you for posting this.  I was actually looking for something just like this, also for a construction project.  I'm using a SD750, so I'm going to see if I can hack it further by detecting the Bv and inhibiting pictures when it's too dark.

Re: Intervalometer Script, uses Time of Day, and Day of Week
« Reply #2 on: 27 / January / 2011, 01:05:25 »
First off, thanks for the idea and posting this code!  I'm new to all this hacking, but have been doing timelapses with my DSLR (rebel xti) for several years now.  I just installed this code on a G9 and have a couple of questions about how it works on your camera.

I'm hoping to use this script with some slight modifications for a 4 month building demolition timelapse here in my hometown.  I have about 3 weeks to get this working, or I'll just have to brute force it and tie up my rebel for that amount of time...not too crazy about that, but I know with that setup there won't be any issues. 

Does the camera have to be on with script started for it to run?  Seems as though it does, but I wondered if CHDK allowed for autostart from a powered off state.  Battery power will not be an issue during this project as I have a wall adapter that works in both my G9 and rebel.  I'll just leave it on the whole time if not.

The time between shots starts off to be 10 seconds, but after about a minute the time between pictures becomes erratic; usually about 5 seconds apart, but anywhere from 4 - 7 seconds.  Is the timing better on your camera model?  Do you have a newer tweak that addresses this that you haven't posted?   

I found another timelapse script that locks the focus to infinity, so I'm going to try to add that to this code.  If I let my rebel autofocus during a timelapse, the zoom is slightly different on each shot making for a jumpy timelapse; I can't use the G9 if it's going to do this. 

BTW, check out the latest timelapse I made of my fraternity being torn down.  There's both a 1 min and 15 min version...the 15 min version is for my fraternity brothers, not the average joe...it's got nice detail though if you decide to scan through it!

http://www.youtube.com/watch?v=tSotlmrnAQc#
http://www.youtube.com/watch?v=zCROsidbwmI#

Thanks again!

Andy

Re: Intervalometer Script, uses Time of Day, and Day of Week
« Reply #3 on: 24 / February / 2012, 15:48:03 »
I'm new to the Scripting, if wanted to add this to my camera, would I paste this code in a *.lua or *.bas file? and do I need to include something other then just this code?

*

Offline reyalp

  • ******
  • 14125
Re: Intervalometer Script, uses Time of Day, and Day of Week
« Reply #4 on: 24 / February / 2012, 15:50:46 »
I'm new to the Scripting, if wanted to add this to my camera, would I paste this code in a *.lua or *.bas file? and do I need to include something other then just this code?
The code above is ubasic, so should be called .bas

Be sure you save the file as plain ascii text. You shouldn't need to include anything else.
Don't forget what the H stands for.

Re: Intervalometer Script, uses Time of Day, and Day of Week
« Reply #5 on: 24 / February / 2012, 16:02:44 »
Thanks...

The reason I ask is that I get a "uBASIC:53 Unk stmt" error when I attempt to run the code.


**UPDATED**
I re-copied over the code and everything seems to working now...Thanks for the help.
« Last Edit: 24 / February / 2012, 16:06:34 by natemac »

Re: Intervalometer Script, uses Time of Day, and Day of Week
« Reply #6 on: 26 / February / 2012, 22:40:59 »
I am shooting timelapse sunrise videos from the lantern room of a 300 yr old lighthouse.  Its free project to help the foundation that provides a web site and information.  This script will be (and I just tested it) great so I can set up cameras before they lock up at 4pm and let them roll from 6am-7:30am without my losing so much sleep.  Thank you DelSenno for the work and posting.

In addition, the function to force infinity focus would be a great one for me to add if I knew what it was.  If somebody has already added that please post a sample of the code and where it goes in the script.  Many thanks.

Re: Intervalometer Script, uses Time of Day, and Day of Week
« Reply #7 on: 27 / February / 2012, 16:31:43 »
Just wanted to say thanks for the help to everyone and a great script.
We have this running in our warehouse right now and with Eye-fi this thing is working great so far. It's only been running between 8am and 6pm and it didn't take any pictures over the weekend. It uploads with the Eye-fi just fine, the only last bit of test is if the "Endless Memory" works on the Eye-fi.
So thanks again, and I'll be sure to share the video when it's over, but I will attach a preview pic.
Thanks again.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal