CHDK Forum

Using CHDK => Script Writing => Completed and Working Scripts => Topic started by: mattkime on 01 / February / 2009, 11:17:39

Title: Night-time time-lapse - sunsetF16.lua
Post by: mattkime on 01 / February / 2009, 11:17:39
This is a new version of the sunset time lapse script.

The script has been modified to achieve several goals -

- Move functionality that would be useful for other scripts into library files.
- Separate code into functions based on intended functionality (i.e. initCamera, initScript, calcNextExposure) and move functions into script specific library to increase script readability
- Save settings and exposure data so they may persist through script resets

built up the work of fbonomi and fudgey - http://chdk.setepontos.com/index.php/topic,2156.msg20057.html (http://chdk.setepontos.com/index.php/topic,2156.msg20057.html)
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: fudgey on 01 / February / 2009, 12:25:51
Hmm...  that can't be right... your zip has a copy of sunsetF15.lua renamed sunsetF16.lua... I guess you zipped in the wrong version?

Btw the name confuses me a bit since a couple of months ago I started improving sunsetF15 and named it sunsetF16 but never finished it.
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: mattkime on 01 / February / 2009, 12:33:48
ah, i see the problem, thanks.

fixed
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: stone1343 on 10 / February / 2009, 23:55:38
Hi everyone, I just tried sunsetF16, it dies on sunset line 12, initConfig:
   set_tv96_direct(current_tv)
It says current_tv is null.

Has anyone else experienced similar problems?

BTW, As much as I like the concept of LUALIB libraries, I'm rapidly coming to the conclusion that there's just not enough confidence that any of them, e.g.  date.lua, is inter-operable between different scripts that use it. There should probably be at least a numeric suffix, so let's just assume SunsetF15 uses Date.lua Version 1, then Date.lua is modified for SunsetF16, now SunsetF15 is possibly broken. It seems like a nice idea, but in practice, with many people developing, I think I'm going to stick with merging the library functions into the mainline script.

Also, huge kudos, to whoever started emu.lua, I like the concept and hope it continues to be developed. For example, I quickly found that it didn't have get_zoom() or set_zoom(), which were easy enough to add.
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: mattkime on 11 / February / 2009, 00:20:11
I'm working on that problem tonight. i have no idea where or how current_tv is getting set to null.

SunsetF15 relies on the libraries it includes. SunsetF16 is being developed with libraries lacking the "f" prefix.

SunsetF16 and the lualibs i'm developing aren't quite ready for prime time. there are some bugs to be worked out. i posted them because people may still find them useful and perhaps someone smarter than me will fix my subtle problem.
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: fudgey on 11 / February / 2009, 12:27:19
Yes, library versioning is very much something that needs to be handled. But aside from propcase.lua, there are no official libraries yet. What mattkime is releasing here are development previews that we hope to include with CHDK distributions one day soon(ish).

Obviously, after a library is released with CHDK it can't be modified in a way which would make it incompatible with old scripts. Then the new version must be renamed (log.lua -> log2.lua for instance). My old libs had an "f-" prefix for "fudgey" so that they wouldn't reserve short, good names for generic libraries we may once decide to include in CHDK.


Merging library functions to your own version of a script is OK (even if not everyone is skilled enough to do that), and it may actually spare you some RAM when you strip away functions that aren't used from large libraries (or the other way around if it's some helper function that gets run once and then garbage collection gets rid of it).
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: mattkime on 06 / April / 2009, 10:54:14
version 1.0.1 of sunsetF16.lua

- fixed infrequent crash.

to do - examine system which determines exposure. i need to do this for my own understanding but i may change the code as a result.

---

for my purposes the code is extremely stable. it _SHOULD_ be able to take pics forever. restarts should only be needed if the eye-fi card loses connection. however, i would be more comfortable stating this if it was thoroughly tested by others. i'm also interested in hearing what features others would like so it better suits their needs.
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: jetzt on 24 / May / 2009, 13:36:42
While trying this script my A710 {0.9.8-758} tells me:
Code: [Select]
:68 module 'util' not foung 00no field package.preload['util']Where can I find that lib and where do I have to put it? ::)

Take it as FAQ: Yes: Placing the content of the folder lualib from the zip to CHDK/LUALIB solved the problem. :D
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: oh2ski2002 on 02 / September / 2009, 09:47:42
anyone have issues with the length of exposure setting?  I have it set to just a couple settings for testing, and it is still doing loooooooong exposures.....thoughts? thanks!
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: Mac on 02 / September / 2009, 11:30:14
Hi mattkime!
Had a problem with downloading SunSetF16.zip.
Contain a number of extraneous folders and a number of zero content files.
Library directory was empty???
Help!
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: mattkime on 02 / September / 2009, 22:01:08
>>anyone have issues with the length of exposure setting?

