Hi,
As PICaxe maths is rather "weak", conversion from log to linear is probably best done using a "piecewise linear" graph transfer characteristic (from a lookup table of data). The advantage is that most of the nasty maths can be done by a curve-fitting process in a spreadsheet such as Excel. Basically, it's the same process as required for (NTC) thermistor calibration and for Sin/Cos/Tan etc. conversions (and their inverses), etc. (which it happens I have a need for, all in one program). Ideally, one should not just take sample (line-end) points from the transfer characteristic, but do (e.g.) a least-squares fit of each line, perhaps even taking into account that PICaxe integer calculations always round down.
However, I couldn't find much on the PICaxe forum except a good example from Jeremy Leach (for ATAN), but that uses nearly all of an M2's named variables (which thus have to be pushed/swapped into the extended RAM space). So I decided to write my own "General Purpose" interpolation (sub-)routine to handle multiple lookup tables (of piecewise-linear transfer characteristic data). I hope to post it in the code snippetts section eventually, so won't give a listing here, as you don't have an immediate need. To Keep It SimpleS, I assumed only a continuous positive gradient in about 16 linear sections of equal size. That shouldn't be a severe limitation because an NTC just needs the scale reversed (e.g. TempC = 100 - TempC) and trignometric angles can be handled my "mirroring" the positive quadrant, etc..
Each line segment is the diagonal of a rectangular "cell" where the position of the lower left corner can be calculated, then its height from the table, to give the gradient. Then the position along the line/sides calculated as a simple ratio (division) and the corner offset added. I used 256 points across the width of each cell and up to 65,535 for the height (i.e. a Word lookup table), thus ~12 bits of input data map to a 16 bits output range. For the "inverse" operation a simple search of the table is first used to find the required cell.
_____
However, it isn't too difficult to make wide range luminance measurements with (just) a PICaxe. The trick is to use a current to time (or frequency) converter (aka an oscillator). The PIcaxe can then use a 16-bit counter-timer (e.g. Timer1 with its Gate Control logic) to achieve up to 1:65k resolution or dynamic range. Timing the period gives more resolution at low light levels (currents) whilst counting a frequency gives more resolution at high brightness levels.
For example, a BPW32 photodiode gives about 8 mA at peak solar level, whilst the input leakage of a PICaxe pin is about 5 nA (max 120 nA) so a range of up to 1,000,000:1 can be possible (e.g. using one of the internal comparators to implement the oscillator). Even a single continuous scale may be possible using Timer1 as the primary Counter/Timer, with the PICaxe checking for overflows of the 16-bit value (if you can work around the PICaxe's operating system). Again, I have had a prototype working for some time with an 08M2, using only an external photodiode, 100 nF capacitor, a transistor or diode and a couple of resistors, which hopefully will one day make its way into the code snippetts section.
Cheers, Alan.