CHDK Wiki
Advertisement

Discuss Your CHDK Scripts

  • How to write them
  • Help in how to write them
  • Better ways to post or share them
  • Etc.



Ultra Intervalometer Script

While posing my Ultra Intervalometer script just now, I started to wonder how it would work to use it for a single shot after a long delay, repeated endlessly. Since I was working off of the original sample scripts, I left in the test to never let the number of shots for each intervalometer sequence to be less than 2 (because that makes the simple intervalometer meaningless in that instance). But the more I think about it, since this script has the endless repeat thingy in it, should I change that to allow for single shots? Then you could set a delay to first shot and sequence it endlessly. Otherwise you'd have to use no delay, and crank up the number of shots really high to get an "endless" type of action.

I think I'll change that now. In the line "if c<2 then let c=5" to "if c<1 then let c=5".

I think it would make the script a little more flexible this way.

Yes? No? Let me know if I should change that back or not.


Also, I was thinking it would be good to have a count-down timer during the pause phase. But I wasn't sure how to go about implementing that in the :pause subroutine.

Would something like this work?

:pause 
 n=(a*60)+b
 for m=1 to n
 print "Interval Begins:", n/60; "min", @(n/60); "sec"
 sleep 1000
 next m
 return


Someone help out here! :-) How do I use the "remainder" @ command in this stuff?

I can't believe I can't think this out, maybe I've been up too late.

[Update: I did some more research into how a "remainder" is calculated and used properly, so I fixed my count-down timer and added in a short tutorial about it in the "tutorial" page I put together, in the "math expressions section."]


Well, this works, but danged if I know how to divvy it up into minutes and seconds, this at least counts down by seconds:

:pause 
 n=(a*60)+b
 for m=1 to n
 print "Interval Begins:", n-m; "sec"
 sleep 1000
 next m
 return

BUT, there's going to be a problem. If the delay time is longer than your Power Saving setting to shut off the display (MAX of 3 minutes on the S3 IS), then the camera shuts off the display before the intervalometer shots are reached. Still though, for shorter Delay to 1st Shot settings it's still usable. I'll add that into the notes about it, until further notice on a work-around for that.

Seems I screwed-up on how the total time is computed for each cycle too. My old nemesis has come back to haunt me. I could do calculus in high-school, but if I was given a simple distance=rate * time, I couldn't do it. It's because the concept of time does not exist in my mind. In my mind it's like always multiplying by zero. The script works fine as is, it's just those print displays aren't right. And that sleep 1000 command in the :pause subroutine would have to be tweaked so each for/next loop really is 1 second. I'd have to time it for 3 minutes and see how much the 1000 should be reduced.


> Someone help out here! :-) How do I use the "remainder" @ command in this stuff?
Why you do not use just the following:

 print "Interval Begins:", (n-m)/60; "min", (n-m)%60; "sec"

-- GrAnd 19:49, 13 May 2007 (UTC) --

Thanks GrAnde, I just now figured it out on my own by reading your other scripts. It's been over 40 years since I've been in math class. :-) I corrected my script and added in a short "%" tutorial for us OLD people. :-)

Nice, I like your Ultra Intervalometer Script! --Harvester 09:36, 14 May 2007 (UTC)
I wanted to post my "advanced self-timer" script now, but then I realised that this functionality already is in your ultra intervalometer. :) Perhaps you could mention somewhere that your script is in so far better as the in-camera self timer, as it does measure focus and exposure again and again right before every shot. I think this is much better for self portraits than the in-camera timer, which only does this once and only in the beginning (when you press the shutter button). And perhaps you could find a better name for parameter g? Perhaps "unlimited" instead of "repeat"? --Harvester 18:20, 14 May 2007 (UTC)
  • Good script, though it would be even better if it could somehow turn the screen off to save power by pressing display a few times. Perhaps this could be added? --May 28, 2007
Is that a camera model specific feature perhaps? On my S3 I really can't turn off the display other than to set the Power Saving feature to turn off the display after set durations. Otherwise I can only toggle between 2 EVF display modes, or if the LCD is open then use the [display] button to toggle that between 2 display modes, It will turn off and revert to the EVF after it's shown its 2 display modes.
If you know how to do it on your camera from script commands, you could always tag on an addendum to the script page of where to include an extra click command or two. Would that suffice?
It would be nice if there was a little command to call up which camera model the script was running on, to make them more universal. But with so many makes and models now supported, it might be best just to tweak the script for your individual camera. This "talk" page here could help in that regard, if you want to change it but don't know how, someone might come along and help. Keoeeit 03:50, 28 May 2007 (UTC)

Script Contests, Photo-Tutorials, Games?

Now that most of the quirks about the scripts have been fixed and all the commands have been documented, I just started to think of some new ways they could be used. For starters, I wonder how a "CHDK Script Contest" could be implemented? Like the most creative use of a script per month or something?

Or how about Photography Tutorials for beginners? The print statements telling them what to do to get better shots? I found out you can pause a script in mid-stream and restart it again right where it left off just by holding down the [Flash] + [Shortcut] buttons on my S3 IS. (Exit and re-enter <ALT> mode while a script is running.) So you could print some instructions, have them pause the script to make exposure settings, find a subject, etc. Then onto the next little task.

