So lets start with air. or some kind of measure of air...

I'm going to start with the easy one to understand- a MAF sensor- which measures the Mass Air Flow. Since we mostly know what air fuel to run, if you measure the mass of air, you then know what the fuel mass you need to deliver. It is as simple as that. There are a lot of small calculations that change that down to an event basis, so that an individual injector will inject the right amount of fuel, as the same air mass at 1500 rpm vs. 3000rpm, the amount of fuel injected is twice as much as the other.

When doing the individual event calculations, it's basic thermodynamics to estimate the relative amount of air in the cylinder vs. what an ideal charge would be. And the ratio of actual in cylinder/ideal in cylinder is pretty universally called load. That load information can be also used for spark advance- but more on that later.

The thermo is pV = mRT, Pressure * Volume = mass if gas * gas constant * gas temperature (in absolute amounts).

With that, you can guesstimate the ideal mass amount if pressure is atmospheric, volume is the total cylinder swept volume, and T is normally 100C/373K. And if you know what m should be based on the MAF and corrected down to an event basis, you can estimate P....

Anyway- the point is that on a MAF system, it's pretty easy to calculate the amount of fuel to inject.

But many aftermarket systems use a MAP sensor- measuring Manifold Air Pressure.

This is where it can get weird.

The most simple injection systems will have a table of MAP vs. RPM that outputs a fuel pulse width. I've played with one of those, and while doing ONE calibration is easy- doing a lot, or modifying that for another engine, or changing hardware is a major PITA. Still, getting a desk top calibration is a spreadsheet of ideal gas law formulations away. That will get you close, and then you need to measure exhaust a/f somehow to correct. That also means you know the fuel flow of the injectors.

The next most simple system just uses the ideal gas law to estimate the mass. Since pV = mRT, m = pV/RT MAP = pressure. And YES- you do need to measure the manifold gas temp. Once that calculation is done, there's a correction to it- which is kind of called volumetric efficiency. It's not used exactly how it's actually defined, but close enough to not matter. This is how the MS system works- you have a table of numbers of 0-1 (or higher, sometimes)- and the ideal gas law is corrected to the actual cylinder mass. I don't know the specific name of that table- but I will say that it's a pretty elegant solution. Once you have that correction, then you know how much fuel to inject. Done.

Above that- you can use the MAP and the air temp to run a series of regressions of mass vs. MAP. That's what most OEM's do- as the actual in cylinder mass being really close to correct is really important. It's not a hard calculation, but not the easiest thing in the world to calibrate- and is normally done using a dyno. The calculation is mostly a linear one, but it's so easy to include a MAP^2 term in it, it's done. The equation coefficients change with engine speed AND cam timing- and even though that seems like a lot of stuff to look up- it's still less than having a bunch of tables correcting voleff.

Again, the point of that is to calculate the mass of air, which gives you a simple calculation for the mass of fuel.

The way the MS works is really nice- and hope that whatever you get is similar. That way, calibrations are quite portable. You can take a V8 calibration that has a similar cyl volume, and similar cam timings- and start with that as the base calibration for a 4 or a 6 cyl engine. Just getting it going does not require perfection- just something reasonably close.

All of the systems are tuned via- are you getting what you are asking for? If you want 14.6:1 in the exhaust- are you getting that? If not, make a correction to the table where it's wrong. That does require that you trust your injection flow rates- but you have to trust part of it just to get going.

So on the MAF system- if you should be getting 14:1, and it's either delivering 13:1 or correcting the same amount- then on the MAF transfer function, lower the air flow at that point where it's wrong.

On the basic PW table- lower the pulse width at that Speed/MAP point to match the error.

On the vol eff table like MS uses, lower the amount by 13/14 - (or let the auto-tune do that for you).

While tuning the air calculation does take a lot of time- it's important to know that all of the tables should be smooth and continuous. There are no step functions (unless there is some flapper valve opening or closing). Even the point that a VCT system moves from A to B- it will be pretty smooth- just sudden.