I have been thinking about it since though. Some of the behaviour of the lags as implemented is a little surprising. In particular, the name suggests it slows down changes, but will get there eventually. In truth, it can simply ignore quite significant changes. Even a lag factor of 99 throws out far more data than you might expect. The code is in assembly language, but here is the equivalent C code:
Code: Select all
outpc.batt += (short)((flash4.adcLF * (adcval - outpc.batt)) / 100);
The same behaviour is there for all the lagged variables, but at various levels of importance. Battery voltage is considered in both injector dead time and coil dwell calculations and is probably the most important, and most prone to this problem. A fraction of a degree of temperature difference makes no odds. MAP and EGO don't seem likely to be critical at the last digit.
Suggestions
Two approaches seem plausible.
- Increase resolution by working with hundredths of a volt rather than tenths. Would require updates to ini file and recalibration of voltage limit values in flash.
- Use rounding in the code. I.e. instead of dividing by 100, divide by 50, shift right and add the carry
Code: Select all
lag V exact asis round
10 0.1 0.010 0.000 0.000
10 0.2 0.020 0.000 0.000
10 0.3 0.030 0.000 0.000
10 0.4 0.040 0.000 0.000
10 0.5 0.050 0.000 0.100
10 0.6 0.060 0.000 0.100
10 0.7 0.070 0.000 0.100
10 0.8 0.080 0.000 0.100
10 0.9 0.090 0.000 0.100
10 1.0 0.100 0.100 0.100
10 1.1 0.110 0.100 0.100
10 1.2 0.120 0.100 0.100
10 1.3 0.130 0.100 0.100
10 1.4 0.140 0.100 0.100
10 1.5 0.150 0.100 0.200
10 1.6 0.160 0.100 0.200
10 1.7 0.170 0.100 0.200
10 1.8 0.180 0.100 0.200
10 1.9 0.190 0.100 0.200
20 0.1 0.020 0.000 0.000
20 0.2 0.040 0.000 0.000
20 0.3 0.060 0.000 0.100
20 0.4 0.080 0.000 0.100
20 0.5 0.100 0.100 0.100
20 0.6 0.120 0.100 0.100
20 0.7 0.140 0.100 0.100
20 0.8 0.160 0.100 0.200
20 0.9 0.180 0.100 0.200
20 1.0 0.200 0.200 0.200
20 1.1 0.220 0.200 0.200
20 1.2 0.240 0.200 0.200
20 1.3 0.260 0.200 0.300
20 1.4 0.280 0.200 0.300
20 1.5 0.300 0.300 0.300
20 1.6 0.320 0.300 0.300
20 1.7 0.340 0.300 0.300
20 1.8 0.360 0.300 0.400
20 1.9 0.380 0.300 0.400
30 0.1 0.030 0.000 0.000
30 0.2 0.060 0.000 0.100
30 0.3 0.090 0.000 0.100
30 0.4 0.120 0.100 0.100
30 0.5 0.150 0.100 0.200
30 0.6 0.180 0.100 0.200
30 0.7 0.210 0.200 0.200
30 0.8 0.240 0.200 0.200
30 0.9 0.270 0.200 0.300
30 1.0 0.300 0.300 0.300
30 1.1 0.330 0.300 0.300
30 1.2 0.360 0.300 0.400
30 1.3 0.390 0.300 0.400
30 1.4 0.420 0.400 0.400
30 1.5 0.450 0.400 0.500
30 1.6 0.480 0.400 0.500
30 1.7 0.510 0.500 0.500
30 1.8 0.540 0.500 0.500
30 1.9 0.570 0.500 0.600
40 0.1 0.040 0.000 0.000
40 0.2 0.080 0.000 0.100
40 0.3 0.120 0.100 0.100
40 0.4 0.160 0.100 0.200
40 0.5 0.200 0.200 0.200
40 0.6 0.240 0.200 0.200
40 0.7 0.280 0.200 0.300
40 0.8 0.320 0.300 0.300
40 0.9 0.360 0.300 0.400
40 1.0 0.400 0.400 0.400
40 1.1 0.440 0.400 0.400
40 1.2 0.480 0.400 0.500
40 1.3 0.520 0.500 0.500
40 1.4 0.560 0.500 0.600
40 1.5 0.600 0.600 0.600
40 1.6 0.640 0.600 0.600
40 1.7 0.680 0.600 0.700
40 1.8 0.720 0.700 0.700
40 1.9 0.760 0.700 0.800
50 0.1 0.050 0.000 0.100
50 0.2 0.100 0.100 0.100
50 0.3 0.150 0.100 0.200
50 0.4 0.200 0.200 0.200
50 0.5 0.250 0.200 0.300
50 0.6 0.300 0.300 0.300
50 0.7 0.350 0.300 0.400
50 0.8 0.400 0.400 0.400
50 0.9 0.450 0.400 0.500
50 1.0 0.500 0.500 0.500
50 1.1 0.550 0.500 0.600
50 1.2 0.600 0.600 0.600
50 1.3 0.650 0.600 0.700
50 1.4 0.700 0.700 0.700
50 1.5 0.750 0.700 0.800
50 1.6 0.800 0.800 0.800
50 1.7 0.850 0.800 0.900
50 1.8 0.900 0.900 0.900
50 1.9 0.950 0.900 1.000
60 0.1 0.060 0.000 0.100
60 0.2 0.120 0.100 0.100
60 0.3 0.180 0.100 0.200
60 0.4 0.240 0.200 0.200
60 0.5 0.300 0.300 0.300
60 0.6 0.360 0.300 0.400
60 0.7 0.420 0.400 0.400
60 0.8 0.480 0.400 0.500
60 0.9 0.540 0.500 0.500
60 1.0 0.600 0.600 0.600
60 1.1 0.660 0.600 0.700
60 1.2 0.720 0.700 0.700
60 1.3 0.780 0.700 0.800
60 1.4 0.840 0.800 0.800
60 1.5 0.900 0.900 0.900
60 1.6 0.960 0.900 1.000
60 1.7 1.020 1.000 1.000
60 1.8 1.080 1.000 1.100
60 1.9 1.140 1.100 1.100
70 0.1 0.070 0.000 0.100
70 0.2 0.140 0.100 0.100
70 0.3 0.210 0.200 0.200
70 0.4 0.280 0.200 0.300
70 0.5 0.350 0.300 0.400
70 0.6 0.420 0.400 0.400
70 0.7 0.490 0.400 0.500
70 0.8 0.560 0.500 0.600
70 0.9 0.630 0.600 0.600
70 1.0 0.700 0.700 0.700
70 1.1 0.770 0.700 0.800
70 1.2 0.840 0.800 0.800
70 1.3 0.910 0.900 0.900
70 1.4 0.980 0.900 1.000
70 1.5 1.050 1.000 1.100
70 1.6 1.120 1.100 1.100
70 1.7 1.190 1.100 1.200
70 1.8 1.260 1.200 1.300
70 1.9 1.330 1.300 1.300
80 0.1 0.080 0.000 0.100
80 0.2 0.160 0.100 0.200
80 0.3 0.240 0.200 0.200
80 0.4 0.320 0.300 0.300
80 0.5 0.400 0.400 0.400
80 0.6 0.480 0.400 0.500
80 0.7 0.560 0.500 0.600
80 0.8 0.640 0.600 0.600
80 0.9 0.720 0.700 0.700
80 1.0 0.800 0.800 0.800
80 1.1 0.880 0.800 0.900
80 1.2 0.960 0.900 1.000
80 1.3 1.040 1.000 1.000
80 1.4 1.120 1.100 1.100
80 1.5 1.200 1.200 1.200
80 1.6 1.280 1.200 1.300
80 1.7 1.360 1.300 1.400
80 1.8 1.440 1.400 1.400
80 1.9 1.520 1.500 1.500
90 0.1 0.090 0.000 0.100
90 0.2 0.180 0.100 0.200
90 0.3 0.270 0.200 0.300
90 0.4 0.360 0.300 0.400
90 0.5 0.450 0.400 0.500
90 0.6 0.540 0.500 0.500
90 0.7 0.630 0.600 0.600
90 0.8 0.720 0.700 0.700
90 0.9 0.810 0.800 0.800
90 1.0 0.900 0.900 0.900
90 1.1 0.990 0.900 1.000
90 1.2 1.080 1.000 1.100
90 1.3 1.170 1.100 1.200
90 1.4 1.260 1.200 1.300
90 1.5 1.350 1.300 1.400
90 1.6 1.440 1.400 1.400
90 1.7 1.530 1.500 1.500
90 1.8 1.620 1.600 1.600
90 1.9 1.710 1.700 1.700
Rob.