RomRaider
Documentation
Community
Developers

Author 
Message 
86inches

Post subject: MAF Shaping and Scaling Spreadsheet Posted: Sat Jan 14, 2017 2:31 pm 


Newbie 
Joined: Mon Dec 29, 2014 12:03 pm Posts: 91

Hello all, I made this spreadsheet because I could never get my MAF quite right. It took some time to figure out exactly how to set this up but once I got it working I was beyond happy with the results.
The point of this tool is to shape a MAF calibration. There are other tools out there to SCALE a MAF calibration from logs.
The intended use here is to use one of the other tools available in this forum to scale a MAF off of logs. Most likely that scaled MAF is going to be buttugly with lots of jump and shakes in it. I tried one of those and it never worked quite right, the MAF calibration wants to be smooth.
SHAPING the MAF to ride the middle(best fit line) of the SCALED calibration was not easy and took a lot of guess work. It occurred to me that maybe the solution is to look at the first derivative of Flow Rate with respect to Voltage. That sort of worked. Then I looked at the second derivative and thats where I found my solution.
The way to SHAPE a MAF curve is by its second derivative. You calibrate and adjust those values then numerically integrate them twice to get a SCALED and SHAPED MAF Calibration.
The second derivative itself is another problem. That took some trial and error to solve. What I found was that (surprise!) you want to start with an exponential function. I chose e^x at first but then later modified it so that the base can be chosen by the user. Some base other than e may work better than others.
In this case I found the x in e^x to be equal to MAF V / Saturation Voltage. Where Saturation Voltage is the Voltage at which the MAF Flow Rate reaches its maximum calibrated value (for example if the max table voltage is 4.7V but you actually reach your measurement limt at 4.4V then 4.4V is the saturation voltage).
To this exponential function I add a line called "CAL" The user will want to adjust the values in this line to actually perform the scaling. As you change CAL to adjust the the second derivative try to concentrate on getting the best fit line for the first derivative more so than the MAF curve itself.
Explanation When you open this there will be a lot of information in front of you. Let me try to explain what it is. One caveat before I begin, copying tables and lines from RomRaider will bring a cell of identification information with them. Before copying anything into this spreadsheet you may need to copy it into a blank excel document first in order to manually remove the identification cell. First of all, don’t touch anything highlighted in grey or yellow. Anything with green text is in shaping the MAF curve. The 1st line is intentionally left blank for aesthetics and note keeping. The 2nd line is MAF V, you will want to paste in the voltage scale you are using. The 3rd line is the MAF Calibration you are trying to reshape or fit a line to. The 6th line has 5 cells which are used to calibrate the first couple cells of the MAF Scale. The 8th line has 1 cell which is the first value of the MAF scale, its best to start with the first value from the MAF calibration that you pasted in and then adjust from there. The 11th line is where the magic happens. These are the values that you will set in order to shape the calculated MAF curve. The 13th line is where you can paste in an optional graph for comparison. For example, the stock curve or the curve you had before rescaling by logs. Line 17 is the saturation voltage. Line 18 is the exponent base. There are 3 graphs each with three lines in them. In all graphs the BLUE line is the MAF Curve you’re trying to fit. The RED line is the Calculated MAF. The GREEN line is the comparison. The leftmost graph contains the MAF Curves. The middle is the first derivative, the right is the second derivative. The yellowhighlighted line is how closely the Calculated MAF value is to the Origin MAF value. The peach highlighted line is how closely the second derivative of the calculated MAF value is to the original. Both are just a ratio. A value of 1 indicates they are the same value, greater than one and the calculation is larger than the original, less than one and the calculation is less than the original.
Instructions So on this spread sheet I have made all the values you need to adjust a bold bright green text, anything you should not touch is greyed out.
1) Paste in the MAF V scale you are to use. 2) Paste the Scaled MAF into the MAF line. 3) Paste the Stock MAF into the Comparison Line. 4) Set the smallest MAF value, Start with what the smallest value is in stockcurve. 5) Set the Tau constant to the Saturation Voltage (if unknown use the largest MAF V value) 6) Set the Base exponent value, start with e. 7) Set all CAL values to 0
8 ) Now, look at the line called % Original MAF. PAY CLOSE ATTENTION TO THIS. Thats why I highlighted it. Then by changing the first 5 values for second derivative of the calculated MAF, "d2M/dV2 C" get the first 6 values of %Original as close to 1.000 as you can.
9) Once that is done start adjusting the values in the CAL line from left to right. Observe the MAF Curve and the first derivative curve to see how well you're SHAPING the curve. Try to concentrate on making a best fit of the First derivative and judge accuracy on the MAF curve itself. Because this is a numerical integration Cal values at lower MAF V points will affect final values at high MAF V points; the cal values have a cumulative effect from left to right. So as you go cell by cell you may want to go back to cells you’ve already adjusted and tweak them a little bit.
Notes. Dont be afraid to use negative numbers. Dont be afraid to adjust the base, tau or initial MAF C value to get things to line up. If you're starting from a good calibration already then be very very skeptical of any values that are more than 7% away from the original value. As I was developing this I made the mistake of reducing measured airflow in some of the idle cells down to 7585% of original and the motor could barely stay running.
You may need to drag out the rows if you have a larger number of boxes (I think the STI MAF has more break points). If you do this you will need to also adjust the graph data ranges. Remember that for both row and column indicators in excel that a $ preceding the row/column reference denotes that it is a constant that will not change during dragging.
The Default Blue MAF is the Stock USDM 2002 WRX MAF. Red is the calculated MAF and as proof of concept I have matched it verry closely to the stock calibration (for example adjust base and uncover the blue curve). As an example the Default Comparison Curve (Green) is the MAF calibration I use for my vehicle, which has gone through many many revisions to get right.
This can supplement some of the other tools available from other users that calculate Injector pulse width compensations and RPM vs MRP tables, etc.
Let me know if any of this is unclear or if the tool itself could use some adjustments. Im always open to constructive criticism.
EDIT 1: 05/17 V22 Adds additional graphs, core operation remains the same. Adds a dV line and graph to see step size between points along the x axis. Adds CAL to the second dervitive graph, this helps to evaluate changes Adds tabs with graphs for idle low mid and high loads Adds tabs with graphs for first half of calibration and second half, to improve visibility Adds a tab called focus to be used to highlight problem areas.
EDIT 2: 6/25 Rescales some graphs for visibility. Adds an additional workbook where the user can set up a graph to view fueling at each MAF breakpoint. If the Original MAF is loaded onto the vehicle but incorrect And if the Calculated MAF is the correct shape, Then the Supplied AFR will be measured instead of the Test Value set up in the spreadsheet. Instructions: Copy the appropriate MAF Scale from workbook one. Use the special paste function to transpose the MAF into the left most columns. When logging data for calibration, set the fueling table to flat values. If there are a lot of gradual changes then select a region of the fueling table, find the richest value in that region, then set all of the cells in that region to that richest value. Keep open loop transition zones in mind as you do this.
Last edited by 86inches on Sun Jun 25, 2017 9:30 am, edited 5 times in total.