it simply doesn't pay attention to that. does the image look overexposed?

>>Had a problem with downloading SunSetF16.zip.
>>Contain a number of extraneous folders and a number of zero content files.

Not sure about the problem, looks fine to me. Maybe your download didn't complete
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: sandeman on 05 / September / 2009, 17:56:33
I have tried sunsetF16 today and it worked great, except for one thing: it did not focus to infinity, while I set r to 1. I think I have found the reason:
The function cam.smartShoot (in cam.lua) does not contain any focusing commands. I think it would need something like set_focus(focusDistance) before the shoot() command:
Code: [Select]
function cam.smartShoot(tv,sv,focusDistance)
  if(tv ~= nil)then set_prop(propcase.TV,tv) end
  if(sv ~= nil)then set_prop(propcase.SV,sv) end

set_focus(focusDistance)

shoot()

local bv=get_bv96()
local av=get_av96()

  return bv, av
end
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: robinski on 15 / September / 2009, 19:14:15
I've tried sunsetf16.lua and it only shot one frame, and shut the camera off. Any hints, or am I just impatient?  Run on Powershot SD890 IS camera.

cheers,
r

Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: soulf2 on 03 / October / 2009, 08:51:14
Canon SD 1100

:86: attempt to call field 'deleteUntilMbFree100CANON' (a nil value)

Any ideas?

Log File:

--- Log opened at 2009/10/03 20:37:12 ---
platform: ixus80_sd1100 101a
version: CHDK 0.9.8-810 built on Sep 28 2009 06:50:22
Sunset F15
Parameters (user given in paranthesis)
min_delay:   15 s
max_tv:   -576   (65 s)
default_sv:   419   (ISO 100)
max_sv:   707   (ISO 800)
histo_under_start:   0   (0)
histo_under_end:   23   (23)
histo_under_limit:   30
histo_under_weight:   0
histo_over_start:   160   (160)
histo_over_end:   1023   (1023)
histo_over_limit:   4
histo_over_weight:   0
histo_median_value:   80   (80)
histo_median_weight:   50
focus_to_inf:   1
jpg_quality:   -1   (no change)
jpg_resolution:   -1   (no change)
startupdelay:   0 min

##   Time   Frame   bv   night_correct   day_correct   dusk_factor   correct   current_tv   smoothed_tv   shoot_tv   shoot_sv   Topt   Tccd   Tbat
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: soulf2 on 03 / October / 2009, 21:02:00
Canon SD 1100

:86: attempt to call field 'deleteUntilMbFree100CANON' (a nil value)

Any ideas?

Fixed... Started from scratch and re-downloaded and replaced all the files. Works great now.

Many thanks for the script!
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: fbonomi on 15 / October / 2009, 15:15:18
There is a problem with this script (problem that is probably present in my original version too) with all cameras that - like the SD1100 (Ixus 80) - have no real aperture/iris.

You can see the problem in the first video posted here by soulf2:
http://chdk.setepontos.com/index.php/topic,4364.msg41550.html (http://chdk.setepontos.com/index.php/topic,4364.msg41550.html)

At about 13", there is a sudden flash.

This flash is caused by the camera's ND filter (wich is left alone by the script) suddenly shutting off...

I mean, the script runs ok, but the camera puts the ND filter during the day (when pointing at the bright sky) and suddenly decides to take it off, causing a strong flash, as the script does not know about the filter and sets the exposure accordingly.

I don't have a "clean" solution to the problem.....

