Results 1 to 15 of 15

Thread: Equation Calculating MAF g/sec from WBO2, Help With VE

  1. #1
    Senior Tuner
    Join Date
    Sep 2008
    Posts
    1,668

    Equation Calculating MAF g/sec from WBO2, Help With VE

    I've got an equation working to calculate a MAF table from my WBO2 data, it works really really really well...I can put just about anything in the table that'll run, take the car for a drive, log the drive, copy and paste directly into the MAF table...interpolate the frequencies below idle and above the rev limiter (to make it look pretty I guess) then I can go log %error, and find I'm usually within 1-2%.

    The equation I'm logging is [USER.9004]*[PID.6200]*([PID.6210.G/SEC]/1000)*([PID.12]/2)*8/60 ...USER.9004 is my Wideband...which I actually log in Lambda and then convert to AFR based on the alcohol % as mass requires AFR to calculate...

    Anyways, PID.6200 is pulsewidth average from bank 1 (bank 2 is the same as I'm in open loop with LTFT zero'd). PID.6210 is injector flowrate, and PID.12 is RPM...so my equation is airmass in g/sec = afr * pulsewidth in milliseconds * ifr in g/sec / 1000 * (rpm /2) * 8 / 60. The trick I've found is to setup the histogram to log the MAF cells you want, and then frequencies a little below and a little above the actual cells...this means the data you get in the cells that goes into the tune is averaged closer to that actual frequency...so if for example I'm getting a lot of data at 3525hz, it wont affect my 3450 or 3600 cells...it'll go into the cells in the middle...I'll only get data in the 3450 cell if I'm actually between 3425 and 3475 hz, and only in the 3600 cell between 3575 and 3625hz...it makes the histogram look huge, but it seems to be better about not letting too much data between cells skew the averages.

    I'm doing this in my 2010 Camaro, which has a fuel pressure sensor...so my IFR is calculated realtime based on that pressure and the MAP sensor reading...I don't know if this will work as well in a car without a fuel pressure sensor. I also don't think this will work with a gen 3 computer...the Gen 4 computers (and hopefully Gen 5 too) report theoretical pulsewidth, not actual...so they actually subtract the dead time/offset from the actual pulsewidth before reporting it...so you can get an accurate calculation of the mass of fuel injected from the scan tool data...to do it on a gen 3, you'd need to output the data somewhere and then subtract dead time from actual to get theoretical...then I guess it should work.

    That said, I had THOUGHT, that I could derive GMVE numbers from this same air mass equation by dividing by MAP, and multiplying by cylinder air charge temp in Kelvin (which is calculated by the PCM before the scan tool from the IAT/CTS bias I believe) and 8 (number of cylinders)...this seems to result in some really screwed up VE numbers though...like well over 8000 at 6400 RPM in my heads/cam LS3...very very unrealistic numbers that I can't even try to use.

    Can anyone help me with the units for GMVE...I guess I don't understand them as well as I'd hoped to, or as well as I need to.
    Last edited by MikeOD; 10-16-2013 at 10:44 AM.
    2010 Camaro SS M6. Stock Bottom End, Heads/Cam/Intake/Headers/Exhaust.
    2005 Silverado RCSB. Forged 370 LQ9/Borg-Forced Inductions T6 S484/Jake's Stage 4 4L80E with D3 Brake/4WD.
    2023 Durango Hellcat

  2. #2
    Senior Tuner DSteck's Avatar
    Join Date
    Mar 2008
    Location
    St. Louis, MO
    Posts
    4,856
    Just out of curiosity, why not log the wideband error directly for the MAF and apply the error? The reason I don't use a back calculation for MAF calibrations is that the data in the MAF table does not translate directly to the final pulse width commanded by the ECM because it goes through a smoothing filter first. When putting calculated values into the MAF table, you can end up with a skewed table that never dials in.

    DSX Tuning - Authorized HP Tuners Dealer
    http://www.dsxtuning.com
    http://www.facebook.com/dsx.tuning
    Just say no to bull s***.
    IF YOU WANT HELP, POST A FILE!

  3. #3
    Just trying to look over some old chicken scrawl and some other peoples calcs and it seems to be mg.*K/kPa although I can barely read my paperwork because its faded badly. I guess a google search may yield the result, I haven't actually tried yet. I typically create GMVE from cylinder airmass based on MAF with either lambda error corrected or STFT corrected depending on what I'm doing. The injector pulse width is the other method (corrected or raw), like you mentioned above. If your equation results in g/secs, I think your GMVE derivation is missing a couple of aspects like rpm.

    My understanding is GMVE would be:

    g/sec x 15 (for 8 cyl) x 1000 (due mg) x MAT (*K) / MAP x RPM

    Have a quick look over that, I haven't got time to double check that and doing it in a complete rush, but seems reasonable.

    Edit: was typing at the same time as Dsteck, but agreed apply the error however you derive it directly in to the calc

  4. #4
    Senior Tuner
    Join Date
    Sep 2008
    Posts
    1,668
    Dave, using it as a starting point to dial in a MAF that's way out where %error requires multiple wash and repeats...this seems to get me into the ballpark so that I can then just apply %error once and I'm good to go on the MAF. Expirimenting on my Camaro, but I've got a few similar cars to tune that it works on...saves me some steps...when %error is out a lot, I can piece through it tediously and change cells individually based on how bad the error is in each one (if it' 4% here, 15% there and so on)...but that just takes time...this way is drive, copy and paste, then drive again, and copy and paste again...MAF is then pretty much good to go...I haven't had an issue with a skewed sensor/table...I know the sensor is filtered, but it's working surprisingly well.

    SSUte01, where does the 15 in your equation come from?
    2010 Camaro SS M6. Stock Bottom End, Heads/Cam/Intake/Headers/Exhaust.
    2005 Silverado RCSB. Forged 370 LQ9/Borg-Forced Inductions T6 S484/Jake's Stage 4 4L80E with D3 Brake/4WD.
    2023 Durango Hellcat

  5. #5
    120/8. 120 (60 x 2 from secs and ignition stroke) and 8 cylinders.

  6. #6
    Senior Tuner
    Join Date
    Sep 2008
    Posts
    1,668
    g/sec (calculated from WBO2) x 15 (for 8 cyl) x 1000 (due mg) x MAT (*K) / MAP x RPM makes MUCH more realistic numbers...I'm going to try to get a bit of a better data log running MAF only (more data above 4K RPM) on my way to work this morning...so I'm sure everyone in traffic will love me HAHA...I'll see how it looks and if it makes sense I'll flash it in and try to drive home SD only and see how things work out.
    2010 Camaro SS M6. Stock Bottom End, Heads/Cam/Intake/Headers/Exhaust.
    2005 Silverado RCSB. Forged 370 LQ9/Borg-Forced Inductions T6 S484/Jake's Stage 4 4L80E with D3 Brake/4WD.
    2023 Durango Hellcat

  7. #7
    Senior Tuner
    Join Date
    Dec 2004
    Location
    Laurel, MD
    Posts
    1,020
    AFRwb=air to fuel ratio, by definition. For our purposes, I will use it per single cylinder, and use mass ratios.
    CAM cylinder air mass
    FM cylinder fuel mass
    AFRwb=CAM/FM
    FM=IFR*IPW (amount=rate * time)
    Merge the equations above:
    CAM=AFRwb*IFR*IPW

    CAM can have two forms, one for MAF, and one for VE, let's do MAF as it's simpler first
    Also remember MAF is a total airflow, so you gotta convert from single cylinder airmass to total, and converting RPM (per minute) to per seconds, so the units agree. Also 2 crank rotations are 1 fueling cycle (4 stroke)
    MAF=CYL*CAM*RPM/(2*60)
    CAM=120*MAF/(CYL*RPM)

    Joining CAM estimations from fuel and from MAF:
    120*MAF/(CYL*RPM)=AFRwb*IFR*IPW

    This equation above allows you to calibrate MAF from fuel consumption. If you got fuel pressure data, you can expand your IFR into a form with MANVAC, BARO, and all that jazz. This exercise is left to the reader

    Form 2, Fuel and GMVE:
    From before:
    CAM=AFRwb*IFR*IPW
    CAM from SD model:
    CAM=GMVE*MAP/MAT (MAT is a temp estimator, it can get complicated in the newer ECUs, or you can just trust that it's correct and use the values the scanner gives you)

    AFRwb*IFR*IPW=GMVE*MAP/MAT
    or isolating GMVE:
    GMVE=AFRwb*IFR*IPW*MAT/MAP

    This allows you to get your GMVE from fuel consumption. Again, if you got fuel pressure sensor, you can make your IFR more realistic


    Practical notes I've never seen anywhere else:
    1. do NOT use average (read: arithmetic mean) values directly in the scanner. arithmetic mean is horrible susceptible to outliers. Since our data is horribly noisy, outliers are frequent, thus your calcs are going to be not as good as they could be. Chopping data up into small areas (aka 'histogram', which btw, is a wrong name for what it does if you're doing anything else but counting frequency) can be detrimental as now you have small amount of data per area, which can make statistical operations (like arithmetic mean) less than useful. Thus, don't use the scanner, treat all GMVE values as if they were on a single surface, and use the median not the arithmetic mean. WAY better results this way.

    2. MAP values on the axis are not precise, since we get them with 0 decimal points. if you look at MAP values as a time series, you're gonna see 98 98 98 97 97 98 97...obviously it does not jump around like that, it's probably something like 98.4 98.0 97.7 97.5 97.4 97.8 97.4 it just gets rounded up. You can get those values by smoothing the MAP values before you start doing any math on them. You cannot do this in the scanner, so again, feel free to abandon it.

  8. #8
    Senior Tuner DSteck's Avatar
    Join Date
    Mar 2008
    Location
    St. Louis, MO
    Posts
    4,856
    What noob uses AFR? Use lambda.

    DSX Tuning - Authorized HP Tuners Dealer
    http://www.dsxtuning.com
    http://www.facebook.com/dsx.tuning
    Just say no to bull s***.
    IF YOU WANT HELP, POST A FILE!

  9. #9
    Senior Tuner
    Join Date
    Sep 2008
    Posts
    1,668
    Marcin,

    I understand why the mean (average) is a poor choice with our noisy data...but why the median over the mode for each piece of the puzzle in the equation? If I'm able to collect IPW, MAT, FP and AFR data at a specific RPM/MAP hit point say for 100 frames, and I understand the limits of significant digits with my consumer grade NGK AFX wideband and thus lop the data off after the decimal before the point where every frame is a unique and meaninglessly different number, if a large amount of those frames are the same number, that is not necessarilly the median, I'd think that data was a more realistic representation of what I should really be plugging back into the equation to come up with the GMVE number for that part of the map. I could be wrong, I don't have the mathematical background you have, but I do want to learn so if I am wrong please tell me why if it's not a bother.

    Dave,

    The Wideband is in lambda...but when calculating mass, unless I'm mistaken, lambda is meaningless without knowing what stoich for the fuel is, and then coming back from lambda with that stoich value to determine afr. You can set the equation up to take a lambda input, it just means you're adding some more math into the equation taking into consideration the alcohol content. You're probably using an alcohol sensor for the X value in here Y=-0.057x+14.67822 (which is stoich for gasoline/alcohol blending from 0-100%) and that's probably buried somewhere in your GMVE equation against your lambda input. Fuel mass is as simple as Marcin put it, IFR times IPW (subtract the injector dead time from the IPW beforehand...which the E38 and E67 kindly do for us), in order to calculate air mass from fuel mass, lambda won't do, AFR does though.
    2010 Camaro SS M6. Stock Bottom End, Heads/Cam/Intake/Headers/Exhaust.
    2005 Silverado RCSB. Forged 370 LQ9/Borg-Forced Inductions T6 S484/Jake's Stage 4 4L80E with D3 Brake/4WD.
    2023 Durango Hellcat

  10. #10
    Senior Tuner
    Join Date
    Dec 2004
    Location
    Laurel, MD
    Posts
    1,020
    Median is the simplest of 'robust' metrics (methods that do not get easily swayed by outliers). There are (much!) more complicated methods to do it, but median works surprisingly well for our data, in my experience. You are correct in that with large amount of data, the arithmetic mean works well, and if you look at the cells with lots of data (normal cruise range) it's all fine. However, other ranges, like WOT and transitions don't get nearly as much data, it's actually difficult to gather 30-50 samples, necessary for your typical statistical functions to become useful.

    I would not be so quick to 'chop off' decimal numbers. If anything, I'd rather 'introduce' detail by pre-processing my data with smoothing (like I described for the MAP values). Noise and imprecisions are a natural thing, and as long the system isn't producing data with non-normally distributed noise, it will work itself out numerically in the process. If you're curious/not sure, plot the raw values against the mean ('residual analysis')

    Also my mathematical background is mostly Google, Wikipedia, and Matlab documentation so don't take me too seriously, I'm just sharing what I've seen playing with ECU data for few years

  11. #11
    Senior Tuner DSteck's Avatar
    Join Date
    Mar 2008
    Location
    St. Louis, MO
    Posts
    4,856
    I do not use alcohol content in my math, but I do use the wideband lambda, commanded lambda, and the commanded AFR in the calculation to alleviate the fact that stoich AFR varies with ethanol content.

    DSX Tuning - Authorized HP Tuners Dealer
    http://www.dsxtuning.com
    http://www.facebook.com/dsx.tuning
    Just say no to bull s***.
    IF YOU WANT HELP, POST A FILE!

  12. #12
    Senior Tuner
    Join Date
    Sep 2008
    Posts
    1,668
    Quote Originally Posted by DSteck View Post
    I do not use alcohol content in my math, but I do use the wideband lambda, commanded lambda, and the commanded AFR in the calculation to alleviate the fact that stoich AFR varies with ethanol content.
    That does the same thing as just using lambda and alcohol content. By working with commanded lambda and commanded AFR you're arriving at the same place...in a car that's got flex fuel. If the car doesn't have flex fuel are you flatlining the Stoich AFR table to match what the fuel should be in order to be sure your commanded AFR falls in line with the actual correct value?
    Last edited by MikeOD; 10-16-2013 at 11:52 AM.
    2010 Camaro SS M6. Stock Bottom End, Heads/Cam/Intake/Headers/Exhaust.
    2005 Silverado RCSB. Forged 370 LQ9/Borg-Forced Inductions T6 S484/Jake's Stage 4 4L80E with D3 Brake/4WD.
    2023 Durango Hellcat

  13. #13
    Senior Tuner DSteck's Avatar
    Join Date
    Mar 2008
    Location
    St. Louis, MO
    Posts
    4,856
    Why would you try to calculate something instead of reading it straight from the ECM? What if I have to edit the stoich AFR table because a certain car just doesn't perform the way it should with the stock one? What if you scale by doubling the stoich AFR table and cutting the injector flow rate in half?

    I never flatline the stoich AFR table in a non flex fuel vehicle unless I'm using one of my tricker boxes.

    The point is that you should ALWAYS use what the ECM provides you because that's what's actually being used to calculate the amount of required fuel.
    Last edited by DSteck; 10-16-2013 at 12:10 PM.

    DSX Tuning - Authorized HP Tuners Dealer
    http://www.dsxtuning.com
    http://www.facebook.com/dsx.tuning
    Just say no to bull s***.
    IF YOU WANT HELP, POST A FILE!

  14. #14
    Senior Tuner
    Join Date
    Sep 2008
    Posts
    1,668
    Quote Originally Posted by DSteck View Post
    Why would you try to calculate something instead of reading it straight from the ECM? What if I have to edit the stoich AFR table because a certain car just doesn't perform the way it should with the stock one? What if you scale by doubling the stoich AFR table and cutting the injector flow rate in half?

    I never flatline the stoich AFR table in a non flex fuel vehicle unless I'm using one of my tricker boxes.

    The point is that you should ALWAYS use what the ECM provides you because that's what's actually being used to calculate the amount of required fuel.
    So you're saying the E38/E67 directly output what they think the stoich AFR is at any given time? I don't see that PID.

    If you're using commanded lambda, actual wideband lambda, and commanded AFR, then in order to calculate the actual fuel mass, you're still going backward from commanded lambda and commanded AFR to get the current stoich that the computer thinks in order to use your wideband lambda to calculate the fuel mass. It's 2 different ways of calculating the same thing.
    2010 Camaro SS M6. Stock Bottom End, Heads/Cam/Intake/Headers/Exhaust.
    2005 Silverado RCSB. Forged 370 LQ9/Borg-Forced Inductions T6 S484/Jake's Stage 4 4L80E with D3 Brake/4WD.
    2023 Durango Hellcat

  15. #15
    Senior Tuner DSteck's Avatar
    Join Date
    Mar 2008
    Location
    St. Louis, MO
    Posts
    4,856
    Quote Originally Posted by MikeOD View Post
    So you're saying the E38/E67 directly output what they think the stoich AFR is at any given time? I don't see that PID.

    If you're using commanded lambda, actual wideband lambda, and commanded AFR, then in order to calculate the actual fuel mass, you're still going backward from commanded lambda and commanded AFR to get the current stoich that the computer thinks in order to use your wideband lambda to calculate the fuel mass. It's 2 different ways of calculating the same thing.
    /facepalm

    The way you suggested uses an ASSumed function for the relationship of stoich AFR to ethanol content. Don't do that.

    DSX Tuning - Authorized HP Tuners Dealer
    http://www.dsxtuning.com
    http://www.facebook.com/dsx.tuning
    Just say no to bull s***.
    IF YOU WANT HELP, POST A FILE!