Top 


welaish

Post subject: Re: MAF Shaping and Scaling Spreadsheet Posted: Sun Jan 15, 2017 4:02 am 


RomRaider Donator 
Joined: Tue Apr 29, 2014 12:48 am Posts: 723

first I would like to thank you for the idea.
I have tried it, but the initial calculated value is very low than the original MAF value. Does that make sense? (attached for your reference)
basically, the target is to make close to 1 as much as you can on Row 9 and 12 is that correct?
_________________ RomRaid!


Top 


86inches

Post subject: Re: MAF Shaping and Scaling Spreadsheet Posted: Sun Jan 15, 2017 11:20 am 


Newbie 
Joined: Mon Dec 29, 2014 12:03 pm Posts: 91

welaish wrote: first I would like to thank you for the idea.
I have tried it, but the initial calculated value is very low than the original MAF value. Does that make sense? (attached for your reference)
basically, the target is to make close to 1 as much as you can on Row 9 and 12 is that correct? Thank you for trying it. The target is not to get as close to 1 as you can, it is to get the red line to slice through the blue line. I found that in doing this it was helpful to evaluate Line 9= New MAF/ Old MAF to see how I was doing. Line 12 is not as important because I think the changes are more easily seen in the graph (the one in the middle). I took a look at the spreadsheet and I see what you mean about the lowMAF rate not being high enough. After you adjust the first 5 boxes on line 6 you want to adjust the boxes in line 11 to continue the process. I took the liberty of trying to smooth the MAF you provided. There is a dip at 1.211, you see that the %original(Line 9) is only .91. But if you look at the boxes to either side they are much closer to 1. For that reason, if it were my vehicle, I would allow this lower calculated value at V=1.211. After that you see that the values in Line 9 sort of go up and down, but none of them ever get too far away from 1; That is the target: to get the red line to slice through the center of the blue. The values in Line 9 should not all equal one but you will want to use that line to make sure the changes you have made are not extreme. Check out graphs 1 and 2, they red line rides the middle rather well. What I did was change the exponent base to 3.2 then massage the values you set in Line 6, then I started adjusting the CAL line. as i went through I found myself going back to spots I had already finished and changing them a little bit to refine points further out on the red line. I also needed to create a new graph to look at just the very low end where you mentioned it was too low. I Was able to see visually how well the red line was fitting the blue line in that area. And you can see that there is a bump in the blue line. In working with this I turned off the second derivative graphs of the blue and green lines because their changes were so much that the detail in the red line was lost.


