Scheduler : a really simple scripting mechanism - Script Writing - CHDK Forum

Scheduler : a really simple scripting mechanism

  • 14 Replies
  • 8410 Views
Scheduler : a really simple scripting mechanism
« on: 25 / May / 2017, 21:21:32 »
Advertisements
I've been thinking for some time about a simple "schedule mode" for CHDK. Something to allow a non-programmer to simply specify a sequence of shots he wants to take (exposure and zoom settings) without requiring him/her to write a uBASIC or Lua script.  Something that can be created with a spreadsheet or Notepad.

Recently, this post got me thinking about it more seriously.   

So I wrote a simple interpreter in Lua - something that opens a standard .CSV (comma seperated values) file that can be created with Notepad or any spreadsheet.  The first version only let you specify a sequence of shots on successive lines like this :
Code: [Select]
shoot,1/500,16.0,800,out
shoot,1/1000,16.0,800,out
shoot,1/500,5.6,400,in
(the in & out refer to the ND filter - the rest should be obvious)

All good. 

But then, remembering reyalp's prescription that all CHDK projects require shipwrights disease, I started adding a few things.  Like a pause command.  And a darkframe command. And a zoom command. And a video command.

All still good.

Then I stepped over the line between a simple shot list and a COMPUTER PROGRAM.  I added a simple loop mechanism using a repeat and next command.

And then I stopped. I think that's all that's needed and any fancier functionality pushes you into really needing to just use a Lua script (or uBASIC if you must).

I modified the dark frame control meteor.lua script to use the new mechanism (answering the request in the post that got me back into this).   I've attached the first version - not a lot of testing but it gives you a good idea of where this is going (although zoom and video are not implemented).

I'll probably add this to the kap_uav.lua script at some point and also write the ultimate balloon.lua script for non-programmers (the existing scripts all assume a fixed time sequence of events that is difficult to adjust for different balloon journey profiles).

And of course, coding this in C and making it a permanent feature of CHDK is always an option at some point. 8)
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Scheduler : a really simple scripting mechanism
« Reply #1 on: 11 / August / 2017, 10:21:09 »
Hi waterwingz,
Just now reading this. How do I go about using this script? Do I upload both, as is, into my SD card and go from there? And, I can edit the values in the CSV, right?

I'm a week away from traveling to Kentucky so hopefully I can do this.


Re: Scheduler : a really simple scripting mechanism
« Reply #2 on: 11 / August / 2017, 13:28:37 »
Just now reading this. How do I go about using this script? Do I upload both, as is, into my SD card and go from there? And, I can edit the values in the CSV, right?
Upload both files to the A/CHDK/SCRIPTS folder on your SD card.  You wll need to edit the CSV file first.  Use the CHDK Script menu to select the eclipse.lua script as your currently loaded script.  Press the shutter button while in <ALT> mode to run it.

Quote
I'm a week away from traveling to Kentucky so hopefully I can do this.
Well, as this script did not seem to attract much interest, there has not been a lot of testing AFAIK.  So I would really strongly suggest that you edit the exposure.csv file for your intended use and then test, test, and test again.

One thing I might yet add is to allow a camera button (or USB remote input) to switch "mode". This would allow the camera to continuously loop in one shooting pattern until a key was pressed and then move on to a different pattern.

Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline axman

  • ***
  • 145
Re: Scheduler : a really simple scripting mechanism
« Reply #3 on: 15 / August / 2017, 16:09:09 »
@wingz, thanks for this!

Initial test using the provided exposure.csv was good.  Comparing requested image parameters with actual results from exifprobe:  results are all pretty close to what was requested.

Will continue to test, but not exhaustively.  Happy to poke at a specific param/combo, if useful.  Just let me know.

*

Offline axman

  • ***
  • 145
Re: Scheduler : a really simple scripting mechanism
« Reply #4 on: 15 / August / 2017, 21:03:26 »
My goal is to line up ~36 'shoot' commands, each having a different Tv, Av, and ISO.  I will customize a csv for each camera + lens (one csv for sx530hs, one csv for m10.)  I won't do anything with dark frames in this script;  I'll make them separately.

But I'm not sure exactly what's expected or required in the csv.  Debug info leaves the LCD so fast, I can't read the line(s) it's complaining about.  By repeatedly pressing shutter to run script (and failing each time), I saw "invalid function."  I looked at the lua, and decided to ask for help instead of hacking on it for days.  Here's my csv;

Code: [Select]
comment,tv,av,sv,ndfilter
repeat,1
shoot,1/2000,6.5,100,out
pause,5
repeat,1
shoot,1/4000,6.5,200,out
pause,5
repeat,1
shoot,1/500,4,200,out
pause,5
repeat,1
shoot,1/250,3.4,800,out
pause,5
repeat,1
shoot,1/60,3.4,800,out
pause,5
repeat,1
shoot,1/30,3.4,800,out
pause,5
repeat,1
shoot,1/2,3.4,800,out
pause,5
repeat,1
shoot,1,3.4,100,out
pause,5
end

