114 CHAPTER 5 Scripting
5.5.2 Exposure-related commands
As already explained in section 4.2.7, the exposure system of Canon cam-
eras is engineered along the APEX system. All entities ( Av, Tv, Ev, Sv, and Bv)
use a logarithmic scale and are divided into 1/3 f-stop. These units are
identified by an index number. Internally, the camera uses an even finer
scale: 32 units per 1/3 f-stop (96 units per f-stop). These finer units can also
be accessed via CHDK functions. Please see Table 5-1 for Tv index and Tv96
numbers and Table 5-2 for Av index and Av96 numbers.
When not using CHDK Overrides (section 4.3.1), the camera will deter-
mine these values from the measured scene brightness and the selected
exposure program. When using CHDK Overrides, however, the user can set
each of those entities to a fixed value. Depending on the camera, exposure
control then works in aperture priority mode or exposure time priority
mode. In the case of cameras without diaphragms, it leaves everything to
the user or to a script; because all of the above entities can be retrieved and
most (except Bv) can be set via script commands, it is possible to organize
exposure control through scripts (section 5.7.4).
Let’s look at the CHDK commands that are available for exposure
control.
Exposure time (Tv)
r = get_nd_present uBasic
r = get_nd_present() Lua
Returns info about the neutral density (ND) filter: 0 = filter present, 1 = no built-in
ND filter, 2 = camera has both a diaphragm and an ND filter.
get_tv x uBasic
x = get_tv() Lua
set_tv x uBasic
set_tv(x) Lua
Retrieves and sets the real exposure time (Tv) index. x = 0 stands for an exposure
time of 1 second. Negative values indicate longer exposure times, positive values indi-
cate shorter times (3 units per f-stop).
get_tv96 x uBasic
x = get_tv96() Lua
set_tv96 x uBasic
set_tv96(x) Lua
Retrieves and sets the internal real Tv value (96 units per f-stop).
get_user_tv_id x uBasic
x = get_user_tv_id() Lua
set_user_tv_id x uBasic
set_user_tv_id(x) Lua
Retrieves and sets the index of the exposure time set by the user (3 units per f-stop).