Camera shuts down after zoom if aflock is set to 0 - Script Writing - CHDK Forum

Camera shuts down after zoom if aflock is set to 0

  • 16 Replies
  • 10370 Views
Camera shuts down after zoom if aflock is set to 0
« on: 10 / August / 2015, 08:23:49 »
Advertisements
Hi everyone,

In order to set focus I am using set_aflock(0) . But this time when I zoom in or out , after zoom camera shuts itself down.To solve problem I am calling set_aflock(1) before zooming.This solves shut down problem but another problem is occuring.The first capture after zoom is not focusing but second shot is focusing.These are code snippets related to problem.

Functions in multicam.lua
Code: [Select]
function mc:zoom(opts)
local cmdulck=string.format('call set_aflock(%d);',0)
self:cmdwait(cmdulck)

if(opts.zo) then
local cmdzo=string.format('call set_zoom(%d);',opts.zo)
self:cmdwait(cmdzo)
end
end

function mc:iso(opts)
if(opts.sv) then
local cmdsv=string.format('call set_sv96(%d);',opts.sv)
self:cmdwait(cmdsv)
end
end

function mc:shutter(opts)
if(opts.tv) then
local cmdtv=string.format('call set_tv96_direct(%d);',opts.tv)
self:cmdwait(cmdtv)
end
end

function mc:focus(opts)
if(opts.fc)then
local cmdlck=string.format('call set_aflock(%d);',1)
self:cmdwait(cmdlck)
local cmdfcs=string.format('call set_focus(%d);',opts.fc)
self:cmdwait(cmdfcs)
end
end

and these are my functions in gui_user.lua

action event of zoom button :

Code: [Select]
action=function(self)
if tonumber(z0text.value)~=nil then
cli:execute(string.format("!mc:zoom({zo=%d})",z0text.value))
end

action event of shoot button :

Code: [Select]
   action=function(self)

if tonumber(ftext.value)~=nil then
add_status(cli:execute(string.format("!mc:focus({fc=%d})",ftext.value)))
end

if tonumber(isotext.value)~=nil then
add_status(cli:execute(string.format("!mc:iso({sv=%d})",isotext.value)))
end

if tonumber(shuttertext.value)~=nil then
add_status(cli:execute(string.format("!mc:shutter({tv=%d})",shuttertext.value)))
end

                    add_status(cli:execute("!mc:cmdwait('shoot_hook_sync',{syncat=600})"))
                end,

I have tried calling set_zoom_speed(x) function as stated in http://chdk.wikia.com/wiki/CHDK_scripting#set_zoom_.2F_set_zoom_rel_.2F_get_zoom_.2F_set_zoom_speed  but it did not work.

I tried calling cmdwait('preshoot') before shoot in shoot button action it didnt work neither.

Is there any advice to solve this ?

Re: Camera shuts down after zoom if aflock is set to 0
« Reply #1 on: 10 / August / 2015, 11:49:37 »
In order to set focus I am using set_aflock(0) . But this time when I zoom in or out , after zoom camera shuts itself down.To solve problem I am calling set_aflock(1) before zooming.This solves shut down problem but another problem is occuring.The first capture after zoom is not focusing but second shot is focusing.These are code snippets related to problem.
I don't know what camera you are using,  but using set_zoom( ) definitely causes problems on some cameras.  I first ran into this almost four years ago and so far there has not been a definitive solution.  See :  set_zoom problems in uBASIC & Lua scripts

From your description,  it sounds like what I think I've seen before where moving the zoom confuses the focus mechanism (i.e the set_zoom call misses some sort of interlock with the focus controller) and the camera gives up and shuts down.  When you lock the focus with set_aflock(1) the camera does not try to refocus and thus does not crash.  It's curious that it actually tries to refocus after the first shot - I don't thing that's supposed to happen once you do a set_aflock(1).

There are a number of possible "fixes" that might help :
  • Insert a sleep(4000) after each set_zoom( ) call to allow things to "settle"
  • Do a "half shoot" press & release after each set_zoom( ) call to force a refocus
  • Change the zoom parameter in platform_camera.h and rebuilt CHDK for your camera
Code: [Select]
#undef  CAM_NEED_SET_ZOOM_DELAY    // Define to add a delay after setting the zoom position before resetting the focus position in shooting_set_zoom
#undef  CAM_USE_ALT_SET_ZOOM_POINT        // Define to use the alternate code in lens_set_zoom_point()
#undef  CAM_USE_ALT_PT_MoveOpticalZoomAt // Define to use the PT_MoveOpticalZoomAt() function in lens_set_zoom_point()

It would be good if you can produce a ROMLOG.LOG to confirm what is causing the crash ( focus_lens_controller or something).  In the CHDK menus,  go to Miscellaneous Stuff -> Debug Parameters ->  Save ROM crash log  and then attach the resulting file to a post here.

