Alternative MAF Sensor Implementation
Thanks JCSBanks, I'm just trying to get an idea of some rough scaling to go from MAF frequency to mass airflow rate. With that, I can get a rough idea of the MAF Scaling/Smoothing values that would work with the HPX MAF sensor.
I took a 15 minute datalog and did a little math formula in logworks to calculate mass airflow rate based on MAP, engine speed and intake air temperature. I realize that some of the assumptions made (100% VE, MAT=IAT) are not the best. But I got something that was surprisingly linear with Mass Airflow (g/s) = 0.1614*MAF Frequency with an R^2 value of 0.9979.
The problem however is that my ambient conditions are pretty far from what the ECU seems to consider standard conditions. I did the same calculations but corrected the maf frequency to a standard temperature of 298k (25C) and a standard barometric pressure of 101kPa. I did this by multiplying the maf frequency by (298/intake temp)*(barometric pressure)/101. This gave me a good linear fit of Mass Airflow (g/s) = 0.170*MAF Frequency with an R^2 value of 0.9991
. Below is the graph of this data.

What I envision here is locking the Baro input to a standard value, like you have in the SD patch. Then changing the IAT comp table to something much more flat. Basically, all it would do is adjust AFRs for large changes in IAT, but actual IAT density compensation would take place in the hotwire MAF. I would also adjust MAF Size so that the loads would be similar to a factory MAF. I also am thinking that maybe adding a 4:1 frequency divider may be needed as well to keep the MAF frequency low enough to not cause problems in the ECU. Speaking of which, is there any kind of a MAF Frequency cap in the ECU that would cause problems? It sounds like the HPX can produce frequencies up to 12,000 HZ.
I took a 15 minute datalog and did a little math formula in logworks to calculate mass airflow rate based on MAP, engine speed and intake air temperature. I realize that some of the assumptions made (100% VE, MAT=IAT) are not the best. But I got something that was surprisingly linear with Mass Airflow (g/s) = 0.1614*MAF Frequency with an R^2 value of 0.9979.
The problem however is that my ambient conditions are pretty far from what the ECU seems to consider standard conditions. I did the same calculations but corrected the maf frequency to a standard temperature of 298k (25C) and a standard barometric pressure of 101kPa. I did this by multiplying the maf frequency by (298/intake temp)*(barometric pressure)/101. This gave me a good linear fit of Mass Airflow (g/s) = 0.170*MAF Frequency with an R^2 value of 0.9991
. Below is the graph of this data.
What I envision here is locking the Baro input to a standard value, like you have in the SD patch. Then changing the IAT comp table to something much more flat. Basically, all it would do is adjust AFRs for large changes in IAT, but actual IAT density compensation would take place in the hotwire MAF. I would also adjust MAF Size so that the loads would be similar to a factory MAF. I also am thinking that maybe adding a 4:1 frequency divider may be needed as well to keep the MAF frequency low enough to not cause problems in the ECU. Speaking of which, is there any kind of a MAF Frequency cap in the ECU that would cause problems? It sounds like the HPX can produce frequencies up to 12,000 HZ.
Last edited by 03whitegsr; Mar 11, 2009 at 11:25 AM. Reason: Changed
No MAF frequency cap, but you'll have the ECU busy responding to MAF pulse interrupts.
Agree on locking baro and flattening IAT comp with the hot wire and hot film sensors I used to use on Subarus if these are similar - they don't need either. If you can get the HPX to produce a 0-2000 Hz signal that is proportional to airflow, then I would also flatten the scaling and smoothing tables too. Is the HPX programmable?
Other option is a voltage sensor and wire it directly to an ADC input (not sure about baro or IAT inputs as they most likely have resistor(s) on them as they read thermistors not voltage), you could use the routine we use for SD conversion to linearize it to airflow (just put the right values in the MAP VE table), and then you need to divide by RPM (you could do this by the right scaling in the RPM VE table) to get MAFSOURCEMAIN which becomes load and airflow later.
Agree on locking baro and flattening IAT comp with the hot wire and hot film sensors I used to use on Subarus if these are similar - they don't need either. If you can get the HPX to produce a 0-2000 Hz signal that is proportional to airflow, then I would also flatten the scaling and smoothing tables too. Is the HPX programmable?
Other option is a voltage sensor and wire it directly to an ADC input (not sure about baro or IAT inputs as they most likely have resistor(s) on them as they read thermistors not voltage), you could use the routine we use for SD conversion to linearize it to airflow (just put the right values in the MAP VE table), and then you need to divide by RPM (you could do this by the right scaling in the RPM VE table) to get MAFSOURCEMAIN which becomes load and airflow later.
03whitegsr,
I went through this a long time ago. Look for my maf scaling thread and the spreadsheet that I attached there. I have the formula that you are looking for, at least from what I understood at that time.
Otherwise, mrfred can tell you the formula that he uses for the mass airflow calculation from the OBD-II subroutine.
Eric
I went through this a long time ago. Look for my maf scaling thread and the spreadsheet that I attached there. I have the formula that you are looking for, at least from what I understood at that time.
Otherwise, mrfred can tell you the formula that he uses for the mass airflow calculation from the OBD-II subroutine.
Eric
In case you can't find it, here are some of the equations that I came up with at that time:
L/s from Hz:
y=.1339x
then for mass airflow, first find air density and multiply above by it:
airdens=Atmospheric_Pressure /14.6956/.08026/(Intake_Air_Temp +273.15)*28.9
y=(-1*10^-08*AirFlow^3 + 2*10^-05*AirFlow^2+ 0.1228*AirFlow - 1) *airdens
y=g/s, Airflow=Hz
Atmospheric_Pressure=baro in psi
Intake_Air_Temp=intake temp in degrees C
So, in LogWorks, I have added math calculations so that I can graph air density and mass aiflow, as well as mass airflow/rev.
These look like this in the math library:
#Forumla to calculate g/s from airflow.baro. (for 0<Hz<1600)
#and intake temp
airdens=Atmospheric_Pressure /14.6956/.08026/(Intake_Air_Temp +273.15)*28.9
massaircalc=(-1*10^-08*AirFlow^3 + 2*10^-05*AirFlow^2+ 0.1228*AirFlow - 1) *airdens
MC(airdens;g/L) = airdens
MC(massair-calc;g/s) = massaircalc
#Forumla to calculate g/s from airflow.baro.
#and intake temp
airdens=Atmospheric_Pressure /14.6956/.08026/(Intake_Air_Temp +273.15)*28.9
massaircalc=(-1*10^-08*AirFlow^3 + 2*10^-05*AirFlow^2+ 0.1228*AirFlow - 1)*airdens
GperRev=massaircalc*60/Engine_Speed
MC(GperRv;g/rev) = GperRev
L/s from Hz:
y=.1339x
then for mass airflow, first find air density and multiply above by it:
airdens=Atmospheric_Pressure /14.6956/.08026/(Intake_Air_Temp +273.15)*28.9
y=(-1*10^-08*AirFlow^3 + 2*10^-05*AirFlow^2+ 0.1228*AirFlow - 1) *airdens
y=g/s, Airflow=Hz
Atmospheric_Pressure=baro in psi
Intake_Air_Temp=intake temp in degrees C
So, in LogWorks, I have added math calculations so that I can graph air density and mass aiflow, as well as mass airflow/rev.
These look like this in the math library:
#Forumla to calculate g/s from airflow.baro. (for 0<Hz<1600)
#and intake temp
airdens=Atmospheric_Pressure /14.6956/.08026/(Intake_Air_Temp +273.15)*28.9
massaircalc=(-1*10^-08*AirFlow^3 + 2*10^-05*AirFlow^2+ 0.1228*AirFlow - 1) *airdens
MC(airdens;g/L) = airdens
MC(massair-calc;g/s) = massaircalc
#Forumla to calculate g/s from airflow.baro.
#and intake temp
airdens=Atmospheric_Pressure /14.6956/.08026/(Intake_Air_Temp +273.15)*28.9
massaircalc=(-1*10^-08*AirFlow^3 + 2*10^-05*AirFlow^2+ 0.1228*AirFlow - 1)*airdens
GperRev=massaircalc*60/Engine_Speed
MC(GperRv;g/rev) = GperRev
Mathamtically, I have been able to rescale everything to some values I found on the sensor.
The values are pretty crazy compared to the factory table. The MAF Smoothing table actually looks very similar to an exponential growth curve, which is similar to the output of the sensor. The MAF Scaling table starts out very low then quickly jumps to near the maximum table values. I'm wondering if just holding the MAFScaling at a constant then adjusting only the MAF Smoothing would get me to the same results without such a wacky MAF Scaling table. I'll post up some charts latter.
The values are pretty crazy compared to the factory table. The MAF Smoothing table actually looks very similar to an exponential growth curve, which is similar to the output of the sensor. The MAF Scaling table starts out very low then quickly jumps to near the maximum table values. I'm wondering if just holding the MAFScaling at a constant then adjusting only the MAF Smoothing would get me to the same results without such a wacky MAF Scaling table. I'll post up some charts latter.
If somebody is interested in this, I think you could probably take the 2D speed density patch and be able to accommodate a 0-5V hotwire MAF pretty easily. It would take a little math to figure it out, but I think it is possible.
If anyone is still interested in implimenting the HPX 0-5V maf with an A/D input I can offer any information that might help.
I've converted my 4g63 powered mirage to a 98 (2055) ecu. I also installed a stock 2G maf and stock injectors back on the car. I have an HPX installed on the 3" upper IC that I havent wired to anything yet.
I've been looking at the 2055 binary for the sensor transfer function tables, but have not found them yet. If I can at least find the IAT transfer function I can use the IAT that is already in the HPX sensor.
Here are some values you might find helpful.
HPX TRANSFER FUNCTION in 3" tube.
Tube size Calculated Tube Area
2.9 6.605
Volts FLOW KG/HR FLOW LBS/MIN
0.350 3.812 0.140066635
0.530 12.292 0.451652943
0.610 15.089 0.554450256
0.740 20.132 0.739750196
0.810 23.464 0.862163298
0.960 32.605 1.198066731
1.090 42.957 1.57844056
1.200 53.507 1.966066762
1.290 63.344 2.327554273
1.450 83.521 3.068928608
1.520 93.461 3.434183201
1.660 115.526 4.244928494
1.890 158.976 5.841495384
1.990 181.129 6.655467225
2.160 224.111 8.234828945
2.320 271.461 9.974681473
2.450 315.382 11.58855218
2.580 364.533 13.39456345
2.810 464.961 17.08472225
3.000 561.294 20.62442862
3.090 611.205 22.45839562
3.210 682.073 25.06237508
3.410 811.363 29.81308558
3.580 932.749 34.27334279
3.740 1057.455 38.85557848
3.880 1175.759 43.20262324
4.150 1431.659 52.6055184
4.380 1682.283 61.81456206
4.700 2080.440 76.44459749
5.000 2476.207 90.98685793
MITSU MAF TRANSFER FUNCTIONS
flow kg/hr
Freq Gen1 gen2 EVO Ratio 2g/1g Ratio evo2g
29.00 9.61 9.91 14.64 1.03 1.48 -0.32
53.50 19.85 20.73 27.90 1.04 1.35 -0.26
80.70 31.08 33.14 43.16 1.07 1.30 -0.23
116.70 45.78 49.72 64.11 1.09 1.29 -0.22
151.40 59.80 66.32 84.99 1.11 1.28 -0.22
185.40 73.44 82.90 105.96 1.13 1.28 -0.22
266.70 105.85 124.34 157.23 1.17 1.26 -0.21
347.50 138.01 165.76 208.46 1.20 1.26 -0.20
509.30 202.92 248.63 308.86 1.23 1.24 -0.19
672.30 269.04 335.20 407.26 1.25 1.21 -0.18
835.40 334.96 414.41 505.72 1.24 1.22 -0.18
1175.50 465.02 580.19 720.19 1.25 1.24 -0.19
1521.50 582.20 745.93 937.31 1.28 1.26 -0.20
1790.30 675.76 870.29 1082.24 1.29 1.24 -0.20
2081.50 782.39 994.59 1216.25 1.27 1.22 -0.18
2100.00 788.69 1000.82 1224.22 1.27 1.22 -0.18
2200.00 822.57 1039.36 1266.57 1.26 1.22 -0.18
2300.00 856.14 1077.07 1308.10 1.26 1.21 -0.18
2400.00 889.42 1113.96 1349.36 1.25 1.21 -0.17
I've converted my 4g63 powered mirage to a 98 (2055) ecu. I also installed a stock 2G maf and stock injectors back on the car. I have an HPX installed on the 3" upper IC that I havent wired to anything yet.
I've been looking at the 2055 binary for the sensor transfer function tables, but have not found them yet. If I can at least find the IAT transfer function I can use the IAT that is already in the HPX sensor.
Here are some values you might find helpful.
HPX TRANSFER FUNCTION in 3" tube.
Tube size Calculated Tube Area
2.9 6.605
Volts FLOW KG/HR FLOW LBS/MIN
0.350 3.812 0.140066635
0.530 12.292 0.451652943
0.610 15.089 0.554450256
0.740 20.132 0.739750196
0.810 23.464 0.862163298
0.960 32.605 1.198066731
1.090 42.957 1.57844056
1.200 53.507 1.966066762
1.290 63.344 2.327554273
1.450 83.521 3.068928608
1.520 93.461 3.434183201
1.660 115.526 4.244928494
1.890 158.976 5.841495384
1.990 181.129 6.655467225
2.160 224.111 8.234828945
2.320 271.461 9.974681473
2.450 315.382 11.58855218
2.580 364.533 13.39456345
2.810 464.961 17.08472225
3.000 561.294 20.62442862
3.090 611.205 22.45839562
3.210 682.073 25.06237508
3.410 811.363 29.81308558
3.580 932.749 34.27334279
3.740 1057.455 38.85557848
3.880 1175.759 43.20262324
4.150 1431.659 52.6055184
4.380 1682.283 61.81456206
4.700 2080.440 76.44459749
5.000 2476.207 90.98685793
MITSU MAF TRANSFER FUNCTIONS
flow kg/hr
Freq Gen1 gen2 EVO Ratio 2g/1g Ratio evo2g
29.00 9.61 9.91 14.64 1.03 1.48 -0.32
53.50 19.85 20.73 27.90 1.04 1.35 -0.26
80.70 31.08 33.14 43.16 1.07 1.30 -0.23
116.70 45.78 49.72 64.11 1.09 1.29 -0.22
151.40 59.80 66.32 84.99 1.11 1.28 -0.22
185.40 73.44 82.90 105.96 1.13 1.28 -0.22
266.70 105.85 124.34 157.23 1.17 1.26 -0.21
347.50 138.01 165.76 208.46 1.20 1.26 -0.20
509.30 202.92 248.63 308.86 1.23 1.24 -0.19
672.30 269.04 335.20 407.26 1.25 1.21 -0.18
835.40 334.96 414.41 505.72 1.24 1.22 -0.18
1175.50 465.02 580.19 720.19 1.25 1.24 -0.19
1521.50 582.20 745.93 937.31 1.28 1.26 -0.20
1790.30 675.76 870.29 1082.24 1.29 1.24 -0.20
2081.50 782.39 994.59 1216.25 1.27 1.22 -0.18
2100.00 788.69 1000.82 1224.22 1.27 1.22 -0.18
2200.00 822.57 1039.36 1266.57 1.26 1.22 -0.18
2300.00 856.14 1077.07 1308.10 1.26 1.21 -0.18
2400.00 889.42 1113.96 1349.36 1.25 1.21 -0.17
Mitsubishi meter temperature curve
Temp Deg F Volts Ohms
-74 4.7
-45 4.53 61500
-20 4.35 27400
1 4.08 13760
5 4.02 12330
10 3.92 10450
19 3.75 8220
25 3.67 7410
30 3.57 6560
35 3.45 5730
40 3.35 5150
50 3.08 3940
55 2.96 3520
59 2.86 3220
63 2.76 2950
66 2.705 2810
69 2.627 2620
72 2.549 2450
75 2.451 2260
81 2.333 2040
83 2.255 1910
86 2.176 1783
91 2.078 1639
102 1.843 1334
110 1.686 1156
126 1.412 888
143 1.118 644
153 0.941 517
164 0.824 438
170 0.784 412
180 0.686 350
210 0.471 229
224 0.392 186
280 0.216 95.8
295 0.176 82.4
325 0.098 61
333 0.078 53.8
368 0 0
Temp Deg F Volts Ohms
-74 4.7
-45 4.53 61500
-20 4.35 27400
1 4.08 13760
5 4.02 12330
10 3.92 10450
19 3.75 8220
25 3.67 7410
30 3.57 6560
35 3.45 5730
40 3.35 5150
50 3.08 3940
55 2.96 3520
59 2.86 3220
63 2.76 2950
66 2.705 2810
69 2.627 2620
72 2.549 2450
75 2.451 2260
81 2.333 2040
83 2.255 1910
86 2.176 1783
91 2.078 1639
102 1.843 1334
110 1.686 1156
126 1.412 888
143 1.118 644
153 0.941 517
164 0.824 438
170 0.784 412
180 0.686 350
210 0.471 229
224 0.392 186
280 0.216 95.8
295 0.176 82.4
325 0.098 61
333 0.078 53.8
368 0 0
If anyone is still interested in implimenting the HPX 0-5V maf with an A/D input I can offer any information that might help.
I've converted my 4g63 powered mirage to a 98 (2055) ecu. I also installed a stock 2G maf and stock injectors back on the car. I have an HPX installed on the 3" upper IC that I havent wired to anything yet.
I've converted my 4g63 powered mirage to a 98 (2055) ecu. I also installed a stock 2G maf and stock injectors back on the car. I have an HPX installed on the 3" upper IC that I havent wired to anything yet.
Ok I think I have this figured out.
I'm using a 0-5v maf that is 97 lb/min at 5V or acbout 1210 cfm at standard conditions.
I'm trying to get the math to work out.
I would have to use the MAP ve table with the highest map value (5V on the pin) equating to about 8600 load. With this value I can use the rpm VE table for a multiplier in the rpm column to come up with and actual load.
Example at 5000 rpm and 5v from the maf
5v= 1210cfm
1210cfm=8600 from the map ve table
rpm *displacement/3456=engine airflow
5000 * 122/3456 = 176CFM
actual airflow from maf / theroetical engine airflow based on RPM= load
1210/176=687% load
now to get this I will have to use the rpm/VE table.
so, my airflow load is 8600 at 5v and 1210cfm
In the 5000 rpm column of the rpm/ve table I would put 8%
8600*8%=687 Load.
The only problems I have with this Is that I cant work with numbers like 8600 in the map/ve table and i would need more precision then 1% incriments in the RPM/VE table.
On top of all of this I would need some way of expanding the map/ve table to something like 64 points. I would need that because the hotwire maf is not linear and i would need enough points betweed 8600 and 0.
Any thoughts or suggestions? I think this might be a way to eliminate the stock restrictive draw thru maf with a blow thru hotwire maf without the pain of SD tuning
I'm using a 0-5v maf that is 97 lb/min at 5V or acbout 1210 cfm at standard conditions.
I'm trying to get the math to work out.
I would have to use the MAP ve table with the highest map value (5V on the pin) equating to about 8600 load. With this value I can use the rpm VE table for a multiplier in the rpm column to come up with and actual load.
Example at 5000 rpm and 5v from the maf
5v= 1210cfm
1210cfm=8600 from the map ve table
rpm *displacement/3456=engine airflow
5000 * 122/3456 = 176CFM
actual airflow from maf / theroetical engine airflow based on RPM= load
1210/176=687% load
now to get this I will have to use the rpm/VE table.
so, my airflow load is 8600 at 5v and 1210cfm
In the 5000 rpm column of the rpm/ve table I would put 8%
8600*8%=687 Load.
The only problems I have with this Is that I cant work with numbers like 8600 in the map/ve table and i would need more precision then 1% incriments in the RPM/VE table.
On top of all of this I would need some way of expanding the map/ve table to something like 64 points. I would need that because the hotwire maf is not linear and i would need enough points betweed 8600 and 0.
Any thoughts or suggestions? I think this might be a way to eliminate the stock restrictive draw thru maf with a blow thru hotwire maf without the pain of SD tuning
Last edited by awdgsx91; Feb 13, 2012 at 10:32 AM.
If anyone can make this patch it would work I think..
WRITECODE [216, 0, 217, 0, 219, 0, 223, 0, 229, 0, 237, 0, 246, 0, 0, 1, 12, 1, _
22, 1, 30, 1, 42, 1, 55, 1, 69, 1, 86, 1, 104, 1, 124, 1, 143, 1, 163, 1, 184, 1, 202, 1,
219, 1, 237, 1, 254, 1, 15, 2, 32, 2, 49, 2, 66, 2, 82, 2, 98, 2, 114, 2, 130, 2, 132, 2,
146, 2, 161, 2, 177, 2, 192, 2, 207, 2, 222, 2, 237, 2, 252, 2, 11, 3, 26, 3, 40, 3, 55, 3,
70, 3, 84, 3, 99, 3, 113, 3, 128, 3, 142, 3, 156, 3, 170, 3, 183, 3, 197, 3, 210, 3, 223, 3, 236, 3, these numbers
249, 3, 255, 3, 255, 3, 255, 3, 255, 3, 255, 3, ] don't mean anything yet but they are the 0-5V maf
flow lookup table 64 points spacing would be 16 A/D counts or .0781V
mafin var Word 'analog input value
mafsourcemain var Word ' load output
massflow var word
flow var word ' interpolated flow value
tempval var Word 'temporary
tablehigh var Word 'high table value
tablelow var Word 'low table value
tempval2 var Word 'temporary #2
avgarray var Word[32] 'array for averaging input samples
countnum var Byte 'integer for counting sample array
arraysum var Word 'summing variable for average
countnum = 0
clearloop: 'zero out array
DOloop: 'start of main loop
Adcin 0, mafin
arraysum = arraysum - avgarray[countnum] 'subtract value at countnum
avgarray[countnum] = mafin 'store new value in array
arraysum = arraysum + mafin 'add to sum value
mafin = arraysum > > 5 'divide by 32
countnum = countnum + 1
If countnum = 32 Then
countnum = 0
Endif
tempval = mafin> > 3 'shift input for table lookup
tempval2 = tempval & 11111111111110 'clear last bit for WORD lookup
Read tempval2 + 2, tablehigh.byte0
Read tempval2 + 3, tablehigh.byte1
Read tempval2, tablelow.byte0
Read tempval2 + 1, tablelow.byte1
tempval = mafin & 00000000001111 'get interpolation value
If tablehigh >= tablelow Then 'get space between table values
tempval2 = tablehigh - tablelow
Else
tempval2 = tablelow - tablehigh
Endif
tempval = tempval2 * tempval 'multiply high/low diff by interp value
flow = tempval > > 4 'divide by table spacing
If tablehigh >= tablelow Then 'offset table value by calculated
massflow= flow + tablelow 'interpolation value
mafsourcemain = massflow
mafsourcemain = mafsourcemain/(122*RPM/3456) '122 is an adjustable displacement scalar
WRITECODE [216, 0, 217, 0, 219, 0, 223, 0, 229, 0, 237, 0, 246, 0, 0, 1, 12, 1, _
22, 1, 30, 1, 42, 1, 55, 1, 69, 1, 86, 1, 104, 1, 124, 1, 143, 1, 163, 1, 184, 1, 202, 1,
219, 1, 237, 1, 254, 1, 15, 2, 32, 2, 49, 2, 66, 2, 82, 2, 98, 2, 114, 2, 130, 2, 132, 2,
146, 2, 161, 2, 177, 2, 192, 2, 207, 2, 222, 2, 237, 2, 252, 2, 11, 3, 26, 3, 40, 3, 55, 3,
70, 3, 84, 3, 99, 3, 113, 3, 128, 3, 142, 3, 156, 3, 170, 3, 183, 3, 197, 3, 210, 3, 223, 3, 236, 3, these numbers
249, 3, 255, 3, 255, 3, 255, 3, 255, 3, 255, 3, ] don't mean anything yet but they are the 0-5V maf
flow lookup table 64 points spacing would be 16 A/D counts or .0781V
mafin var Word 'analog input value
mafsourcemain var Word ' load output
massflow var word
flow var word ' interpolated flow value
tempval var Word 'temporary
tablehigh var Word 'high table value
tablelow var Word 'low table value
tempval2 var Word 'temporary #2
avgarray var Word[32] 'array for averaging input samples
countnum var Byte 'integer for counting sample array
arraysum var Word 'summing variable for average
countnum = 0
clearloop: 'zero out array
DOloop: 'start of main loop
Adcin 0, mafin
arraysum = arraysum - avgarray[countnum] 'subtract value at countnum
avgarray[countnum] = mafin 'store new value in array
arraysum = arraysum + mafin 'add to sum value
mafin = arraysum > > 5 'divide by 32
countnum = countnum + 1
If countnum = 32 Then
countnum = 0
Endif
tempval = mafin> > 3 'shift input for table lookup
tempval2 = tempval & 11111111111110 'clear last bit for WORD lookup
Read tempval2 + 2, tablehigh.byte0
Read tempval2 + 3, tablehigh.byte1
Read tempval2, tablelow.byte0
Read tempval2 + 1, tablelow.byte1
tempval = mafin & 00000000001111 'get interpolation value
If tablehigh >= tablelow Then 'get space between table values
tempval2 = tablehigh - tablelow
Else
tempval2 = tablelow - tablehigh
Endif
tempval = tempval2 * tempval 'multiply high/low diff by interp value
flow = tempval > > 4 'divide by table spacing
If tablehigh >= tablelow Then 'offset table value by calculated
massflow= flow + tablelow 'interpolation value
mafsourcemain = massflow
mafsourcemain = mafsourcemain/(122*RPM/3456) '122 is an adjustable displacement scalar
Last edited by awdgsx91; Feb 13, 2012 at 10:40 AM.






