Category Archives: MAF tuning

MAF tuning


Hi guys! I’m a BMW fan and I’m happy to see you here on my blog. This blog is about my first BMW electronic project and I hope it will be helpful. This project is about Mass Air Flow converter – a powerful device which helps replace expensive Bosch HFM5 MAF sensors with cheap and higher quality Siemens HFM62C/11. Also converter gives a little tuning ability of the engine power. All information on this blog is free for use. You can download all project files on my download page and use them as you want.

MAF tuning (theory)

Most of BMW owners know about MAF sensor problems and methods to solve these problems. The first and most common way to solve MAF issue is to clean it.
Sensitive element of the HFM5 type MAF sensror:
The strongest enemy of HFM5 type MAFs is dirty air filter and engine oil in intake air system. Of course you can clean it, but this method is helpful in 50% issues.  It didn’t help me :( at all. After I tried to clean my MAF sensor, I ordered another one. The new one also died after 4 month of use. I found on the WEB a part to replace stock MAF sensor. It’s also Bosch HFM5 but not for BMW and has a little different characteristics, but it is much cheaper than stock part. I ordered replacement part (Bosch 0 280 218 037) and I got it working! This replacement part fixed my issue and it works only for BMW 13 62 1 433 565 stock part! Also Bosch sensors  have a lots of faults: reproductions with bad quality from Asia, very expensive, .
Impact on vehicle:
  • Unacceptable curve deviation, consequentially inaccurate air mass measurement:
  • Increase of fuel consumption up to 20%
  • Bad engine characteristic (driveability), loss of power/torque
  • Danger of engine damages, due to thermal and mechanical overload (full load)
  • Danger of exhaust system damages (catalytic converter)
  • Increase of pollutant emissions, violation of emission standards, higher particulate emissions (Diesel), smoke emitting (full load)

All this can happen with my and your engine due to Bosch reproductions! After it will happen you can order another one and another … But I choose another way: MAF tuning.
I started my project in search of mass air-flow meter not manufactured by Bosch to avoid falsification and I found Siemens/VDO 5WK9 635 (HFM62C/11) or 20.3855.

This sensor doesn’t afraid fo engine oil or dirty filters because it’s sensitive element has another principle that’s why I choose it!
I found on  Russian website information about replacement Bosch HFM5 sensor to Siemens for their vehicles. All needed to be done in my project is to convert Siemens MAF values into Bosch HFM5 values and send them to ECU (BMS46 in my case). I don’t want to do this by coding and flashing my ECU, I want to develop MAF value converter as standalone unit.
Let’s start with datasheet for Bosch HFM5 sensor. In the document we can find a table “Output voltage UA = f(Qm) of the air-mass meter“:
Bosch HFM5 curves

kg/h Voltages
8   1.4837
10  1.5819
15  1.7898
30  2.2739
60  2.8868
120 3.6255
250 4.4727
370 4.9406

We have only eight points! It’s not enough to build whole curve, we need at least 256 points. We can only guess about exponential dependence of curve #1. On the web I found perfect application CurveExpert Professional which can find the equation for our MAF dependence. First, we have to load data into CurveExpert Professional:Screenshot from 2014-05-12 15:04:00

X axis – liters per hour; Y axis – voltages. Then go to the Tools->Curve finder and uncheck all check boxes except Built-in non linear regressions and press OK. Application will find many equations for our data, we need only first in the left list
Screenshot from 2014-05-12 15:15:38

This is the best approximation equation for our eight-points curve! Double click on this item gives us equation:
HFM5 approximate equation

Equation helps us to approximate our curve with error equal 0.005852 volts. Here is our curve:
HFM5 approximate curve
Then we need to do the same steps for Siemens MAF sensor. I found datasheet for Siemens/VDO HFM62C/11 only in Russian :( . All we need in this document is only voltage/mass dependence, it looks like Bosch HFM5 table:
kg/h   voltages
0        0.02
4.93     0.22
7.9      0.5
11.95    0.78
41.31    1.8
61.54    2.2
106.69   2.8
183.49   3.4
402.05   4.3
465.83   4.5
572.73   4.8

We need to load above data into CurveExpert Professional.
Screenshot from 2014-05-12 15:43:12

In this case X axis – voltages and Y axis – air mass because we need expression Vb(Ms(Vs)), where:

  • Vb – voltages on Bosch HFM5 sensor
  • Ms – air mass on Siemens HFM62C/11 sensor
  • Vs – voltages on Siemens HFM62C/11 sensor

After same steps as done above for Bosch we get approximation equation for Siemens:


The next step in MAF tuning is replacement table calculation using above two equations. I have an evaluation board with C8051 core CPU with 8-bit ADC (Analog to Digital Converter) and 12-bit DAC (Digital to Analog Converter) and 3.3 V power supply and 2.5 V reference supply for DAC and ADC. Siemens output voltages is from 0 to 5 V that’s why we need to put resistive divider with ratio equal two before ADC. Now we have to compute input Anti-aliasing filter. To do this we need to know MAF values frequency range. For example: my engine has 4 cylinders and 6000 crankshaft rpm. 6000  is equal  100 Hz, two valves opens and closes per revolution, it means 100*2=200 Hz  – maximum frequency for my engine. So, to make input filter I use FilterLab application from Microchip. After I loaded data into the application, I got ready input filter circuit:

Output filter is computed with same tool and data, but only one difference we have for output filter: we must use multiplication to 2 due to divider above.  Our output signal must be in range 0-5 V and our reference source is 2.5 V that’s why multiplication factor is 2 (2*2.5=5).
Here is the output filter circuit:

Each value in replacement table has equation:
(Vb/divider)/((5V/divider)/256) – 0.5/((5V/divider)/256) where:

  • Vb – equation for Bosch(Ms)
  • Ms – equation for Siemens(Vs)
  • Vs – voltages form Siemens ->ADC with step equal 0.0095703125 V (2,5/256 = 0.0095703125)
  • 256 – 8-bit ADC (2^8)

MAF tuning (homemade PCB for prototype)

Today I manufactured PCBs for filter prototype board. I used  this method. It calls “Laser Iron” method (from Laser printer and Iron – hence Laser Iron).

MAF tuning (first results)

So, I have first results!  Prototype device is almost ready and software part is also ready. First, measurements look like true. This weekend I will test it carefully.  On the left is my Bosch HFM5 sensor and on the right is Siemens sensor. Green square board is my evaluation.

MAF tuning (debug with vacuum cleaner)

Today I made measurement stand for Bosch and Siemens sensors:



It looks like BFG :) As you see it consists of two MAF sensors (on the left there is Bosch HFM5 sensor and on the right there is Siemens 20.3855 sensor).  My vacuum cleaner with operated air draft makes up to 60 kg per hour of air. First measurement results are not what I expected :( ! Bosch output and converter output values are not same! Even if I make measurement without converter part they are different. OK, I set vacuum cleaner airstream intensity such that I measure 1.80 V on Siemens output. It means that air mass equal 41.31 kg/h (Siemens datasheet). Then I measure Bosch output and I see 2.1 V. This voltages is less than 30 kg/h. It confuses me. I don’t understand anything. Here are results:


On the left column there are Bosch values, in the middle – converter and on the right there are differences between Bosch and converter output.
Bingo! I think I understand reason of my fail. I have a replacement part for Bosch MAF sensor, not stock (BMW 13 62 1 433 565) and it’s curve is NOT curve #1 in HFM5 datasheet. I recalculated another replacement table for curve #2 and it works fine! I see the same output values from Bosch HFM5 sensor and my converter. IT WORKS!!!  Here is curve #2:

kg/h curve #1 curve #2
8    1.4837     1.239
10   1.5819     1.3644
15   1.7898     1.5241
30   2.2739     1.8748
60   2.8868     2.371
120  3.6255     2.9998
250  4.4727     3.7494
370  4.9406     4.1695
480             4.4578

Now I’m sure it works fine. Curve #2 is for part number Bosch 0 280 218 019 and for 0 280 218 037 too. Here are the results. Difference is 0.01 – 0.02 volts due to approximation error 0,016960 volts.
I don’t understand one thing: during measurements I see that Bosch 0 280 218 037 is equal to curve #2 (0 280 218 019). This part numbers differs only in last numbers 037 and 019. Official replacement part for BMW 13 62 1 433 565 is Bosch 0 280 217 124 and part number with curve #1 is 0 280 217 123. They also differs only in last numbers! But my engine works fine with 0 280 218 037. Maybe curve #1 is what I’m looking for? I’ll test it on my vehicle soon.

MAF tuning (prepare to install)

Everything is ready to be installed into my bimmer. First problem is that the power supply +12V output to MAF sensor is not for big load.
In HFM5 datasheet we can see that maximum input current is less than 100 mA (Input current IV < 0.1 A). Now let’s look at Siemens datasheet. For HFM62C/11 input current at power on is less than 1000 mA and in working mode is less than 500 mA. This difference between input current for Bosch and Siemens MAFs  is to big and our ECU (BMS46 in my case) will be damaged if we connect Siemens MAF sensor to the stock connector. The best way to get +12V power for Siemens MAF sensor is to insert relay:
relay-12v-wiring-schematics Filter prototype board and HFM5 connector: install2

MAF tuning (test drive)

Today everything been installed into my vehicle. It’s quite easy to do wiring in the DME box. Here is picture:
Siemens MAF sensor is shorter than Bosch HFM5 and I need to do something with that :) . My converter evaluation board will be next to the MAF sensor in this installation.  It looks funny.
Here is video how my engine (M43TU) works with Siemens MAF sensor and converter.

Wow! Test drive gives better results than I expected! It seems like my converter works better with curve #2 than Bosch 0 280 218 037. The car runs perfect, idle is stable, at full throttle there is no feeling like passing another car on an uphill.
Curve #1 gives me the worst results. The idle drop down to around 300 rpms then back to a 1K rpms then settle and the car stalls every once in a while :( . I applied adaptations reset in INPA but it doesn’t help, curve #1 still works bad.

MAF tuning (keep testing)

In two days I tested some replacement tables made of curves from HFM5 datasheet. It’s hard to say what curve is the best. Red curve in the picture is good enough for me, but I keep testing.
Red curve gives me very good results over 3000 rpms. My engine works very smooth at idle with this curve. Vehicle responds much better than Bosch 0 280 218 037 sensor. The engine performance is really better!

MAF tuning (final schematic and PCB)

So, I decided to make final schematic of MAF TO MAF converter. I choose STM32F1xx as CPU. It’s very cheap, about $3 and powerful enough for this project. It has ARM Cortex M3 core, 12-bit DAC, 12-bit ADC and runs up to 72 MHz. This microcontroller doesn’t have 2.5 V reference source for DAC and ADC and we need to recalculate our replacement tables for 3.3 V source. I added jumpers into the schematic, they allow to select which replacement table use on start. There are up to 16 tables may be hardcoded into the converter memory! Schematic and PCB design made with DipTrace CAD software.
PCB top and bottom
How it has to look:
Screenshot from 2014-05-15 13:09:09
Here is homemade PCB for converter final version.
All I need is to rewrite my code and recalculate replacement tables.

MAF tuning (FINAL)

First converter release is finished. It soldered at homemade PCB and tested with BFG test stand.
I know, you want to ask me how to make replacement table. To do this I have LibreOffice Calc document and all calculations were done there. Let’s have a look at the part of this document: Screenshot from 2014-05-13 09:06:50

The red circle is parameters set which CurveExpert Proffesional gives us as result. We can change manually that four parameters (a, t, n, k) and resulting curve will change too. Zero based DAC column is our replacement table in HEX. It will change too with parameters changing. You should copy this column into array and include it into your software. The red oval on the left is converter output voltages at control points of air mass.
Resulting curve is dashed red line on the chart:
I used silicon sealant to cover converter board and protect it.
And in the car:
I’m sure, this project is able to replace not only HFM5 type MAF sensors, it can replace all MAF sensors with known curve characteristics.

Soon I’ll add some features into the project:

  • It will be able to make visual configuration of the replacement table and load it into converter in runtime from the laptop or Android device via Bluetooth.
  • Oxygen sensor monitoring will be added. I think it is very interesting to monitor current fuel/air ratio.

Now go to my download page and make your car life better with MAF2MAF converter! :)