A possible workaround would be to force the ND filter OFF via the CHDK overrdides menu (I haven't been able to control the ND filter properly via script commands) and then adjusting the exposure accordingly (under-exposing by 3 stops) when (and if) the camera decides to put the ND filter on.....

mattkime, (or anyone else) do you have any brighter idea?
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: fbonomi on 15 / October / 2009, 15:52:14
Actually, the script is reading the aperture "correctly", i.e. the ND filter is felt:

Extracted from soulf2's log:

Code: [Select]
Measured: 1224 575, Calculated: 1068
Measured: 835 575, Calculated: 679
Measured: 823 292, Calculated: 950
Measured: 813 292, Calculated: 940
Measured: 809 292, Calculated: 936

you clearly see the "aperture" jump from 575 to 292, and the difference is 283, quite close to 96*3...

so, it could work...

probably the problem is that line 83
av=get_av96()

is actually called AFTER line 214:
local calculated_tv=bv-av+default_sv

So the exposure is calculated based on the "aperture" of the PREVIOUS shot....

So if might be a SINGLE faulty exposure, but due to the "smoothing" the flash is made longer.....

soulf2, could you post the complete log somewhere?
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: soulf2 on 15 / October / 2009, 16:40:08
No problem....


Download @ http://204.202.231.100/F16.log (http://204.202.231.100/F16.log)

It should include all 3 days of logs.   :)


Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: soulf2 on 25 / November / 2009, 15:05:36
The time gap between photos increases to over 2 min after the sun goes down.

Reducing the max exposure to 20 or 30s and increasing the picsAnHour does not appear to close the gap.

How do I decrease the gap to take 1 or 2 photos/min?


Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: mattkime on 25 / November / 2009, 15:41:01
I really need to do another pass over the script. I got it working for my purposes but I need to account for other people's intentions.

which cameras have a ND filter? Most of my experience is with an a650.

One problem I believe I corrected over the previous versions is that the exposure calc matches the current exposure. Its something to verify. Small changes in lighting as is common with timelapse tends to hide the problem. I'll check this in my script and perhaps upload an updated version.

I do have a similar problem on camera setup. my current script throws away the first exposure for this reason. i have no idea why it happens but it does. just can't get the exposure correctly the first time. i don't think i see the problem except for the first frame.

oh, if any smooth code is in use, i removed it from my current version. would be easy to put back in.

I suspect that we might be talking about two different version of the script.

>>How do I decrease the gap to take 1 or 2 photos/min?

I'm not sure off the top of my head. Its possible that you're hitting against the dark frame after each exposure.

---

Great to hear about someone taking my code for a spin. Hopefully i can help you solve a few of these problems.

Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: augustoal on 18 / January / 2010, 12:03:01
hi, i've been using this script on a sx200. It worked fine until about three weeks ago. When i turn on the script it takes a really long exposure, almost infinitely, it never finish that photo. This happen even when i put exposure limit in 1 second, can anyone help me?
Thanks
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: Lamerjack on 21 / February / 2010, 15:23:17
version 1.0.1 of sunsetF16.lua

- fixed infrequent crash.

Hi mattkime.
I think that your timelapse is the best that i have found!
Im using With a canon A470 and Canon Sx110is.
I noticed that using the last version. If i set pics hours on the canon a470 at 360 the script shoots every 25 seconds instead of 10 seconds. With previous versions was more accurate.
Im using build 0.9.9, revision 874 but i tested also with previous releases.

p.s. in the changelog you say:
- fixed infrequent crash. How was happening this crash? Because with this release (always with a470 that is my battle photocamera) sometime i found the camera turned off... With lens retracted like if i shut down the camera. Sometime happen after 4 hours sometime after 20hours...
Im trying to understand if is software or powersupply problems.
Best regards and thankyou for the script.
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: Lamerjack on 21 / February / 2010, 15:25:25
hi, i've been using this script on a sx200. It worked fine until about three weeks ago. When i turn on the script it takes a really long exposure, almost infinitely, it never finish that photo. This happen even when i put exposure limit in 1 second, can anyone help me?
Thanks
Before was working and now doesn't work?
Did you try to go in CHDK\DATA
and delete all the files related to sunset?
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: Lamerjack on 21 / February / 2010, 15:41:16
version 1.0.1 of sunsetF16.lua

- fixed infrequent crash.

Hi mattkime.
I think that your timelapse is the best that i have found!
Im using With a canon A470 and Canon Sx110is.
I noticed that using the last version. If i set pics hours on the canon a470 at 360 the script shoots every 25 seconds instead of 10 seconds. With previous versions was more accurate.
Im using build 0.9.9, revision 874 but i tested also with previous releases.

I deleted the log (was 16mb long) and now seems work fine.
Can be a too big log the cause? Is possible to deactivate the log or the log is used to load the previous exposition?
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: Kipper on 15 / March / 2010, 14:07:37
I've tried sunsetf16.lua and it only shot one frame, and shut the camera off. Any hints, or am I just impatient?  Run on Powershot SD890 IS camera.

cheers,
r


I know this is an older post but,

Check the number of photos per hour setting, if it's too low and your camera power saving settings are on, the camera may turn off before the next picture.

