114 C H A P T E R 5 Scripting5.5.2 Exposure-related commandsAs 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 areidentified by an index number. Internally, the camera uses an even finerscale: 32 units per 1/3 f-stop (96 units per f-stop). These finer units can alsobe accessed via CHDK functions. Please see Table 5-1 for Tv index and Tv96numbers 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 selectedexposure program. When using CHDK Overrides, however, the user can seteach of those entities to a fixed value. Depending on the camera, exposurecontrol then works in aperture priority mode or exposure time prioritymode. In the case of cameras without diaphragms, it leaves everything tothe user or to a script; because all of the above entities can be retrieved andmost (except Bv) can be set via script commands, it is possible to organizeexposure control through scripts (section 5.7.4).Let’s look at the CHDK commands that are available for exposurecontrol.Exposure time (Tv)r = get_nd_present uBasicr = get_nd_present() LuaReturns info about the neutral density (ND) filter: 0 = filter present, 1 = no built-inND filter, 2 = camera has both a diaphragm and an ND filter.get_tv x uBasicx = get_tv() Luaset_tv x uBasicset_tv(x) LuaRetrieves and sets the real exposure time (Tv) index. x = 0 stands for an exposuretime of 1 second. Negative values indicate longer exposure times, positive values indi-cate shorter times (3 units per f-stop).get_tv96 x uBasicx = get_tv96() Luaset_tv96 x uBasicset_tv96(x) LuaRetrieves and sets the internal real Tv value (96 units per f-stop).get_user_tv_id x uBasicx = get_user_tv_id() Luaset_user_tv_id x uBasicset_user_tv_id(x) LuaRetrieves and sets the index of the exposure time set by the user (3 units per f-stop).