SX30 IS Release - available on the autobuild server - page 27 - CHDK Releases - CHDK Forum  

SX30 IS Release - available on the autobuild server

  • 282 Replies
  • 87813 Views
Re: SX30 IS Release - available on the autobuild server
« Reply #260 on: 19 / December / 2011, 21:18:53 »
Advertisements
Hi CHDK folks!

SX30 100p running 0.9.9-1487full that I compiled on Win7x64 with CHDK-shell

I am struggling to get focus all the way to infinity at full zoom in a script on the SX30. I can get it partway there, but not all the way.

I poked around in the code and was using ptpcamgui and realized that (at least for the SX30) get_focus() was returning 32 bits (and the focus value was greater than 65535). I assumed it must be 32-bit signed integer since I see a value of -1 sometimes, but when I try set_focus(2147483647), I only got 126582 the first time, then 128866 the next couple times, and now I just got 129366.

Any insight? This value looks like it must be infinity for the SX30, based on comparison to when I zoom to infinity with the camera, but I don't quite know why it's that number... though it's pretty close to 2x65535...

Also, is there a way to call a CHDK shortcut from within a script, like the alt+up one that zooms me to infinity?

On a related note, I am having a helluva time using any focus code but the code philmoz sent me earlier that uses left-right-click iterations to get to infinity. If I use set_prop(props.FOCUS_MODE,1) and get_prop(props.Focus_Mode), I can see that the prop values are changing, but for the life of me I can't write a script that uses those to set focus to infinity. I get a crash either there or when I try to take a pic.

Is the set_prop function not fully implemented? Here's philmoz's code that works:

Code: [Select]
-- switch to manual focus mode and focus to infinity
function pre_focus()
   print("SetFocusInfinity")
-- attempt to set focus to infinity
  local p = get_prop(props.FOCUS_MODE)
  if p == 1 then
    print "Manual focus (MF) found"
  else
    while p ~= 1  do
  sleep(500)
      click("left")
      click("right")
      click("set")
  sleep(500)
      p = get_prop(props.FOCUS_MODE)
    end
    print "Focus set to manual (MF)"
  end

  local focused = false
  print("focusing to infinity")
  set_focus(65535)
  focused = true
  return focused
end
and mine that doesn't (replete with debugging print statements):
Code: [Select]
function pre_focus()
   print("SetFocusInfinity")
-- attempt to set focus to infinity
  local p = get_prop(props.FOCUS_MODE)
  if p == 1 then
    print("Manual focus (MF) found")
  else
    set_prop(props.FOCUS_MODE,1)
    p = get_prop(props.FOCUS_MODE)
if p == 1 then
  print("Manual focus (MF) set!")
  sleep(1000)
else
  print("Manual focus failed")
              sleep(1000)
    end
    print("Focus function complete")
    sleep(1000)
  end

  local focused = false
  print("focusing to infinity")
  sleep(1000)
  print("autofocus unlocked")
  set_focus(50000)
  print("focus locked to big number")
  sleep(1000)
  focused = true
  return focused
The script dies when setting focus to 50000 (or 0, or anything I try)

Thanks for any insight,

Andy


A720 1.00c | D10 1.00b |SX220 1.01a | SX230 ? | SX30 1.00p CHDK ver. 1.1.0-r1727

*

Offline philmoz

  • *****
  • 3146
    • Photos
Re: SX30 IS Release - available on the autobuild server
« Reply #261 on: 20 / December / 2011, 03:47:17 »
Hi CHDK folks!

SX30 100p running 0.9.9-1487full that I compiled on Win7x64 with CHDK-shell

I am struggling to get focus all the way to infinity at full zoom in a script on the SX30. I can get it partway there, but not all the way.

I poked around in the code and was using ptpcamgui and realized that (at least for the SX30) get_focus() was returning 32 bits (and the focus value was greater than 65535). I assumed it must be 32-bit signed integer since I see a value of -1 sometimes, but when I try set_focus(2147483647), I only got 126582 the first time, then 128866 the next couple times, and now I just got 129366.

Any insight? This value looks like it must be infinity for the SX30, based on comparison to when I zoom to infinity with the camera, but I don't quite know why it's that number... though it's pretty close to 2x65535...

Also, is there a way to call a CHDK shortcut from within a script, like the alt+up one that zooms me to infinity?

On a related note, I am having a helluva time using any focus code but the code philmoz sent me earlier that uses left-right-click iterations to get to infinity. If I use set_prop(props.FOCUS_MODE,1) and get_prop(props.Focus_Mode), I can see that the prop values are changing, but for the life of me I can't write a script that uses those to set focus to infinity. I get a crash either there or when I try to take a pic.

Is the set_prop function not fully implemented? Here's philmoz's code that works:

Code: [Select]
-- switch to manual focus mode and focus to infinity
function pre_focus()
   print("SetFocusInfinity")
-- attempt to set focus to infinity
  local p = get_prop(props.FOCUS_MODE)
  if p == 1 then
    print "Manual focus (MF) found"
  else
    while p ~= 1  do
  sleep(500)
      click("left")
      click("right")
      click("set")
  sleep(500)
      p = get_prop(props.FOCUS_MODE)
    end
    print "Focus set to manual (MF)"
  end

  local focused = false
  print("focusing to infinity")
  set_focus(65535)
  focused = true
  return focused
end
and mine that doesn't (replete with debugging print statements):
Code: [Select]
function pre_focus()
   print("SetFocusInfinity")
-- attempt to set focus to infinity
  local p = get_prop(props.FOCUS_MODE)
  if p == 1 then
    print("Manual focus (MF) found")
  else
    set_prop(props.FOCUS_MODE,1)
    p = get_prop(props.FOCUS_MODE)
if p == 1 then
  print("Manual focus (MF) set!")
  sleep(1000)
else
  print("Manual focus failed")
              sleep(1000)
    end
    print("Focus function complete")
    sleep(1000)
  end

  local focused = false
  print("focusing to infinity")
  sleep(1000)
  print("autofocus unlocked")
  set_focus(50000)
  print("focus locked to big number")
  sleep(1000)
  focused = true
  return focused
The script dies when setting focus to 50000 (or 0, or anything I try)

Thanks for any insight,

Andy




Your sample code works fine on my SX30 - perhaps post the full script in case the problem lies elsewhere.

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)

Re: SX30 IS Release - available on the autobuild server
« Reply #262 on: 20 / December / 2011, 22:25:50 »
Your sample code works fine on my SX30 - perhaps post the full script in case the problem lies elsewhere.

Phil.
I've attached the full script here. please use caution - enabling the disk checking size and number of files to delete (and uncommenting the os.delete command) will allow deleting images from the card.

Thanks for taking a look.
A720 1.00c | D10 1.00b |SX220 1.01a | SX230 ? | SX30 1.00p CHDK ver. 1.1.0-r1727

*

Offline philmoz

  • *****
  • 3146
    • Photos
Re: SX30 IS Release - available on the autobuild server
« Reply #263 on: 21 / December / 2011, 00:50:11 »
Your sample code works fine on my SX30 - perhaps post the full script in case the problem lies elsewhere.

Phil.
I've attached the full script here. please use caution - enabling the disk checking size and number of files to delete (and uncommenting the os.delete command) will allow deleting images from the card.

Thanks for taking a look.


There does seem to be some strangeness in the numbers returned by get_focus as you zoom to the telephoto end - I'll do some investigating (but may not be till the new year).

set_focus(65535) seems to work in all cases on my camera to set infinity though.

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)


Re: SX30 IS Release - available on the autobuild server
« Reply #264 on: 23 / December / 2011, 03:22:09 »
There does seem to be some strangeness in the numbers returned by get_focus as you zoom to the telephoto end - I'll do some investigating (but may not be till the new year).

set_focus(65535) seems to work in all cases on my camera to set infinity though.
This is driving me nuts.

I made a script that loops through all 200 zoom steps doing this:

