The problems we had to face with the scripts where the following:
Switch to photo/video mode
This is now a standard feature of CHDK, so the custom core is no longer necessary, the scripts will work with the "main" CHDK trunk.
Shooting photos in the stratosphere would be cool, shooting videos would be cool to, so shooting photos and videos would be twice as cool!
The problem is, in our camera switching from photo mode to video mode and back requires moving a physical switch on the camera, and there's no-one up there to do that.
The standard CHDK version does not yet support this, and the only case where it has been done is on a single type of camera the A570IS. The hack is discussed here. This is a function that is quite useful for all cases where you want your camera to take photos and videos in an un-attended situation, like UAV (unmanned aerial vehicles), KAP (kite aereal photography) and our case.
By playing with the C source of CHDK, I managed to hack this change for our camera too (even though in a much less elegan way that was done for the A570).
General mission control
Our photographic strategy required that we changed the behaviour of the camera during the mission: shoot fewer photos in the first phase of the ascent, shoot more photos in high altitude, and shoot here and some videos in specific moments.
I developed a general-purpose scheduler (as a LUA script running under CHDK) that allows to specify a sort of "mission shedule".
The base idea is that we define a MET (mission elapsed time, ain't it cool to link to NASA to explain your terms ?) and that we are able to tell the camera "at this time in mission, execute this piece of code".
We therefore have METs (mission elapsed time expressed in seconds) and METp: mission elapsed time expressed in periods. In this case, we call a "period" an arbirary length of time that will limit the "granularity" of the scheduler. For example, if we decide that a period lasts 60 seconds, we will be able to define our mission with a 1-minute resolution.
From the software poin of viw, it's all rather primitive: as interrupts are not supported in CHDK, it's all polled, this means that somewhere in the program there is a lop that repeatedly calls a function refresh_mets() that checks the time elapsed and (if needed) calls snippets of code that have been scheduled.
Mode detail about the scheduler in this post in the CHDK forum.
Fast TV mode
This was a quite critical part, completely replacing the exposure calculations made by Canon and attempting to expose in a different way, better suited to our purpose.
The calculation of exposure settings in a camera are a bit arcane, but I discovered that it's more difficoult to find some documentation than to actually perform the calculations themselves.
The basics are: you have the following values:
- Luminosity of the scene (how much light is there?)
- Aperture (how big is the hole that we have to let the light in, and how much do we enlarge this image?)
- Shutter time (for how long will we keep the shutter open?)
- Sensitivity (how fast does our "film" react to light?)
all these factors can be changed, and only if they satisfy a certain equation the photo will be correctly exposed.
The calculations are a bit tricky, but mainly because we are accustomed to using certain measure of units: if you accept using other, unusual unts of measure and to express all these values with their base-2 logarithm, the calculations become very easy.
That's the so-called APEX (Additive system of Photographic EXposure), developed in the '60s. All those values are expressed in logarithmic units called Av (Aperture value), Sv (Sensitivity value), Tv (Time value) and Bv (Brightness Value). More details on the APEX system in this Wikipedia page, but if you really want to understand you should read this PDF file by Douglas A. Kerr.
To transform between these values, these Excel files might be handy:
Tv to seconds conversion: TV_SEC.XLS
Sv to ISO conversion: SV_ISO.XLS
The exposure equation then gets simple and elegant:
Av + Tv = Bv + Sv
Internally, Canon cameras already use the APEX system, with the only difference that we store the values in 1/96th step, to avoid floating point calculations.
So, Tv is internally expressed as Tv96, and for example a value of 542 Tv96 is equivalent to 6.645 Tv and to 0.0199 seconds, that is about 1/50th of a second.
Once I understood all this, my fast TV routines became rather simple:
- Get the shutter time I wanted (Tv)
- Measure the luminosity of the scene (Bv) using the camera's meter
- Aperture is fixed in my camera (Av)
- I get the ISO value (Sv) that will correctly expose the photo
The only caveats where:
- Do not go below a certain ISO value (the camera has a fixed limit on this)
- Do not go below a certain ISO value (photos become very noisy when ISO gets too high)