Top 


welaish

Post subject: Re: MAF Shaping and Scaling Spreadsheet Posted: Mon Jan 16, 2017 12:14 am 


RomRaider Donator 
Joined: Tue Apr 29, 2014 12:48 am Posts: 723

Quote: I took the liberty of trying to smooth the MAF you provided. There is a dip at 1.211, you see that the %original(Line 9) is only .91. But if you look at the boxes to either side they are much closer to 1. For that reason, if it were my vehicle, I would allow this lower calculated value at V=1.211. That's the exact Idle value, I have never touched the values lower than 1.211v on MAF scaling. I guess that's why. Quote: What I did was change the exponent base to 3.2 then massage the values you set in Line 6, then I started adjusting the CAL line. as i went through I found myself going back to spots I had already finished and changing them a little bit to refine points further out on the red line.
On what basis do you choose the exponential value? you just add the value until you see the graph is near to splice the other graph then start making adjustment? Thanks for your inputs, I will try to refine it a little bit and try it out on the car lets see if it gets smoother while cruising.
_________________ RomRaid!


Top 


86inches

Post subject: Re: MAF Shaping and Scaling Spreadsheet Posted: Mon Jan 16, 2017 11:48 am 


Newbie 
Joined: Mon Dec 29, 2014 12:03 pm Posts: 91

welaish wrote: Quote: I took the liberty of trying to smooth the MAF you provided. There is a dip at 1.211, you see that the %original(Line 9) is only .91. But if you look at the boxes to either side they are much closer to 1. For that reason, if it were my vehicle, I would allow this lower calculated value at V=1.211. That's the exact Idle value, I have never touched the values lower than 1.211v on MAF scaling. I guess that's why. Quote: What I did was change the exponent base to 3.2 then massage the values you set in Line 6, then I started adjusting the CAL line. as i went through I found myself going back to spots I had already finished and changing them a little bit to refine points further out on the red line.
On what basis do you choose the exponential value? you just add the value until you see the graph is near to splice the other graph then start making adjustment? Thanks for your inputs, I will try to refine it a little bit and try it out on the car lets see if it gets smoother while cruising. I raised the exponent base a little bit because I saw that your peak airflow is scaled at 400. So I wanted to increase the rate of growth between the points a little bit. It is not necessary to do this, the same results could be achieved using a smaller base and larger values in the CAL Line. This is one of the interesting things about the sheet, you can achieve the same (or very similar) results using different settings. If its idling fine and you still want to smooth the graph then maybe get the line to cut between the bump and the others, or ride the line on top of the bump. You can also paste sections of the calculated MAF into your base calibration if you want to test in steps.


Top 


welaish

Post subject: Re: MAF Shaping and Scaling Spreadsheet Posted: Mon Jan 23, 2017 5:36 am 


RomRaider Donator 
Joined: Tue Apr 29, 2014 12:48 am Posts: 723

The car is smoother, I love the linear power delivery on cruising.
I made small modification I plotted the exponential trend and used the same formula to calculate MAF and adjust. its the best method to smooth the MAF curve so far.
_________________ RomRaid!


Top 


Kodename47

Post subject: Re: MAF Shaping and Scaling Spreadsheet Posted: Tue Jan 24, 2017 5:19 am 


Newbie 
Joined: Sun Jul 13, 2014 6:12 pm Posts: 80

I had a play and added a couple of rows that seem to help. The main one a smoothed average row that aids in what to add in the Cal cells. It also give a live feedback of whether the MAF difference is more/less than 2.5% different so it's visible at a quick glance as you're editing it. This is more relevant in OL where most will have tied down the MAF scale and 2.5% is going to be more.


Top 


Perscitus

Post subject: Re: MAF Shaping and Scaling Spreadsheet Posted: Sun Jan 29, 2017 10:33 am 


Newbie 
Joined: Mon Mar 09, 2015 4:22 pm Posts: 74

Great idea and a nice tool 86inches.
I had a go and got this far.
Could you have a look and suggest what else I should/can do?
NA EZ36D, custom intake, full exhaust. Saturation voltage ~4 to 4.1V
Original MAF scale in CL (up to 2.5V or so) was typically lean and in OL  typically rich.


Top 


86inches

Post subject: Re: MAF Shaping and Scaling Spreadsheet Posted: Sun Jan 29, 2017 3:21 pm 


Newbie 
Joined: Mon Dec 29, 2014 12:03 pm Posts: 91

Perscitus wrote: Great idea and a nice tool 86inches.
I had a go and got this far.
Could you have a look and suggest what else I should/can do?
NA EZ36D, custom intake, full exhaust. Saturation voltage ~4 to 4.1V
Original MAF scale in CL (up to 2.5V or so) was typically lean and in OL  typically rich. Thanks Perscitus. I changed your base back to e, then tweaked the low voltage cells then kind of went back and for from low to high working my way up. I removed the comparison graph because it was hard to see how the red line was fitting the blue. Attached is the results I got. The low load area looks like it might be a bit high. You may want to dial that in differently and just splice it onto a curve that works for mid to high voltage with a little bit of gradation at the joint. Let me know how this works out for you.


Top 


Perscitus

Post subject: Re: MAF Shaping and Scaling Spreadsheet Posted: Mon Jan 30, 2017 12:39 am 


Newbie 
Joined: Mon Mar 09, 2015 4:22 pm Posts: 74


Top 


Perscitus

Post subject: Re: MAF Shaping and Scaling Spreadsheet Posted: Thu Feb 09, 2017 11:40 am 


Newbie 
Joined: Mon Mar 09, 2015 4:22 pm Posts: 74

Had a chance to drive and log with the new shaped/scaled MAF. Impressive!
Looks like I have some more work cut out in OL, but this is by far the best shaping/scaling method thus far.
Does wonders for drivability, especially on the low end  likely a function of how the ECU interpolates between MAFvs and used that to figure out Load, Fueling, Timing.
Thanks a million 86inches!


Top 


trez0r

Post subject: Re: MAF Shaping and Scaling Spreadsheet Posted: Fri Feb 10, 2017 8:19 am 


Experienced 
Joined: Fri Sep 02, 2016 4:42 am Posts: 248 Location: Riga, Latvia

Can you describe Saturation Voltage in more detail? It's unclear to me what it is and what it does.


Top 


86inches

Post subject: Re: MAF Shaping and Scaling Spreadsheet Posted: Fri Feb 10, 2017 2:03 pm 


Newbie 
Joined: Mon Dec 29, 2014 12:03 pm Posts: 91

trez0r wrote: Can you describe Saturation Voltage in more detail? It's unclear to me what it is and what it does. Yes. The saturation voltage, in this context, is the point on the X axis (int this case MAF V) where the the dependant variable (MAF g/s in this case) reaches its maximum allowed value. These pictures help illustrate this: This is the stock 2002 usdm maf calibration The maximum allowed value for the dependant variable(MAF g/s) is 300 g/s and this value is effectively reached in the final X axis break point at 4.69V, making 4.69V the saturation voltage. Now take the following MAF Calibration (its not a real calibration just one adjusted arbitrarily to illustrate the point). This curve reaches its maximum allowed value of 300 g/s at 4.57V, so 4.57V becomes the saturation voltage. The spread sheet works under the assumption that you know something about the transfer function youre attempting to smooth. For my application I knew that 300g/s would be reached before 4.69V by experimentation and data collection. With that said, the spread sheet is very flexible. If you suspect that the saturation voltage would actually occur at 6V or even 10V, go ahead and use that number. Likewise if changing this value helps to get you your desired result dont confine yourself to a value that should work but does not. It may help to just download the spreadsheet and observe what happens when you change the saturation voltage. If this explanation is not clear let me know and I will try to explain further.


Top 


trez0r

Post subject: Re: MAF Shaping and Scaling Spreadsheet Posted: Fri Feb 10, 2017 4:41 pm 


Experienced 
Joined: Fri Sep 02, 2016 4:42 am Posts: 248 Location: Riga, Latvia

Thanks, that explained it!


Top 


Perscitus

Post subject: Re: MAF Shaping and Scaling Spreadsheet Posted: Tue Feb 21, 2017 3:03 pm 


Newbie 
Joined: Mon Mar 09, 2015 4:22 pm Posts: 74

hey 86inches, I took another stab at the smoothing and purposefully leaned out the top of the curve a bit more.
Let me know what you think and if I'm getting the idea of how to use the tool.
I've added a few additional tabs that make it easier for me to zoom in on particular voltage ranges (very low, idle, mid, high etc.) Would actually be great if I could make CAL adjustments on those tabs to see how the plot changes but flipping back and forth between tabs isn't bad either.


Top 


Who is online 
Users browsing this forum: No registered users and 2 guests 

You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum

