CHDKPTP: S90 Primary Focal Plane Configuration - hacking out the CCD - page 59 - Creative Uses of CHDK - CHDK Forum

CHDKPTP: S90 Primary Focal Plane Configuration - hacking out the CCD

  • 704 Replies
  • 194710 Views
*

Offline SticK

  • *****
  • 779
Re: CHDKPTP: S90 Primary Focal Plane Configuration - hacking out the CCD
« Reply #580 on: 19 / August / 2013, 01:41:49 »
Advertisements
Not sure why you get a dark image above, from my testing I would expect it to be over exposed.
I didn't research why once it was brighter, and now dark.  It is consistently incorrect though. 

Quote
Anyway if you used ISO_MODE to set 400 before the shot rather than using -sv, it should all be OK. The shoot command doesn't try to set values you don't specify, so you can simply leave the -sv out and call set_prop() beforehand.
So really for my purposes, since I always select a different Tv and Sv for each shot, while keeping the liveview at one brightness (I hope soon), functionally then there would be no difference between these two pseudocode snippets:
Code: [Select]
setprop ISO_MODE 400
shoot -tv=1/8
and this:
Code: [Select]
shoot_SticK(1/8, 400)Correct?

edit: I modified the 2nd snippet to shoot_SticK() so that ISO values are consistent between the two versions because shoot_SticK() works in Canon ISOs.
« Last Edit: 19 / August / 2013, 07:39:52 by SticK »

*

Offline SticK

  • *****
  • 779
Re: CHDKPTP: S90 Primary Focal Plane Configuration - hacking out the CCD
« Reply #581 on: 19 / August / 2013, 09:11:05 »
PRELIMINARY RESULTS for ISO PTM

@srsa_4c

From boot, if I haven't yet shot with shoot_SticK(), my liveview starts dim at Canon 100, with ISO icon at 100.  Canon Tv is set to 1/15.
  1 > I do PTMGetCurrent and get 2.  Expected.
  2 > I start with shoot_SticK(1/8, 100) to get a reference gray scale.  OK.
  3 > I do PTMSetCurrent 14 for ISO 1600, liveview goes bright and the OSD ISO icon goes to 1600.  Excellent so far, the desired result.
  4 > I do shoot_SticK(1/8, 200).   Liveview goes dark, expected.  Image checks out OK.
  5 > I do PTMSetCurrent 14 in the hope to reset liveview bright.  The light meter does go up, but liveview remains dark.
  6 > I press SHOOT HALF (according to reyalp), and the liveview goes bright.  OK so far (but it would be nice not to have to use SHOOT HALF -but- I can live with it if necessary).
  7 > I do shoot_SticK(1/8, 200).  Liveview goes dark, expected.  However, image is dark.  I do *not* press SHOOT HALF (liveview still dark).
  8 > I do shoot_SticK(1/8, 200) again. This time image is OK.
  9 > If I circulate from step 6, behavior remains the same.

So here I decided to examine EXIF from the dark image.  It turns out that all the EXIF data matched the reference greyscale image in step 2.  So what's happening?  My external exposure H/W state machine got thrown off by the SHOOT HALF and explains why your solution worked first time in step 1 to 4.  So I modified the cyclic steps 4 to 7 to include 6b:

  4 > I do shoot_SticK(1/8, 200).   Liveview goes dark, expected.  Image checks out OK.
  5 > I do PTMSetCurrent 14 in the hope to reset liveview bright.  The light meter does go up, but liveview remains dark.
  6 > I press SHOOT HALF (according to reyalp), and the liveview goes bright.  OK so far (but it would be nice not to have to use SHOOT HALF -but- I can live with it if necessary).
  6b > I manually reset the state machine of my external exposure hardware.
  7 > I do shoot_SticK(1/8, 200).  Liveview goes dark, expected.  Now, image is OK. Beautiful!


VERY PRELIMINARY CONCLUSION

This looks *very* interesting.  It seems that maybe there is no "override suppression problem" on the 1st shot after PTMSetCurrent (which agrees with reyalp's earlier correct suspicion), and my dark images were related to SHOOT HALF fudging with my exposure H/W which was being reset by the 1st shot, but I still need more testing to be convinced.   So, very nice indeed, if you can solve the step 6 SHOOT HALF quirk, that's the solution.
« Last Edit: 19 / August / 2013, 09:16:15 by SticK »

*

Offline srsa_4c

  • ******
  • 4451
Re: CHDKPTP: S90 Primary Focal Plane Configuration - hacking out the CCD
« Reply #582 on: 19 / August / 2013, 11:12:58 »
@SticK

You could try dropping every trace of ISO override completely, and just use the PTM function to set ISO as desired (for photo and for live view). I haven't yet tried it on a manual camera, so I don't know whether it works flawlessly. If it doesn't work, perhaps a little delay before calling the PTM function will help. Note that all the other shooting parameters can be adjusted the same way, once their ID is found.

About 'bricking': I tried it on a really old (a410) and a relatively new (a3200) camera, and PTM_SetCurrentItem only appears to accept values that are valid in the current shooting mode, hence the probability of bricking is close to zero.

*

Offline SticK

  • *****
  • 779
Re: CHDKPTP: S90 Primary Focal Plane Configuration - hacking out the CCD
« Reply #583 on: 19 / August / 2013, 14:15:59 »
You could try dropping every trace of ISO override completely, and just use the PTM function to set ISO as desired (for photo and for live view).
Very interesting // your idea will receive some attention and thought.

Quote
Note that all the other shooting parameters can be adjusted the same way, once their ID is found.
Fabulous ... a new arsenal has been found!

Since having to press SHOOT HALF to update liveview with a new PTM ISO value interferes with my external hardware, can you look at a way of doing the same, but w/o actually having to operate the other redundant functions of SHOOT HALF ?   You may need to look at difference between shoot_half and the code associated with the SHOOT HALF button because they behave differently.  Issuing a shoot_half call doesn't update the liveview.  In the meantime I will write up a new shoot_SticK() and explore your solution and ideas.

*

Offline SticK

  • *****
  • 779
Re: CHDKPTP: S90 Primary Focal Plane Configuration - hacking out the CCD
« Reply #584 on: 19 / August / 2013, 18:56:45 »
@reyalp

Could you please help me with Lua syntax again?  I've been struggling with this all day.

Code: [Select]
function shoot_SticK(Tv, Sv)
local l,r = con:execwait('return call_event_proc("PTM_GetCurrentItem",0x8006)')  -- save the current ISO index
printf("Current ISO index setting=%s\n", r)
local_shoot(Tv, 2, Sv, "G:\\CANON_S90\\")
    con:execwait('call_event_proc("PTM_SetCurrentItem",0x8006,r)') -- restore the saved ISO index
end
The printf shows the correct value so the 1st event call is OK.  I'd expect that if the whole block were OK, then if I pressed the HALF SHOOT button after executing shoot_SticK(), I'd get the liveview to return bright.  But it doesn't.  So I gather the second event call seems not have any effect, AFAIK.  However .... for example, say the printf part returns 14.  If I comment out the 2nd event call, and execute this call from the command line:
   >=return call_event_proc("PTM_SetCurrentItem",0x8006,14)
do the HALF SHOOT, then the liveview returns bright.

edit: so the basic new functionality seems to work.
« Last Edit: 19 / August / 2013, 21:34:53 by SticK »

*

Offline reyalp

  • ******
  • 14128
Re: CHDKPTP: S90 Primary Focal Plane Configuration - hacking out the CCD
« Reply #585 on: 19 / August / 2013, 21:42:00 »
Code: [Select]
function shoot_SticK(Tv, Sv)
local l,r = con:execwait('return call_event_proc("PTM_GetCurrentItem",0x8006)')  -- save the current ISO index
printf("Current ISO index setting=%s\n", r)
local_shoot(Tv, 2, Sv, "G:\\CANON_S90\\")
    con:execwait('call_event_proc("PTM_SetCurrentItem",0x8006,r)') -- restore the saved ISO index
end
In the last line, you aren't sending the value of r, you are just trying to use r as a camera side variable, which will be nil.
Try something like
Code: [Select]
con:execwait(string.format('call_event_proc("PTM_SetCurrentItem",0x8006,%d)',r))
As always, you should display the status of your remote calls.  call_event_proc will throw a lua error if you pass it a nil value, but you won't see it since you aren't doing anything with the status of execwait.

You can use cli:print_status for this purpose, like
Code: [Select]
cli:print_status(con:execwait(string.format('call_event_proc("PTM_SetCurrentItem",0x8006,%d)',r)))
This will give you an error message in the console if the remote call fails.
Don't forget what the H stands for.

*

Offline SticK

  • *****
  • 779
Re: CHDKPTP: S90 Primary Focal Plane Configuration - hacking out the CCD
« Reply #586 on: 19 / August / 2013, 21:51:56 »
Thank you reyalp, and for the additional info on the exception throw // I'll try this out.  I should add that by hand, things are looking *very* good with srsa's solution.  I still need a good amount of work on this to get some reliable results.  I'm pretty sure about one thing though, that the shoot-half (button press) liveview brightness update seems to do way too much, and adds a good chunk of a second to latency.  If there is a way to just extract the liveview update function alone w/o affecting anything else from the (likely myriad of) other actions shoot-half does, that would be the solution ... I'm quite sure.

edit Ahh!  Now I see, con:execwait() expects a string! Hence my original
Code: [Select]
con:execwait('call_event_proc("PTM_SetCurrentItem",0x8006,r)') sends a literal "r" instead of its value.  It would be nice if you could write one-page PDF that explains first principles like this and useful tips, and put it at the very top of the wiki.  That would really help a lot folks like me.
« Last Edit: 19 / August / 2013, 23:03:22 by SticK »

*

Offline reyalp

  • ******
  • 14128
Re: CHDKPTP: S90 Primary Focal Plane Configuration - hacking out the CCD
« Reply #587 on: 19 / August / 2013, 22:02:28 »
If there is a way to just extract the liveview update function alone w/o affecting anything else from the (likely myriad of) other actions shoot-half does, that would be the solution ... I'm quite sure.
Maybe there's an eventproc that does some of this. One could look for likely names http://chdk.wikia.com/wiki/User:ReyalP/EventProcNotes (note these are from a540, so not all will be the same on S90)

The stuff under Capture.Create and RegisterShootSeqEvent would be where I'd start.

Don't forget what the H stands for.

*

Offline SticK

  • *****
  • 779
Re: CHDKPTP: S90 Primary Focal Plane Configuration - hacking out the CCD
« Reply #588 on: 20 / August / 2013, 01:31:31 »
Congrats folks ... I'm pleased to announce that it looks like we have a solution.  This wasn't easy on all sides ... but here it is:
Code: [Select]
-- usage: >!local_shoot(1/8, 2.8, 400, "C:\\CANON_S90\\")
function local_shoot(tv, av, canon_sv, destdir)
local sv = canon_sv / 1.6461 -- ISO correction for S90 so that CHDK EXIF data is the same as Canon.
-- note: a cammnd line call syntax to shoot is:
--   >shoot -tv=1/8 -sv=100
cli:execute('shoot -tv='..tv..' -av='..av..' -sv='..sv..'')
sys.sleep(2400)
local l,r=con:execwait('return get_meminfo().free_size')
print(" free", r)   
printf(" free: %s\n",r)   
dcimdl(destdir, true, false)
end

function shoot_SticK(Tv, Sv)
local l,r = con:execwait('return call_event_proc("PTM_GetCurrentItem",0x8006)')  -- save the current ISO index for liveview
printf("Current ISO index setting=%s\n", r)
local_shoot(Tv, 2, Sv, "G:\\CANON_S90\\")
    sys.sleep(20)    
    cli:print_status(con:execwait(string.format('call_event_proc("PTM_SetCurrentItem",0x8006,%d)', r))) -- restore the saved ISO index
    sys.sleep(20)    
con:execwait('press("shoot_half")') -- update liveview brightness
con:execwait('release("shoot_half")')
end
On top of the good news, there's more good news.  It turns out that we may not need the extracted update call because shoot_half works quite well: all it needs is a "flash" as you see here.   I tried a delay between press and release of up to 1/2 s and that did not generate any spurious signal to my external hardware, so I feel this solution is reliable in that corner.   I found that the two 20 ms sleeps guarantee consistent behavior for file transfer over the USB when the cam is first booted, and may not even be needed.

@srsa_4c

Here's the very interesting department: I noted that if I peeked at the ISO index after local_shoot(), it hadn't changed.  So I tried shoot-half at that point, and there was no effect.  Hence SetCurrentItem must do more than just poke the same value back.  Can you offer us some insight?

How to handle Create?

Code: [Select]
call_event_proc("UI.CreatePublic")... would need to go into the FW.  The reason is sometimes if there is a ptp error or shutdown, CHDKPTP cannot know that condition, and that can lead to confusing operation if not handled in FW.  I tested create instantiation after PUP while the camera is still in PLAY mode.  That works fine, so if you can be so kind to install it as the last hack in your exisiting sequence, and please post a new ZIP, I will put it through a battery of tests.
« Last Edit: 20 / August / 2013, 01:40:32 by SticK »

*

Offline srsa_4c

  • ******
  • 4451
Re: CHDKPTP: S90 Primary Focal Plane Configuration - hacking out the CCD
« Reply #589 on: 20 / August / 2013, 10:04:43 »
@SticK

UI.CreatePublic: This registers lots of event procedures and consumes memory. It will be unneeded because the PTM event procedures can be called directly. Downside is that your script will become camera and firmware version dependent. A future version of CHDK may integrate these event procedures as 'native' Lua functions, I don't plan to hack them into CHDK 1.1.

About that required half-shoot:
I believe that most of CHDK exposure overrides were invented to allow control over exposure parameters on cameras without an M mode (and, of course, to allow script control). You won't have any problems using them on a cam with only P mode - due to the always running AE. However, in M mode, AE may not be running at all, hence your problems with the liveview brightness.

What you could do - as I tried to explain earlier - is to drop ISO override from your shoot command, and control ISO using the PTM eventproc. If that's not enough, you could drop the Av and Tv overrides too, and control all these by the PTM eventproc - you can do it, you're in M mode. Of course, you need to find out the ID for Av and Tv (you don't even need Av, I guess).

The highest PTM ID on your camera is 0x806d. Av and Tv will likely have an ID close to 0x8000.
I could make you a CHDK 1.3 testbuild for your 100c camera (typing/pasting those long commands into the CHDKPTP console can become boring), but you never used the related debug tool in the CHDK menu, so I don't know whether it would help.

Here's how to call the PTM event procedures directly (so you don't need UI.CreatePublic):
100c:
call_event_proc("PTM_GetCurrentItem",<ID>) ->          call_func_ptr(0xff8950cc, <ID>)
call_event_proc("PTM_SetCurrentItem, <ID>, <value>) -> call_func_ptr(0xff993e2c, <ID>, <value>)


101a
call_event_proc("PTM_GetCurrentItem",<ID>) ->          call_func_ptr(0xff8950f8, <ID>)
call_event_proc("PTM_SetCurrentItem, <ID>, <value>) -> call_func_ptr(0xff993e80, <ID>, <value>)


101c
PTM_GetCurrentItem 0xff895148
PTM_SetCurrentItem 0xff99403c
« Last Edit: 20 / August / 2013, 18:43:59 by srsa_4c »

 

Related Topics


SimplePortal © 2008-2014, SimplePortal