1)set zoom to the loop variable (starts at 0)
2)read get_zoom() into a variable (zoomLvl)
3)read get_focus() into a variable (startFocus)
4)read get_hyp_dist() into a variable (hyfDist)
5)set_focus(hyfDist)
6)read get_focus() into another variable (hyfFocus1)
7)set_focus(65535)
8)read get_focus() into another variable (infFocus)
9)set focus back to the hyperfocal distance
10) read get_focus() again, to hyfFocus2.

then I log "timestamp,zoomLvl,startFocus,hyfDist,hyfFocus1,infFocus,hyfFocus2"

and get a nice table. Well, that's what I hoped.

I got the hyperfocal distance, but I can't set focus at all in the script. It's behaving very strangely. I run it in P or M mode and if I enable a block that sets manual focus, it dies when it tries to zoom to 1 (loop iteration 2). If I don't set manual focus, it goes all the way through, but I can't get it to focus. Any pointers? Tried with several builds. script and table attached.  here's a (badly formatted) preview of the table:

timestamp      zoomLvl   startFocus   hyfDist   hyfFocus1   infFocus   hyfFocus2
20111222_23:02:43   0   2703      654      2965   2965   2703
20111222_23:02:46   1   404         706      400      400      397
20111222_23:02:49   2   1109      728      1148   1148   1109
20111222_23:02:52   3   423         743      423      436      436
20111222_23:02:55   4   394         764      400      397      397

Hopefully I just suck at lua.
A720 1.00c | D10 1.00b |SX220 1.01a | SX230 ? | SX30 1.00p CHDK ver. 1.1.0-r1727

*

Offline philmoz

  • *****
  • 3146
    • Photos
Re: SX30 IS Release - available on the autobuild server
« Reply #265 on: 23 / December / 2011, 05:24:12 »
There does seem to be some strangeness in the numbers returned by get_focus as you zoom to the telephoto end - I'll do some investigating (but may not be till the new year).

set_focus(65535) seems to work in all cases on my camera to set infinity though.
This is driving me nuts.

I made a script that loops through all 200 zoom steps doing this:

1)set zoom to the loop variable (starts at 0)
2)read get_zoom() into a variable (zoomLvl)
3)read get_focus() into a variable (startFocus)
4)read get_hyp_dist() into a variable (hyfDist)
5)set_focus(hyfDist)
6)read get_focus() into another variable (hyfFocus1)
7)set_focus(65535)
8)read get_focus() into another variable (infFocus)
9)set focus back to the hyperfocal distance
10) read get_focus() again, to hyfFocus2.

then I log "timestamp,zoomLvl,startFocus,hyfDist,hyfFocus1,infFocus,hyfFocus2"

and get a nice table. Well, that's what I hoped.

I got the hyperfocal distance, but I can't set focus at all in the script. It's behaving very strangely. I run it in P or M mode and if I enable a block that sets manual focus, it dies when it tries to zoom to 1 (loop iteration 2). If I don't set manual focus, it goes all the way through, but I can't get it to focus. Any pointers? Tried with several builds. script and table attached.  here's a (badly formatted) preview of the table:

timestamp      zoomLvl   startFocus   hyfDist   hyfFocus1   infFocus   hyfFocus2
20111222_23:02:43   0   2703      654      2965   2965   2703
20111222_23:02:46   1   404         706      400      400      397
20111222_23:02:49   2   1109      728      1148   1148   1109
20111222_23:02:52   3   423         743      423      436      436
20111222_23:02:55   4   394         764      400      397      397

Hopefully I just suck at lua.


Try the attached build for SX30 1.00p.

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)

Re: SX30 IS Release - available on the autobuild server
« Reply #266 on: 23 / December / 2011, 16:13:16 »
Try the attached build for SX30 1.00p.

Phil.
Hi Phil,

I threw your test firmware on my camera and ran the script again in M mode.

With MF enabled, it gets through more iterations, and properly sets focus to the hyperfocal distance.

But but not to infinity. It still crashes the camera at the same point in the script --set_zoom(i)--, and not always at the same interval. I recorded crashes at iteration 61, 21, and 14 in M mode and 5 and 16 in P mode (I changed logging so the log is cleaner and more verbose, and writes the print statements to the log) .Here are the results of the longest test, I clean it up to remove the verbose logging in successful iterations.

Code: [Select]

--- Log opened at 2011-12-23@11:33:56 ---
platform: sx30 100p
version: CHDK 0.9.9 built on Dec 23 2011 21:22:16
Focus set to manual (MF)
--- Log closed at 2011-12-23@11:33:56 ---

--- Log opened at 2011-12-23@11:33:57 ---
platform: sx30 100p
version: CHDK 0.9.9 built on Dec 23 2011 21:22:16

start of test
timestamp zoomLvl startFocus hyfDist hyfFocus1 infFocus hyfFocus2
20111223_11:34:03 0 3288 654 660 -1 660
20111223_11:34:09 1 656 711 766 -1 720
20111223_11:34:15 2 735 728 750 -1 766
20111223_11:34:21 3 782 748 799 -1 782
20111223_11:34:27 4 815 769 783 -1 815
20111223_11:34:33 5 815 791 799 -1 815
20111223_11:34:39 6 849 814 832 -1 849
20111223_11:34:45 7 867 833 867 -1 867
20111223_11:34:52 8 886 857 886 -1 849
20111223_11:34:58 9 927 880 891 -1 909
20111223_11:35:04 10 946 906 927 -1 927
20111223_11:35:10 11 946 932 946 -1 967
20111223_11:35:16 12 1000 958 981 -1 1020
20111223_11:35:23 13 1063 986 1041 -1 981
20111223_11:35:29 14 1041 1013 1041 -1 1041
20111223_11:35:35 15 1063 1037 1063 -1 1041
20111223_11:35:41 16 1134 1067 1063 -1 1109
20111223_11:35:47 17 1085 1097 1153 -1 1153
20111223_11:35:54 18 1153 1127 1131 -1 1177
20111223_11:36:00 19 1227 1160 1201 -1 1201
20111223_11:36:06 20 1211 1229 1342 -1 1281
20111223_11:36:12 21 1362 1266 1253 -1 1334
20111223_11:36:18 22 1334 1301 1307 -1 1391
20111223_11:36:24 23 1334 1338 1362 -1 1422
20111223_11:36:30 24 1405 1376 1405 -1 1461
20111223_11:36:37 25 1461 1414 1405 -1 1491
20111223_11:36:43 26 1559 1460 1559 -1 1461
20111223_11:36:49 27 1640 1502 1461 -1 1559
20111223_11:36:55 28 1648 1544 1615 35932 1615
20111223_11:37:01 29 1615 1592 1583 -1 1683
20111223_11:37:08 30 1648 1637 1753 -1 1648
20111223_11:37:14 31 1790 1684 1648 -1 1790
20111223_11:37:20 32 1753 1737 1790 -1 1868
20111223_11:37:26 33 1779 1786 1926 -1 1887
20111223_11:37:32 34 1814 1842 1967 -1 1926
20111223_11:37:38 35 2009 1894 2009 -1 2009
20111223_11:37:44 36 2009 1957 2100 -1 1967
20111223_11:37:51 37 2058 2018 1977 -1 2147
20111223_11:37:57 38 2054 2077 2197 -1 2147
20111223_11:38:03 39 2229 2141 2276 50302 2276
20111223_11:38:09 40 2375 2209 2325 -1 2229
20111223_11:38:15 41 2387 2281 2297 57504 2435
20111223_11:38:22 42 2435 2358 2297 33535 2435
20111223_11:38:28 43 2428 2428 2535 38329 2428
20111223_11:38:34 44 2589 2504 2484 -1 2645
20111223_11:38:40 45 2589 2587 2703 -1 2764
20111223_11:38:46 46 2764 2668 2828 -1 2828
20111223_11:38:52 47 2965 2753 2903 -1 2843
20111223_11:38:58 48 2903 2840 2903 64683 2903
20111223_11:39:05 49 3028 2934 2965 -1 3093
20111223_11:39:11 50 2965 3038 3232 64683 3232
20111223_11:39:17 51 3288 3135 3218 47916 3361
20111223_11:39:23 52 3218 3234 3438 -1 3438
20111223_11:39:29 53 3288 3349 3602 -1 3438
20111223_11:39:36 54 3487 3455 3565 -1 3647
20111223_11:39:42 55 3953 3578 3609 -1 3861
20111223_11:39:48 56 3861 3691 3773 -1 3953
20111223_11:39:54 57 3811 3823 4080 57504 4080
20111223_11:40:00 58 4108 3960 3930 -1 4203
20111223_11:40:07 59 4203 4091 4108 -1 4408
20111223_11:40:13 60 4633 4236 4108 -1 4303
zoomvar = 61
about to crash camera
setting zoom to 61

