Question re shutter setting - General Help and Assistance on using CHDK stable releases - CHDK Forum supplierdeeply

Question re shutter setting

  • 9 Replies
  • 1330 Views
Question re shutter setting
« on: 29 / January / 2023, 17:23:01 »
Advertisements
@reyalp

I have a ‘bug’ in one of my scripts that is driving me crazy.

I have this function

Code: [Select]
function bookend()
    set_user_tv96(usec_to_tv96(1000))
    set_av96_direct(get_max_av96())
    local ecnt = get_exp_count()
    snap()
    set_user_tv96(s_start)
    set_av96_direct(av)
    repeat sleep(10) until (get_exp_count() ~= ecnt)
end

I call it when I want a dark frame, ie a bookend when bracketing.

What I see is that the shutter is not explicitly set to 1/1000 every time I call the function, as I would expect.

Sometimes, the shutter is left at the previous shutter value, although the aperture is changed, as expected, every time.

Are you aware of a situation when set_user_tv96 won’t explicitly set the shutter value?

Cheers

Garry

*

Offline reyalp

  • ******
  • 14118
Re: Question re shutter setting
« Reply #1 on: 29 / January / 2023, 19:58:10 »
What I see is that the shutter is not explicitly set to 1/1000 every time I call the function, as I would expect.


Are you aware of a situation when set_user_tv96 won’t explicitly set the shutter value?
set_user_tv96 should set the shutter speed for modes where the Canon firmware allows manual shutter input, like Tv and M. It will not work at all in other modes.

It rounds the value to the nearest supported value in the cameras shooting.c shutter_speeds_table. If you want to set arbitrary values, setting the USER_TV propcase should be otherwise equivalent, but 1/000th should be present for pretty much every camera, so this is unlikely to be relevant to your problem.

It also most likely need to be set outside of half press, or more specifically, before get_shooting goes true and the value is transferred to the normal shutter propcases.

If your script used regular CHDK Tv overrides (set_tv96_direct etc) in the same shooting cycle (that is, without a half press or shot between the regular override and the user override) they would probably clobber the "user" value. CHDK overrides set from the menu would also likely interfere.

Values beyond what the firmware would allow, or some arbitrary higher value may be ignored, but I would expect 1/1000th to work pretty much everywhere.

As ever, I would recommend reducing the apparent failure to the simplest possible case. For example, if you use a script that just takes two shots with different user_tv96 values values, are they reliable applied? If so, adding more aspects of the affected script.

In the code you posted, I can't tell what "snap" does.

It would also be helpful to know which cameras you see this on.
Don't forget what the H stands for.

Re: Question re shutter setting
« Reply #2 on: 30 / January / 2023, 00:26:42 »
@reyalp

Thanks for the insight.

I’m using this script https://gist.github.com/pigeonhill/3fe9e52621db7149eb3505bd60b395cb

I see the issue on both my G7X and G5X.

As I say it’s strange, as calling bookends works most of the time.

I’ll carry on investigating/testing and report back when I have something to say.

Cheers

Garry

*

Offline reyalp

  • ******
  • 14118
Re: Question re shutter setting
« Reply #3 on: 30 / January / 2023, 01:26:14 »
I’m using this script https://gist.github.com/pigeonhill/3fe9e52621db7149eb3505bd60b395cb
One thing I notice is that bookend() is called in a lot of different places. Figuring out whether only some of these calls are affected could help narrow down the problem.

A possible cause is if bookend were called before get_shooting goes false from a preceding shot. In that case, the new USER_TV value would likely not be applied. It looks like this could potentially happen for the final bookend call, since some of the preceding code uses myshoot() directly, which only waits for the raw hook, and does not itself release shoot_half.

I'm a big fan using logs to collect detailed information about what actually happened. In this case, you could log each call to bookend() and the get_shooting() state on entry.


While not likely to be directly related to this problem, another thing I noticed is that seems like some of this code calls myshoot() without shoot_half already held. For example, on line 616, it releases shoot_half and waits for get_shooting to go false, and then calls myshoot, which presses shoot_full_only.