But what really brought this to mind just now is I was thinking if there could be any kinds of script games that could be played with the camera? Maybe something like....

print "You'll have 30 seconds"
print "to find something that"
print "moves fast enough to"
print "pan the camera."
print "5 shots will be taken"
print "Make sure the subject"
print "is in all frames."

pause 30000

(do the timer countdown, & shots)

print "Your next subject must"
print "be properly exposed"
print "at 1/1250th of a second"
print "at f/8.0. You have"
print "1 minute to find it!"

(set exposure and f/stop to take the next shot, 
if they can't find the right subject it won't 
turn out right)

print "How's your hand-held"
print "skills? The next shot"
print "will require a subject"
print "exposed for 1 full sec."

etc.

Or more things along that line. It could even be a contest of sorts. Everyone download the same script and share what shots they were able to get within the constraints/discipline of the script. Stuff like that. I see how some scripts could be a challenge to even a seasoned photographer.

Silly ideas? (I'm up late, drinking coffee, thinking too much. :-) )

A RND function would be fun. Let the camera fire off shots at random intervals all day, just to see what you get. :-)

GET_AV statement

You can see from "property case" 3 the AV-number (39) with different apertures and on the next page there is the TV number (40).

In uBASIC source code (platform/generic/shooting.c) there are tabels ApertureSize and ShutterSpeed. There are a couple of strange things in these tables (or my a710).

const ApertureSize aperture_sizes_table[] = {
   {  9, 288, "2.8", },   // 283, pc 39
   { 10, 320, "3.2", },
   { 11, 352, "3.5", },
   { 12, 384, "4.0", },
   { 13, 416, "4.5", },
   { 14, 448, "5.0", },
   { 15, 480, "5.6", },
   { 16, 512, "6.3", },
   { 17, 544, "7.1", },
   { 18, 576, "8.0", },
};

If I set the aperture to 2.8 I get the value 283, not 288. That's why my results differ from Harvester's. Maybe a710 has a slighty more powerful lense (2,78 vs 2,83)?


The TV has two strange things, why are values -10 and 29 missing? This deviates from the over-all trend of one step corresponding to 1/3 EV. A710is has a strange behaviour: I set the speed to 1/1600 when aperture is 5.6, then I change the aperture to 3.5 and the speed changes to 1/1500 (property value = 1008).

const ShutterSpeed shutter_speeds_table[] = {  // pc=40
   {-13, -384, "15", 15000000  },
   {-12, -352, "13", 13000000  },
   {-11, -320, "10", 10000000  },
   {-9, -288, "8", 8000000  },        // -10 missing
   {-8, -256, "6", 6000000  },
   {-7, -224, "5", 5000000  },
...
   {27, 864, "1/500",   2000 },
   {28, 896, "1/640",   1563 },
   {30, 928, "1/800",   1250 },    // 29 missing
   {31, 960, "1/1000",   1000 },
   {32, 992, "1/1250",    800 },  
// {xx, 1008, "1/1500"    667 },     1008, if aperture >4.0 then 1/1500 is the fastest.
   {33, 1021, "1/1600",    625 },
   {34, 1053, "1/2000",    500 },
   {35, 1084, "1/2500",    400 },


I have the following proposals:

1) remove the missing steps (-10 and 29) from the table so each step is 1/3 EV

2) if different camera's have different values, the tables should be moved to specific camera platform. If the only deviation is the 2.8 aperture, then it is enough if GET_AV with property case 39=283 returns 9. Even in my camera "set_AV 9" sets the aperture correctly to 2.8.

3) Maybe a more generic solution would be to use the actual property case values in the set_ and get_ statements, then 1/3 EV step correspond to 32. (I do not know why the fastest steps are not exactly equal to 32)

Any comments? -Stebu

IF / THEN / ELSE GOSUB = Parse Error?

I tried to shorten up this bit of code:

:interval
 if p>0 then gosub "pause"
 print "Shot 1 of", d
 if a=0 then shoot
 if a=1 then gosub "vid"
 if a=2 then gosub "vid"
 for n=2 to d
 sleep t*100
 print "Shot", n, "of", d
 if a=0 then shoot
 if a=1 then gosub "vid"
 if a=2 then gosub "vid"
 next n
 if j=1 then goto "interval" else end

to

:interval
 if p>0 then gosub "pause"
 print "Shot 1 of", d
 if a=0 then shoot else gosub "vid"
 for n=2 to d
 sleep t*100
 print "Shot", n, "of", d
 if a=0 then shoot else gosub "vid"
 next n
 if j=1 then goto "interval" else end

But I got a parse error on that if a=0 then shoot else gosub "vid" section. I take it that this isn't supposed to work? Or is this just a bug in the uBASIC section? Or it's just not allowed no matter what?

I also tried if a>0 then gosub "vid" else shoot because that syntax seemed to work with the if p>0 then gosub "pause"' line, But that didn't work either. I guess it just don't like the else with a gosub routine, or the shoot command, not sure which.

Keoeeit 10:13, 29 May 2007 (UTC)

Advertisement