checking exposure - best method? - page 3 - Script Writing - CHDK Forum

checking exposure - best method?

  • 28 Replies
  • 16335 Views
Re: checking exposure - best method?
« Reply #20 on: 01 / May / 2009, 11:31:56 »
Advertisements
Maybe he means that a uBasic instruction takes a very short time compared with the 10 msecond scan rate.

heh, i don't know what that means either but i'm fascinated to hear more.

*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: checking exposure - best method?
« Reply #21 on: 01 / May / 2009, 11:50:44 »
A single uBasic instruction is executed every 10 ms, in the camera's timing loop.

Therefore, between each uBasic instruction the camera has time to "mind its own business"

Even a tight uBasic loop

for n=1 to 100000
next

will have a small delay (abd 10 ms) between the "for" and the "next".

Lua, on the contrary, does not automatically introduce these delays. I am not exactly certain on how Lua behaves from this point of view, i never needed to investigate.

Anyway, I do not know the exact details but a similar loop in Lua can put the camera in quite a "time-hunger" mode.

Therefore, a small "sleep" here and there often helps.

Re: checking exposure - best method?
« Reply #22 on: 01 / May / 2009, 11:54:12 »
who added the lua code? would it be possible to have a less hungry mode?

*

Offline fbonomi

  • ****
  • 469
  • A570IS SD1100/Ixus80
    • Francesco Bonomi
Re: checking exposure - best method?
« Reply #23 on: 01 / May / 2009, 12:06:23 »
Velo did it. all credit for this HUGE improvement to CHDK goes to him.

Here he proposed it:
http://chdk.setepontos.com/index.php/topic,1172.0.html
And was met with very little enthusiasm (by myself too, I must say)

Here he implemented it:
http://chdk.setepontos.com/index.php/topic,1194.0.html
(and indeed there are discussions of sleeps)

Kudos to Velo!

*

Offline reyalp

  • ******
  • 14125
Re: checking exposure - best method?
« Reply #24 on: 01 / May / 2009, 20:30:17 »
I'm confused about what you mean when you say "camera won't expect those to happen instantly"
A human pressing the button would take a measurable amount of time (tens to hundreds of milliseconds).
edit: it is unreasonable to expect the canon firmware to behave correctly if you do the entire sequence in some tiny fraction of that.
Quote
I was unaware that ubasic sleeps after every instruction. Are there downsides to this?
The downsides should be obvious. Note that there is a patch floating around to remove/modify this limitation. I think it's already in SDM.
Quote
It seems to me that if sleep commands are required after specific commands that they should be implemented in lua somehow, rather than requiring the programmer to add them.
You appear to be forgetting what the H in CHDK stands for. No one knows exactly what is required for each possible sequence of code on each specific camera. We are doing all kinds of things that the original authors of the canon firmware never expected, using horrible hacks and only the vaguest understanding of the code it is interacting with. There is no spec that says "you must sleep x milliseconds between Y and Z".

If you can determine that something is always or frequently necessary for stable operation, document it as best as you can and maybe someone will address it in code.
Don't forget what the H stands for.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: checking exposure - best method?
« Reply #25 on: 09 / May / 2009, 11:52:06 »
I will try everything you recommend above but i must note that i find your flippant tone to be extremely obnoxious.

You have no idea how much time i put into isolating that problem.

Well, I don't want to pick a fight, but I guess you don't know how little time I've had lately on my hands for CHDK. If my mind serves me right, that particular message of yours (with the crashing script) was open on my browser for 3 days or so waiting for my attention as I found it to be worrying. So, before going away for a few more days, I cooked up a quick checklist as I thought it was better than not to post anything. I do have an idea of how much time it takes to do these things, and your work is greatly appreciated. I'm prompt by nature, sorry if that makes me appear rude.

2. Adding the sleep commands seems to fix the problem. I'm using sleep(100), can i use a smaller value? I don't understand why this fixes it. None of my other code requires sleep commands for stability.
3. No crashing with the uBasic version either.

What are these usual checks that you mention? While they don't seem necessary I'm still curious about them.

As others have said, ubasic spends 10 ms minimum on each command (the camera's keyboard poll interval) unless patched with more or less experimental code. A sleep(1) command in Lua between commands that potentially require some delay should be enough if similar ubasic code works reliably. MDFB used to crash on some cameras when old versions lifted the shutter using only release half. Adding release full (and thus wasting another 10 ms) fixed it. Even in ubasic scripts with those 10 ms delays the basic debugging method has always been to add sleep between commands when in doubt; stuff like keypresses just can't be done at a too rapid rate or something will be disregarded by the firmware (and to be exact these shutter commands are keypresses).

Flash seems to be the cause of many troubles (e.g. it often crashes the cam on motion detection on my a570, but that's just one thing that's been reported -- some have been fixed, some not) and thus it's best to disable it when pinpointing a problem such as this.

Ae lock on the other hand is not compatible with get_shooting() check loops (they check a propcase which never get the desired value and the script hangs).



reyalp: Maybe these press/release shoot_full/half commands should yield in Lua by default? Could an optional parameter be added to disable that in case it's not desireable in some cases?

Re: checking exposure - best method?
« Reply #26 on: 09 / May / 2009, 16:13:48 »
fudgey - no hard feelings. i'm happy to do all the work i can to fix these things but sometimes others have ideas i haven't tried yet. in any case, i'm  glad that you helped me improve my code.


*

Offline fe50

  • ******
  • 3152
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50
Re: checking exposure - best method?
« Reply #27 on: 11 / May / 2009, 09:07:49 »
@mattkime
Just a suggestion: have you tested higher values for the "Script shoot delay" setting from the CHDK script menu ?

This delay is executed at the end of the shoot code, by default it's set to zero on the current CHDK versions; in older CHDK version this value was set to 20 (= 0.1s x 20 --> 2 s delay at the end of the shoot command)...

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: checking exposure - best method?
« Reply #28 on: 11 / May / 2009, 10:02:15 »
Just a suggestion: have you tested higher values for the "Script shoot delay" setting from the CHDK script menu ?

This delay is executed at the end of the shoot code, by default it's set to zero on the current CHDK versions; in older CHDK version this value was set to 20 (= 0.1s x 20 --> 2 s delay at the end of the shoot command)...

That only affects the shoot command in lua and ubasic, not shooting done with separate keypresses (It's used by core/kbd.c function kbd_sched_shoot() to wait after shoot full release). The shoot command doesn't release shoot_half, btw, but it waits a bit (20 ms) between press shoot full and release shoot full.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal