How to use CHDK-PT or other tool to view focus length table in firmware? - Firmware Dumping - CHDK Forum  

How to use CHDK-PT or other tool to view focus length table in firmware?

  • 4 Replies
  • 2092 Views
Advertisements
Hi,

I am trying to accurately set focus to infinity in a script for my SX30. I keep crashing it or overshooting the zoom by guesstimating, and I am getting ranges from ~5000 max to around 126000 max depending on the zoom step. I already have the code to calculate focus, I just need the table so I can make a linear or polynomial fit to it.

I saw in the main.c for my camera the following:
Code: [Select]
// Focus length table in firmware @ FFFEA5CC
#define NUM_FL 201 // 0 - 200, entries in firmware
extern int focus_len_table[NUM_FL];
Can I use CHDK-PT to see this? I got confused as to where it would be - primary.bin or one of the generated files. I am still very much learning. I couldn't even find the address in the primary.bin file, so I am a wee bit lost...

Here's what I'm doing to focus (using an equation I derived from a table for G5 or something, which is very wrong for the SX30)
Code: [Select]
  local focused = false
  print("calculating infinity")
  infinity = 6*get_zoom()^2-(100*get_zoom())+5000
  print("infinity = ",infinity)
  sleep(1000)
  print("focusing to infinity")
  set_focus(infinity)
  focused = true
  return focused

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

*

Offline philmoz

  • *****
  • 3123
    • Photos
Re: How to use CHDK-PT or other tool to view focus length table in firmware?
« Reply #1 on: 20 / December / 2011, 03:52:45 »
Hi,

I am trying to accurately set focus to infinity in a script for my SX30. I keep crashing it or overshooting the zoom by guesstimating, and I am getting ranges from ~5000 max to around 126000 max depending on the zoom step. I already have the code to calculate focus, I just need the table so I can make a linear or polynomial fit to it.

I saw in the main.c for my camera the following:
Code: [Select]
// Focus length table in firmware @ FFFEA5CC
#define NUM_FL 201 // 0 - 200, entries in firmware
extern int focus_len_table[NUM_FL];
Can I use CHDK-PT to see this? I got confused as to where it would be - primary.bin or one of the generated files. I am still very much learning. I couldn't even find the address in the primary.bin file, so I am a wee bit lost...

Here's what I'm doing to focus (using an equation I derived from a table for G5 or something, which is very wrong for the SX30)
Code: [Select]
  local focused = false
  print("calculating infinity")
  infinity = 6*get_zoom()^2-(100*get_zoom())+5000
  print("infinity = ",infinity)
  sleep(1000)
  print("focusing to infinity")
  set_focus(infinity)
  focused = true
  return focused

Thanks for any pointers

Despite the name, focus_len_table contains the focal lengths for zooming not setting subject distance (focus).

set_focus(65535) will set infinity (provided you are in manual focus mode).

BTW - how do you overshoot infinity?

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: How to use CHDK-PT or other tool to view focus length table in firmware?
« Reply #2 on: 20 / December / 2011, 06:19:10 »
I am trying to accurately set focus to infinity in a script for my SX30.

For small sensor cameras with large depth-of-field the statement is meaningless.

At wide angle, focusing at two metres (or even nearer) will bring infinity "into focus".

At telephoto, it will be many metres.

By focusing at 65535 you will be losing foreground focus.

Why not just focus at hyperfocal distance ?

Everything from half that distance to infinity will be in focus.

Re: How to use CHDK-PT or other tool to view focus length table in firmware?
« Reply #3 on: 20 / December / 2011, 22:21:24 »
 
Why not just focus at hyperfocal distance ?

Everything from half that distance to infinity will be in focus.
um... Oh... then yes, I want to focus at hyperfocal distance.

That will be even better I think (but the stuff I want to see is pretty much 100 to 5000 meters away). So how can I easily set focus to the hyperfocal distance? I still need the focal length table to calculate hyperfocal distance, yes? Looking at the equation now.. doesn't look too bad, but then I need to query aperture (with get_tv()?) to calculate F-value, and then I have to figure out how big my circle of confusion is somehow... (feels pretty close to infinite right now ;))

Despite the name, focus_len_table contains the focal lengths for zooming not setting subject distance (focus).
Sorry I didn't clarify. I realized that, I was just going to use it to calculate infinity, much as a DOF post I read was doing for the SX20.

set_focus(65535) will set infinity (provided you are in manual focus mode).
I thought that was the case, until I got back values that were twice as high as infinity. :o
I was setting focus to 65535 with no zoom and it seemed to work fine, but when I was all the way zoomed on the SX30, that 65535 didn't get me to infinity. When I manually set the focus to infinity at full zoom (with lever), and queried it with get_focus(), I got values that were more like 126582 to 129386, like I described in another post.

Anyway, I am confusedissimo, but making progress. I've attached the full script I am working on, if you're interested in taking a look.. Philmoz also replied to the zoom portion in the SX30 IS release thread here, but I don't know if either (or both) of these threads is the right place for script discussion...
A720 1.00c | D10 1.00b |SX220 1.01a | SX230 ? | SX30 1.00p CHDK ver. 1.1.0-r1727


*

Offline philmoz

  • *****
  • 3123
    • Photos
Re: How to use CHDK-PT or other tool to view focus length table in firmware?
« Reply #4 on: 20 / December / 2011, 22:38:24 »

That will be even better I think (but the stuff I want to see is pretty much 100 to 5000 meters away). So how can I easily set focus to the hyperfocal distance? I still need the focal length table to calculate hyperfocal distance, yes? Looking at the equation now.. doesn't look too bad, but then I need to query aperture (with get_tv()?) to calculate F-value, and then I have to figure out how big my circle of confusion is somehow... (feels pretty close to infinite right now ;))


In Lua the "get_hyp_dist" function should do this for you.

Quote

Anyway, I am confusedissimo, but making progress. I've attached the full script I am working on, if you're interested in taking a look.. Philmoz also replied to the zoom portion in the SX30 IS release thread here, but I don't know if either (or both) of these threads is the right place for script discussion...


Will take a look later tonight and let you know.

I haven't seen get_focus return anything larger than 65535 on my camera; but I've been wrong before :)

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)

 

Related Topics