Conversion of get_tv96 to actual shutter speed - CHDK limitations - General Discussion and Assistance - CHDK Forum supplierdeeply

Conversion of get_tv96 to actual shutter speed - CHDK limitations

  • 2 Replies
  • 4130 Views
Advertisements
I'm basically trying to write a quick light meter given a fixed aperture setting. This will give you the cameras estimated shutter speed for a given light condition. (This is useful for those of us without manual, Tv, Av modes).

Basics..
Code: [Select]
Tv = log2 (1 / T)

lets say x is our shutter speed (1/100)
x = 100

the value y, will be the camera's value for 1/100 (get_tv96) which is around 637
y = ~637

[(ln(x) / ln(2)) x 96] = y

solving for x we get..

x = e^(y/96 * ln(2))

Obviously CHDK doesn't have a log/ln function, nor does it have the constant "e". I can get around this, since I can hard-code approximations of "e" and ln(2). However, CHDK doesn't appear to have an exponent function, so I'm stuck.

Am I doing this the hard way? Is there a function that will just display Tv as a fraction? I suppose even a decimal might work at this point..


« Last Edit: 13 / May / 2010, 13:28:34 by BrandonSi »

*

Offline reyalp

  • ******
  • 14080
Re: Conversion of get_tv96 to actual shutter speed - CHDK limitations
« Reply #1 on: 15 / May / 2010, 01:28:28 »
The camera values are in APEX*96. So you could just work in APEX units, they really are much more sensible ;) See http://dougkerr.net/Pumpkin/articles/APEX.pdf

You can get the values for full stops by bit shifting.
apex = tv96/96
if apex >= 0
value = 1/(1 << apex)
else
value = 1 << -apex

If you want, you can fudge the remainder of tv96/96 in afterward
The 1/  above hast to be implied or added as text, since both scripting languages use integers only.
shifting in lua is done with functions documented here http://chdk.wikia.com/wiki/LUA/LUA_Reference

In lua, you could also easily make a table mapping APEX*96 values to string or number representations of the TV. Full, 1/3, and 1/2 stops should be all the stock firmware uses (all conveniently exact fractions of 96). CHDK overrides might use arbitrary values, in which case you'd want to round.
Don't forget what the H stands for.

Re: Conversion of get_tv96 to actual shutter speed - CHDK limitations
« Reply #2 on: 18 / May / 2010, 10:37:26 »
Thanks reyalp! I had no idea both scripting languages did not support floating point numbers.. I guess I am stuck with Apex. Thanks :)

 

Related Topics