After my last post I drank some more wine, read the comments it generated and got down to some jolly good proper thinking. I realised that I was distracting myself with standard deviation and such like, and a more empirical approach may work.
The rough pseudo code is
for each log entry that isn't filtered out by temp/RPM etc
Find the AFR in the future by doing a bilinear interpolation on a delay table
Find the actual VE by doing a bilinear interpolation on this record
Find the target AFR by doing a bilinear interpolation on this record
Work out how far out of whack the actual AFR is
For each of the 4 cells involved in the current reading, add a weighted adjustment record depending on where the bilinear interpolation lands
for each cell that has more adjustment records than the minimum number of hits required
Calculate a weighted average adjustment to apply to the cell
create a new VE table by applying the adjustments to the base table
And it seems to work. Circa a couple of hundred lines of the finest Javascript to run in your browser.
I captured a fairly long log file where the car was definitely running lean, and it recommended adding quite a bit of fuel into a number of cells.
I then drove the car to work on Tuesday morning, and captured a new log. This said I was running too rich and I should take some fuel out
I then drove home and captured a new log. This said I was still a little rich, but it looks like I’m homing in on what the values should be
There is a degree of oscillation going on, which I hope will smooth out over time. I suspect there is some realtime PID code going to go into MSDroid at some point in the future, but for now I’m happy with what I’ve done with it.
I also added the ability to export the new MSQ file, and the ability to load a second one to compare the VE tables in them. I realised that this was far away from the original ‘Log Viewer’ idea (Yay! Go Go Creeping Featureitis!) so the original URL has been deprecated and this is now officially https://VEAnal.smithfamily.org.uk
I did have an idea about tuning the Lambda delay table by doing a binary search on potential values but it only seemed to make any difference with small log files. I guess in the long term, everything is average.