Thank you very much for the insight @aferris2, much appreciated!I used to be involved in the software design of these. Never did anything on VW, but did work with several other manufacturers. They all work in a similar way though.
As the ECU's are usually supplied by the likes of Bosch, Delphi etc it is no wonder they are similar between vehicle brands. After all, R&D is expensive and there's a limited set of sensor and actuator types to work with so it would be total waste to completely redesign the platforms for each brand.
These counters make it much easier to process continual accumulation of various things (in addition to fuel usage, you also have similar systems for distance travelled and running time). For fuel usage, the raw data will come from the engine controller sisnce it knows how much fuel is squirted in by the injectors. The idea is that you can sample the counter values at a relatively slow rate. Fuel used (in this case) is the difference between this sample and the previous one. So, as long as you sample at least once per cycle of the counter, you get the right value for the fuel used. To work out the short term and long term fuel efficiencies, you just add all of the individual differences and do some fancy maths.
This makes absolutely perfect sense from realtime perspective, which the vehicle CAN is undoubtedly designed for. It's just a nuisance from analysis point of view as the dbc file syntax is not powerful enough to do the accumulation directly and some additional code is required. For simplicity, I just iterated over all recorded samples and accumulated on 15 bit register overflow - the overflow is anyway frequent enough at every 32.768mL of fuel consumed. No fancy maffs were hurt.
I've encountered also some other signals that are hard or not at all possible to handle with dbc, even by resorting to extended multiplexing. So, while dbc handles the bulk signal extraction nicely enough it's just not covering all the bases.
Fuel tank level will use the signal from the sensor in the fuel tank, not the fuel used signal from the ECM. Many vehicles have only one sensor, but quite a few have more than one. This signal tends to be very noisy (think about fuel sloshing around in the tank as you go over bumps and round corners) so there is a lot of filtering needed to get a stable reading. Add in algorithms to cope with tank filling (and emptying) and resting on slopes and it gets really complicated. Essentially you work out what the fuel level is when the ignition is turned on by comparing the new reading with the reading when you last switched the ignition off. Big changes mean more (or less) fuel in the tank. Small changes are probably due to sitting on a slope.
Finally, there will be a map to convert fuel tank sensor level to true tank level as a percentage. This should compensate for the shape of the tank which will very rarely be a nice rectangular box. Of course, this only works if the tank doesn't change shape between development and actual production of the final vehicle.
Complex indeed. This is basically why I wanted to have a more stable consumption metric, the tank level is pretty coarse and simply wrong in many occasions. I guess one of these days I probably have to make another synthetic consumption estimate signal based on @mmi special formula (using average injection quantities) and see how that compares to what's reported by ECU.
On T6 there's btw this adaptation that might affect how the needle moves - but I haven't looked into it at all and don't know if the reported CAN values would also be affected:
Code:
IDE00714-MAS00888-Additional coding-Tank characteristic curve,1 ,1
@aferris2 any tips on recommended reading materials regarding ECU design, CAN or something along those lines?