Max. focus = 65536, or 65535? - Script Writing - CHDK Forum

Max. focus = 65536, or 65535?

  • 1 Replies
  • 1452 Views
Max. focus = 65536, or 65535?
« on: 06 / June / 2012, 18:18:39 »
Advertisements
This looks like a very minor question, only a millimeter out of 65 meters, but the uBASIC docs say that maximum distance we can command the lens to focus to is 65536mm.  That's a familiar number to anyone who works in binary, 2^16, and that's why it worries me.  Do Canon and CHDK read the lowest 16 bits of the binary number, or the 17th bit, or something more arbitrary?  If I enter 65535, the camera processor gets the binary number 1111111111111111  If I enter 65536 and the camera only cares about the lowest 16 bits, then it sees  (1)0000000000000000, so having added 1 to the previous number turns the result to 0.  Or does the camera look for that 17th bit and interpret that alone as infinity?

Or does it use 32-bit numbers and only care that the number is greater than 65535?

I notice that CHDK's focus override counts up to 65535, then loops back to zero in my S3 IS.

Eric
S3 IS with LensMate filter/hood adapter

*

Offline philmoz

  • *****
  • 3356
    • Photos
Re: Max. focus = 65536, or 65535?
« Reply #1 on: 06 / June / 2012, 18:30:57 »
Old cameras used a 16 bit unsigned value for focus distance.
Newer cameras use a 32 bit value.
Some posts on this:
http://chdk.setepontos.com/index.php?topic=7482.msg80116#msg80116
http://chdk.setepontos.com/index.php?topic=2509.msg79886#msg79886

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)

 

Related Topics