I would generally avoid pressing shoot_full_only without having shoot_half held, for two reasons:
1) Going to full press without waiting for get_shooting() in half press is known to trigger various bugs on some ports, like incorrect overrides or missed CHDK raw files
2) Having shoot_full_only pressed without shoot_half is impossible using the physical buttons, so the firmware probably doesn't expect it.

X_Bracket appears to do the correct sequence, pressing shoot_half, waiting for get_shooting, and then doing multiple shoot_full_only clicks to take individual shots, and then releasing shoot_half when done.
Don't forget what the H stands for.


Re: Question re shutter setting
« Reply #4 on: 30 / January / 2023, 01:33:58 »
I’m using this script https://gist.github.com/pigeonhill/3fe9e52621db7149eb3505bd60b395cb
One thing I notice is that bookend() is called in a lot of different places. Figuring out whether only some of these calls are affected could help narrow down the problem.

A possible cause is if bookend were called before get_shooting goes false from a preceding shot. In that case, the new USER_TV value would likely not be applied. It looks like this could potentially happen for the final bookend call, since some of the preceding code uses myshoot() directly, which only waits for the raw hook, and does not itself release shoot_half.

I'm a big fan using logs to collect detailed information about what actually happened. In this case, you could log each call to bookend() and the get_shooting() state on entry.


While not likely to be directly related to this problem, another thing I noticed is that seems like some of this code calls myshoot() without shoot_half already held. For example, on line 616, it releases shoot_half and waits for get_shooting to go false, and then calls myshoot, which presses shoot_full_only.

I would generally avoid pressing shoot_full_only without having shoot_half held, for two reasons:
1) Going to full press without waiting for get_shooting() in half press is known to trigger various bugs on some ports, like incorrect overrides or missed CHDK raw files
2) Having shoot_full_only pressed without shoot_half is impossible using the physical buttons, so the firmware probably doesn't expect it.

X_Bracket appears to do the correct sequence, pressing shoot_half, waiting for get_shooting, and then doing multiple shoot_full_only clicks to take individual shots, and then releasing shoot_half when done.

Yes I was thinking along the lines you hint at, ie the problem happens only with the closing bookmark.

Off to work now, more investigating later.

Cheers

Garry

Re: Question re shutter setting
« Reply #5 on: 30 / January / 2023, 01:58:19 »
@reyalp

Managed to sqeeze in a quick test along the lines you suggested, ie to address:

Quote
While not likely to be directly related to this problem, another thing I noticed is that seems like some of this code calls myshoot() without shoot_half already held. For example, on line 616, it releases shoot_half and waits for get_shooting to go false, and then calls myshoot, which presses shoot_full_only.

That is changed all 'hanging' myshoot() calls to the correct use, ie snap()

Updated code: https://gist.github.com/pigeonhill/3fe9e52621db7149eb3505bd60b395cb

But I still have the issue.

More later ;-)

Re: Question re shutter setting
« Reply #6 on: 30 / January / 2023, 14:05:19 »
@reyalp

OK, although I don't fully understand why, I've found out what was going wrong, ie using set_user_tv96(s_start)

The following is the corrected code, showing what I've done.

The script works as expected now :-)

Code: [Select]
function bookend()
    --set_user_tv96(usec_to_tv96(1000))
    set_tv96_direct(usec_to_tv96(1000))
    set_av96_direct(get_max_av96())
    local ecnt = get_exp_count()
    snap()
    --set_user_tv96(s_start)
    set_tv96_direct(s_start)
    set_av96_direct(av)
    repeat sleep(10) until (get_exp_count() ~= ecnt)
end

Re: Question re shutter setting
« Reply #7 on: 01 / February / 2023, 03:04:43 »
@reyalp

OK, although I don't fully understand why, I've found out what was going wrong, ie using set_user_tv96(s_start)

The following is the corrected code, showing what I've done.

The script works as expected now :-)