Do I need a 'next' in there?

Is it required that Tv value be "one over something"?
Can Tv be a value like    .8     or        1.2    ?
 
Thanks for any guidance.  This is hot stuff! 

Re: Scheduler : a really simple scripting mechanism
« Reply #5 on: 15 / August / 2017, 21:05:15 »
My goal is to line up ~36 'shoot' commands, each having a different Tv, Av, and ISO.  I will customize a csv for each camera + lens (one csv for sx530hs, one csv for m10.)  I won't do anything with dark frames in this script;  I'll make them separately.

That's pretty much what the script was written for.

Quote
But I'm not sure exactly what's expected or required in the csv.

Documentation? Manuals? Oh, yea.  Well, if there had been any interest in this concept I would probably have gotten to that.  I've done a little editing work in the CHDK wikia afterall.

Quote
Debug info leaves the LCD so fast, I can't read the line(s) it's complaining about.
Yea - that's annoying. The secret here is to go to the CHDK  Miscellaneous Stuff menu and then the Console sub menu. Select Display last console.  That will let your review everything printed out when your script ran. Note that you can extend the time the console is display from this menu too.

If you do enough of this,  you probably want to add it to the CHDK User Menu and enable that to come up when you enter <ALT>.

It would be quite easy to add a PC based editor / syntax checker for the .CSV file. Just not something I've gotten around to.

Quote
By repeatedly pressing shutter to run script (and failing each time), I saw "invalid function."  I looked at the lua, and decided to ask for help instead of hacking on it for days.  Here's my csv;
<snip>
Do I need a 'next' in there?

You only need a line that says "Repeat n" when you want to come back to that point n times.  So all the "Repeat 1" lines in your file are not needed. 

And for each "Repeat n" line you need a corresponding "Next" line.  When the script hits that - it loops back to the previous "Repeat" statement.   (Nested Repeats/Next statements are supported).

Also,  f stops need to be decimal numbers - i.e. 4.0 rather than 4.  Fixable at some point but that's how it works right now.

Here's your file, cleaned up a bit :
Code: [Select]
comment,tv,av,sv,ndfilter
repeat,35
shoot,1/2000,6.5,100,out
pause,5
shoot,1/4000,6.5,200,out
pause,5
shoot,1/500,4.0,200,out
pause,5
shoot,1/250,3.4,800,out
pause,5
shoot,1/60,3.4,800,out
pause,5
shoot,1/30,3.4,800,out
pause,5
shoot,1/2,3.4,800,out
pause,5
shoot,1,3.4,100,out
pause,5
next
end

Quote
Is it required that Tv value be "one over something"?

Yes.  Or at least I think so.  It's been a while.

Quote
Can Tv be a value like    .8     or        1.2    ?

Not yet.  It's a script - anything is possible eventually.
« Last Edit: 15 / August / 2017, 22:48:38 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline axman

  • ***
  • 145
Re: Scheduler : a really simple scripting mechanism
« Reply #6 on: 15 / August / 2017, 23:25:51 »
Mr Wingz, thank you, kind Sir!   :xmas

I hope you know I was not complaining about lack of docs.  Grateful for the script, the knowledge sharing (console tip: Yeah!  Thanks!), and especially the swift response.  You saved me from hauling the generator, laptop, and many hours of chdkptp-fumbling.  @reyalp should thank you, too - this script saved him a few tens of questions "how do i blah blah" - which I'll ask anyway, but now, I can save those up for some other topic.  :-)  Peace, Love and Cold Beer!

This Script Is Freakin' SWEET!!!  :-D

Appropriate music to go along with my happy dance.  :-D  :-D  :-D

https://www.youtube.com/watch?v=9wjZrswriz0&list=PLEQdwrAGbxncZFLH4KETau3-uncnqVtWD

Gonna be amazing.

Re: Scheduler : a really simple scripting mechanism
« Reply #7 on: 16 / August / 2017, 14:57:58 »
I'll be testing the script today and tomorrow night. I'll let you know how it goes.

Re: Scheduler : a really simple scripting mechanism
« Reply #8 on: 16 / August / 2017, 23:50:13 »
I'm getting an error. Getting the following message immediately after pressing the shutter button in Alt mode:
"Started
A/CHDK/SCRIPTS/ECLIPSE.LUA:204: native calls disabled
Terminated"
It may be important to know that I'm using CHDK on a EOS M3. Any ideas?

Re: Scheduler : a really simple scripting mechanism
« Reply #9 on: 16 / August / 2017, 23:53:11 »
I'm getting an error. Getting the following message immediately after pressing the shutter button in Alt mode:
"Started
A/CHDK/SCRIPTS/ECLIPSE.LUA:204: native calls disabled
Terminated"
It may be important to know that I'm using CHDK on a EOS M3. Any ideas?
Go to the CHDK Miscellaneous menu and enable Lua native calls. 
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics


SimplePortal © 2008-2014, SimplePortal