FYI :  set_zoom_speed(x) only works of a few older cameras.
« Last Edit: 10 / August / 2015, 11:56:46 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Camera shuts down after zoom if aflock is set to 0
« Reply #2 on: 11 / August / 2015, 05:24:33 »
1) I have called sleep before zoom,after zoom but it did not work because i think program is not reaching to sleep after zoom as camera shuts down just after zoom.

2)I have called both cmdwait('preshoot') and press('shoo_half')=relase('shoot_half') after zoom before shoot .Unfortunately it did not work.

3) set_zoom_speed(x) is not changing any thing.My camera model is SX170IS maybe it does not support set zoom speed.

I could not find camera.h file actually where is it located?

I am attaching my romlog file please check that .

*

Offline srsa_4c

  • ******
  • 4451
Re: Camera shuts down after zoom if aflock is set to 0
« Reply #3 on: 12 / August / 2015, 18:31:49 »
Test builds for the sx170 with this change:
Code: [Select]
--- platform/sx170is/platform_camera.h (revision 4222)
+++ platform/sx170is/platform_camera.h (working copy)
@@ -102,6 +102,7 @@
     #define  CAM_FILEWRITETASK_SEEKS                1 // Camera's FileWriteTask can do Lseek() - DryOS r50 or higher, the define could also be CAM_DRYOS_2_3_R50
 
     #define CAM_HAS_ZOOM_LEVER                      1 // Camera has dedicated zoom buttons
+    #define CAM_NEED_SET_ZOOM_DELAY                 300 // Define to add a delay after setting the zoom position
     #define CAM_USE_OPTICAL_MAX_ZOOM_STATUS         1 // Use ZOOM_OPTICAL_MAX to reset zoom_status when switching from digital to optical zoom
     #define CAM_USE_ALT_SET_ZOOM_POINT              1 // Define to use the alternate code in lens_set_zoom_point()
     #define CAM_USE_ALT_PT_MoveOpticalZoomAt        1 // Define to use the PT_MoveOpticalZoomAt() function in lens_set_zoom_point()
@simtek
Please install the appropriate build on your cam's SD card, and see whether it still crashes after set_zoom. Note that ps.fi2 files for the "firmware update" boot method are not included.

edit:
test builds removed
« Last Edit: 23 / August / 2015, 19:15:54 by srsa_4c »

Re: Camera shuts down after zoom if aflock is set to 0
« Reply #4 on: 13 / August / 2015, 08:06:51 »
Hi , I could not see any camera_platform.h file to make that code change.In which file should I make those changes ?


By saying pi2 file I don't get what you mean. I can see that there is no fi2 file in your zip.But I have fi2 in the firmware I uploaded to SD card.Actually what should I do ? How can I generate that file

*

Offline adong

  • **
  • 66
Re: Camera shuts down after zoom if aflock is set to 0
« Reply #5 on: 13 / August / 2015, 11:02:27 »
camera_platform.h is in the code, you cannot see the file in compiled binaries.

srsa gave you precompiled zips so that you can test immediately.

You cannot use the ps.fi2 file that you currently have (as it refers to an old binary), you must make your sd card bootable.

Follow the instructions on this page to make your sd card bootable: http://chdk.wikia.com/wiki/Prepare_your_SD_card
Follow the section "Bootable SD Card Method" (method 2 is most likely the easiest for you)

When your card is bootable, unzip the full contents of the zip you downloaded in your sd card, and lock it. Boot chdk.

Re: Camera shuts down after zoom if aflock is set to 0
« Reply #6 on: 14 / August / 2015, 05:02:58 »
camera_platform.h is in the code, you cannot see the file in compiled binaries.

srsa gave you precompiled zips so that you can test immediately.

You cannot use the ps.fi2 file that you currently have (as it refers to an old binary), you must make your sd card bootable.

Follow the instructions on this page to make your sd card bootable: http://chdk.wikia.com/wiki/Prepare_your_SD_card
Follow the section "Bootable SD Card Method" (method 2 is most likely the easiest for you)

When your card is bootable, unzip the full contents of the zip you downloaded in your sd card, and lock it. Boot chdk.


If I download firmwares attached in the post there is no option to firmware update in settings.

Camera shuts down after zoom if aflock is set to 0
« Reply #7 on: 14 / August / 2015, 07:16:14 »
Did you read the post you quoted. It answers your question.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Camera shuts down after zoom if aflock is set to 0
« Reply #8 on: 14 / August / 2015, 10:04:48 »
Did you read the post you quoted. It answers your question.

I didn`t understand at first but now I have solved the problem.Thank you very much  :)
« Last Edit: 14 / August / 2015, 10:09:57 by simtek »

*

Offline srsa_4c

  • ******
  • 4451
Re: Camera shuts down after zoom if aflock is set to 0
« Reply #9 on: 15 / August / 2015, 05:31:10 »
now I have solved the problem
Can you confirm that the test build works without crashing? Or you had to do something else to solve the problem?

 

Related Topics


SimplePortal © 2008-2014, SimplePortal