I'll try it without the MF code now.
A720 1.00c | D10 1.00b |SX220 1.01a | SX230 ? | SX30 1.00p CHDK ver. 1.1.0-r1727

Re: SX30 IS Release - available on the autobuild server
« Reply #267 on: 23 / December / 2011, 17:48:59 »
Just ran the script again with the MF codeblock disabled and it went fine. I ran it in P mode, first, then in M, and got two different results for hyperfocal distance, both of which were different than the value I got in the previous code.

I posted a google spreadsheet with the values here.

Went through all modes and max hyperfocalDist seems to run between 365916 and ~750000.

Do you think it might have something to do with the bug identified in this post?

Let me know if the google spreadsheet link is better or if you want some other file (or none).
Oh, here's a pretty chart too (attached PDF)
A720 1.00c | D10 1.00b |SX220 1.01a | SX230 ? | SX30 1.00p CHDK ver. 1.1.0-r1727


Re: SX30 IS Release - available on the autobuild server
« Reply #268 on: 24 / December / 2011, 12:26:08 »
I ran my timelapse script (modified to use hyperfocal distance instead of infinity) overnight with the SX30(p) and an SX220. Zoom set to 50% on both.

The SX220 focused fine, but the SX30 is out of focus.

It's still running the test version you posted.
A720 1.00c | D10 1.00b |SX220 1.01a | SX230 ? | SX30 1.00p CHDK ver. 1.1.0-r1727

*

Offline philmoz

  • *****
  • 3146
    • Photos
Re: SX30 IS Release - available on the autobuild server
« Reply #269 on: 12 / January / 2012, 19:36:47 »
I ran my timelapse script (modified to use hyperfocal distance instead of infinity) overnight with the SX30(p) and an SX220. Zoom set to 50% on both.

The SX220 focused fine, but the SX30 is out of focus.

It's still running the test version you posted.

Updated
The latest version on the autobuild server should (hopefully) fix the crash problem - it seems to have sorted it out on my camera at least. If you can test it that would be great.

I'm still looking at the focus distance and hyper-focal stuff.
What I've learned so far:
- hyper focal distance is dependant on aperture so you will get different values depending on the aperture setting chosen before running the script
- it's not clear yet if changing the zoom position in a script also updates the aperture (e.g. if you zoom to telephoto the previous aperture may no longer be valid). the aperture may not update until you half press the shutter - this may cause incorrect hyper-focal distances to be calculated.

- The get_hyp_dist function calculates the hyper focal distance using the maximum available aperture for the chosen zoom position. If you have manually set another aperture for taking a shot and set the focus to the calculated hyper focal distance the result may not be what you expected.

- because of the extreme zoom on the SX30 the hyper focal distance can be very large at the telephoto end (up to around 800 metres). the camera appears to only be able to set the focus distance to a maximum of 80 metres so for telephoto zoom lengths it may be better to set the focus to infinity.
- The SX30 (and SX40) support focus distances greater than 65535; but CHDK limits the value sent to the firmware to a max of 65535. Removing this code limit allows the camera to set longer focus distances.

- CHDK assumes an infinity focus value of 65535 (approx 65 metres); but this may not be correct for the SX30 (as above it seems to be able to set the focus distance larger than this).

- I am still trying to determine the correct 'infinity' value for the SX30.

I'll post more info once I've done some more investigation.

Phil.
« Last Edit: 13 / January / 2012, 02:22:27 by philmoz »
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)

 

Related Topics