Set zoom problems - page 2 - Script Writing - CHDK Forum

Set zoom problems

  • 19 Replies
  • 8626 Views
Re: Set zoom problems
« Reply #10 on: 26 / October / 2011, 22:01:15 »
Advertisements
Well I'm sorry to say, but no go.  I ran your exact script under both normal script execution and autostart.  Under normal execution it zooms out as expected to the correct position and takes a picture.  Under autostart, it essentially ignores the zoom command and the zoom starts at zero and then it shoot a picture.  I have replicated this result on an A480, an A495, a G11, and finally a S5IS.  They all behave exactly the same, testing multiple times on each camera.  Yes, I did account for the different zoom steps available on each camera and adjust a to something in the cameras range.

Well now I'm stumped.  Can you try your macro on another camera (if you have one) or can anyone else try this on their camera and tell me if I'm either the biggest dolt out there, or this is a major bug of CHDK.  Again, run it as a normal script when the camera is already up and running and run it as a Autostart script.  And check that it actually zoomed out by getting out of CHDK and seeing if the zoom is in anything other than at full wideout after this script has executed in autostart mode. At least on my end I am seeing completely different behaviors.  I have no doubt SkyWalker that this is running perfectly on your end, but there is clearly something in these other cameras that is not working correctly.

Re: Set zoom problems
« Reply #11 on: 26 / October / 2011, 22:09:26 »
Long shot idea here - did you try putting a sleep(4000) as the first line of the script ?  Maybe give the camera time to settle in autostart mode before the script touches the zoom ?
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Set zoom problems
« Reply #12 on: 28 / October / 2011, 17:14:36 »
Nope, an initial sleep command does not work.

However, modifying the script as follows does work; added a single extra shoot before doing the set_zoom a.  If I do that then it will do the set_zoom a correctly before doing the next shoot command.  Weird huh ?  Obviously I'd like to avoid having to do that, but I suppose that will await someone figuring out what this bug is and how to fix it. I'm not skilled enough to do so myself.

rem Test

@param a Zoom Step
@default a 2

  cls
  print "Set when ready..."
  print " "

:check_again
  wait_click
  is_key k "set"
  if k=1 then goto "ok"
  goto "check_again"

:ok
  shoot
  set_zoom a
  sleep 1000

  press "shoot_half"
  sleep 1000

  shoot

  release "shoot_half"

Re: Set zoom problems
« Reply #13 on: 28 / October / 2011, 17:50:51 »
Obviously I'd like to avoid having to do that, but I suppose that will await someone figuring out what this bug is and how to fix it.

Hey - great job finding this work around !   FWIW,  I would not hold my breath waiting for someone to figure this out any farther.  I'm just glad to see a solution of sorts.

Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Set zoom problems
« Reply #14 on: 28 / October / 2011, 18:52:39 »
Nope, an initial sleep command does not work.

However, modifying the script as follows does work; added a single extra shoot before doing the set_zoom a.  If I do that then it will do the set_zoom a correctly before doing the next shoot command.  Weird huh ?  Obviously I'd like to avoid having to do that, but I suppose that will await someone figuring out what this bug is and how to fix it. I'm not skilled enough to do so myself.

rem Test

@param a Zoom Step
@default a 2

  cls
  print "Set when ready..."
  print " "

:check_again
  wait_click
  is_key k "set"
  if k=1 then goto "ok"
  goto "check_again"

:ok
  shoot
  set_zoom a
  sleep 1000

  press "shoot_half"
  sleep 1000

  shoot

  release "shoot_half"

Are you starting the camera in record or playback mode when the script is set to autostart?

If you start in playback mode then the set_zoom won't do anything - zoom is not active unless in record mode.
The 'press shoot_half' command will set the camera to record mode; but you've already done the set_zoom so no zoom will happen.

Putting the extra 'shoot' in will also switch you to record mode, since this is before the set_zoom this time the zoom will happen.

The following code at the start of the script will switch to record mode if the camera is in playback mode (and you can then remove the extra shoot). The first sleep is to make sure the camera is fully started before trying to switch to record - you may need to adjust the sleep value.
Code: [Select]
  if get_mode = 0 then goto "in_rec"
  sleep 1000
  set_record 1
:wait_rec
  sleep 100
  if get_mode <> 0 then goto "wait_rec"
:in_rec

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

Re: Set zoom problems
« Reply #15 on: 29 / October / 2011, 11:04:13 »
Thank you, thank you, thank you.  That did it.  I suspected something like that might be the case, but I didn't know about the set_record command.

Re: Set zoom problems
« Reply #16 on: 29 / October / 2011, 15:24:48 »
Final test script in case anyone is interested.  On the A480 it is interesting; if I use set_zoom X with the variable X set to 2, the script runs about half the time and the other half the time it crashes miserably and the camera shuts down.  In the instances where the camera shuts down, the zoom has an initial quick zoom out and then seems to continue to zoom out in slow motion until the camera turns off.  I can put in any length of sleep command in and around that set_zoom and it makes no difference in its behavior.  If instead I code directly set_zoom 2, then it functions flawlessly every time.  There must be some feedback variables on the zoom motor that CHDK doesn't have full access to or some timing issues with respect to command implementation that sleep isn't going to solve and that results in this flaky behavior. I guess this is just part and parcel of having a hack instead of access to the underlying source for the camera.  Still, this is far far better than not having access to this development platform at all.

rem Test

if get_mode = 0 then goto "in_rec"
  sleep 2000
  set_record 1
:wait_rec
  sleep 100
  if get_mode <> 0 then goto "wait_rec"

:in_rec
  sleep 1000
  set_zoom 4
  sleep 2000
  press "shoot_half"
  sleep 1000
  shoot
  release "shoot_half"

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Set zoom problems
« Reply #17 on: 29 / October / 2011, 21:53:20 »
On the A480 it is interesting; if I use set_zoom X with the variable X set to 2, the script runs about half the time and the other half the time it crashes miserably and the camera shuts down.  In the instances where the camera shuts down, the zoom has an initial quick zoom out and then seems to continue to zoom out in slow motion until the camera turns off. 

Strange - if you put a 'print X' before the set_zoom does it show the correct value?
Is this only on the A480?

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

Re: Set zoom problems
« Reply #18 on: 11 / December / 2011, 10:44:04 »
I had a problem with set_zoom on the A470 crashing the camera. The script was:

@title Zoom Series
@param a Max Zoom
@default a 6
@param b Start Delay
@default b 5
@param d Delay between shots
@default d 10
@param c Direction (+ in/- out)
@default c 1

d = 1000*d - 600
print "Starting..."
if c < 0 then set_zoom a
for j = 0 to b
   print (b-j)
   sleep 960
next j

for i = 0 to a
   if c < 0 then j = a - i else j = i
   set_zoom j
   press "shoot_half"
   sleep 600
   shoot
   cls
   print "Shot " (i + 1)
   sleep d
next i
end

Works fine on SX110 and SX120 (where the max zoom value a should be set to 22).

After the last crash the A470 could no longer load CHDK! Removing the script and its configuration files allowed CHDK to load again.

Hope this helps someone.

Re: Set zoom problems
« Reply #19 on: 11 / December / 2011, 10:48:27 »
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics


SimplePortal © 2008-2014, SimplePortal