I had a similar issue on my S3is, the default for the script was 12 pics per hour, so the camera would turn off before the picture work be taken. Either reset the power saving or set the script value to a higher number of shots.
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: flipper321 on 06 / April / 2010, 03:56:50
Many thanks for the script - works really well on my SX200is

Is there any way to incorporate some of the power saving methods some other scripts have - either the "display off" method or at the very least the backlight off?

Thanks
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: shaltzman on 04 / May / 2010, 22:29:28
Hello
I have 2 questions with this script in particular and more generalties:
-Is it possible to run sunsetf16 on my s90?
-I see that several scripts who ran with my a590 doesn't work with the s90: for each script I use to run with my a590, I have to find a new version or another script for the s90?

Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: levislee on 02 / October / 2010, 13:44:22
is this script can work in the a590is?is it fit it?my cam is a590is and the chdk is the 1o1b 0.9.9 953.thanks a lot!
This is a new version of the sunset time lapse script.

The script has been modified to achieve several goals -

- Move functionality that would be useful for other scripts into library files.
- Separate code into functions based on intended functionality (i.e. initCamera, initScript, calcNextExposure) and move functions into script specific library to increase script readability
- Save settings and exposure data so they may persist through script resets

built up the work of fbonomi and fudgey - http://chdk.setepontos.com/index.php/topic,2156.msg20057.html (http://chdk.setepontos.com/index.php/topic,2156.msg20057.html)
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: levislee on 02 / October / 2010, 13:47:26
hi, Is it possible to run sunsetF16 on my a590?thks!
i am sorry for my pour english.
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: flyvholm on 29 / August / 2011, 00:41:55
Question: What in this script makes it dependent on Collaborative Build? Is it something that is core to the script's abilities or something that could be excluded? Or alternatively, is whatever it requires from Collaborative Build something that will eventually be implemented in the main build so this dependency can go away? Given the purpose of the script it's rather unfortunate that it cannot be used with any of the newer models that have good low light performance.  :(
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: reyalp on 29 / August / 2011, 01:59:26
Question: What in this script makes it dependent on Collaborative Build?
The current CHDK trunk is (descendent of) the collaborative build. It should work fine.
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: davem666 on 02 / September / 2011, 17:44:19
Hi, I'm trying to use SunsetF16 to create a time lapse, but the Startup Delay doesn't seem to work. I put the startup delay at 330 minutes and put the camera out last night (so it would start taking pictures ~1 hour before sunrise). But the camera started taking pictures almost immediately once I started the script. I've been messing around with it today and the same thing happens no matter what I put as the Startup delay. Any one else have this issue or have any suggestions on what I can do?

Camera: SD 870 IS (IXUS 860)
Thanks,
Dave
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: oronocova on 24 / February / 2012, 06:20:53
Hi, first post here.  Been lurking using CHDK off and on for a couple years or so.

Anyway, is anyone using this script on an A590IS?  I am using the latest build for version B firmware.  Both this script and the intervalometer script (lua) (that comes in the full build) stop working after a while.  I just get "Press shutter to close."  I can use the ultra intervalometer script (bas) without issue.

Thanks!
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: outslider on 24 / February / 2012, 07:14:23
I can only say I had the same problem a few times. I dodn't post that anywhere. At the moment I'm not able to test this more now...

SX130IS, 1.00c
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: oronocova on 26 / February / 2012, 17:07:15
Thanks for the reply.  Yeah I have not had any trouble with scripts written in .bas doing this on the A590.  I've had them run 10hrs plus.  I downloaded YASS which is .bas and I'm going to try it this week I hope.
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: outslider on 26 / February / 2012, 18:00:19
I have discovered that my problem with script stuck was a different kind. Simply I had a loop like:

Code: (lua) [Select]
repeat
    sleep(10)
    until get_shooting()

to get Tv, focus and so on.
Unfortunately sometimes (very rarely, but that's enough) my camera didn't do half-shoot process properly and then script was stuck in never-ending loop with half_shoot pressed (get_shooting never returning true). I have lost a couple of minutes from last time lapse, just before sunrise (and there were so nice colors then...).

The solution was safety check - stay with half_shoot pressed for some while, and if this while takes too long, then try again. Seems to be working. The dirty code:

Code: (lua) [Select]
self_test=false
    repeat
        press("shoot_half")             --we press shoot_half to get all exposure params
        step=0
        repeat
            sleep(10)
            if (get_shooting()) then    --if we are lucky, camera can shoot now,
                step=300                --so we set step>200 to leave safety loop
                self_test=true          --and set self_test to true to leave outside loop
                end
            step=step+1
            until step>200
        if(self_test==false) then       --we had no luck this time, camera missed something,
            release("shoot_half")       --so we release shoot_half and go back.
            end
        until self_test==true

I have almost done very nice script for time lapses, with auto Tv (on Av, ISO fixed) and additional linear correction of the exposure (I need to a  little underexpose at night but well-exposed on day).

Currently it works nice on day and night, sunrise and sunset.

Auto Tv is based on camera measured brightness, Tv, Av, ISO and some calculations from APEX.

In a few days I should post this script on forum.
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: thowi on 24 / October / 2013, 17:03:52
Fantastic script, and very well thought out.
Probably one of the most sophisticated time-lapse scripts I've seen!
I also really like the description in the document.

Unfortunately it doesn't work for me :(
I always get an error:
sunset.lua:12: bad argument #1 to 'set_tv96_direct' (number expected, got nil)
*** TERMINATED ***

Do you have an idea what could be the issue?

I'm running on a G11, CHDK 1.2.0-3155-0, using the F16 version.

Thanks!
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: schnellerstefan on 03 / October / 2014, 04:43:45
Hi everyone, I'm using CHDK (or at least try to) to create night-time time-lapse videos. I found the sunsetF16 and think it can do what I want. Unfortunately it doesn't take pictures with longer exposure than 15 seconds.

I am using a S5IS with CHDK 1.2

I hope someone has a hint how I can solve this problem.
the Sunset.tbl:
Code: [Select]
return {
-- Table: {1}
{
   ["current_tv"]=-333,
   ["picsAnHour"]=120,
   ["histo_over_start"]=160,
   ["jpg_resolution"]=-1,
   ["default_sv"]=419,
   ["dusk_start_tv"]=96,
   ["histo_under_end"]=23,
   ["dusk_start_sec1000"]=500,
   ["histo_over_end"]=1023,
   ["dusk_duration_ev"]=576,
   ["histo_median_value"]=80,
   ["max_tv"]=-576,
   ["histo_median_weight"]=50,
   ["histo_under_weight"]=0,
   ["histo_under_start"]=0,
   ["shoot_sv"]=419,
   ["shoot_tv"]=-333,
   ["jpg_quality"]=-1,
   ["histo_over_limit"]=4,
   ["histo_under_limit"]=30,
},
}

the log attached
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: waterwingz on 03 / October / 2014, 19:41:46
Unfortunately it doesn't take pictures with longer exposure than 15 seconds.
As written, the script should allow exposures as long as 65 seconds.  If your S5is is limited to 15 seconds then it may be a problem with the CHDK port.   

According to the Camera Features Table (http://chdk.wikia.com/wiki/CameraFeatureTable) the camera should support extended exposure times and there have not been any recent changes in the code that supports that.

Can you achieve exposures longer than 15 seconds using the Overrride Tv menu item in the Enhanced Photo Operations menu ?

Incidentally,  I'm not a big fan of this script as it contains code that will automatically delete images if it thinks the SD card is almost full. Some other options for your application might include : yass4.lua (http://chdk.setepontos.com/index.php?topic=10493) meteor.lua (http://chdk.wikia.com/wiki/Meteor_Intervalometer_with_Dark_Frame_Management)
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: schnellerstefan on 04 / October / 2014, 11:46:39
Hi waterwingz, thanks for your reply and your links to the other scripts. The meteor.lua said it requires Lua native calls to be enabled. Doing this also the sunsetF16.lua works.

I am just wondering why the exif info says only 15 seconds but the Iso is going up. Watching the camera im sure the exposure time was about 60 seconds.

Quote
Can you achieve exposures longer than 15 seconds using the Overrride Tv menu item in the Enhanced Photo Operations menu ?
Just to answer your qustion: yes that did work before.
Im using the camera and SD card only for that purpose so im not afraid of deleted data but maybe I'll test the other scripts anyways.
Title: Re: Night-time time-lapse - sunsetF16.lua
Post by: waterwingz on 04 / October / 2014, 11:55:10
I am just wondering why the exif info says only 15 seconds but the Iso is going up. Watching the camera im sure the exposure time was about 60 seconds.
AFAIK, the exif info in the JPG image does not always reflect the actual value used when CHDK overrides are applied. So observing the actual exposure is the only way to tell ( that and checking the resulting image actual exposure).