Code: [Select]
function bookend()
    --set_user_tv96(usec_to_tv96(1000))
    set_tv96_direct(usec_to_tv96(1000))
    set_av96_direct(get_max_av96())
    local ecnt = get_exp_count()
    snap()
    --set_user_tv96(s_start)
    set_tv96_direct(s_start)
    set_av96_direct(av)
    repeat sleep(10) until (get_exp_count() ~= ecnt)
end

@reyalp

I’m not sure you’ve had time to look at my ‘resolution’ to the problem I was having.

When you do get a chance, I would welcome any insight, ie why one way works and one doesn’t.

Cheers

Garry


*

Offline reyalp

  • ******
  • 14118
Re: Question re shutter setting
« Reply #8 on: 01 / February / 2023, 17:22:09 »
Weird, I'm 99.9% sure I wrote a detailed response yesterday :blink:

Let's try again. It's good that you are able to work around this using normal overrides, but leaves unexplained why the "user" ones weren't working. I'm not clear why that is, and am unlikely to make a useful guess without actually sitting down and debugging with controlled tests and logs.

So instead, I'll try to explain how the _user and regular overrides are differ. In particular, the set calls you have after the snap() call may not be doing what you expect.

Normal CHDK overrides for Tv, Av, Sv and ND (set_tv96* etc, as opposed to the _user ones in the previous version) have more complicated logic than just setting a setting.

If called outside of shoot half (when get_shooting() is false) they just save the value in internal CHDK variables. Then, when the next shoot half happens and get_shooting goes true, the values are transferred to the propcases to override whatever the Canon firmware would have done. The CHDK variables are then cleared, so the override are only applied to one shot or half shoot cycle. They are also effectively cleared if the script ends before a shoot half happens. (Technically there's a bunch of other, sometimes camera specific subtleties I'm ignoring for brevity)

The above means that if you use something like set_tv96_direct outside of half shoot, and then read back the Tv value (from the propcase or get_tv96), you won't see the value you just set.

If called while get_shooting is true, these overrides are applied immediately (setting the propcases and, for things like ND and Av, potentially moving actuators), and the CHDK variables aren't touched. This allows you to override exposure where multiple shots are taken in a single half press cycle, like continuous mode, or when holding half and clicking full.

The reason it's done this was is that the normal exposure propcases (PROPACASE_TV etc) are normally updated by the Canon firmware at that point in half shoot. If auto-exposure is enabled, the values come from the camera AE calculation, if a setting is manually controlled, the value comes from the "user" propcases. To be effective, CHDK overrides need to be applied after the Canon firmware does its thing.

In contrast to the above, the CHDK "user" functions just set the corresponding "user" propcase immediately, which should be mostly equivalent to setting the value in the UI. The Canon firmware should take care of transferring these values into the standard propcases on shoot half, assuming the shooting mode allows manual control of the setting and no CHDK overrides interfere.

So getting back to your script, since "snap" waits for get_shooting to go false, the set_tv96_direct(s_start) and set_av96_direct(av) calls after snap are setting values that would be applied in the next half shoot cycle, wherever that may happen in the script, but it won't, for example, affect the live preview or UI display. This may be harmless, but it also may lead to confusion, especially in functions like bookend that can be called in multiple places.

Generally, I would recommend thinking of the normal overrides (again, set_tv96_direct and friends) as "set the exposure for the next half press or shot", as opposed to thinking of them like setting the controls in the UI. If you need to track values between shots, I'd suggest doing that in script variables rather than trying to "restore" them after a shot.

That said, calling an override function multiple times outside of half press doesn't *break* anything, it just updates the CHDK values, so whatever was set closest to the half shoot is the one that takes effect.
Don't forget what the H stands for.

Re: Question re shutter setting
« Reply #9 on: 01 / February / 2023, 17:34:29 »
@reyalp

Many thanks for the detailed insight. 

As usual, I shall reflect on what you say and, if necessary, tweak my script.

Cheers

Garry

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal