This is a very old artcile I found from LouieLouie

before it disappears completely, I copy the text:

AFM Adjustment for 'Big 6' (M30) Engines

Simple test and adjustment of the AFM for smoother running

The test vehicles are an '88 535is (build date 5/87) and an '88 735iL (build date 5/88) with the 3.5 litre straight six with an electro/mechanical Air Flow Meter. The procedures are pretty much the same with either car and probably applies to the 3.3 litre engines also (I haven't done our 633 yet). I've read some otherwise very good articles by other people who have done this with success - I just took more pictures and am sharing my experiece. Your mileage may vary.

Some of the indicators that an adjustment seemed necessary were:
•The air-bleed screw on the AFM was completely closed (enrichening the mixture)
•The idle was rough even after a meticulous setting of valve lash
•Slight hesitation off idle
•I can't vouch for this but I would imagine a low HC (hydrocarbon) measurement from emissions test

I'll assume that all air leaks have been delt with and the valves have been adjusted prior to performing any thing else.
Step 1 is to test the environment: 1.Bring the engine up to operating temperature. This ensures that the ECU is using the proper portion of the mixture map.
2.Disconnect the O2 sensor lead. This puts the ECU in 'open-loop' mode. This may not cause any apparent change at idle but will prevent the ECU from correcting the mixture while we test
3.Remove the air filter from the intake to the AFM.
4.Set the air-bleed screw to the middle of its range - roughly 2.5 to 3 turns counter clockwise (refer to Fig 7 or 8 for its location).

Here's where we press the vane open (slightly) to simulate more air is passing thru and causing the ECU to richen the mix. On my 535 it was very noticeable that the idle smoothed out and gained a few rpm - the 735 not as much.

Fig 5. Manually adjusting AFM vane

--------------------------------------------------------------------------------

If you've decided to continue with the adjustment you'll have to remove the small plastic cover on the underside of the AFM. It is held in place with a bead of silicone sealer - use a thin blade like a box knife along the edge of the cover and pull away as much of the sealer as you can. Then carefully pry the cover off with something wide like a putty knife to avoid damaging the cover.
AFM cover
Fig 6. AFM cover

--------------------------------------------------------------------------------

Once the cover is off and the AFM is upside down, you can see the idle air-bleed screw in the upper left corner (it is recessed in the hole and takes a 3/16" internal hex wrench to adjust) and the toothed plastic gear that controls tension of the spring that closes the AFM vane.
AFM guts
Fig 7. AFM guts
At the bottom center of Fig. 7 is a hole in the casting, and on the sprocket is a mark to show the original position that lined up with that hole. As you can see it is two teeth to the right, next to the wire retaining clip (now you know which direction to turn the sprocket).

Did you mark the sprocket? If you lose control of it and it unwinds - FIXING IT WON'T BE PRETTY!!!
As you can see in this picture,
the wire retaining clip holds the sprocket down on the right end and indexes it with the left end. I pulled the indexing end back and rotated the sprocket counter-clockwise (as you face it) to relax the spring tension. This can also be done on the car with the engine running. At approx. 7 o'clock over the sprocket and under the black wire is a metal tab that can be used to manipulate the vane while the engine is running if you have the air filter attached like is shown in fig 8.
--------------------------------------------------------------------------------

Here is a picture of the AFM upside down on a hi-tech support with the cover off and the wiring harness plugged in. The air filter cover is attached to keep hot air from distorting the readings and to duplicate the intake tract. You can barely make out the 3/16" allen wrench for adjusting the air-bleed. With the car running you can make your adjustments 'live'. I rotated the sprocket one notch at a time and then manipulate the vane open slightly to see if the idle changed perceptively. As soon as no change is detected, I began carefully adjusting the air-bleed for any additional gains. I noticed that the vane would occilate a small amount while running even with the "best" setting.
AFM test535
Fig 8. 535 AFM in test mode

AFM test735
Fig 9. 735 AFM in test mode (engine running)

As you saw in figure 7 my 535 was showing 2 notches of correction to make it run good. I went back following my own instructions (!!!) to see if it made sense to me and I wound up moving two more notches. The 735 seemed to like 3 notches. I have not had to go thru emissions yet so I don't know if I'll be setting it back.
The adjustments are not radical. If you look at figure 4 again you'll see the rubber band around the AFM that holds the cover on while I road-test the adjustments before sealing the cover.

*** Some new data ***

The day after I did these modifications on my 535 I went to my local Washington-state emmissions station. They did not have the previous test data on file but here is the results:
..................HC(ppm)..CO(%)..CO + CO2(%)
Cruise Limit.... 150.......... 1............. >=6
Cruise Emissions 9......... 0.03.......... 15.73
Idle Limit........ 220......... 4.............. >=6
Idle Emissions... 4............. 0................ 15.4

Since these are adaptive Motronic ECU's and we only set the AFM during the cycle while the engine was at operating temperature, it did run a little rough the next morning - but after that first cycle it has started and run fine. I will test the 735 soon.

AFM Adjustment for BMW M30