Meter - Completed and Working Scripts - CHDK Forum

Meter

  • 5 Replies
  • 6753 Views
Meter
« on: 19 / June / 2010, 13:43:06 »
Advertisements
Hi

I wanted to be able to use my IXUS 850 as a meter for my old film cameras (many of which don't have meters) - it was possible using the OSD, but not ideal, so I wrote this script in LUA.   Feedback much appreciated.

FEATURES
- it doesn't affect your camera settings (it resets any changes it does make, and these are minimal)
- not limited by hardware capabilities (camera shutter speed or aperture)
- Supports Spot and Centre-weighted metering
- fast startup
- attempts to minimize battery consumption

I have done my best to make it portable, but don't have any other devices to test it on; please let me know if it does or doesn't work on your model.

DESIGN NOTES
1. It uses the camera meter to get the brightness value - Aperture and Shutter Speed are calculated mathematically (Bv+Sv=Av+Tv) by the program (not using the camera's in internal routines) so it is not limited by the hardware.  
2. At present, the program only alters the metering mode and zoom setting and the focusing mode.  All are reset to the original settings before it exits.
3. Spot metering is done at full zoom - this means you can meter directly off a person's face when they are ten feet away.  Ideal for the lazy.
4. Centre-weighted metering is done at slightly less than minimum zoom - on the Ixus850, this gives about the right field of view for a 40mm (35mm equivalent) lens, which is close to the typical lens fitted to old film cameras.

TESTING/BENCHMARK
I have tested against my Pentax K100D with both centre-weighted and spot metering, and its usually bang on or within 1/3 stop, which is within a sensible margin of error for real world photography.

ENHANCEMENTS - in priority
1. Restore settings even if you use SHUTTER to quit
2. My eyes are getting old, so I would REALLY like to make the text bigger.
3. Automatically change the shutter speed to a valid range when reading is OVER or UNDER
4. Add more speed settings No Point - mechanical shutters are not that accurate
4. remove the high speed settings above 1/8000
5. Switch f-stop intervals between 1/3,1/2 and full f stop
6. Remove ISO settings above 6400
7. Ought to disable IS to save more power

Anyway, thanks for CHDK - its absolutely fantastic.

Jon

Code: [Select]
--[[
@title Weston Meter
rem Author: daviesjpuk@gmail.com
rem Version : 1.0
rem Description : Turns your CHDK camera into a spot or centre weighted meter.  Tested on SD800 IS.
@param a Film Speed
@default a 16
@param b Shutter Speed
@default b 13
@param c Mode Centre/Spot
@default c 0
@param d Meter Adjustment
@default d 0
--]]

-- standard ISO speeds - see [url=http://en.wikipedia.org/wiki/Film_speed#Film_speed_systems]Wikimedia Error[/url]
FilmSpeed = {6, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64, 80, 100,125,160,200,250,320,400,500,640,800,1000,1250,1600,2000,2500,3000,3200,4000,5000,6400,12800,25600,51200,102400}
-- film SV [url=http://johnlind.tripod.com/science/scienceexposure.html]Photographic Science:  Exposure[/url]
sv96=   {90,130,161,186,226,257,288,322,353,384,418,449,480,511,545,576,607,641,672,703,737,768,798, 830, 864, 895, 925, 951, 960, 991, 1022,1056,1152, 1248, 1344, 1440}

ShutterSpeed = {"1/16000","1/8000 ","1/4000 ","1/2000 ","1/1000 ","1/500  ","1/250  ","1/125  ","1/60   ","1/30  ","1/15  ","1/8    ","1/4    ","1/2    ","1s     ","2s     ","4s     ", "8s     ", "15s    ","30s    ","1m     ","2m    ","4m    ","6m    "}
tv96 = {1341,   1245,    1149,    1053,    957,     861,    765,    669,    567,   471,    375,   288,  192,  96,  0,  -96,-192,-288,-375,-471,-567,-663, -759, -855}

-- Fno96= {0,51,93,147,192,243,285,331,384,435,477,527,576,624,664,710,768,816,856}
maxav96={-18,30,76,125,174,222,268,313,363,414,460,507,556,605,648,692,745,797,840,884}
Fno= {"LOW ","f1  ","f1.2 ","f1.4","f1.7","f2  ","f2.4","f2.8","f3.3","f4  ","f4.8","f5.6","f6.7","f8  ","f9.5","f11 ","f13 ","f16 ","f19 ","f22 ","OVER"}

props=require("propcase")
Settings = {}

function Mode ()
if c<1 then
-- minimal zoom, centre weighted
set_zoom(1)
set_prop(props.METERING_MODE,2)
else
-- maximum zoom, point meter
set_zoom(get_zoom_steps())
set_prop(props.METERING_MODE,1)
end
end

function MeterScene()
press ("shoot_half")
sleep (1500)
release ("shoot_half")
end

function SettingsSave ()
-- Settings[1]=get_nd_filter()
Settings[2]=get_prop(props.FOCUS_MODE)
Settings[3]=get_prop(props.METERING_MODE)
---   Settings[4]=get_prop(props.WB_ADJ)
return
end

function SettingsRestore ()
-- set_nd_filter(Settings[1])
set_prop(props.FOCUS_MODE,Settings[2])
set_prop(props.METERING_MODE,Settings[3])
--   set_prop(props.WB_ADJ,Settings[4])
return
end

function SettingsMetering ()
-- nd filter OUT, Focus manual (so it doesnt hunt)
-- set_nd_filter(2)
set_prop(props.FOCUS_MODE,4)
return
end

function FnoLookup(Reading)
    for i=1,table.getn(maxav96),1 do
if Reading<maxav96[i] then
return i
end
end
return table.getn(Fno)   -- didn't find one - use the biggest
end

function Results ()

local av96

-- av+tv=bv+sv
av96=get_bv96()+d+sv96[a]-tv96[b]

if c==0 then
MODE="CENTRE"
else
MODE="SPOT  "
end

print (string.format("ISO %6d    Mode %s",FilmSpeed[a],MODE))

print (string.format("   %s    %s",ShutterSpeed[b],Fno[FnoLookup(av96)]))

print ("[DISP.] help  [MENU] end")

return
end

function help ()
---     1234567890123456789012345
cls ()
print ("Film ISO      [Up][Down]")
print ("Shutter       [<][>]")
print ("Spot/Centre   [Zoom]")
print ("Meter         [SET]")
print ("End           [MENU]")
wait_click ()
end


SettingsSave()
SettingsMetering()
Mode ()
MeterScene()

repeat
cls()
Results()
  wait_click ()
if is_key("set") then
MeterScene()
elseif is_key("down") then
if a>1 then a=a-1 end
elseif is_key("up")  then
if a<table.getn(FilmSpeed) then a=a+1 end
elseif is_key("left") then
if b>1 then b=b-1 end
elseif is_key("right") then
if b<table.getn(ShutterSpeed) then b=b+1 end
elseif is_key("zoom_in") then
if c ~= 1 then
c=1
Mode()
MeterScene()
end
elseif is_key("zoom_out") then
if c~= 0 then
c=0
Mode()
MeterScene()
end
elseif is_key("display") or is_key("print") then
help()
end
until is_key("menu")

SettingsRestore()
press ("print")
« Last Edit: 23 / June / 2010, 13:25:04 by daviesjpuk »

Re: Meter
« Reply #1 on: 21 / June / 2010, 20:18:32 »
Cool idea. But I get an error of

:86: attempt to perform arithmetic on global 'tv96' (a table value) PRESS SHUTTER TO CLOSE

Did I do something wrong or is there some simple edit to make it work? This is on an S2 IS.


Re: Meter
« Reply #2 on: 23 / June / 2010, 04:23:12 »
You didn't do anything wrong!  I screwed up the process of posting the code, and lost a small (but vital) piece.

I have modified my original message - I'd be grateful if you'd give it another try and let me know how it goes. 

Thanks

Jon

Re: Meter
« Reply #3 on: 26 / June / 2010, 03:59:49 »
Thanks for fixing it. It seems to work now. The only issue I had was in setting the zoom setting for spot metering. It worked, but then when zooming back out the camera shut down when it reached the wide limit. Each time I turned it back on it kept doing that. Until I quickly tried to change the zoom setting when it was powering up or trying to run the script again. Eventually one of those times unsaved some script setting, or something. I didn't try using the zoom feature again with the script. It was too hard to get it out of whatever crash condition it got stuck in, for me to want to try it again.

Otherwise I think it's a neat idea and everything else it is meant to do seems to work as stated. I really like how you included the little help screen too. More scripts could/should use that idea.

*

Offline an0n

  • ***
  • 152
Re: Meter
« Reply #4 on: 26 / June / 2010, 07:34:47 »
@daviesjpuk,

Hi,

Tested the script with default values (centre), and mode to 1 (spot) with an A720IS.

Appears to work ok, although have yet to apply the obtained settings to a film camera, I am
interested to try that, and will report when I have. I did see that the Subject Distance shortcut
key still works when script is stopped even though NO OVERRIDES is shown. I too liked the help
dialogue. Thanks for the effort, and publishing the script.

Cheers
A720IS.

Re: Meter
« Reply #5 on: 09 / July / 2010, 01:41:06 »
hey this is a pretty sweet idea - works well on my SD870.     The built in help was a nice bonus.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal